]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: Prevented erasure of element from onode_map during iteration
authorAdam Kupczyk <akupczyk@redhat.com>
Wed, 2 Dec 2020 22:47:30 +0000 (17:47 -0500)
committerIgor Fedotov <ifedotov@suse.com>
Tue, 2 Feb 2021 11:23:06 +0000 (14:23 +0300)
When onode.exists == false getting reference and then releasing it might delete it from container.
It must not happen during iteration.

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

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

index eb44f128dcd8db8bde0b4c1aae0912e9fd62a3f5..8ebf29920995cd6992ad2abfd8f47d4edfbbe3c2 100644 (file)
@@ -1985,12 +1985,12 @@ void BlueStore::OnodeSpace::rename(
   cache->_trim();
 }
 
-bool BlueStore::OnodeSpace::map_any(std::function<bool(OnodeRef)> f)
+bool BlueStore::OnodeSpace::map_any(std::function<bool(Onode*)> f)
 {
   std::lock_guard l(cache->lock);
   ldout(cache->cct, 20) << __func__ << dendl;
   for (auto& i : onode_map) {
-    if (f(i.second)) {
+    if (f(i.second.get())) {
       return true;
     }
   }
@@ -9630,7 +9630,7 @@ void BlueStore::_reap_collections()
   while (p != removed_colls.end()) {
     CollectionRef c = *p;
     dout(10) << __func__ << " " << c << " " << c->cid << dendl;
-    if (c->onode_map.map_any([&](OnodeRef o) {
+    if (c->onode_map.map_any([&](Onode* o) {
          ceph_assert(!o->exists);
          if (o->flushing_count.load()) {
            dout(10) << __func__ << " " << c << " " << c->cid << " " << o->oid
@@ -15224,7 +15224,7 @@ int BlueStore::_remove_collection(TransContext *txc, const coll_t &cid,
     }
     size_t nonexistent_count = 0;
     ceph_assert((*c)->exists);
-    if ((*c)->onode_map.map_any([&](OnodeRef o) {
+    if ((*c)->onode_map.map_any([&](Onode* o) {
         if (o->exists) {
           dout(1) << __func__ << " " << o->oid << " " << o
                  << " exists in onode_map" << dendl;
index 30876877ab1df32ca61203e5cd2e011668a2bf18..1b6bde9638e91ffd7ebff392adaa951a170f4e7a 100644 (file)
@@ -1297,7 +1297,7 @@ public:
     void dump(CephContext *cct);
 
     /// return true if f true for any item
-    bool map_any(std::function<bool(OnodeRef)> f);
+    bool map_any(std::function<bool(Onode*)> f);
   };
 
   class OpSequencer;