From d34432fbfa599f4d422edd5c3c2648c4229b9d25 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Fri, 29 Jan 2021 17:53:40 +0800 Subject: [PATCH] crimson/osd: clone local object only if we can there is no need to stat local object if we don't plan to clone local object to target object. Signed-off-by: Kefu Chai --- .../osd/replicated_recovery_backend.cc | 43 +++++++++---------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/src/crimson/osd/replicated_recovery_backend.cc b/src/crimson/osd/replicated_recovery_backend.cc index fb715bf309e7..8a3d0db7e13d 100644 --- a/src/crimson/osd/replicated_recovery_backend.cc +++ b/src/crimson/osd/replicated_recovery_backend.cc @@ -947,29 +947,28 @@ ReplicatedRecoveryBackend::prep_push_target( if (omap_header.length()) { t->omap_setheader(coll->get_cid(), target_oid, omap_header); } + if (complete || !recovery_info.object_exist) { + return seastar::make_ready_future(target_oid.hobj); + } + // clone overlap content in local object if using a new object return store->stat(coll, ghobject_t(recovery_info.soid)).then( - [this, &recovery_info, complete, t, target_oid] (auto st) { - // TODO: pg num bytes counting - if (!complete) { - // clone overlap content in local object - if (recovery_info.object_exist) { - uint64_t local_size = std::min(recovery_info.size, (uint64_t)st.st_size); - interval_set local_intervals_included, local_intervals_excluded; - if (local_size) { - local_intervals_included.insert(0, local_size); - local_intervals_excluded.intersection_of(local_intervals_included, recovery_info.copy_subset); - local_intervals_included.subtract(local_intervals_excluded); - } - for (auto [off, len] : local_intervals_included) { - logger().debug(" clone_range {} {}~{}", - recovery_info.soid, off, len); - t->clone_range(coll->get_cid(), ghobject_t(recovery_info.soid), - target_oid, off, len, off); - } - } - } - return seastar::make_ready_future(target_oid.hobj); - }); + [this, &recovery_info, t, target_oid] (auto st) { + // TODO: pg num bytes counting + uint64_t local_size = std::min(recovery_info.size, (uint64_t)st.st_size); + interval_set local_intervals_included, local_intervals_excluded; + if (local_size) { + local_intervals_included.insert(0, local_size); + local_intervals_excluded.intersection_of(local_intervals_included, recovery_info.copy_subset); + local_intervals_included.subtract(local_intervals_excluded); + } + for (auto [off, len] : local_intervals_included) { + logger().debug(" clone_range {} {}~{}", + recovery_info.soid, off, len); + t->clone_range(coll->get_cid(), ghobject_t(recovery_info.soid), + target_oid, off, len, off); + } + return seastar::make_ready_future(target_oid.hobj); + }); } seastar::future<> ReplicatedRecoveryBackend::submit_push_data( -- 2.47.3