mirror of
https://github.com/ceph/ceph
synced 2024-12-28 06:23:08 +00:00
crimson/osd: extract read_omap_for_push_op()
extract read_omap_for_push_op() out of build_push_op() for better readability Signed-off-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
parent
d302ffb8d3
commit
26e61a02ec
@ -426,40 +426,11 @@ seastar::future<ObjectRecoveryProgress> ReplicatedRecoveryBackend::build_push_op
|
||||
);
|
||||
}
|
||||
return seastar::make_ready_future<>();
|
||||
}().then([this, &recovery_info] {
|
||||
return shard_services.get_store().get_omap_iterator(coll,
|
||||
ghobject_t(recovery_info.soid));
|
||||
}).then([&progress, &available, &new_progress, pop](auto iter) {
|
||||
if (!progress.omap_complete) {
|
||||
return iter->lower_bound(progress.omap_recovered_to).then(
|
||||
[iter, &new_progress, pop, &available](int ret) {
|
||||
return seastar::repeat([iter, &new_progress, pop, &available] {
|
||||
if (!iter->valid()) {
|
||||
new_progress.omap_complete = true;
|
||||
return seastar::make_ready_future<seastar::stop_iteration>(
|
||||
seastar::stop_iteration::yes);
|
||||
}
|
||||
if (!pop->omap_entries.empty()
|
||||
&& ((crimson::common::local_conf()->osd_recovery_max_omap_entries_per_chunk > 0
|
||||
&& pop->omap_entries.size()
|
||||
>= crimson::common::local_conf()->osd_recovery_max_omap_entries_per_chunk)
|
||||
|| available <= iter->key().size() + iter->value().length())) {
|
||||
new_progress.omap_recovered_to = iter->key();
|
||||
return seastar::make_ready_future<seastar::stop_iteration>(
|
||||
seastar::stop_iteration::yes);
|
||||
}
|
||||
pop->omap_entries.insert(make_pair(iter->key(), iter->value()));
|
||||
if ((iter->key().size() + iter->value().length()) <= available)
|
||||
available -= (iter->key().size() + iter->value().length());
|
||||
else
|
||||
available = 0;
|
||||
return iter->next().then([](int r) {
|
||||
return seastar::stop_iteration::no;
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
return seastar::make_ready_future<>();
|
||||
}().then([this, &recovery_info, &progress, &new_progress, &available, pop] {
|
||||
return read_omap_for_push_op(recovery_info.soid,
|
||||
progress,
|
||||
new_progress,
|
||||
available, pop);
|
||||
}).then([this, &recovery_info, &progress, &available, pop] {
|
||||
logger().debug("build_push_op: available: {}, copy_subset: {}",
|
||||
available, recovery_info.copy_subset);
|
||||
@ -544,6 +515,51 @@ ReplicatedRecoveryBackend::read_object_for_push_op(
|
||||
}));
|
||||
}
|
||||
|
||||
seastar::future<>
|
||||
ReplicatedRecoveryBackend::read_omap_for_push_op(
|
||||
const hobject_t& oid,
|
||||
const ObjectRecoveryProgress& progress,
|
||||
ObjectRecoveryProgress& new_progress,
|
||||
uint64_t max_len,
|
||||
PushOp* push_op)
|
||||
{
|
||||
return shard_services.get_store().get_omap_iterator(coll, ghobject_t{oid})
|
||||
.then([&progress, &new_progress, &max_len, push_op](auto omap_iter) {
|
||||
if (progress.omap_complete) {
|
||||
return seastar::make_ready_future<>();
|
||||
}
|
||||
return omap_iter->lower_bound(progress.omap_recovered_to).then(
|
||||
[omap_iter, &new_progress, &max_len, push_op](int ret) {
|
||||
return seastar::repeat([omap_iter, &new_progress, &max_len, push_op] {
|
||||
if (!omap_iter->valid()) {
|
||||
new_progress.omap_complete = true;
|
||||
return seastar::make_ready_future<seastar::stop_iteration>(
|
||||
seastar::stop_iteration::yes);
|
||||
}
|
||||
unsigned entry_size = omap_iter->key().size() + omap_iter->value().length();
|
||||
if (!push_op->omap_entries.empty() &&
|
||||
((crimson::common::local_conf()->osd_recovery_max_omap_entries_per_chunk > 0 &&
|
||||
(push_op->omap_entries.size() >=
|
||||
crimson::common::local_conf()->osd_recovery_max_omap_entries_per_chunk)) ||
|
||||
max_len <= entry_size)) {
|
||||
new_progress.omap_recovered_to = omap_iter->key();
|
||||
return seastar::make_ready_future<seastar::stop_iteration>(
|
||||
seastar::stop_iteration::yes);
|
||||
}
|
||||
push_op->omap_entries.emplace(omap_iter->key(), omap_iter->value());
|
||||
if (entry_size >= max_len) {
|
||||
max_len -= entry_size;
|
||||
} else {
|
||||
max_len = 0;
|
||||
}
|
||||
return omap_iter->next().then([](int r) {
|
||||
return seastar::stop_iteration::no;
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
std::list<std::map<pg_shard_t, pg_missing_t>::const_iterator>
|
||||
ReplicatedRecoveryBackend::get_shards_to_push(const hobject_t& soid)
|
||||
{
|
||||
|
@ -134,4 +134,10 @@ private:
|
||||
uint64_t offset,
|
||||
uint64_t max_len,
|
||||
PushOp* push_op);
|
||||
seastar::future<> read_omap_for_push_op(
|
||||
const hobject_t& oid,
|
||||
const ObjectRecoveryProgress& progress,
|
||||
ObjectRecoveryProgress& new_progress,
|
||||
uint64_t max_len,
|
||||
PushOp* push_op);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user