From: Adam C. Emerson Date: Tue, 9 Feb 2021 23:10:50 +0000 (-0500) Subject: rgw: Leave the zero'th shard of the zero'th generation for cls_lock X-Git-Tag: v17.1.0~2399^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0d4e0abb8a699417ea75a6cd390786189ab964eb;p=ceph.git rgw: Leave the zero'th shard of the zero'th generation for cls_lock 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 --- diff --git a/src/rgw/rgw_log_backing.cc b/src/rgw/rgw_log_backing.cc index eab60e672b9e..67fc92558691 100644 --- a/src/rgw/rgw_log_backing.cc +++ b/src/rgw/rgw_log_backing.cc @@ -168,6 +168,7 @@ log_backing_type(librados::IoCtx& ioctx, bs::error_code log_remove(librados::IoCtx& ioctx, int shards, const fu2::unique_function& 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; } diff --git a/src/rgw/rgw_log_backing.h b/src/rgw/rgw_log_backing.h index cd677764c579..e592bc29b2bc 100644 --- a/src/rgw/rgw_log_backing.h +++ b/src/rgw/rgw_log_backing.h @@ -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& get_oid, + bool leave_zero, optional_yield y);