From feea66b30b0fc6f14dc921edd041920bc89b2d60 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 15 Dec 2020 16:40:44 +0800 Subject: [PATCH] crimson/osd: do not use do_with() unless necessary in this change, a seastar::do_with() is removed, as the captured variables are passed to submit_push_data() by value. so no need to keep them alive after the call. Signed-off-by: Kefu Chai --- .../osd/replicated_recovery_backend.cc | 69 +++++++++---------- 1 file changed, 33 insertions(+), 36 deletions(-) diff --git a/src/crimson/osd/replicated_recovery_backend.cc b/src/crimson/osd/replicated_recovery_backend.cc index 2467fb90a96..b61ea19fd8f 100644 --- a/src/crimson/osd/replicated_recovery_backend.cc +++ b/src/crimson/osd/replicated_recovery_backend.cc @@ -650,45 +650,42 @@ seastar::future ReplicatedRecoveryBackend::_handle_pull_response( }; return prepare_waiter.then([this, first=pi.recovery_progress.first, &pi, &pop, t, response]() mutable { - return seastar::do_with(interval_set(), - bufferlist(), - interval_set(), - [this, &pop, &pi, first, t, response] - (auto& data_zeros, auto& data, - auto& usable_intervals) { - std::tie(usable_intervals, data) = - trim_pushed_data(pi.recovery_info.copy_subset, - pop.data_included, pop.data); - pi.recovery_progress = pop.after_progress; - logger().debug("new recovery_info {}, new progress {}", - pi.recovery_info, pi.recovery_progress); - uint64_t z_offset = pop.before_progress.data_recovered_to; - uint64_t z_length = pop.after_progress.data_recovered_to - - pop.before_progress.data_recovered_to; - if (z_length) - data_zeros.insert(z_offset, z_length); - bool complete = pi.is_complete(); - bool clear_omap = !pop.before_progress.omap_complete; - return submit_push_data(pi.recovery_info, first, complete, clear_omap, + pi.recovery_progress = pop.after_progress; + logger().debug("new recovery_info {}, new progress {}", + pi.recovery_info, pi.recovery_progress); + interval_set data_zeros; + { + uint64_t offset = pop.before_progress.data_recovered_to; + uint64_t length = (pop.after_progress.data_recovered_to - + pop.before_progress.data_recovered_to); + if (length) { + data_zeros.insert(offset, length); + } + } + auto [usable_intervals, data] = + trim_pushed_data(pi.recovery_info.copy_subset, + pop.data_included, pop.data); + bool complete = pi.is_complete(); + bool clear_omap = !pop.before_progress.omap_complete; + return submit_push_data(pi.recovery_info, first, complete, clear_omap, data_zeros, usable_intervals, data, pop.omap_header, pop.attrset, pop.omap_entries, t).then( - [this, response, &pi, &pop, &data, complete, t] { - pi.stat.num_keys_recovered += pop.omap_entries.size(); - pi.stat.num_bytes_recovered += data.length(); + [this, response, &pi, &pop, complete, t, bytes_recovered=data.length()] { + pi.stat.num_keys_recovered += pop.omap_entries.size(); + pi.stat.num_bytes_recovered += bytes_recovered; - if (complete) { - pi.stat.num_objects_recovered++; - pg.get_recovery_handler()->on_local_recover( - pop.soid, recovering.at(pop.soid).pi->recovery_info, - false, *t); - return seastar::make_ready_future(true); - } else { - response->soid = pop.soid; - response->recovery_info = pi.recovery_info; - response->recovery_progress = pi.recovery_progress; - return seastar::make_ready_future(false); - } - }); + if (complete) { + pi.stat.num_objects_recovered++; + pg.get_recovery_handler()->on_local_recover( + pop.soid, recovering.at(pop.soid).pi->recovery_info, + false, *t); + return seastar::make_ready_future(true); + } else { + response->soid = pop.soid; + response->recovery_info = pi.recovery_info; + response->recovery_progress = pi.recovery_progress; + return seastar::make_ready_future(false); + } }); }); }