From: Varsha Rao Date: Mon, 23 Dec 2019 10:49:58 +0000 (+0530) Subject: mds: Reorganize structure members in StrayManager header X-Git-Tag: v15.1.1~606^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4ed510977e603ca2aeb69e31ac53ee413f8a3f8e;p=ceph.git mds: Reorganize structure members in StrayManager header Fixes: https://tracker.ceph.com/issues/43408 Signed-off-by: Varsha Rao --- diff --git a/src/mds/StrayManager.h b/src/mds/StrayManager.h index 53e421103124..ca40e67dad1c 100644 --- a/src/mds/StrayManager.h +++ b/src/mds/StrayManager.h @@ -25,30 +25,88 @@ class CDentry; class StrayManager { - protected: - // Has passed through eval_stray and still has refs - elist delayed_eval_stray; + // My public interface is for consumption by MDCache +public: + explicit StrayManager(MDSRank *mds, PurgeQueue &purge_queue_); + void set_logger(PerfCounters *l) {logger = l;} + void activate(); - // strays that have been trimmed from cache - std::set trimmed_strays; + bool eval_stray(CDentry *dn); - // Global references for doing I/O - MDSRank *mds; - PerfCounters *logger; + void set_num_strays(uint64_t num); + uint64_t get_num_strays() const { return num_strays; } - bool started; + /** + * Queue dentry for later evaluation. (evaluate it while not in the + * middle of another metadata operation) + */ + void queue_delayed(CDentry *dn); - // Stray dentries for this rank (including those not in cache) - uint64_t num_strays; + /** + * Eval strays in the delayed_eval_stray list + */ + void advance_delayed(); - // Stray dentries - uint64_t num_strays_delayed; + /** + * Remote dentry potentially points to a stray. When it is touched, + * call in here to evaluate it for migration (move a stray residing + * on another MDS to this MDS) or reintegration (move a stray dentry's + * inode into a non-stray hardlink dentry and clean up the stray). + * + * @param stray_dn a stray dentry whose inode has been referenced + * by a remote dentry + * @param remote_dn (optional) which remote dentry was touched + * in an operation that led us here: this is used + * as a hint for which remote to reintegrate into + * if there are multiple remotes. + */ + void eval_remote(CDentry *remote_dn); - // Entries that have entered enqueue() but not been persistently - // recorded by PurgeQueue yet - uint64_t num_strays_enqueuing; + /** + * Given a dentry within one of my stray directories, + * send it off to a stray directory in another MDS. + * + * This is for use: + * * Case A: when shutting down a rank, we migrate strays + * away from ourselves rather than waiting for purge + * * Case B: when a client request has a trace that refers to + * a stray inode on another MDS, we migrate that inode from + * there to here, in order that we can later re-integrate it + * here. + * + * In case B, the receiver should be calling into eval_stray + * on completion of mv (i.e. inode put), resulting in a subsequent + * reintegration. + */ + void migrate_stray(CDentry *dn, mds_rank_t dest); - PurgeQueue &purge_queue; + /** + * Update stats to reflect a newly created stray dentry. Needed + * because stats on strays live here, but creation happens + * in Server or MDCache. For our purposes "creation" includes + * loading a stray from a dirfrag and migrating a stray from + * another MDS, in addition to creations per-se. + */ + void notify_stray_created(); + + /** + * Update stats to reflect a removed stray dentry. Needed because + * stats on strays live here, but removal happens in Server or + * MDCache. Also includes migration (rename) of strays from + * this MDS to another MDS. + */ + void notify_stray_removed(); + +protected: + friend class StrayManagerIOContext; + friend class StrayManagerLogContext; + friend class StrayManagerContext; + + friend class C_StraysFetched; + friend class C_OpenSnapParents; + friend class C_PurgeStrayLogged; + friend class C_TruncateStrayLogged; + friend class C_IO_PurgeStrayPurged; void truncate(CDentry *dn); @@ -73,17 +131,6 @@ class StrayManager */ void _truncate_stray_logged(CDentry *dn, LogSegment *ls); - friend class StrayManagerIOContext; - friend class StrayManagerLogContext; - friend class StrayManagerContext; - - friend class C_StraysFetched; - friend class C_OpenSnapParents; - friend class C_PurgeStrayLogged; - friend class C_TruncateStrayLogged; - friend class C_IO_PurgeStrayPurged; - - // Call this on a dentry that has been identified as // eligible for purging. It will be passed on to PurgeQueue. void enqueue(CDentry *dn, bool trunc); @@ -92,7 +139,6 @@ class StrayManager // after opening snap parents. void _enqueue(CDentry *dn, bool trunc); - /** * When hard links exist to an inode whose primary dentry * is unlinked, the inode gets a stray primary dentry. @@ -121,77 +167,30 @@ class StrayManager void _eval_stray_remote(CDentry *stray_dn, CDentry *remote_dn); - // My public interface is for consumption by MDCache - public: - explicit StrayManager(MDSRank *mds, PurgeQueue &purge_queue_); - void set_logger(PerfCounters *l) {logger = l;} - void activate(); + // Has passed through eval_stray and still has refs + elist delayed_eval_stray; - bool eval_stray(CDentry *dn); + // strays that have been trimmed from cache + std::set trimmed_strays; - void set_num_strays(uint64_t num); - uint64_t get_num_strays() const { return num_strays; } + // Global references for doing I/O + MDSRank *mds; + PerfCounters *logger; - /** - * Queue dentry for later evaluation. (evaluate it while not in the - * middle of another metadata operation) - */ - void queue_delayed(CDentry *dn); + bool started; - /** - * Eval strays in the delayed_eval_stray list - */ - void advance_delayed(); + // Stray dentries for this rank (including those not in cache) + uint64_t num_strays; - /** - * Remote dentry potentially points to a stray. When it is touched, - * call in here to evaluate it for migration (move a stray residing - * on another MDS to this MDS) or reintegration (move a stray dentry's - * inode into a non-stray hardlink dentry and clean up the stray). - * - * @param stray_dn a stray dentry whose inode has been referenced - * by a remote dentry - * @param remote_dn (optional) which remote dentry was touched - * in an operation that led us here: this is used - * as a hint for which remote to reintegrate into - * if there are multiple remotes. - */ - void eval_remote(CDentry *remote_dn); + // Stray dentries + uint64_t num_strays_delayed; - /** - * Given a dentry within one of my stray directories, - * send it off to a stray directory in another MDS. - * - * This is for use: - * * Case A: when shutting down a rank, we migrate strays - * away from ourselves rather than waiting for purge - * * Case B: when a client request has a trace that refers to - * a stray inode on another MDS, we migrate that inode from - * there to here, in order that we can later re-integrate it - * here. - * - * In case B, the receiver should be calling into eval_stray - * on completion of mv (i.e. inode put), resulting in a subsequent - * reintegration. - */ - void migrate_stray(CDentry *dn, mds_rank_t dest); + // Entries that have entered enqueue() but not been persistently + // recorded by PurgeQueue yet + uint64_t num_strays_enqueuing; - /** - * Update stats to reflect a newly created stray dentry. Needed - * because stats on strays live here, but creation happens - * in Server or MDCache. For our purposes "creation" includes - * loading a stray from a dirfrag and migrating a stray from - * another MDS, in addition to creations per-se. - */ - void notify_stray_created(); + PurgeQueue &purge_queue; - /** - * Update stats to reflect a removed stray dentry. Needed because - * stats on strays live here, but removal happens in Server or - * MDCache. Also includes migration (rename) of strays from - * this MDS to another MDS. - */ - void notify_stray_removed(); }; #endif // STRAY_MANAGER_H