rgw: add NextMarker param for bucket listing

Partially fixes #8858.

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
This commit is contained in:
Yehuda Sadeh 2014-07-17 11:24:51 -07:00 committed by Yehuda Sadeh
parent e6cf618c25
commit 924686f0b6
7 changed files with 21 additions and 10 deletions

View File

@ -1518,7 +1518,7 @@ int main(int argc, char **argv)
do {
list<rgw_bi_log_entry> 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;

View File

@ -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<RGWObjEnt> 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);

View File

@ -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<RGWObjEnt>::iterator iter;

View File

@ -202,6 +202,7 @@ class RGWListBucket : public RGWOp {
protected:
string prefix;
string marker;
string next_marker;
string max_keys;
string delimiter;
int max;

View File

@ -2251,7 +2251,8 @@ int rgw_policy_from_attrset(CephContext *cct, map<string, bufferlist>& attrset,
* here.
*/
int RGWRados::list_objects(rgw_bucket& bucket, int max, string& prefix, string& delim,
string& marker, vector<RGWObjEnt>& result, map<string, bool>& common_prefixes,
string& marker, string *next_marker, vector<RGWObjEnt>& result,
map<string, bool>& 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;

View File

@ -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<RGWObjEnt>& result, map<string, bool>& 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<RGWObjEnt>& result,
map<string, bool>& common_prefixes, bool get_content_type, string& ns, bool enforce_ns,
bool *is_truncated, RGWAccessListFilter *filter);
virtual int create_pool(rgw_bucket& bucket);

View File

@ -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);