Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rgw: add support for end_marker parameter for GET on Swift container. #4224

Merged
merged 1 commit into from Apr 9, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/rgw/rgw_common.h
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
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
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
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
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
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