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.84~74^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=924686f0b6593deffcd1d4e80ab06b1e7af00dcb;p=ceph.git rgw: add NextMarker param for bucket listing Partially fixes #8858. Signed-off-by: Yehuda Sadeh --- diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 052dd2559d54..22742c2d074d 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -1518,7 +1518,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 298df5064111..4afe1ae10192 100644 --- a/src/rgw/rgw_bucket.cc +++ b/src/rgw/rgw_bucket.cc @@ -372,7 +372,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); @@ -388,7 +388,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; @@ -641,7 +641,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 56b498d6af0b..714349f4f8df 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -706,7 +706,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) @@ -1104,7 +1104,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 6b2cc8ce1861..ea33bfbc784b 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -2251,7 +2251,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) { @@ -2318,6 +2319,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 ad29f2de8155..63c9ac73fdd3 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -1440,8 +1440,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 7780b3242765..f6291a0ea7ef 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -257,6 +257,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);