]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: do not release the global snaprealm until unmounting 45114/head
authorXiubo Li <xiubli@redhat.com>
Tue, 22 Feb 2022 03:46:44 +0000 (11:46 +0800)
committerXiubo Li <xiubli@redhat.com>
Fri, 15 Apr 2022 02:51:31 +0000 (10:51 +0800)
The global snaprealm would be created and then destroyed immediately
every time when updating it.

Fixes: https://tracker.ceph.com/issues/54362
Signed-off-by: Xiubo Li <xiubli@redhat.com>
src/client/Client.cc

index 806293aad8271ce90fd51c50983d8c8e848784bd..8434380fe8ef5b53e4e48820616282737910c8f1 100644 (file)
@@ -4907,10 +4907,20 @@ void Client::invalidate_snaprealm_and_children(SnapRealm *realm)
 SnapRealm *Client::get_snap_realm(inodeno_t r)
 {
   SnapRealm *realm = snap_realms[r];
-  if (!realm)
+
+  ldout(cct, 20) << __func__ << " " << r << " " << realm << ", nref was "
+                 << (realm ? realm->nref : 0) << dendl;
+  if (!realm) {
     snap_realms[r] = realm = new SnapRealm(r);
-  ldout(cct, 20) << __func__ << " " << r << " " << realm << " " << realm->nref << " -> " << (realm->nref + 1) << dendl;
+
+    // Do not release the global snaprealm until unmounting.
+    if (r == CEPH_INO_GLOBAL_SNAPREALM)
+      realm->nref++;
+  }
+
   realm->nref++;
+  ldout(cct, 20) << __func__ << " " << r << " " << realm << ", nref now is "
+                 << realm->nref << dendl;
   return realm;
 }
 
@@ -6598,6 +6608,13 @@ void Client::_unmount(bool abort)
 
   _close_sessions();
 
+  // release the global snapshot realm
+  SnapRealm *global_realm = snap_realms[CEPH_INO_GLOBAL_SNAPREALM];
+  if (global_realm) {
+    ceph_assert(global_realm->nref == 1);
+    put_snap_realm(global_realm);
+  }
+
   mref_writer.update_state(CLIENT_UNMOUNTED);
 
   ldout(cct, 2) << "unmounted." << dendl;