From: J. Eric Ivancich Date: Tue, 3 Sep 2019 14:49:12 +0000 (-0400) Subject: rgw: move after-delimiter logic so available in both rgw & cls/osd X-Git-Tag: v15.1.0~56^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ae7383a51ca86c01bc152293973d3640a31decfc;p=ceph.git rgw: move after-delimiter logic so available in both rgw & cls/osd 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 --- diff --git a/src/cls/rgw/cls_rgw_types.h b/src/cls/rgw/cls_rgw_types.h index 2b2907ba6fab..d9212639fed9 100644 --- a/src/cls/rgw/cls_rgw_types.h +++ b/src/cls/rgw/cls_rgw_types.h @@ -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; diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index bc405369976f..38ce49f5341d 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -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());