Skip to content

Commit 8e96db1

Browse files
committed
mds/*: forward-declare MDSContext
Signed-off-by: Max Kellermann <[email protected]>
1 parent 856ce1b commit 8e96db1

23 files changed

+113
-92
lines changed

src/mds/CDir.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <set>
2323
#include <string>
2424
#include <string_view>
25+
#include <vector>
2526

2627
#include "common/config.h"
2728
#include "include/buffer_fwd.h"
@@ -38,6 +39,7 @@ struct session_info_t;
3839
class bloom_filter;
3940
class CDentry;
4041
class MDCache;
42+
class MDSContext;
4143

4244
std::ostream& operator<<(std::ostream& out, const class CDir& dir);
4345

@@ -402,8 +404,8 @@ class CDir : public MDSCacheObject, public Counter<CDir> {
402404
void try_remove_dentries_for_stray();
403405
bool try_trim_snap_dentry(CDentry *dn, const std::set<snapid_t>& snaps);
404406

405-
void split(int bits, std::vector<CDir*>* subs, MDSContext::vec& waiters, bool replay);
406-
void merge(const std::vector<CDir*>& subs, MDSContext::vec& waiters, bool replay);
407+
void split(int bits, std::vector<CDir*>* subs, std::vector<MDSContext*>& waiters, bool replay);
408+
void merge(const std::vector<CDir*>& subs, std::vector<MDSContext*>& waiters, bool replay);
407409

408410
bool should_split() const;
409411
bool should_split_fast() const;
@@ -507,10 +509,10 @@ class CDir : public MDSCacheObject, public Counter<CDir> {
507509
return waiting_on_dentry.count(string_snap_t(dname, snap));
508510
}
509511
void add_dentry_waiter(std::string_view dentry, snapid_t snap, MDSContext *c);
510-
void take_dentry_waiting(std::string_view dentry, snapid_t first, snapid_t last, MDSContext::vec& ls);
512+
void take_dentry_waiting(std::string_view dentry, snapid_t first, snapid_t last, std::vector<MDSContext*>& ls);
511513

512514
void add_waiter(uint64_t mask, MDSContext *c) override;
513-
void take_waiting(uint64_t mask, MDSContext::vec& ls) override; // may include dentry waiters
515+
void take_waiting(uint64_t mask, std::vector<MDSContext*>& ls) override; // may include dentry waiters
514516
void finish_waiting(uint64_t mask, int result = 0); // ditto
515517

516518
// -- import/export --
@@ -754,10 +756,10 @@ class CDir : public MDSCacheObject, public Counter<CDir> {
754756
/* If you set up the bloom filter, you must keep it accurate!
755757
* It's deleted when you mark_complete() and is deliberately not serialized.*/
756758

757-
mempool::mds_co::compact_map<version_t, MDSContext::vec_alloc<mempool::mds_co::pool_allocator> > waiting_for_commit;
759+
mempool::mds_co::compact_map<version_t, std::vector<MDSContext*, mempool::mds_co::pool_allocator<MDSContext*>>> waiting_for_commit;
758760

759761
// -- waiters --
760-
mempool::mds_co::map< string_snap_t, MDSContext::vec_alloc<mempool::mds_co::pool_allocator> > waiting_on_dentry; // FIXME string_snap_t not in mempool
762+
mempool::mds_co::map< string_snap_t, std::vector<MDSContext*, mempool::mds_co::pool_allocator<MDSContext*>>> waiting_on_dentry; // FIXME string_snap_t not in mempool
761763

