From 22a628534307d35e3fa90fb36a98f81cbf7cb7f6 Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Mon, 25 Mar 2024 22:13:40 -0700 Subject: [PATCH] crimson/osd/pg_backend: generalize PGBackend::list_objects, add overloads Signed-off-by: Samuel Just --- src/crimson/osd/pg_backend.cc | 6 ++++-- src/crimson/osd/pg_backend.h | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/crimson/osd/pg_backend.cc b/src/crimson/osd/pg_backend.cc index 8589980c484..bcdf2a6b178 100644 --- a/src/crimson/osd/pg_backend.cc +++ b/src/crimson/osd/pg_backend.cc @@ -1080,12 +1080,14 @@ PGBackend::remove(ObjectState& os, ceph::os::Transaction& txn, } PGBackend::interruptible_future, hobject_t>> -PGBackend::list_objects(const hobject_t& start, uint64_t limit) const +PGBackend::list_objects( + const hobject_t& start, const hobject_t &end, uint64_t limit) const { auto gstart = start.is_min() ? ghobject_t{} : ghobject_t{start, 0, shard}; + auto gend = end.is_max() ? ghobject_t::get_max() : ghobject_t{end, 0, shard}; return interruptor::make_interruptible(store->list_objects(coll, gstart, - ghobject_t::get_max(), + gend, limit)) .then_interruptible([](auto ret) { auto& [gobjects, next] = ret; diff --git a/src/crimson/osd/pg_backend.h b/src/crimson/osd/pg_backend.h index f3f27fd05ba..6d1a1271a44 100644 --- a/src/crimson/osd/pg_backend.h +++ b/src/crimson/osd/pg_backend.h @@ -228,9 +228,42 @@ public: epoch_t min_epoch, epoch_t map_epoch, std::vector&& log_entries); + + /** + * list_objects + * + * List a prefix of length up to limit of the ordered set of logical + * librados objects in [start, end) stored by the PG. + * + * Output excludes objects maintained locally on each pg instance such as: + * - pg_meta object (see hobject_t::is_pgmeta, ghobject_t::make_pgmeta) + * - snap mapper + * as well as + * - temp objects (see hobject_t::is_temp(), hobject_t::make_temp_hobject()) + * - ec rollback objects (see ghobject_t::is_no_gen) + * + * @param [in] start inclusive beginning of range + * @param [in] end exclusive end of range + * @param [in] limit upper bound on number of objects to return + * @return pair where object_list is the output list + * above and next is > the elements in object_list and <= the + * least eligible object in the pg > the elements in object_list + */ interruptible_future, hobject_t>> list_objects( const hobject_t& start, + const hobject_t& end, uint64_t limit) const; + interruptible_future, hobject_t>> list_objects( + const hobject_t& start, + uint64_t limit) const { + return list_objects(start, hobject_t::get_max(), limit); + } + interruptible_future, hobject_t>> list_objects( + const hobject_t& start, + const hobject_t& end) { + return list_objects(start, end, std::numeric_limits::max()); + } + using setxattr_errorator = crimson::errorator< crimson::ct_error::file_too_large, crimson::ct_error::enametoolong>; -- 2.39.5