From 262466609208e81f8fe54560fd07a81a4b78cd68 Mon Sep 17 00:00:00 2001 From: "Adam C. Emerson" Date: Tue, 9 Feb 2021 18:10:50 -0500 Subject: [PATCH] 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 (cherry picked from commit 0d4e0abb8a699417ea75a6cd390786189ab964eb) Signed-off-by: Adam C. Emerson --- src/rgw/rgw_log_backing.cc | 16 +++++++++++++--- src/rgw/rgw_log_backing.h | 1 + 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/rgw/rgw_log_backing.cc b/src/rgw/rgw_log_backing.cc index eab60e672b9e8..67fc925586919 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 cd677764c5795..e592bc29b2bcf 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); -- 2.39.5