From 2a9fac2cc4b10af04c52e12f34932e6d2d91441f Mon Sep 17 00:00:00 2001 From: Mykola Golub Date: Sun, 14 Feb 2021 11:50:32 +0000 Subject: [PATCH] librbd: make rename be always executed by lock owner Fixes: https://tracker.ceph.com/issues/49115 Signed-off-by: Mykola Golub --- src/librbd/Operations.cc | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/src/librbd/Operations.cc b/src/librbd/Operations.cc index 2c06df6a034..30bb7efb3a6 100644 --- a/src/librbd/Operations.cc +++ b/src/librbd/Operations.cc @@ -671,30 +671,17 @@ int Operations::rename(const char *dstname) { return -EEXIST; } - if (m_image_ctx.test_features(RBD_FEATURE_JOURNALING)) { - uint64_t request_id = util::reserve_async_request_id(); - r = invoke_async_request(OPERATION_RENAME, - exclusive_lock::OPERATION_REQUEST_TYPE_GENERAL, - true, - boost::bind(&Operations::execute_rename, this, - dstname, _1), - boost::bind(&ImageWatcher::notify_rename, - m_image_ctx.image_watcher, request_id, - dstname, _1)); - if (r < 0 && r != -EEXIST) { - return r; - } - } else { - C_SaferCond cond_ctx; - { - std::shared_lock owner_lock{m_image_ctx.owner_lock}; - execute_rename(dstname, &cond_ctx); - } - - r = cond_ctx.wait(); - if (r < 0) { - return r; - } + uint64_t request_id = util::reserve_async_request_id(); + r = invoke_async_request(OPERATION_RENAME, + exclusive_lock::OPERATION_REQUEST_TYPE_GENERAL, + true, + boost::bind(&Operations::execute_rename, this, + dstname, _1), + boost::bind(&ImageWatcher::notify_rename, + m_image_ctx.image_watcher, request_id, + dstname, _1)); + if (r < 0 && r != -EEXIST) { + return r; } m_image_ctx.set_image_name(dstname); -- 2.39.5