From: Casey Bodley Date: Mon, 20 Feb 2023 16:17:34 +0000 (-0500) Subject: rgw/rados: add obj_find_part() to RGWObjManifest X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=792ec70a4fb5632cdedb5595158bf0c99a3712c6;p=ceph.git rgw/rados: add obj_find_part() to RGWObjManifest Signed-off-by: Casey Bodley (cherry picked from commit 8ae61ca506473915e25961a44d451ce481cebe59) --- diff --git a/src/rgw/driver/rados/rgw_obj_manifest.cc b/src/rgw/driver/rados/rgw_obj_manifest.cc index 92ade8120fdf8..cd2e2a21d9499 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 6984184aa5ed2..0cca288221db2 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; @@ -545,6 +554,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; } @@ -580,6 +593,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.