]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cls/rgw: remove index entry after cancelling last racing delete op
authorCasey Bodley <cbodley@redhat.com>
Wed, 8 Feb 2023 19:01:29 +0000 (14:01 -0500)
committerCasey Bodley <cbodley@redhat.com>
Thu, 23 Feb 2023 19:31:32 +0000 (14:31 -0500)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 08efcc2536c34935a516bf850a9f909c0a3b3f52)

Conflicts:
src/cls/rgw/cls_rgw.cc CLS_LOG_BITX() -> CLS_LOG()

src/cls/rgw/cls_rgw.cc

index 7c9fb71933d01b009ca73cddd3d424605efeae65..17a20601e64af3a8d96c12ed5a0254fc0a8483ce 100644 (file)
@@ -1102,12 +1102,28 @@ int rgw_bucket_complete_op(cls_method_context_t hctx, bufferlist *in, bufferlist
   if (op.op == CLS_RGW_OP_CANCEL) {
     log_op = false; // don't log cancelation
     if (op.tag.size()) {
-      // we removed this tag from pending_map so need to write the changes
-      bufferlist new_key_bl;
-      encode(entry, new_key_bl);
-      rc = cls_cxx_map_set_val(hctx, idx, &new_key_bl);
-      if (rc < 0) {
-        return rc;
+      if (!entry.exists && entry.pending_map.empty()) {
+        // a racing delete succeeded, and we canceled the last pending op
+        CLS_LOG(20, "INFO: %s: removing map entry with key=%s",
+                __func__, escape_str(idx).c_str());
+        rc = cls_cxx_map_remove_key(hctx, idx);
+        if (rc < 0) {
+          CLS_LOG(1, "ERROR: %s: unable to remove map key, key=%s, rc=%d",
+                  __func__, escape_str(idx).c_str(), rc);
+          return rc;
+        }
+      } else {
+        // we removed this tag from pending_map so need to write the changes
+        CLS_LOG(20, "INFO: %s: setting map entry at key=%s",
+                __func__, escape_str(idx).c_str());
+        bufferlist new_key_bl;
+        encode(entry, new_key_bl);
+        rc = cls_cxx_map_set_val(hctx, idx, &new_key_bl);
+        if (rc < 0) {
+          CLS_LOG(1, "ERROR: %s: unable to set map val, key=%s, rc=%d",
+                  __func__, escape_str(idx).c_str(), rc);
+          return rc;
+        }
       }
     }
   } // CLS_RGW_OP_CANCEL