]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: differentiate Anchor types to clarify purpose
authorPatrick Donnelly <pdonnell@redhat.com>
Mon, 12 Feb 2018 18:27:51 +0000 (10:27 -0800)
committerYan, Zheng <zyan@redhat.com>
Thu, 15 Feb 2018 09:09:25 +0000 (17:09 +0800)
* 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 <pdonnell@redhat.com>
src/mds/Anchor.h
src/mds/OpenFileTable.cc
src/mds/OpenFileTable.h

index 0054a850087f52a34d76eb300b3c9d3576825104..9f6e82a5fc24c2f1b647ff7d26b3e63779642329 100644 (file)
@@ -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
index 9dc262b56536b4f51431f6a7480409c8cf81723f..398cc9f531fe146ca996f9980201e36e03cb86bd 100644 (file)
@@ -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;
index 38e12b3828035ed03c68ad88acef9df0f9b14e7d..b5cb151ee041eeb5e0f07134ab8165c6b50ed5ee 100644 (file)
@@ -68,7 +68,7 @@ protected:
 
   version_t omap_version = 0;
 
-  map<inodeno_t, Anchor> anchor_map;
+  map<inodeno_t, OpenedAnchor> anchor_map;
   set<dirfrag_t> dirfrags;
 
   std::map<inodeno_t, unsigned> dirty_items; // ino -> dirty state
@@ -95,7 +95,7 @@ protected:
   void _commit_finish(int r, uint64_t log_seq, MDSInternalContextBase *fin);
 
   std::map<std::string, bufferlist> loaded_journal;
-  map<inodeno_t, Anchor> loaded_anchor_map;
+  map<inodeno_t, RecoveredAnchor> loaded_anchor_map;
   set<dirfrag_t> loaded_dirfrags;
   list<MDSInternalContextBase*> waiting_for_load;
   bool load_done = false;