From 64767f898b877c00bfcde2acf54f9a255c606c34 Mon Sep 17 00:00:00 2001 From: Varsha Rao Date: Fri, 9 Aug 2019 13:25:37 +0530 Subject: [PATCH] mds: Reorganize class members in DamageTable header Fixes: https://tracker.ceph.com/issues/41178 Signed-off-by: Varsha Rao --- src/mds/DamageTable.h | 217 ++++++++++++++++++++---------------------- 1 file changed, 103 insertions(+), 114 deletions(-) diff --git a/src/mds/DamageTable.h b/src/mds/DamageTable.h index a408036cb21..18a61e08b12 100644 --- a/src/mds/DamageTable.h +++ b/src/mds/DamageTable.h @@ -36,68 +36,65 @@ typedef enum class DamageEntry { public: - damage_entry_id_t id; - utime_t reported_at; - - // path is optional, advisory. Used to give the admin an idea of what - // part of his tree the damage affects. - std::string path; + DamageEntry() + { + id = ceph::util::generate_random_number(0, 0xffffffff); + reported_at = ceph_clock_now(); + } - DamageEntry() - { - id = ceph::util::generate_random_number(0, 0xffffffff); - reported_at = ceph_clock_now(); - } + virtual ~DamageEntry(); - virtual damage_entry_type_t get_type() const = 0; + virtual damage_entry_type_t get_type() const = 0; + virtual void dump(Formatter *f) const = 0; - virtual ~DamageEntry(); + damage_entry_id_t id; + utime_t reported_at; - virtual void dump(Formatter *f) const = 0; + // path is optional, advisory. Used to give the admin an idea of what + // part of his tree the damage affects. + std::string path; }; - typedef std::shared_ptr DamageEntryRef; - class DirFragIdent { public: - inodeno_t ino; - frag_t frag; - - bool operator<(const DirFragIdent &rhs) const - { - if (ino == rhs.ino) { - return frag < rhs.frag; - } else { - return ino < rhs.ino; + DirFragIdent(inodeno_t ino_, frag_t frag_) + : ino(ino_), frag(frag_) + {} + + bool operator<(const DirFragIdent &rhs) const + { + if (ino == rhs.ino) { + return frag < rhs.frag; + } else { + return ino < rhs.ino; + } } - } - DirFragIdent(inodeno_t ino_, frag_t frag_) - : ino(ino_), frag(frag_) - {} + inodeno_t ino; + frag_t frag; }; class DentryIdent { public: - std::string dname; - snapid_t snap_id; - - bool operator<(const DentryIdent &rhs) const - { - if (dname == rhs.dname) { - return snap_id < rhs.snap_id; - } else { - return dname < rhs.dname; + DentryIdent(std::string_view dname_, snapid_t snap_id_) + : dname(dname_), snap_id(snap_id_) + {} + + bool operator<(const DentryIdent &rhs) const + { + if (dname == rhs.dname) { + return snap_id < rhs.snap_id; + } else { + return dname < rhs.dname; + } } - } - DentryIdent(std::string_view dname_, snapid_t snap_id_) - : dname(dname_), snap_id(snap_id_) - {} + std::string dname; + snapid_t snap_id; }; /** @@ -122,86 +119,78 @@ class DentryIdent */ class DamageTable { -protected: - - // Map of all dirfrags reported damaged - std::map dirfrags; - - // Store dentries in a map per dirfrag, so that we can - // readily look up all the bad dentries in a particular - // dirfrag - std::map > dentries; - - // Map of all inodes which could not be resolved remotely - // (i.e. have probably/possibly missing backtraces) - std::map remotes; - - // All damage, by ID. This is a secondary index - // to the dirfrag, dentry, remote maps. It exists - // to enable external tools to unambiguously operate - // on particular entries. - std::map by_id; - - // I need to know my MDS rank so that I can check if - // metadata items are part of my mydir. - const mds_rank_t rank; - - bool oversized() const; - -public: - - /** - * Return true if no damage entries exist - */ - bool empty() const - { - return by_id.empty(); - } - - /** - * Indicate that a dirfrag cannot be loaded. - * - * @return true if fatal - */ - bool notify_dirfrag(inodeno_t ino, frag_t frag, std::string_view path); - - /** - * Indicate that a particular dentry cannot be loaded. - * - * @return true if fatal - */ - bool notify_dentry( - inodeno_t ino, frag_t frag, - snapid_t snap_id, std::string_view dname, std::string_view path); - - /** - * Indicate that a particular Inode could not be loaded by number - */ - bool notify_remote_damaged( - inodeno_t ino, std::string_view path); - - bool is_dentry_damaged( + public: + explicit DamageTable(const mds_rank_t rank_) + : rank(rank_) + { + ceph_assert(rank_ != MDS_RANK_NONE); + } + + /** + * Return true if no damage entries exist + */ + bool empty() const + { + return by_id.empty(); + } + + /** + * Indicate that a dirfrag cannot be loaded. + * + * @return true if fatal + */ + bool notify_dirfrag(inodeno_t ino, frag_t frag, std::string_view path); + + /** + * Indicate that a particular dentry cannot be loaded. + * + * @return true if fatal + */ + bool notify_dentry( + inodeno_t ino, frag_t frag, + snapid_t snap_id, std::string_view dname, std::string_view path); + + /** + * Indicate that a particular Inode could not be loaded by number + */ + bool notify_remote_damaged(inodeno_t ino, std::string_view path); + + bool is_dentry_damaged( const CDir *dir_frag, std::string_view dname, const snapid_t snap_id) const; - bool is_dirfrag_damaged( - const CDir *dir_frag) const; + bool is_dirfrag_damaged(const CDir *dir_frag) const; - bool is_remote_damaged( - const inodeno_t ino) const; + bool is_remote_damaged(const inodeno_t ino) const; + void dump(Formatter *f) const; - explicit DamageTable(const mds_rank_t rank_) - : rank(rank_) - { - ceph_assert(rank_ != MDS_RANK_NONE); - } + void erase(damage_entry_id_t damage_id); - void dump(Formatter *f) const; + protected: + // I need to know my MDS rank so that I can check if + // metadata items are part of my mydir. + const mds_rank_t rank; - void erase(damage_entry_id_t damage_id); -}; + bool oversized() const; -#endif // DAMAGE_TABLE_H_ + // Map of all dirfrags reported damaged + std::map dirfrags; + + // Store dentries in a map per dirfrag, so that we can + // readily look up all the bad dentries in a particular + // dirfrag + std::map > dentries; + // Map of all inodes which could not be resolved remotely + // (i.e. have probably/possibly missing backtraces) + std::map remotes; + + // All damage, by ID. This is a secondary index + // to the dirfrag, dentry, remote maps. It exists + // to enable external tools to unambiguously operate + // on particular entries. + std::map by_id; +}; +#endif // DAMAGE_TABLE_H_ -- 2.39.5