]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fix `radosgw-admin object unlink ...` 66152/head
authorJ. Eric Ivancich <ivancich@redhat.com>
Tue, 4 Nov 2025 21:55:38 +0000 (16:55 -0500)
committerJ. Eric Ivancich <ivancich@redhat.com>
Wed, 19 Nov 2025 18:26:28 +0000 (13:26 -0500)
The unlink subcommand did not handle unsharded bucket indices
appropriately. These are when the number of shards listed in the
bucket instance object is 0. In that case there will actually be 1
shard.

When number of shards as 0 is passed into the function that maps
object names to shards, it returns -1. And that was not handled
properly. That is now fixed.

Signed-off-by: J. Eric Ivancich <ivancich@redhat.com>
(cherry picked from commit 9eeb71e28526df8ce2b920d4f50763a734264416)

src/rgw/driver/rados/rgw_rados.cc

index 707b35f7095632cedb71a0a6208ec2ca6dfe5515..437aba4eae79393d463bdb78e0a9fa7df5f307a2 100644 (file)
@@ -10274,8 +10274,11 @@ int RGWRados::remove_objs_from_index(const DoutPrefixProvider *dpp,
   std::map<int, std::set<std::string>> sharded_removals;
   for (const auto& entry_key : entry_key_list) {
     const rgw_obj_key obj_key(entry_key);
-    const uint32_t shard =
-      RGWSI_BucketIndex_RADOS::bucket_shard_index(obj_key, num_shards);
+    const uint32_t shard = [&obj_key, num_shards]() -> uint32_t {
+      int32_t temp = RGWSI_BucketIndex_RADOS::bucket_shard_index(obj_key, num_shards);
+      return (-1 == temp) ? 0 : (uint32_t) temp;
+    }();
+
 
     // entry_key already combines namespace and name, so we first have
     // to break that apart before we can then combine with instance