Skip to content

Commit

Permalink
rgw: add support for end_marker for GET on Swift container.
Browse files Browse the repository at this point in the history
Fixes: ceph#10682
Backport: hammer
Signed-off-by: Radoslaw Zarzynski <[email protected]>
  • Loading branch information
rzarzynski committed Apr 7, 2015
1 parent f3f37a3 commit 50cf743
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/rgw/rgw_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/rgw/rgw_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/rgw/rgw_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ class RGWListBucket : public RGWOp {
string prefix;
rgw_obj_key marker;
rgw_obj_key next_marker;
rgw_obj_key end_marker;
string max_keys;
string delimiter;
bool list_versions;
Expand Down
15 changes: 14 additions & 1 deletion src/rgw/rgw_rados.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2315,6 +2315,7 @@ int rgw_policy_from_attrset(CephContext *cct, map<string, bufferlist>& 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.
Expand All @@ -2335,13 +2336,20 @@ int RGWRados::Bucket::List::list_objects(int max, vector<RGWObjEnt> *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();
Expand Down Expand Up @@ -2407,6 +2415,11 @@ int RGWRados::Bucket::List::list_objects(int max, vector<RGWObjEnt> *result,
continue;
}

if (cur_end_marker_valid && cur_end_marker <= obj) {
truncated = false;
goto done;
}

if (count < max) {
params.marker = obj;
next_marker = obj;
Expand Down
1 change: 1 addition & 0 deletions src/rgw/rgw_rados.h
Original file line number Diff line number Diff line change
Expand Up @@ -1641,6 +1641,7 @@ class RGWRados
string prefix;
string delim;
rgw_obj_key marker;
rgw_obj_key end_marker;
string ns;
bool enforce_ns;
RGWAccessListFilter *filter;
Expand Down
1 change: 1 addition & 0 deletions src/rgw/rgw_rest_swift.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 50cf743

Please sign in to comment.