]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: Purge onode when it does exist
authorAdam Kupczyk <akupczyk@redhat.com>
Wed, 2 Dec 2020 22:44:25 +0000 (17:44 -0500)
committerAdam Kupczyk <akupczyk@redhat.com>
Mon, 14 Dec 2020 15:25:57 +0000 (10:25 -0500)
Added logic for erasing onode from onode_map it is last reference and exists==false.

Signed-off-by: Adam Kupczyk <akupczyk@redhat.com>
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h

index c050ac9a6fb10b761d25a81d4c8613b6e1f7e5ae..8e5b0e73ac2cf4b963585711020468da0da37659 100644 (file)
@@ -1045,7 +1045,14 @@ struct LruOnodeCacheShard : public BlueStore::OnodeCacheShard {
     --num_pinned;
     dout(20) << __func__ << this << " " << " " << " " << o->oid << " unpinned" << dendl;
   }
-
+  void _unpin_and_rm(BlueStore::Onode* o) override
+  {
+    o->pop_cache();
+    ceph_assert(num_pinned);
+    --num_pinned;
+    ceph_assert(num);
+    --num;
+  }
   void _trim_to(uint64_t new_size) override
   {
     if (new_size >= lru.size()) {
@@ -3493,7 +3500,13 @@ void BlueStore::Onode::put() {
       n = --nref;
     }
     if (cached && r) {
-      ocs->_unpin(this);
+      if (exists) {
+        ocs->_unpin(this);
+      } else {
+        ocs->_unpin_and_rm(this);
+        // remove will also decrement nref and delete Onode
+        c->onode_map._remove(oid);
+      }
     }
   }
   if (n == 0) {
index d41c60f505d9e70345a771c4e9a0e7abac9b61a1..942b88286b16900368856214d236be5c2faf96b1 100644 (file)
@@ -1225,6 +1225,7 @@ public:
                                    PerfCounters *logger);
     virtual void _add(Onode* o, int level) = 0;
     virtual void _rm(Onode* o) = 0;
+    virtual void _unpin_and_rm(Onode* o) = 0;
 
     virtual void move_pinned(OnodeCacheShard *to, Onode *o) = 0;
     virtual void add_stats(uint64_t *onodes, uint64_t *pinned_onodes) = 0;
@@ -1286,7 +1287,7 @@ public:
     mempool::bluestore_cache_meta::unordered_map<ghobject_t,OnodeRef> onode_map;
 
     friend struct Collection; // for split_cache()
-
+    friend struct Onode; // for put()
     friend struct LruOnodeCacheShard;
     void _remove(const ghobject_t& oid);
   public: