From 8ae61ca506473915e25961a44d451ce481cebe59 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Mon, 20 Feb 2023 11:17:34 -0500 Subject: [PATCH] rgw/rados: add obj_find_part() to RGWObjManifest Signed-off-by: Casey Bodley --- src/rgw/driver/rados/rgw_obj_manifest.cc | 21 +++++++++++++++++++++ src/rgw/driver/rados/rgw_obj_manifest.h | 15 +++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/rgw/driver/rados/rgw_obj_manifest.cc b/src/rgw/driver/rados/rgw_obj_manifest.cc index e7fc363907ffe..2e9f943500896 100644 --- a/src/rgw/driver/rados/rgw_obj_manifest.cc +++ b/src/rgw/driver/rados/rgw_obj_manifest.cc @@ -197,6 +197,27 @@ bool RGWObjManifest::get_rule(uint64_t ofs, RGWObjManifestRule *rule) return true; } +auto RGWObjManifest::obj_find_part(const DoutPrefixProvider *dpp, + int part_num) const + -> obj_iterator +{ + const obj_iterator end = obj_end(dpp); + if (end.get_cur_part_id() == 0) { // not mulitipart + return end; + } + + // linear search over parts/stripes + for (obj_iterator i = obj_begin(dpp); i != end; ++i) { + if (i.get_cur_part_id() == part_num) { + return i; + } + if (i.get_cur_part_id() > part_num) { + return end; + } + } + return end; +} + int RGWObjManifest::generator::create_begin(CephContext *cct, RGWObjManifest *_m, const rgw_placement_rule& head_placement_rule, const rgw_placement_rule *tail_placement_rule, diff --git a/src/rgw/driver/rados/rgw_obj_manifest.h b/src/rgw/driver/rados/rgw_obj_manifest.h index b6b89653372d3..af0ce9ce0fa37 100644 --- a/src/rgw/driver/rados/rgw_obj_manifest.h +++ b/src/rgw/driver/rados/rgw_obj_manifest.h @@ -20,6 +20,7 @@ #pragma once +#include #include "rgw_zone_types.h" #include "rgw_bucket_types.h" #include "rgw_obj_types.h" @@ -57,6 +58,14 @@ public: } } + std::optional get_head_obj() const { + if (is_raw) { + return std::nullopt; + } else { + return obj; + } + } + rgw_raw_obj get_raw_obj(const RGWZoneGroup& zonegroup, const RGWZoneParams& zone_params) const; rgw_raw_obj get_raw_obj(RGWRados* store) const; @@ -547,6 +556,10 @@ public: return ofs; } + const std::string& get_cur_override_prefix() const { + return cur_override_prefix; + } + int get_cur_part_id() const { return cur_part_id; } @@ -582,6 +595,8 @@ public: obj_iterator obj_find(const DoutPrefixProvider *dpp, uint64_t ofs) const { return obj_iterator{dpp, this, std::min(ofs, obj_size)}; } + // return an iterator to the beginning of the given part number + obj_iterator obj_find_part(const DoutPrefixProvider *dpp, int part_num) const; /* * simple object generator. Using a simple single rule manifest. -- 2.39.5