From: Radoslaw Zarzynski Date: Mon, 30 Mar 2015 13:00:59 +0000 (+0200) Subject: rgw: add support for end_marker for GET on Swift container. X-Git-Tag: v9.0.1~165^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F4224%2Fhead;p=ceph.git rgw: add support for end_marker for GET on Swift container. Fixes: #10682 Backport: hammer Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index 0a796c08deaf..a26d96e7c0fe 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -967,6 +967,9 @@ struct rgw_obj_key { } return (r < 0); } + bool operator<=(const rgw_obj_key& k) const { + return !(k < *this); + } void encode(bufferlist& bl) const { ENCODE_START(1, 1, bl); ::encode(name, bl); diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 24f85ac4da5f..b499a03790b1 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -1227,6 +1227,7 @@ void RGWListBucket::execute() list_op.params.prefix = prefix; list_op.params.delim = delimiter; list_op.params.marker = marker; + list_op.params.end_marker = end_marker; list_op.params.list_versions = list_versions; ret = list_op.list_objects(max, &objs, &common_prefixes, &is_truncated); diff --git a/src/rgw/rgw_op.h b/src/rgw/rgw_op.h index e5c1fde009a8..c036b78a06db 100644 --- a/src/rgw/rgw_op.h +++ b/src/rgw/rgw_op.h @@ -249,6 +249,7 @@ protected: string prefix; rgw_obj_key marker; rgw_obj_key next_marker; + rgw_obj_key end_marker; string max_keys; string delimiter; bool list_versions; diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 5183747aff33..9ee56f82dd26 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -2315,6 +2315,7 @@ int rgw_policy_from_attrset(CephContext *cct, map& attrset, * Any skipped results will have the matching portion of their name * inserted in common_prefixes with a "true" mark. * marker: if filled in, begin the listing with this object. + * end_marker: if filled in, end the listing with this object. * result: the objects are put in here. * common_prefixes: if delim is filled in, any matching prefixes are placed * here. @@ -2335,13 +2336,20 @@ int RGWRados::Bucket::List::list_objects(int max, vector *result, } result->clear(); - rgw_obj marker_obj, prefix_obj; + rgw_obj marker_obj, end_marker_obj, prefix_obj; marker_obj.set_instance(params.marker.instance); marker_obj.set_ns(params.ns); marker_obj.set_obj(params.marker.name); rgw_obj_key cur_marker; marker_obj.get_index_key(&cur_marker); + end_marker_obj.set_instance(params.end_marker.instance); + end_marker_obj.set_ns(params.ns); + end_marker_obj.set_obj(params.end_marker.name); + rgw_obj_key cur_end_marker; + end_marker_obj.get_index_key(&cur_end_marker); + const bool cur_end_marker_valid = !cur_end_marker.empty(); + prefix_obj.set_ns(params.ns); prefix_obj.set_obj(params.prefix); string cur_prefix = prefix_obj.get_index_key_name(); @@ -2407,6 +2415,11 @@ int RGWRados::Bucket::List::list_objects(int max, vector *result, continue; } + if (cur_end_marker_valid && cur_end_marker <= obj) { + truncated = false; + goto done; + } + if (count < max) { params.marker = obj; next_marker = obj; diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index a3fd6c09d737..47fa126e1c25 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -1641,6 +1641,7 @@ public: string prefix; string delim; rgw_obj_key marker; + rgw_obj_key end_marker; string ns; bool enforce_ns; RGWAccessListFilter *filter; diff --git a/src/rgw/rgw_rest_swift.cc b/src/rgw/rgw_rest_swift.cc index fb59e4f854d8..0e4a133f9f97 100644 --- a/src/rgw/rgw_rest_swift.cc +++ b/src/rgw/rgw_rest_swift.cc @@ -117,6 +117,7 @@ int RGWListBucket_ObjStore_SWIFT::get_params() { prefix = s->info.args.get("prefix"); marker = s->info.args.get("marker"); + end_marker = s->info.args.get("end_marker"); max_keys = s->info.args.get("limit"); ret = parse_max_keys(); if (ret < 0) {