]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: Leave the zero'th shard of the zero'th generation for cls_lock
authorAdam C. Emerson <aemerson@redhat.com>
Tue, 9 Feb 2021 23:10:50 +0000 (18:10 -0500)
committerAdam C. Emerson <aemerson@redhat.com>
Mon, 5 Apr 2021 17:48:09 +0000 (13:48 -0400)
Since data sync locks that object, instead of deleting it, truncate
the object and clear the omap.

(cls_lock uses xattrs.)

Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
(cherry picked from commit 0d4e0abb8a699417ea75a6cd390786189ab964eb)
Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
src/rgw/rgw_log_backing.cc
src/rgw/rgw_log_backing.h

index eab60e672b9e853a893e8de5ebe5162499a95ea3..67fc9255869191f08ffb655628233e01efc4b9d3 100644 (file)
@@ -168,6 +168,7 @@ log_backing_type(librados::IoCtx& ioctx,
 bs::error_code log_remove(librados::IoCtx& ioctx,
                          int shards,
                          const fu2::unique_function<std::string(int) const>& get_oid,
+                         bool leave_zero,
                          optional_yield y)
 {
   bs::error_code ec;
@@ -204,7 +205,16 @@ bs::error_code log_remove(librados::IoCtx& ioctx,
                 << ", r=" << r << dendl;
     }
     librados::ObjectWriteOperation op;
-    op.remove();
+    if (i == 0 && leave_zero) {
+      // Leave shard 0 in existence, but remove contents and
+      // omap. cls_lock stores things in the xattrs. And sync needs to
+      // rendezvous with locks on generation 0 shard 0.
+      op.omap_set_header({});
+      op.omap_clear();
+      op.truncate(0);
+    } else {
+      op.remove();
+    }
     r = rgw_rados_operate(ioctx, oid, &op, null_yield);
     if (r < 0 && r != -ENOENT) {
       if (!ec)
@@ -291,7 +301,7 @@ bs::error_code logback_generations::setup(log_type def,
          auto ec = log_remove(ioctx, shards,
                               [this](int shard) {
                                 return this->get_oid(0, shard);
-                              }, y);
+                              }, true, y);
          if (ec) return ec;
        }
        std::unique_lock lock(m);
@@ -631,7 +641,7 @@ bs::error_code logback_generations::remove_empty(optional_yield y) noexcept {
        auto ec = log_remove(ioctx, shards,
                             [this, gen_id](int shard) {
                               return this->get_oid(gen_id, shard);
-                            }, y);
+                            }, (gen_id == 0), y);
        if (ec) {
          return ec;
        }
index cd677764c5795cca26fb4d3a737e33f0b6acc70e..e592bc29b2bcf18e69447f14a43429b8185ac967 100644 (file)
@@ -88,6 +88,7 @@ bs::error_code log_remove(librados::IoCtx& ioctx,
                          /// A function taking a shard number and
                          /// returning an oid.
                          const fu2::unique_function<std::string(int) const>& get_oid,
+                         bool leave_zero,
                          optional_yield y);