Skip to content

Commit

Permalink
crimson/osd/pg: filter out snapmapper objects when doing pgls/pgnls
Browse files Browse the repository at this point in the history
Signed-off-by: Xuehan Xu <xuxuehan@qianxin.com>
  • Loading branch information
xxhdx1985126 committed Feb 21, 2024
1 parent 9868bea commit 32408e9
Showing 1 changed file with 27 additions and 10 deletions.
37 changes: 27 additions & 10 deletions src/crimson/osd/ops_executer.cc
Expand Up @@ -1173,7 +1173,8 @@ static PG::interruptible_future<ceph::bufferlist> do_pgnls_common(
const hobject_t& lower_bound,
const std::string& nspace,
const uint64_t limit,
const PGLSFilter* const filter)
const PGLSFilter* const filter,
const PG &pg)
{
if (!(lower_bound.is_min() ||
lower_bound.is_max() ||
Expand All @@ -1183,9 +1184,16 @@ static PG::interruptible_future<ceph::bufferlist> do_pgnls_common(
}

return backend.list_objects(lower_bound, limit).then_interruptible(
[&backend, filter, nspace](auto&& ret)
[&backend, filter, nspace, &pg](auto&& ret)
-> PG::interruptible_future<std::tuple<std::vector<hobject_t>, hobject_t>> {
auto& [objects, next] = ret;
auto is_snapmapper = [&pg](const hobject_t &obj) {
if (obj == pg.make_snapmapper_oid().hobj) {
return false;
} else {
return true;
}
};
auto in_my_namespace = [&nspace](const hobject_t& obj) {
using crimson::common::local_conf;
if (obj.get_namespace() == local_conf()->osd_hit_set_namespace) {
Expand Down Expand Up @@ -1213,7 +1221,8 @@ static PG::interruptible_future<ceph::bufferlist> do_pgnls_common(
}
};

auto range = objects | boost::adaptors::filtered(in_my_namespace)
auto range = objects | boost::adaptors::filtered(is_snapmapper)
| boost::adaptors::filtered(in_my_namespace)
| boost::adaptors::transformed(to_pglsed);
logger().debug("do_pgnls_common: finishing the 1st stage of pgls");
return seastar::when_all_succeed(std::begin(range),
Expand Down Expand Up @@ -1270,7 +1279,8 @@ static PG::interruptible_future<> do_pgnls(
lower_bound,
nspace,
osd_op.op.pgls.count,
nullptr /* no filter */)
nullptr /* no filter */,
pg)
.then_interruptible([&osd_op](bufferlist bl) {
osd_op.outdata = std::move(bl);
return seastar::now();
Expand Down Expand Up @@ -1314,7 +1324,8 @@ static PG::interruptible_future<> do_pgnls_filtered(
lower_bound,
nspace,
osd_op.op.pgls.count,
filter.get())
filter.get(),
pg)
.then_interruptible([&osd_op](bufferlist bl) {
osd_op.outdata = std::move(bl);
return seastar::now();
Expand All @@ -1329,7 +1340,8 @@ static PG::interruptible_future<ceph::bufferlist> do_pgls_common(
const hobject_t& lower_bound,
const std::string& nspace,
const uint64_t limit,
const PGLSFilter* const filter)
const PGLSFilter* const filter,
const PG &pg)
{
if (!(lower_bound.is_min() ||
lower_bound.is_max() ||
Expand All @@ -1340,12 +1352,15 @@ static PG::interruptible_future<ceph::bufferlist> do_pgls_common(

using entries_t = decltype(pg_ls_response_t::entries);
return backend.list_objects(lower_bound, limit).then_interruptible(
[&backend, filter, nspace](auto&& ret) {
[&backend, filter, nspace, &pg](auto&& ret) {
auto& [objects, next] = ret;
return PG::interruptor::when_all(
PG::interruptor::map_reduce(std::move(objects),
[&backend, filter, nspace](const hobject_t& obj)
[&backend, filter, nspace, &pg](const hobject_t& obj)
-> PG::interruptible_future<hobject_t>{
if (obj == pg.make_snapmapper_oid().hobj) {
return seastar::make_ready_future<hobject_t>();
}
if (obj.get_namespace() == nspace) {
if (filter) {
return pgls_filter(*filter, backend, obj);
Expand Down Expand Up @@ -1399,7 +1414,8 @@ static PG::interruptible_future<> do_pgls(
lower_bound,
nspace,
osd_op.op.pgls.count,
nullptr /* no filter */)
nullptr /* no filter */,
pg)
.then_interruptible([&osd_op](bufferlist bl) {
osd_op.outdata = std::move(bl);
return seastar::now();
Expand Down Expand Up @@ -1443,7 +1459,8 @@ static PG::interruptible_future<> do_pgls_filtered(
lower_bound,
nspace,
osd_op.op.pgls.count,
filter.get())
filter.get(),
pg)
.then_interruptible([&osd_op](bufferlist bl) {
osd_op.outdata = std::move(bl);
return seastar::now();
Expand Down

0 comments on commit 32408e9

Please sign in to comment.