mirror of
https://github.com/ceph/ceph
synced 2025-01-20 01:51:34 +00:00
crimson/os/seastore/seastore: add helpers to simplify omap usage
Add _omap_get_values and _omap_get_value to clarify omap_get_values and get_attr. Also resolves a clang linker error. Signed-off-by: Samuel Just <sjust@redhat.com>
This commit is contained in:
parent
7d56e0e342
commit
75827db6a3
@ -259,23 +259,10 @@ SeaStore::get_attr_errorator::future<ceph::bufferlist> SeaStore::get_attr(
|
||||
bl.append(ceph::bufferptr(&layout.ss[0], layout.ss_size));
|
||||
return seastar::make_ready_future<ceph::bufferlist>(std::move(bl));
|
||||
}
|
||||
return seastar::do_with(
|
||||
BtreeOMapManager(*transaction_manager),
|
||||
return _omap_get_value(
|
||||
t,
|
||||
layout.xattr_root.get(),
|
||||
std::string(name),
|
||||
[&t](auto &manager, auto& root, auto& name) {
|
||||
if (root.is_null()) {
|
||||
return get_attr_ertr::make_ready_future<ceph::bufferlist>(
|
||||
ceph::bufferlist());
|
||||
}
|
||||
return manager.omap_get_value(root, t, name).safe_then([](auto opt)
|
||||
-> get_attr_ertr::future<ceph::bufferlist> {
|
||||
if (!opt) {
|
||||
return crimson::ct_error::enodata::make();
|
||||
}
|
||||
return seastar::make_ready_future<ceph::bufferlist>(std::move(*opt));
|
||||
});
|
||||
});
|
||||
name);
|
||||
}).handle_error(crimson::ct_error::input_output_error::handle([FNAME] {
|
||||
ERROR("EIO when getting attrs");
|
||||
abort();
|
||||
@ -338,10 +325,6 @@ seastar::future<struct stat> SeaStore::stat(
|
||||
);
|
||||
}
|
||||
|
||||
using omap_int_ertr_t = OMapManager::base_ertr::extend<
|
||||
crimson::ct_error::enoent
|
||||
>;
|
||||
|
||||
auto
|
||||
SeaStore::omap_get_header(
|
||||
CollectionRef c,
|
||||
@ -351,52 +334,84 @@ SeaStore::omap_get_header(
|
||||
return seastar::make_ready_future<bufferlist>();
|
||||
}
|
||||
|
||||
auto
|
||||
SeaStore::read_errorator::future<SeaStore::omap_values_t>
|
||||
SeaStore::omap_get_values(
|
||||
CollectionRef ch,
|
||||
const ghobject_t &oid,
|
||||
const omap_keys_t &keys)
|
||||
-> read_errorator::future<omap_values_t>
|
||||
{
|
||||
using int_ret_t = omap_int_ertr_t::future<omap_values_t>;
|
||||
auto c = static_cast<SeastoreCollection*>(ch.get());
|
||||
return repeat_with_onode<omap_values_t>(
|
||||
c,
|
||||
oid,
|
||||
[this, &keys](auto &t, auto &onode) -> int_ret_t {
|
||||
auto omap_root = onode.get_layout().omap_root.get();
|
||||
if (omap_root.is_null()) {
|
||||
return seastar::make_ready_future<omap_values_t>();
|
||||
} else {
|
||||
return seastar::do_with(
|
||||
BtreeOMapManager(*transaction_manager),
|
||||
omap_root,
|
||||
omap_values_t(),
|
||||
[&](auto &manager, auto &root, auto &ret) -> int_ret_t {
|
||||
return crimson::do_for_each(
|
||||
keys.begin(),
|
||||
keys.end(),
|
||||
[&](auto &key) {
|
||||
return manager.omap_get_value(
|
||||
root,
|
||||
t,
|
||||
key
|
||||
).safe_then([&ret, &key](auto &&p) {
|
||||
if (p) {
|
||||
bufferlist bl;
|
||||
bl.append(*p);
|
||||
ret.emplace(
|
||||
std::make_pair(
|
||||
std::move(key),
|
||||
std::move(bl)));
|
||||
}
|
||||
return seastar::now();
|
||||
});
|
||||
}).safe_then([&ret] {
|
||||
return std::move(ret);
|
||||
});
|
||||
});
|
||||
[this, &keys](auto &t, auto &onode) {
|
||||
omap_root_t omap_root = onode.get_layout().omap_root.get();
|
||||
return _omap_get_values(
|
||||
t,
|
||||
std::move(omap_root),
|
||||
keys);
|
||||
});
|
||||
}
|
||||
|
||||
SeaStore::_omap_get_value_ret SeaStore::_omap_get_value(
|
||||
Transaction &t,
|
||||
omap_root_t &&root,
|
||||
std::string_view key) const
|
||||
{
|
||||
return seastar::do_with(
|
||||
BtreeOMapManager(*transaction_manager),
|
||||
std::move(root),
|
||||
std::string(key),
|
||||
[&t](auto &manager, auto& root, auto& key) -> _omap_get_value_ret {
|
||||
if (root.is_null()) {
|
||||
return crimson::ct_error::enodata::make();
|
||||
}
|
||||
return manager.omap_get_value(
|
||||
root, t, key
|
||||
).safe_then([](auto opt) -> _omap_get_value_ret {
|
||||
if (!opt) {
|
||||
return crimson::ct_error::enodata::make();
|
||||
}
|
||||
return seastar::make_ready_future<ceph::bufferlist>(std::move(*opt));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
SeaStore::_omap_get_values_ret SeaStore::_omap_get_values(
|
||||
Transaction &t,
|
||||
omap_root_t &&omap_root,
|
||||
const omap_keys_t &keys) const
|
||||
{
|
||||
if (omap_root.is_null()) {
|
||||
return seastar::make_ready_future<omap_values_t>();
|
||||
}
|
||||
return seastar::do_with(
|
||||
BtreeOMapManager(*transaction_manager),
|
||||
std::move(omap_root),
|
||||
omap_values_t(),
|
||||
[&](auto &manager, auto &root, auto &ret) {
|
||||
return crimson::do_for_each(
|
||||
keys.begin(),
|
||||
keys.end(),
|
||||
[&](auto &key) {
|
||||
return manager.omap_get_value(
|
||||
root,
|
||||
t,
|
||||
key
|
||||
).safe_then([&ret, &key](auto &&p) {
|
||||
if (p) {
|
||||
bufferlist bl;
|
||||
bl.append(*p);
|
||||
ret.emplace(
|
||||
std::make_pair(
|
||||
std::move(key),
|
||||
std::move(bl)));
|
||||
}
|
||||
return seastar::now();
|
||||
});
|
||||
}).safe_then([&ret] {
|
||||
return std::move(ret);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -195,6 +195,22 @@ private:
|
||||
});
|
||||
}
|
||||
|
||||
using _omap_get_value_ertr = OMapManager::base_ertr::extend<
|
||||
crimson::ct_error::enodata
|
||||
>;
|
||||
using _omap_get_value_ret = _omap_get_value_ertr::future<ceph::bufferlist>;
|
||||
_omap_get_value_ret _omap_get_value(
|
||||
Transaction &t,
|
||||
omap_root_t &&root,
|
||||
std::string_view key) const;
|
||||
|
||||
using _omap_get_values_ertr = OMapManager::base_ertr;
|
||||
using _omap_get_values_ret = _omap_get_values_ertr::future<omap_values_t>;
|
||||
_omap_get_values_ret _omap_get_values(
|
||||
Transaction &t,
|
||||
omap_root_t &&root,
|
||||
const omap_keys_t &keys) const;
|
||||
|
||||
using _omap_list_bare_ret = OMapManager::omap_list_bare_ret;
|
||||
using _omap_list_ret = OMapManager::omap_list_ret;
|
||||
_omap_list_ret _omap_list(
|
||||
|
Loading…
Reference in New Issue
Block a user