summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYehuda Sadeh <yehuda@inktank.com>2013-03-06 19:32:21 -0800
committerYehuda Sadeh <yehuda@inktank.com>2013-03-07 09:46:49 -0800
commite06d2061761ffa95c5e8512197dd38aff513422f (patch)
treee34ee8c7d4587300ae9aa4cf6aa523d1c94a6336
parent9cb6c33f0e2281b66cc690a28e08459f2e62ca13 (diff)
downloadceph-wip-4363.tar.gz
rgw: don't iteraste through all objects when in namespacewip-4363
Fixes: #4363 Backport: argnaut, bobtail When listing objects in namespace don't iterate through all the objects, only go though the ones that starts with the namespace prefix Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
-rw-r--r--src/rgw/rgw_rados.cc22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc
index 552d8703c4e..aa33cfdc904 100644
--- a/src/rgw/rgw_rados.cc
+++ b/src/rgw/rgw_rados.cc
@@ -509,11 +509,22 @@ int RGWRados::list_objects(rgw_bucket& bucket, int max, string& prefix, string&
int count = 0;
string cur_marker = marker;
bool truncated;
+ string ns_prefix;
if (bucket_is_system(bucket)) {
return -EINVAL;
}
result.clear();
+ if (!ns.empty()) {
+ ns_prefix = "_";
+ ns_prefix += ns + "_";
+ if (cur_marker < ns_prefix) {
+ cur_marker = ns_prefix;
+ } else if (cur_marker.substr(0, ns.size()) > ns_prefix) {
+ truncated = false;
+ goto done;
+ }
+ }
do {
std::map<string, RGWObjEnt> ent_map;
@@ -527,8 +538,16 @@ int RGWRados::list_objects(rgw_bucket& bucket, int max, string& prefix, string&
string obj = eiter->first;
string key = obj;
- if (!rgw_obj::translate_raw_obj_to_obj_in_ns(obj, ns))
+ if (!rgw_obj::translate_raw_obj_to_obj_in_ns(obj, ns)) {
+ if (!ns.empty()) {
+ /* we're not under the namespace anymore, we're done */
+ truncated = false;
+ goto done;
+ }
+
+ /* we're not under the namespace this object is in, next! */
continue;
+ }
if (filter && !filter->filter(obj, key))
continue;
@@ -552,6 +571,7 @@ int RGWRados::list_objects(rgw_bucket& bucket, int max, string& prefix, string&
}
} while (truncated && count < max);
+done:
if (is_truncated)
*is_truncated = truncated;