From 7f73a7e01106b555adc165014cba3a964eae756f Mon Sep 17 00:00:00 2001 From: Matan Breizman Date: Wed, 9 Nov 2022 09:48:00 +0000 Subject: [PATCH] crimson/osd/pg: with_locked_obc() avoid head/clone distinguish The head or clone branch seperation can be done later on (in with_obc()). Signed-off-by: Matan Breizman --- src/crimson/osd/object_context_loader.cc | 52 +++++++------------ src/crimson/osd/object_context_loader.h | 4 +- src/crimson/osd/pg.cc | 18 ++----- .../osd/replicated_recovery_backend.cc | 4 +- 4 files changed, 27 insertions(+), 51 deletions(-) diff --git a/src/crimson/osd/object_context_loader.cc b/src/crimson/osd/object_context_loader.cc index 2c93a879a5f0..a08271c6593e 100644 --- a/src/crimson/osd/object_context_loader.cc +++ b/src/crimson/osd/object_context_loader.cc @@ -38,7 +38,7 @@ using crimson::common::local_conf; with_obc_func_t&& func) { assert(!oid.is_head()); - return with_head_obc(oid.get_head(), + return with_obc(oid.get_head(), [oid, func=std::move(func), this](auto head) mutable -> load_obc_iertr::future<> { if (!head->obs.exists) { @@ -84,14 +84,18 @@ using crimson::common::local_conf; template ObjectContextLoader::load_obc_iertr::future<> - ObjectContextLoader::with_head_obc(hobject_t oid, - with_obc_func_t&& func) + ObjectContextLoader::with_obc(hobject_t oid, + with_obc_func_t&& func) { - auto [obc, existed] = - shard_services.get_cached_obc(std::move(oid)); - return with_head_obc(std::move(obc), - existed, - std::move(func)); + if (oid.is_head()) { + auto [obc, existed] = + shard_services.get_cached_obc(std::move(oid)); + return with_head_obc(std::move(obc), + existed, + std::move(func)); + } else { + return with_clone_obc(oid, std::move(func)); + } } ObjectContextLoader::load_obc_iertr::future @@ -177,34 +181,18 @@ using crimson::common::local_conf; // explicitly instantiate the used instantiations template ObjectContextLoader::load_obc_iertr::future<> - ObjectContextLoader::with_head_obc(hobject_t, - with_obc_func_t&&); - - template ObjectContextLoader::load_obc_iertr::future<> - ObjectContextLoader::with_head_obc(hobject_t, - with_obc_func_t&&); - - template ObjectContextLoader::load_obc_iertr::future<> - ObjectContextLoader::with_head_obc(hobject_t, - with_obc_func_t&&); - - template ObjectContextLoader::load_obc_iertr::future<> - ObjectContextLoader::with_head_obc(hobject_t, - with_obc_func_t&&); - - template ObjectContextLoader::load_obc_iertr::future<> - ObjectContextLoader::with_clone_obc(hobject_t, - with_obc_func_t&&); + ObjectContextLoader::with_obc(hobject_t, + with_obc_func_t&&); template ObjectContextLoader::load_obc_iertr::future<> - ObjectContextLoader::with_clone_obc(hobject_t, - with_obc_func_t&&); + ObjectContextLoader::with_obc(hobject_t, + with_obc_func_t&&); template ObjectContextLoader::load_obc_iertr::future<> - ObjectContextLoader::with_clone_obc(hobject_t, - with_obc_func_t&&); + ObjectContextLoader::with_obc(hobject_t, + with_obc_func_t&&); template ObjectContextLoader::load_obc_iertr::future<> - ObjectContextLoader::with_clone_obc(hobject_t, - with_obc_func_t&&); + ObjectContextLoader::with_obc(hobject_t, + with_obc_func_t&&); } diff --git a/src/crimson/osd/object_context_loader.h b/src/crimson/osd/object_context_loader.h index e211fd1159a3..4115630abca0 100644 --- a/src/crimson/osd/object_context_loader.h +++ b/src/crimson/osd/object_context_loader.h @@ -32,8 +32,8 @@ public: std::function (ObjectContextRef)>; template - load_obc_iertr::future<> with_head_obc(hobject_t oid, - with_obc_func_t&& func); + load_obc_iertr::future<> with_obc(hobject_t oid, + with_obc_func_t&& func); template load_obc_iertr::future<> with_clone_obc(hobject_t oid, diff --git a/src/crimson/osd/pg.cc b/src/crimson/osd/pg.cc index eb30c9817216..e80782eb51ed 100644 --- a/src/crimson/osd/pg.cc +++ b/src/crimson/osd/pg.cc @@ -1006,23 +1006,11 @@ PG::with_locked_obc(const hobject_t &hobj, const hobject_t oid = get_oid(hobj); switch (get_lock_type(op_info)) { case RWState::RWREAD: - if (oid.is_head()) { - return obc_loader.with_head_obc(oid, std::move(f)); - } else { - return obc_loader.with_clone_obc(oid, std::move(f)); - } + return obc_loader.with_obc(oid, std::move(f)); case RWState::RWWRITE: - if (oid.is_head()) { - return obc_loader.with_head_obc(oid, std::move(f)); - } else { - return obc_loader.with_clone_obc(oid, std::move(f)); - } + return obc_loader.with_obc(oid, std::move(f)); case RWState::RWEXCL: - if (oid.is_head()) { - return obc_loader.with_head_obc(oid, std::move(f)); - } else { - return obc_loader.with_clone_obc(oid, std::move(f)); - } + return obc_loader.with_obc(oid, std::move(f)); default: ceph_abort(); }; diff --git a/src/crimson/osd/replicated_recovery_backend.cc b/src/crimson/osd/replicated_recovery_backend.cc index 6297ca87ba4a..559776e380b7 100644 --- a/src/crimson/osd/replicated_recovery_backend.cc +++ b/src/crimson/osd/replicated_recovery_backend.cc @@ -33,7 +33,7 @@ ReplicatedRecoveryBackend::recover_object( // start tracking the recovery of soid return maybe_pull_missing_obj(soid, need).then_interruptible([this, soid, need] { logger().debug("recover_object: loading obc: {}", soid); - return pg.obc_loader.with_head_obc(soid, + return pg.obc_loader.with_obc(soid, [this, soid, need](auto obc) { logger().debug("recover_object: loaded obc: {}", obc->obs.oi.soid); auto& recovery_waiter = get_recovering(soid); @@ -678,7 +678,7 @@ ReplicatedRecoveryBackend::_handle_pull_response( auto prepare_waiter = interruptor::make_interruptible( seastar::make_ready_future<>()); if (pi.recovery_progress.first) { - prepare_waiter = pg.obc_loader.with_head_obc( + prepare_waiter = pg.obc_loader.with_obc( pi.recovery_info.soid, [&pi, &recovery_waiter, &pop](auto obc) { pi.obc = obc; recovery_waiter.obc = obc; -- 2.47.3