]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: get rid of fake onode nref increment for pinned entry 44311/head
authorIgor Fedotov <ifedotov@suse.com>
Tue, 14 Dec 2021 14:56:37 +0000 (17:56 +0300)
committerIgor Fedotov <ifedotov@suse.com>
Mon, 20 Dec 2021 12:15:15 +0000 (15:15 +0300)
Looks like this isn't necessary any more after fixing
https://tracker.ceph.com/issues/53002

Signed-off-by: Igor Fedotov <igor.fedotov@croit.io>
src/os/bluestore/BlueStore.cc

index 4d8b7f3f3e13f43e5e919de5ae5c94336c50fc77..78709eb5dc870fcfec868dd6620551d2b1f46832 100644 (file)
@@ -3623,14 +3623,7 @@ void BlueStore::Onode::calc_omap_tail(
   _key_encode_u64(o->onode.nid, out);
   out->push_back('~');
 }
-//
-// A tricky thing about Onode's ref counter is that we do an additional
-// increment when newly pinned instance is detected. And -1 on unpin.
-// This prevents from a conflict with a delete call (when nref == 0).
-// The latter might happen while the thread is in unpin() function
-// (and e.g. waiting for lock acquisition) since nref is already
-// decremented. And another 'putting' thread on the instance will release it.
-//
+
 void BlueStore::Onode::get() {
   if (++nref >= 2 && !pinned) {
     OnodeCacheShard* ocs = c->get_onode_cache();
@@ -3643,11 +3636,7 @@ void BlueStore::Onode::get() {
     }
     bool was_pinned = pinned;
     pinned = nref >= 2;
-    // additional increment for newly pinned instance
     bool r = !was_pinned && pinned;
-    if (r) {
-      ++nref;
-    }
     if (cached && r) {
       ocs->_pin(this);
     }
@@ -3657,7 +3646,7 @@ void BlueStore::Onode::get() {
 void BlueStore::Onode::put() {
   ++put_nref;
   int n = --nref;
-  if (n == 2) {
+  if (n == 1) {
     OnodeCacheShard* ocs = c->get_onode_cache();
     ocs->lock.lock();
     // It is possible that during waiting split_cache moved us to different OnodeCacheShard.
@@ -3667,8 +3656,7 @@ void BlueStore::Onode::put() {
       ocs->lock.lock();
     }
     bool need_unpin = pinned;
-    pinned = pinned && nref > 2; // intentionally use > not >= as we have
-                                 // +1 due to pinned state
+    pinned = pinned && nref >= 2;
     need_unpin = need_unpin && !pinned;
     if (cached && need_unpin) {
       if (exists) {
@@ -3679,10 +3667,6 @@ void BlueStore::Onode::put() {
         c->onode_map._remove(oid);
       }
     }
-    // additional decrement for newly unpinned instance
-    if (need_unpin) {
-      --nref;
-    }
     ocs->lock.unlock();
   }
   auto pn = --put_nref;