]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: cleanup snaprealm past parents open check
authorYan, Zheng <zyan@redhat.com>
Thu, 3 Aug 2017 03:11:08 +0000 (11:11 +0800)
committerYan, Zheng <zyan@redhat.com>
Fri, 9 Feb 2018 10:41:27 +0000 (18:41 +0800)
For new format snaprealm, there is no need to open past parent,
SnapRealm::have_past_parents_open() always return true, In multimds
setup, mds may use snaprealm whithout opening past parents. So the
assertion in SnapRealm::check_cache() is wrong.

Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
src/mds/MDCache.cc
src/mds/Server.cc
src/mds/SnapRealm.cc
src/mds/SnapRealm.h

index 9a703d9c5e373874a45d9c2ee6158651249ab739..c55df5c7a17b89381004fc037e58c1cecc007747 100644 (file)
@@ -7943,7 +7943,7 @@ int MDCache::path_traverse(MDRequestRef& mdr, Message *req, MDSInternalContextBa
     return -ESTALE;
 
   // make sure snaprealm are open...
-  if (mdr && cur->snaprealm && !cur->snaprealm->is_open() &&
+  if (mdr && cur->snaprealm && !cur->snaprealm->have_past_parents_open() &&
       !cur->snaprealm->open_parents(_get_waiter(mdr, req, fin))) {
     return 1;
   }
@@ -8109,7 +8109,7 @@ int MDCache::path_traverse(MDRequestRef& mdr, Message *req, MDSInternalContextBa
 
       cur = in;
       // make sure snaprealm are open...
-      if (mdr && cur->snaprealm && !cur->snaprealm->is_open() &&
+      if (mdr && cur->snaprealm && !cur->snaprealm->have_past_parents_open() &&
          !cur->snaprealm->open_parents(_get_waiter(mdr, req, fin))) {
        return 1;
       }
index 1002bfc600e87b6932354cd6f4387b9cec5b2e77..cfd89fcfe04ee10fd487dc4e079b7c07062a990a 100644 (file)
@@ -3095,7 +3095,7 @@ void Server::handle_client_lookup_ino(MDRequestRef& mdr,
     return;
   }
 
-  if (mdr && in->snaprealm && !in->snaprealm->is_open() &&
+  if (mdr && in->snaprealm && !in->snaprealm->have_past_parents_open() &&
       !in->snaprealm->open_parents(new C_MDS_RetryRequest(mdcache, mdr))) {
     return;
   }
index 4b7f7075daf71d0aef93ceef8481c488e19f4c99..b705a29f3de3181bd70e220e7655e6fb16eef892 100644 (file)
@@ -187,7 +187,7 @@ bool SnapRealm::open_parents(MDSInternalContextBase *retryorfinish) {
   return true;
 }
 
-bool SnapRealm::have_past_parents_open(snapid_t first, snapid_t last)
+bool SnapRealm::have_past_parents_open(snapid_t first, snapid_t last) const
 {
   dout(10) << "have_past_parents_open [" << first << "," << last << "]" << dendl;
   if (open)
@@ -196,18 +196,19 @@ bool SnapRealm::have_past_parents_open(snapid_t first, snapid_t last)
   if (!srnode.past_parent_snaps.empty())
     assert(mdcache->mds->snapclient->get_cached_version() > 0);
 
-  for (map<snapid_t, snaplink_t>::iterator p = srnode.past_parents.lower_bound(first);
+  for (auto p = srnode.past_parents.lower_bound(first);
        p != srnode.past_parents.end();
        ++p) {
     if (p->second.first > last)
       break;
     dout(10) << " past parent [" << p->second.first << "," << p->first << "] was "
             << p->second.ino << dendl;
-    if (open_past_parents.count(p->second.ino) == 0) {
+    auto q = open_past_parents.find(p->second.ino);
+    if (q == open_past_parents.end()) {
       dout(10) << " past parent " << p->second.ino << " is not open" << dendl;
       return false;
     }
-    SnapRealm *parent_realm = open_past_parents[p->second.ino].first;
+    SnapRealm *parent_realm = q->second.first;
     if (!parent_realm->have_past_parents_open(std::max(first, p->second.first),
                                              std::min(last, p->first)))
       return false;
@@ -282,7 +283,7 @@ void SnapRealm::build_snap_set(set<snapid_t> &s,
 
 void SnapRealm::check_cache() const
 {
-  assert(open);
+  assert(have_past_parents_open());
   uint64_t destroy_seq = mdcache->mds->snapclient->get_destroy_seq();
   if (cached_seq >= srnode.seq &&
       cached_destroy_seq == destroy_seq)
@@ -632,7 +633,6 @@ void SnapRealm::prune_past_parents()
 {
   dout(10) << "prune_past_parents" << dendl;
   check_cache();
-  assert(open);
 
   // convert past_parents to past_parent_snaps
   if (!srnode.past_parents.empty()) {
index cbbe6abb460d7989a443106f0ee3ab64321f281c..5799808fa379a8f90d158f1602c14fe6aed30eb8 100644 (file)
@@ -46,15 +46,13 @@ public:
   MDCache *mdcache;
   CInode *inode;
 
-  bool open;                        // set to true once all past_parents are opened
+  mutable bool open;                        // set to true once all past_parents are opened
   SnapRealm *parent;
   set<SnapRealm*> open_children;    // active children that are currently open
   set<SnapRealm*> open_past_children;  // past children who has pinned me
   map<inodeno_t, pair<SnapRealm*, set<snapid_t> > > open_past_parents;  // these are explicitly pinned.
   unsigned num_open_past_parents;
 
-
-
   elist<CInode*> inodes_with_caps;             // for efficient realm splits
   map<client_t, xlist<Capability*>* > client_caps;   // to identify clients who need snap notifications
 
@@ -77,12 +75,11 @@ public:
     return false;
   }
 
-  bool is_open() const { return open; }
   void _close_parents() { open = false; }
   bool _open_parents(MDSInternalContextBase *retryorfinish, snapid_t first=1, snapid_t last=CEPH_NOSNAP);
   bool open_parents(MDSInternalContextBase *retryorfinish);
   void _remove_missing_parent(snapid_t snapid, inodeno_t parent, int err);
-  bool have_past_parents_open(snapid_t first=1, snapid_t last=CEPH_NOSNAP);
+  bool have_past_parents_open(snapid_t first=1, snapid_t last=CEPH_NOSNAP) const;
   void add_open_past_parent(SnapRealm *parent, snapid_t last);
   void remove_open_past_parent(inodeno_t ino, snapid_t last);
   void close_parents();