]> git.apps.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)
committerIgor Fedotov <ifedotov@suse.com>
Tue, 2 Feb 2021 11:22:33 +0000 (14:22 +0300)
Added logic for erasing onode from onode_map it is last reference and exists==false.

Signed-off-by: Adam Kupczyk <akupczyk@redhat.com>
(cherry picked from commit aaebfe0abe78bf46c52ef6c4481c517353edf9ac)

 Conflicts:
   (trivial) src/os/bluestore/BlueStore.h

src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h

index c6f67f95066cc2f575427543cc7f867acc711d6c..eb44f128dcd8db8bde0b4c1aae0912e9fd62a3f5 100644 (file)
@@ -1128,7 +1128,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()) {
@@ -3576,7 +3583,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 f0536080141b77eacff70c44815d2875039d6f20..30876877ab1df32ca61203e5cd2e011668a2bf18 100644 (file)
@@ -1214,6 +1214,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;
@@ -1274,8 +1275,8 @@ public:
     /// forward lookups
     mempool::bluestore_cache_meta::unordered_map<ghobject_t,OnodeRef> onode_map;
 
-    friend class Collection; // for split_cache()
-
+    friend struct Collection; // for split_cache()
+    friend struct Onode; // for put()
     friend struct LruOnodeCacheShard;
     void _remove(const ghobject_t& oid);
   public: