]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/rados: add obj_find_part() to RGWObjManifest
authorCasey Bodley <cbodley@redhat.com>
Mon, 20 Feb 2023 16:17:34 +0000 (11:17 -0500)
committerCasey Bodley <cbodley@redhat.com>
Tue, 21 Nov 2023 16:09:23 +0000 (11:09 -0500)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/driver/rados/rgw_obj_manifest.cc
src/rgw/driver/rados/rgw_obj_manifest.h

index e7fc363907ffe76c2c11c08c5f4458c165384cbd..2e9f94350089687bd4cf5c96085a9bf6ca8a6c7a 100644 (file)
@@ -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,
index b6b89653372d31551706d503e89cc803cb96e5d9..af0ce9ce0fa37c3ad7c5319c44d1b57a8c5a3d0d 100644 (file)
@@ -20,6 +20,7 @@
 
 #pragma once
 
+#include <optional>
 #include "rgw_zone_types.h"
 #include "rgw_bucket_types.h"
 #include "rgw_obj_types.h"
@@ -57,6 +58,14 @@ public:
     }
   }
 
+  std::optional<rgw_obj> 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.