Merge PR #36359 into master

* refs/pull/36359/head:
	mds: place MDSGatherBuilder on the stack

Reviewed-by: Zheng Yan <zyan@redhat.com>
This commit is contained in:
Patrick Donnelly 2020-07-31 14:18:52 -07:00
commit 73fc236088
No known key found for this signature in database
GPG Key ID: 3A2A7E25BEA8AADB
3 changed files with 22 additions and 24 deletions

View File

@ -151,26 +151,25 @@ private:
dout(20) << __func__ << dendl;
// Attach contexts to wait for all expiring segments to expire
MDSGatherBuilder *expiry_gather = new MDSGatherBuilder(g_ceph_context);
MDSGatherBuilder expiry_gather(g_ceph_context);
const auto &expiring_segments = mdlog->get_expiring_segments();
for (auto p : expiring_segments) {
p->wait_for_expiry(expiry_gather->new_sub());
p->wait_for_expiry(expiry_gather.new_sub());
}
dout(5) << __func__ << ": waiting for " << expiry_gather->num_subs_created()
dout(5) << __func__ << ": waiting for " << expiry_gather.num_subs_created()
<< " segments to expire" << dendl;
if (!expiry_gather->has_subs()) {
if (!expiry_gather.has_subs()) {
trim_segments();
delete expiry_gather;
return;
}
Context *ctx = new LambdaContext([this](int r) {
handle_expire_segments(r);
});
expiry_gather->set_finisher(new MDSInternalContextWrapper(mds, ctx));
expiry_gather->activate();
expiry_gather.set_finisher(new MDSInternalContextWrapper(mds, ctx));
expiry_gather.activate();
}
void handle_expire_segments(int r) {
@ -331,9 +330,9 @@ private:
auto now = mono_clock::now();
auto duration = std::chrono::duration<double>(now-recall_start).count();
MDSGatherBuilder *gather = new MDSGatherBuilder(g_ceph_context);
MDSGatherBuilder gather(g_ceph_context);
auto flags = Server::RecallFlags::STEADY|Server::RecallFlags::TRIM;
auto [throttled, count] = server->recall_client_state(gather, flags);
auto [throttled, count] = server->recall_client_state(&gather, flags);
dout(10) << __func__
<< (throttled ? " (throttled)" : "")
<< " recalled " << count << " caps" << dendl;
@ -345,17 +344,16 @@ private:
recall_client_state();
}));
ctx->start_timer();
gather->set_finisher(new MDSInternalContextWrapper(mds, ctx));
gather->activate();
gather.set_finisher(new MDSInternalContextWrapper(mds, ctx));
gather.activate();
mdlog->flush(); /* use down-time to incrementally flush log */
do_trim(); /* use down-time to incrementally trim cache */
} else {
if (!gather->has_subs()) {
delete gather;
if (!gather.has_subs()) {
return handle_recall_client_state(0);
} else if (recall_timeout > 0 && duration > recall_timeout) {
gather->set_finisher(new C_MDSInternalNoop);
gather->activate();
gather.set_finisher(new C_MDSInternalNoop);
gather.activate();
return handle_recall_client_state(-ETIMEDOUT);
} else {
uint64_t remaining = (recall_timeout == 0 ? 0 : recall_timeout-duration);
@ -365,8 +363,8 @@ private:
}));
ctx->start_timer();
gather->set_finisher(new MDSInternalContextWrapper(mds, ctx));
gather->activate();
gather.set_finisher(new MDSInternalContextWrapper(mds, ctx));
gather.activate();
}
}
}

View File

@ -741,24 +741,24 @@ void Server::handle_client_session(const cref_t<MClientSession> &m)
}
}
void Server::flush_session(Session *session, MDSGatherBuilder *gather) {
void Server::flush_session(Session *session, MDSGatherBuilder& gather) {
if (!session->is_open() ||
!session->get_connection() ||
!session->get_connection()->has_feature(CEPH_FEATURE_EXPORT_PEER)) {
return;
}
version_t seq = session->wait_for_flush(gather->new_sub());
version_t seq = session->wait_for_flush(gather.new_sub());
mds->send_message_client(
make_message<MClientSession>(CEPH_SESSION_FLUSHMSG, seq), session);
}
void Server::flush_client_sessions(set<client_t>& client_set, MDSGatherBuilder& gather)
{
for (set<client_t>::iterator p = client_set.begin(); p != client_set.end(); ++p) {
Session *session = mds->sessionmap.get_session(entity_name_t::CLIENT(p->v));
for (const auto& client : client_set) {
Session *session = mds->sessionmap.get_session(entity_name_t::CLIENT(client.v));
ceph_assert(session);
flush_session(session, &gather);
flush_session(session, gather);
}
}
@ -1814,7 +1814,7 @@ std::pair<bool, uint64_t> Server::recall_client_state(MDSGatherBuilder* gather,
m->head.max_caps = newlim;
mds->send_message_client(m, session);
if (gather) {
flush_session(session, gather);
flush_session(session, *gather);
}
caps_recalled += session->notify_recall_sent(newlim);
recall_throttle.hit(recall);

View File

@ -319,7 +319,7 @@ private:
friend class Batch_Getattr_Lookup;
void reply_client_request(MDRequestRef& mdr, const ref_t<MClientReply> &reply);
void flush_session(Session *session, MDSGatherBuilder *gather);
void flush_session(Session *session, MDSGatherBuilder& gather);
MDSRank *mds;
MDCache *mdcache;