Skip to content

Commit dc8d75f

Browse files
committed
Merge PR ceph#59171 into main
* refs/pull/59171/head: client: use vectors for context lists Reviewed-by: Venky Shankar <[email protected]>
2 parents 48cb2d6 + 1de14a5 commit dc8d75f

File tree

5 files changed

+16
-33
lines changed

5 files changed

+16
-33
lines changed

src/client/Client.cc

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4265,7 +4265,7 @@ void Client::signal_cond_list(list<ceph::condition_variable*>& ls)
42654265
}
42664266
}
42674267

4268-
void Client::wait_on_context_list(list<Context*>& ls)
4268+
void Client::wait_on_context_list(std::vector<Context*>& ls)
42694269
{
42704270
ceph::condition_variable cond;
42714271
bool done = false;
@@ -4276,30 +4276,14 @@ void Client::wait_on_context_list(list<Context*>& ls)
42764276
l.release();
42774277
}
42784278

4279-
void Client::signal_context_list(list<Context*>& ls)
4280-
{
4281-
while (!ls.empty()) {
4282-
ls.front()->complete(0);
4283-
ls.pop_front();
4284-
}
4285-
}
4286-
42874279
void Client::signal_caps_inode(Inode *in)
42884280
{
42894281
// Process the waitfor_caps list
4290-
while (!in->waitfor_caps.empty()) {
4291-
in->waitfor_caps.front()->complete(0);
4292-
in->waitfor_caps.pop_front();
4293-
}
4282+
signal_context_list(in->waitfor_caps);
42944283

42954284
// New items may have been added to the pending list, move them onto the
42964285
// waitfor_caps list
4297-
while (!in->waitfor_caps_pending.empty()) {
4298-
Context *ctx = in->waitfor_caps_pending.front();
4299-
4300-
in->waitfor_caps_pending.pop_front();
4301-
in->waitfor_caps.push_back(ctx);
4302-
}
4286+
std::swap(in->waitfor_caps, in->waitfor_caps_pending);
43034287
}
43044288

43054289
void Client::wake_up_session_caps(MetaSession *s, bool reconnect)
@@ -11914,7 +11898,7 @@ void Client::C_nonblocking_fsync_state::advance()
1191411898
ldout(clnt->cct, 15) << "waiting on unsafe requests, last tid " << req->get_tid() << dendl;
1191511899

1191611900
req->get();
11917-
clnt->add_nonblocking_onfinish_to_context_list(req->waitfor_safe, advancer);
11901+
req->waitfor_safe.push_back(advancer);
1191811902
// ------------ here is a state machine break point
1191911903
return;
1192011904
}
@@ -11940,7 +11924,7 @@ void Client::C_nonblocking_fsync_state::advance()
1194011924
ldout(clnt->cct, 10) << "ino " << in->ino << " has " << in->cap_refs[CEPH_CAP_FILE_BUFFER]
1194111925
<< " uncommitted, waiting" << dendl;
1194211926
advancer = new C_nonblocking_fsync_state_advancer(clnt, this);
11943-
clnt->add_nonblocking_onfinish_to_context_list(in->waitfor_commit, advancer);
11927+
in->waitfor_commit.push_back(advancer);
1194411928
// ------------ here is a state machine break point but we have to
1194511929
// return to this case because this might loop.
1194611930
progress = 1;
@@ -11998,9 +11982,9 @@ void Client::C_nonblocking_fsync_state::advance()
1199811982
<< " for C_nonblocking_fsync_state " << this
1199911983
<< dendl;
1200011984
if (progress == 3)
12001-
clnt->add_nonblocking_onfinish_to_context_list(in->waitfor_caps, advancer);
11985+
in->waitfor_caps.push_back(advancer);
1200211986
else
12003-
clnt->add_nonblocking_onfinish_to_context_list(in->waitfor_caps_pending, advancer);
11987+
in->waitfor_caps_pending.push_back(advancer);
1200411988
// ------------ here is a state machine break point
1200511989
// the advancer completion will resume with case 3
1200611990
progress = 4;
@@ -16808,7 +16792,7 @@ void Client::ms_handle_remote_reset(Connection *con)
1680816792
case MetaSession::STATE_OPENING:
1680916793
{
1681016794
ldout(cct, 1) << "reset from mds we were opening; retrying" << dendl;
16811-
list<Context*> waiters;
16795+
std::vector<Context*> waiters;
1681216796
waiters.swap(s->waiting_for_open);
1681316797
_closed_mds_session(s.get());
1681416798
auto news = _get_or_open_mds_session(mds);

src/client/Client.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,11 +1057,10 @@ class Client : public Dispatcher, public md_config_obs_t {
10571057
// helpers
10581058
void wake_up_session_caps(MetaSession *s, bool reconnect);
10591059

1060-
void add_nonblocking_onfinish_to_context_list(std::list<Context*>& ls, Context *onfinish) {
1061-
ls.push_back(onfinish);
1060+
void wait_on_context_list(std::vector<Context*>& ls);
1061+
void signal_context_list(std::vector<Context*>& ls) {
1062+
finish_contexts(cct, ls, 0);
10621063
}
1063-
void wait_on_context_list(std::list<Context*>& ls);
1064-
void signal_context_list(std::list<Context*>& ls);
10651064
void signal_caps_inode(Inode *in);
10661065

10671066
// -- metadata cache stuff

src/client/Inode.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,9 @@ struct Inode : RefCountedObject {
238238
std::map<frag_t,int> fragmap; // known frag -> mds mappings
239239
std::map<frag_t, std::vector<mds_rank_t>> frag_repmap; // non-auth mds mappings
240240

241-
std::list<Context*> waitfor_caps;
242-
std::list<Context*> waitfor_caps_pending;
243-
std::list<Context*> waitfor_commit;
241+
std::vector<Context*> waitfor_caps;
242+
std::vector<Context*> waitfor_caps_pending;
243+
std::vector<Context*> waitfor_commit;
244244
std::list<ceph::condition_variable*> waitfor_deleg;
245245

246246
Dentry *get_first_parent() {

src/client/MetaRequest.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ struct MetaRequest {
7070

7171
ceph::condition_variable *caller_cond = NULL; // who to take up
7272
ceph::condition_variable *dispatch_cond = NULL; // who to kick back
73-
std::list<Context*> waitfor_safe;
73+
std::vector<Context*> waitfor_safe;
7474

7575
InodeRef target;
7676
UserPerm perms;

src/client/MetaSession.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ struct MetaSession {
4747
int mds_state = MDSMap::STATE_NULL;
4848
bool readonly = false;
4949

50-
std::list<Context*> waiting_for_open;
50+
std::vector<Context*> waiting_for_open;
5151

5252
xlist<Cap*> caps;
5353
// dirty_list keeps all the dirty inodes before flushing in current session.

0 commit comments

Comments
 (0)