762764
private:
763765
friend std::ostream& operator<<(std::ostream& out, const class CDir& dir);
@@ -778,9 +780,9 @@ class CDir : public MDSCacheObject, public Counter<CDir> {
778780
void remove_null_dentries();
779781

780782
void prepare_new_fragment(bool replay);
781-
void prepare_old_fragment(std::map<string_snap_t, MDSContext::vec >& dentry_waiters, bool replay);
783+
void prepare_old_fragment(std::map<string_snap_t, std::vector<MDSContext*> >& dentry_waiters, bool replay);
782784
void steal_dentry(CDentry *dn); // from another dir. used by merge/split.
783-
void finish_old_fragment(MDSContext::vec& waiters, bool replay);
785+
void finish_old_fragment(std::vector<MDSContext*>& waiters, bool replay);
784786
void init_fragment_pins();
785787
std::string get_path() const;
786788

src/mds/CInode.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#include "include/compact_set.h"
3434

3535
#include "MDSCacheObject.h"
36-
#include "MDSContext.h"
3736
#include "flock.h"
3837
#include "inode_backtrace.h" // for inode_backtrace_t
3938

@@ -52,6 +51,7 @@ class CDentry;
5251
class CDir;
5352
class CInode;
5453
class MDCache;
54+
class MDSContext;
5555
class LogSegment;
5656
struct SnapRealm;
5757
class Session;
@@ -683,7 +683,7 @@ class CInode : public MDSCacheObject, public InodeStoreBase, public Counter<CIno
683683
void set_ambiguous_auth() {
684684
state_set(STATE_AMBIGUOUSAUTH);
685685
}
686-
void clear_ambiguous_auth(MDSContext::vec& finished);
686+
void clear_ambiguous_auth(std::vector<MDSContext*>& finished);
687687
void clear_ambiguous_auth();
688688

689689
const inode_const_ptr& get_inode() const {
@@ -777,12 +777,12 @@ class CInode : public MDSCacheObject, public InodeStoreBase, public Counter<CIno
777777
void decode_store(ceph::buffer::list::const_iterator& bl);
778778

779779
void add_dir_waiter(frag_t fg, MDSContext *c);
780-
void take_dir_waiting(frag_t fg, MDSContext::vec& ls);
780+
void take_dir_waiting(frag_t fg, std::vector<MDSContext*>& ls);
781781
bool is_waiting_for_dir(frag_t fg) {
782782
return waiting_on_dir.count(fg);
783783
}
784784
void add_waiter(uint64_t tag, MDSContext *c) override;
785-
void take_waiting(uint64_t tag, MDSContext::vec& ls) override;
785+
void take_waiting(uint64_t tag, std::vector<MDSContext*>& ls) override;
786786

787787
// -- encode/decode helpers --
788788
void _encode_base(ceph::buffer::list& bl, uint64_t features);
@@ -792,7 +792,7 @@ class CInode : public MDSCacheObject, public InodeStoreBase, public Counter<CIno
792792
void _encode_locks_state_for_replica(ceph::buffer::list& bl, bool need_recover);
793793
void _encode_locks_state_for_rejoin(ceph::buffer::list& bl, int rep);
794794
void _decode_locks_state_for_replica(ceph::buffer::list::const_iterator& p, bool is_new);
795-
void _decode_locks_rejoin(ceph::buffer::list::const_iterator& p, MDSContext::vec& waiters,
795+
void _decode_locks_rejoin(ceph::buffer::list::const_iterator& p, std::vector<MDSContext*>& waiters,
796796
std::list<SimpleLock*>& eval_locks, bool survivor);
797797

798798
// -- import/export --
@@ -957,7 +957,7 @@ class CInode : public MDSCacheObject, public InodeStoreBase, public Counter<CIno
957957
/* Freeze the inode. auth_pin_allowance lets the caller account for any
958958
* auth_pins it is itself holding/responsible for. */
959959
bool freeze_inode(int auth_pin_allowance=0);
960-
void unfreeze_inode(MDSContext::vec& finished);
960+
void unfreeze_inode(std::vector<MDSContext*>& finished);
961961
void unfreeze_inode();
962962

963963
void freeze_auth_pin();
@@ -1207,7 +1207,7 @@ class CInode : public MDSCacheObject, public InodeStoreBase, public Counter<CIno
12071207
ceph_lock_state_t *flock_locks = nullptr;
12081208

12091209
// -- waiting --
1210-
mempool::mds_co::compact_map<frag_t, MDSContext::vec > waiting_on_dir;
1210+
mempool::mds_co::compact_map<frag_t, std::vector<MDSContext*>> waiting_on_dir;
12111211

12121212

12131213
// -- freezing inode --

src/mds/Locker.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
#include <memory>
2020
#include <set>
2121
#include <string_view>
22+
#include <vector>
2223

2324
#include "common/ref.h"
2425
#include "include/mempool.h"
2526
#include "include/types.h"
2627

27-
#include "MDSContext.h"
2828
#include "mdstypes.h" // for xattr_map
2929
#include "Mutation.h"
3030
#include "SimpleLock.h"
@@ -39,6 +39,7 @@ class MClientLease;
3939
class MClientReply;
4040
class MDCache;
4141
class MLock;
42+
class MDSContext;
4243
class MDSRank;
4344
class Session;
4445
class CDentry;
@@ -96,9 +97,9 @@ class Locker {
9697
void eval_lock_caches(Capability *cap);
9798
void put_lock_cache(MDLockCache* lock_cache);
9899

99-
void eval_gather(SimpleLock *lock, bool first=false, bool *need_issue=0, MDSContext::vec *pfinishers=0);
100+
void eval_gather(SimpleLock *lock, bool first=false, bool *need_issue=0, std::vector<MDSContext*> *pfinishers=0);
100101
void eval(SimpleLock *lock, bool *need_issue);
101-
void eval_any(SimpleLock *lock, bool *need_issue, MDSContext::vec *pfinishers=0, bool first=false) {
102+
void eval_any(SimpleLock *lock, bool *need_issue, std::vector<MDSContext*> *pfinishers=0, bool first=false) {
102103
if (!lock->is_stable())
103104
eval_gather(lock, first, need_issue, pfinishers);
104105
else if (lock->get_parent()->is_auth())

src/mds/LogSegment.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include "include/elist.h"
1919
#include "include/interval_set.h"
2020
#include "include/Context.h"
21-
#include "MDSContext.h"
2221
#include "mdstypes.h"
2322
#include "CInode.h"
2423
#include "CDentry.h"
@@ -35,6 +34,10 @@
3534
class CDir;
3635
class CInode;
3736
class CDentry;
37+
class MDSContext;
38+
class C_MDSInternalNoop;
39+
using MDSGather = C_GatherBase<MDSContext, C_MDSInternalNoop>;
40+
using MDSGatherBuilder = C_GatherBuilderBase<MDSContext, MDSGather>;
3841
class MDSRank;
3942
struct MDPeerUpdate;
4043

@@ -56,12 +59,7 @@ class LogSegment {
5659
{}
5760

5861
void try_to_expire(MDSRank *mds, MDSGatherBuilder &gather_bld, int op_prio);
59-
void purge_inodes_finish(interval_set<inodeno_t>& inos){
60-
purging_inodes.subtract(inos);
61-
if (NULL != purged_cb &&
62-
purging_inodes.empty())
63-
purged_cb->complete(0);
64-
}
62+
void purge_inodes_finish(interval_set<inodeno_t>& inos);
6563
void set_purged_cb(MDSContext* c){
6664
ceph_assert(purged_cb == NULL);
6765
purged_cb = c;
@@ -107,7 +105,7 @@ class LogSegment {
107105
version_t sessionmapv = 0;
108106
std::map<int,version_t> tablev;
109107

110-
MDSContext::vec expiry_waiters;
108+
std::vector<MDSContext*> expiry_waiters;
111109
};
112110

113111
static inline std::ostream& operator<<(std::ostream& out, const LogSegment& ls) {

src/mds/MDCache.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,9 +1049,9 @@ class MDCache {
10491049
void encode_replica_inode(CInode *in, mds_rank_t to, bufferlist& bl,
10501050
uint64_t features);
10511051

1052-
void decode_replica_dir(CDir *&dir, bufferlist::const_iterator& p, CInode *diri, mds_rank_t from, MDSContext::vec& finished);
1053-
void decode_replica_dentry(CDentry *&dn, bufferlist::const_iterator& p, CDir *dir, MDSContext::vec& finished);
1054-
void decode_replica_inode(CInode *&in, bufferlist::const_iterator& p, CDentry *dn, MDSContext::vec& finished);
1052+
void decode_replica_dir(CDir *&dir, bufferlist::const_iterator& p, CInode *diri, mds_rank_t from, std::vector<MDSContext*>& finished);
1053+
void decode_replica_dentry(CDentry *&dn, bufferlist::const_iterator& p, CDir *dir, std::vector<MDSContext*>& finished);
1054+
void decode_replica_inode(CInode *&in, bufferlist::const_iterator& p, CDentry *dn, std::vector<MDSContext*>& finished);
10551055

10561056
void encode_replica_stray(CDentry *straydn, mds_rank_t who, bufferlist& bl);
10571057
void decode_replica_stray(CDentry *&straydn, CInode **in, const bufferlist &bl, mds_rank_t from);
@@ -1159,7 +1159,7 @@ class MDCache {
11591159
ceph_tid_t discover_last_tid = 0;
11601160

11611161
// waiters
1162-
std::map<int, std::map<inodeno_t, MDSContext::vec > > waiting_for_base_ino;
1162+
std::map<int, std::map<inodeno_t, std::vector<MDSContext*> > > waiting_for_base_ino;
11631163

11641164
std::map<inodeno_t,std::map<client_t, reconnected_cap_info_t> > reconnected_caps; // inode -> client -> snap_follows,realmino
11651165
std::map<inodeno_t,std::map<client_t, snapid_t> > reconnected_snaprealms; // realmino -> client -> realmseq
@@ -1206,7 +1206,7 @@ class MDCache {
12061206
uleader() {}
12071207
std::set<mds_rank_t> peers;
12081208
LogSegment *ls = nullptr;
1209-
MDSContext::vec waiters;
1209+
std::vector<MDSContext*> waiters;
12101210
bool safe = false;
12111211
bool committing = false;
12121212
bool recovering = false;
@@ -1217,7 +1217,7 @@ class MDCache {
12171217
mds_rank_t leader;
12181218
LogSegment *ls = nullptr;
12191219
MDPeerUpdate *su = nullptr;
1220-
MDSContext::vec waiters;
1220+
std::vector<MDSContext*> waiters;
12211221
};
12221222

12231223
struct open_ino_info_t {
@@ -1234,14 +1234,14 @@ class MDCache {
12341234
version_t tid = 0;
12351235
int64_t pool = -1;
12361236
int last_err = 0;
1237-
MDSContext::vec waiters;
1237+
std::vector<MDSContext*> waiters;
12381238
};
12391239

12401240
ceph_tid_t open_ino_last_tid = 0;
12411241
std::map<inodeno_t,open_ino_info_t> opening_inodes;
12421242

12431243
bool open_ino_batch = false;
1244-
std::map<CDir*, std::pair<std::vector<std::string>, MDSContext::vec> > open_ino_batched_fetch;
1244+
std::map<CDir*, std::pair<std::vector<std::string>, std::vector<MDSContext*>> > open_ino_batched_fetch;
12451245

12461246
friend struct C_MDC_OpenInoTraverseDir;
12471247
friend struct C_MDC_OpenInoParentOpened;
@@ -1400,7 +1400,7 @@ class MDCache {
14001400

14011401
std::map<inodeno_t,std::map<client_t,std::map<mds_rank_t,cap_reconnect_t> > > cap_imports; // ino -> client -> frommds -> capex
14021402
std::set<inodeno_t> cap_imports_missing;
1403-
std::map<inodeno_t, MDSContext::vec > cap_reconnect_waiters;
1403+
std::map<inodeno_t, std::vector<MDSContext*> > cap_reconnect_waiters;
14041404
int cap_imports_num_opening = 0;
14051405

14061406
std::set<CInode*> rejoin_undef_inodes;
@@ -1410,7 +1410,7 @@ class MDCache {
14101410

14111411
std::vector<CInode*> rejoin_recover_q, rejoin_check_q;
14121412
std::list<SimpleLock*> rejoin_eval_locks;
1413-
MDSContext::vec rejoin_waiters;
1413+
std::vector<MDSContext*> rejoin_waiters;
14141414

14151415
std::unique_ptr<MDSContext> rejoin_done;
14161416
std::unique_ptr<MDSContext> resolve_done;
@@ -1439,7 +1439,7 @@ class MDCache {
14391439
int bits = 0;
14401440
bool committed = false;
14411441
LogSegment *ls = nullptr;
1442-
MDSContext::vec waiters;
1442+
std::vector<MDSContext*> waiters;
14431443
frag_vec_t old_frags;
14441444
bufferlist rollback;
14451445
};
@@ -1510,12 +1510,12 @@ class MDCache {
15101510
void trim_non_auth(); // trim out trimmable non-auth items
15111511

15121512
void adjust_dir_fragments(CInode *diri, frag_t basefrag, int bits,
1513-
std::vector<CDir*>* frags, MDSContext::vec& waiters, bool replay);
1513+
std::vector<CDir*>* frags, std::vector<MDSContext*>& waiters, bool replay);
15141514
void adjust_dir_fragments(CInode *diri,
15151515
const std::vector<CDir*>& srcfrags,
15161516
frag_t basefrag, int bits,
15171517
std::vector<CDir*>* resultfrags,
1518-
MDSContext::vec& waiters,
1518+
std::vector<MDSContext*>& waiters,
15191519
bool replay);
15201520
CDir *force_dir_fragment(CInode *diri, frag_t fg, bool replay=true);
15211521
void get_force_dirfrag_bound_set(const std::vector<dirfrag_t>& dfs, std::set<CDir*>& bounds);
@@ -1572,7 +1572,7 @@ class MDCache {
15721572
std::pair<dirfrag_t, std::string> shutdown_export_next;
15731573

15741574
bool opening_root = false, open = false;
1575-
MDSContext::vec waiting_for_open;
1575+
std::vector<MDSContext*> waiting_for_open;
15761576

15771577
// -- snaprealms --
15781578
SnapRealm *global_snaprealm = nullptr;

src/mds/MDLog.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ class MDLog {
272272

273273
bool already_replayed = false;
274274

275-
MDSContext::vec waitfor_replay;
275+
std::vector<MDSContext*> waitfor_replay;
276276

277277
// -- segments --
278278
std::map<uint64_t,LogSegment*> segments;

src/mds/MDSCacheObject.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include "include/types.h"
1313

1414
#include "mdstypes.h"
15-
#include "MDSContext.h"
1615
#include "include/elist.h"
1716

1817
#define MDS_REF_SET // define me for improved debug output, sanity checking
@@ -278,10 +277,10 @@ class MDSCacheObject {
278277
}
279278
waiting.insert(std::pair<waiter_seq_t, waiter>(seq, waiter{mask, c}));
280279
}
281-
virtual void take_waiting(uint64_t mask, MDSContext::vec& ls) {
280+
virtual void take_waiting(uint64_t mask, std::vector<MDSContext*>& ls) {
282281
take_waiting(waitmask_t(mask), ls);
283282
}
284-
void take_waiting(waitmask_t mask, MDSContext::vec& ls);
283+
void take_waiting(waitmask_t mask, std::vector<MDSContext*>& ls);
285284
void finish_waiting(uint64_t mask, int result = 0) {
286285
finish_waiting(waitmask_t(mask), result);
287286
}

src/mds/MDSRank.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,6 +1428,10 @@ void MDSRank::send_message(const ref_t<Message>& m, const ConnectionRef& c)
14281428
c->send_message2(m);
14291429
}
14301430

1431+
void MDSRank::kick_waiters_for_any_client_connection() {
1432+
finish_contexts(g_ceph_context, waiting_for_any_client_connection);
1433+
}
1434+
14311435
class C_MDS_RetrySendMessageMDS : public MDSInternalContext {
14321436
public:
14331437
C_MDS_RetrySendMessageMDS(MDSRank* mds, mds_rank_t who, ref_t<Message> m)

0 commit comments

Comments
 (0)