]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: move after-delimiter logic so available in both rgw & cls/osd
authorJ. Eric Ivancich <ivancich@redhat.com>
Tue, 3 Sep 2019 14:49:12 +0000 (10:49 -0400)
committerJ. Eric Ivancich <ivancich@redhat.com>
Fri, 24 Jan 2020 18:44:09 +0000 (13:44 -0500)
Since we need to be able to calculate a key a path subdirectory both
in rgw and cls, move the code that calculates that to cls_rgw_types.h,
which is shared by both rgw and cls/osd.

Signed-off-by: J. Eric Ivancich <ivancich@redhat.com>
src/cls/rgw/cls_rgw_types.h
src/rgw/rgw_rados.cc

index 2b2907ba6fab060a1fc13b2fe8ac8cda12c3bbce..d9212639fed92ede4eaefcda6c5e05a0e2ae1d1b 100644 (file)
@@ -62,6 +62,19 @@ static inline uint64_t cls_rgw_get_rounded_size(uint64_t size)
   return (size + ROUND_BLOCK_SIZE - 1) & ~(ROUND_BLOCK_SIZE - 1);
 }
 
+/*
+ * This takes a string that either wholly contains a delimiter or is a
+ * path that ends with a delimiter and appends a new character to the
+ * end such that when a we request bucket-index entries *after* this,
+ * we'll get the next object after the "subdirectory". This works
+ * because we append a '\xFF' charater, and no valid UTF-8 character
+ * can contain that byte, so no valid entries can be skipped.
+ */
+static inline std::string cls_rgw_after_delim(const std::string& path) {
+  // assert: ! path.empty()
+  return path + '\xFF';
+}
+
 struct rgw_bucket_pending_info {
   RGWPendingState state;
   ceph::real_time timestamp;
index bc405369976fe6efaf462747bd9681bb1c30667b..38ce49f5341d14eadf5bb715b2a2c0cea6eebb69 100644 (file)
@@ -1707,15 +1707,6 @@ int RGWRados::Bucket::update_bucket_id(const string& new_bucket_id)
 }
 
 
-static inline std::string after_delim(std::string_view delim)
-{
-  // assert: ! delim.empty()
-  std::string result{delim.data(), delim.length()};
-  result += char(255);
-  return result;
-}
-
-
 /**
  * Get ordered listing of the objects in a bucket.
  *
@@ -1767,7 +1758,7 @@ int RGWRados::Bucket::List::list_objects_ordered(int64_t max_p,
   string after_delim_s; /* needed in !params.delim.empty() AND later */
 
   if (!params.delim.empty()) {
-    after_delim_s = after_delim(params.delim);
+    after_delim_s = cls_rgw_after_delim(params.delim);
     /* if marker points at a common prefix, fast forward it into its
      * upper bound string */
     int delim_pos = cur_marker.name.find(params.delim, cur_prefix.size());