From: Patrick Donnelly Date: Mon, 12 Feb 2018 18:27:51 +0000 (-0800) Subject: mds: differentiate Anchor types to clarify purpose X-Git-Tag: v13.1.0~436^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=542fbd3933763933bf3af15e8f626c6d2391b0c6;p=ceph.git mds: differentiate Anchor types to clarify purpose * A RecoveredAnchor has an mds auth hint and is used during recovery only. * An OpenedAnchor has a reference count for the number of children and is used for constructing the current OpenFileTable on disk. Signed-off-by: Patrick Donnelly --- diff --git a/src/mds/Anchor.h b/src/mds/Anchor.h index 0054a850087..9f6e82a5fc2 100644 --- a/src/mds/Anchor.h +++ b/src/mds/Anchor.h @@ -31,15 +31,11 @@ public: inodeno_t ino; // anchored ino inodeno_t dirino; std::string d_name; - __u8 d_type; - union { - mutable int nref; // how many children - mutable mds_rank_t auth; // auth hint - }; + __u8 d_type = 0; - Anchor() : d_type(0), nref(0) {} - Anchor(inodeno_t i, inodeno_t di, std::string_view str, __u8 tp, int nr) : - ino(i), dirino(di), d_name(str), d_type(tp), nref(nr) { } + Anchor() {} + Anchor(inodeno_t i, inodeno_t di, std::string_view str, __u8 tp) : + ino(i), dirino(di), d_name(str), d_type(tp) {} void encode(bufferlist &bl) const; void decode(bufferlist::iterator &bl); @@ -55,4 +51,21 @@ inline bool operator==(const Anchor &l, const Anchor &r) { ostream& operator<<(ostream& out, const Anchor &a); +class RecoveredAnchor : public Anchor { +public: + RecoveredAnchor() {} + + mds_rank_t auth = MDS_RANK_NONE; // auth hint +}; + +class OpenedAnchor : public Anchor { +public: + OpenedAnchor(inodeno_t i, inodeno_t di, std::string_view str, __u8 tp, int nr) : + Anchor(i, di, str, tp), + nref(nr) + {} + + mutable int nref = 0; // how many children +}; + #endif diff --git a/src/mds/OpenFileTable.cc b/src/mds/OpenFileTable.cc index 9dc262b5653..398cc9f531f 100644 --- a/src/mds/OpenFileTable.cc +++ b/src/mds/OpenFileTable.cc @@ -483,7 +483,7 @@ void OpenFileTable::_load_finish(int op_r, int header_r, int values_r, std::piecewise_construct, std::make_tuple(ino), std::make_tuple()); - Anchor& anchor = it->second; + RecoveredAnchor& anchor = it->second; decode(anchor, p); assert(ino == anchor.ino); anchor.auth = MDS_RANK_NONE; diff --git a/src/mds/OpenFileTable.h b/src/mds/OpenFileTable.h index 38e12b38280..b5cb151ee04 100644 --- a/src/mds/OpenFileTable.h +++ b/src/mds/OpenFileTable.h @@ -68,7 +68,7 @@ protected: version_t omap_version = 0; - map anchor_map; + map anchor_map; set dirfrags; std::map dirty_items; // ino -> dirty state @@ -95,7 +95,7 @@ protected: void _commit_finish(int r, uint64_t log_seq, MDSInternalContextBase *fin); std::map loaded_journal; - map loaded_anchor_map; + map loaded_anchor_map; set loaded_dirfrags; list waiting_for_load; bool load_done = false;