From: Yehuda Sadeh Date: Thu, 17 Jul 2014 18:24:51 +0000 (-0700) Subject: rgw: add NextMarker param for bucket listing X-Git-Tag: v0.80.5~5^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=cb0a7ab8eb1d2fc8799b97c5a387b5f4f93b515c;p=ceph.git rgw: add NextMarker param for bucket listing Partially fixes #8858. Signed-off-by: Yehuda Sadeh (cherry picked from commit 924686f0b6593deffcd1d4e80ab06b1e7af00dcb) --- diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index ec8387803719..e31a28a67668 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -1495,7 +1495,7 @@ int main(int argc, char **argv) do { list entries; ret = store->list_objects(bucket, max_entries - count, prefix, delim, - marker, result, common_prefixes, true, + marker, NULL, result, common_prefixes, true, ns, false, &truncated, NULL); if (ret < 0) { cerr << "ERROR: store->list_objects(): " << cpp_strerror(-ret) << std::endl; diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc index 9827bad309c9..3c4f66c9e089 100644 --- a/src/rgw/rgw_bucket.cc +++ b/src/rgw/rgw_bucket.cc @@ -368,7 +368,7 @@ int rgw_remove_bucket(RGWRados *store, const string& bucket_owner, rgw_bucket& b if (delete_children) { int max = 1000; - ret = store->list_objects(bucket, max, prefix, delim, marker, + ret = store->list_objects(bucket, max, prefix, delim, marker, NULL, objs, common_prefixes, false, ns, true, NULL, NULL); @@ -384,7 +384,7 @@ int rgw_remove_bucket(RGWRados *store, const string& bucket_owner, rgw_bucket& b } objs.clear(); - ret = store->list_objects(bucket, max, prefix, delim, marker, objs, common_prefixes, + ret = store->list_objects(bucket, max, prefix, delim, marker, NULL, objs, common_prefixes, false, ns, true, NULL, NULL); if (ret < 0) return ret; @@ -630,7 +630,7 @@ int RGWBucket::check_bad_index_multipart(RGWBucketAdminOpState& op_state, do { vector result; - int r = store->list_objects(bucket, max, prefix, delim, marker, + int r = store->list_objects(bucket, max, prefix, delim, marker, NULL, result, common_prefixes, false, ns, true, &is_truncated, NULL); diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 7894927cfc2d..8979619293c3 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -704,7 +704,7 @@ static int iterate_user_manifest_parts(CephContext *cct, RGWRados *store, off_t do { #define MAX_LIST_OBJS 100 - int r = store->list_objects(bucket, MAX_LIST_OBJS, obj_prefix, delim, marker, + int r = store->list_objects(bucket, MAX_LIST_OBJS, obj_prefix, delim, marker, NULL, objs, common_prefixes, true, no_ns, true, &is_truncated, NULL); if (r < 0) @@ -1102,7 +1102,9 @@ void RGWListBucket::execute() if (ret < 0) return; - ret = store->list_objects(s->bucket, max, prefix, delimiter, marker, objs, common_prefixes, + string *pnext_marker = (delimiter.empty() ? NULL : &next_marker); + + ret = store->list_objects(s->bucket, max, prefix, delimiter, marker, pnext_marker, objs, common_prefixes, !!(s->prot_flags & RGW_REST_SWIFT), no_ns, true, &is_truncated, NULL); } @@ -2993,7 +2995,7 @@ void RGWListBucketMultiparts::execute() } } marker_meta = marker.get_meta(); - ret = store->list_objects(s->bucket, max_uploads, prefix, delimiter, marker_meta, objs, common_prefixes, + ret = store->list_objects(s->bucket, max_uploads, prefix, delimiter, marker_meta, NULL, objs, common_prefixes, !!(s->prot_flags & RGW_REST_SWIFT), mp_ns, true, &is_truncated, &mp_filter); if (!objs.empty()) { vector::iterator iter; diff --git a/src/rgw/rgw_op.h b/src/rgw/rgw_op.h index 95a34edc2b94..b141ed5bd1bc 100644 --- a/src/rgw/rgw_op.h +++ b/src/rgw/rgw_op.h @@ -202,6 +202,7 @@ class RGWListBucket : public RGWOp { protected: string prefix; string marker; + string next_marker; string max_keys; string delimiter; int max; diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index cb84ab37fafe..a2600beeb76a 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -2086,7 +2086,8 @@ int rgw_policy_from_attrset(CephContext *cct, map& attrset, * here. */ int RGWRados::list_objects(rgw_bucket& bucket, int max, string& prefix, string& delim, - string& marker, vector& result, map& common_prefixes, + string& marker, string *next_marker, vector& result, + map& common_prefixes, bool get_content_type, string& ns, bool enforce_ns, bool *is_truncated, RGWAccessListFilter *filter) { @@ -2153,6 +2154,10 @@ int RGWRados::list_objects(rgw_bucket& bucket, int max, string& prefix, string& continue; } + if (next_marker) { + *next_marker = obj; + } + if (filter && !filter->filter(obj, key)) continue; diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 5cc9c73407b9..d50fb592edb9 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -1392,8 +1392,9 @@ public: * here. */ virtual int list_objects(rgw_bucket& bucket, int max, std::string& prefix, std::string& delim, - std::string& marker, std::vector& result, map& common_prefixes, - bool get_content_type, string& ns, bool enforce_ns, bool *is_truncated, RGWAccessListFilter *filter); + std::string& marker, std::string *next_marker, std::vector& result, + map& common_prefixes, bool get_content_type, string& ns, bool enforce_ns, + bool *is_truncated, RGWAccessListFilter *filter); virtual int create_pool(rgw_bucket& bucket); diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index b28c2a947922..84499b0e43ec 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -254,6 +254,8 @@ void RGWListBucket_ObjStore_S3::send_response() if (!prefix.empty()) s->formatter->dump_string("Prefix", prefix); s->formatter->dump_string("Marker", marker); + if (is_truncated && !next_marker.empty()) + s->formatter->dump_string("NextMarker", next_marker); s->formatter->dump_int("MaxKeys", max); if (!delimiter.empty()) s->formatter->dump_string("Delimiter", delimiter);