]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
bluestore: Fix _setattr() with rare memory alignments
authorAlex Ainscow <aainscow@uk.ibm.com>
Tue, 10 Jun 2025 09:54:13 +0000 (10:54 +0100)
committerAlex Ainscow <aainscow@uk.ibm.com>
Wed, 2 Jul 2025 08:40:46 +0000 (09:40 +0100)
Fix an issue in BlueStore_setattr whereby if a buffer was contiguous and non-partial, then bluestore could completely drop the attribute.

setattr seems to be rarely used outside of new EC. In new EC it is only
used on non-primary shards, so this was only ever seen if the non-primary
happened to be on the same OSD as the primary - this is transient and rare
that scrubbing would actually catche the issue.

Fixes: https://tracker.ceph.com/issues/71623
Signed-off-by: Alex Ainscow <aainscow@uk.ibm.com>
(cherry picked from commit d4e2d4977016bce22a4b9e779c5da54be2d4aaba)

src/os/bluestore/BlueStore.cc

index 2e627945e71747b408e54aaec5045faddc3d73c5..d76442e9a57c00b512b46a4b0f6e728a230dc79f 100644 (file)
@@ -17992,6 +17992,8 @@ int BlueStore::_remove(TransContext *txc,
   return r;
 }
 
+
+
 int BlueStore::_setattr(TransContext *txc,
                        CollectionRef& c,
                        OnodeRef& o,
@@ -18002,18 +18004,13 @@ int BlueStore::_setattr(TransContext *txc,
           << " " << name << " (" << val.length() << " bytes)"
           << dendl;
   int r = 0;
-  if (!val.length()) {
-    auto& b = o->onode.attrs[name.c_str()] = bufferptr("", 0);
-    b.reassign_to_mempool(mempool::mempool_bluestore_cache_meta);
-  } else if (!val.is_contiguous()) {
-    val.rebuild();
-    auto& b = o->onode.attrs[name.c_str()] = val.front();
-    b.reassign_to_mempool(mempool::mempool_bluestore_cache_meta);
-  } else if (val.front().is_partial()) {
+
+  if (!val.is_contiguous() || val.front().is_partial()) {
     val.rebuild();
-    auto& b = o->onode.attrs[name.c_str()] = val.front();
-    b.reassign_to_mempool(mempool::mempool_bluestore_cache_meta);
   }
+  auto& b = o->onode.attrs[name.c_str()] = val.front();
+  b.reassign_to_mempool(mempool::mempool_bluestore_cache_meta);
+
   txc->write_onode(o);
   dout(10) << __func__ << " " << c->cid << " " << o->oid
           << " " << name << " (" << val.length() << " bytes)"