]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: rectify support for GET on Swift's account with limit == 0.
authorRadoslaw Zarzynski <rzarzynski@mirantis.com>
Mon, 30 Mar 2015 19:11:39 +0000 (21:11 +0200)
committerRadoslaw Zarzynski <rzarzynski@mirantis.com>
Mon, 20 Apr 2015 13:04:53 +0000 (15:04 +0200)
Fixes: #10683
Backport: hammer
Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
src/cls/user/cls_user.cc
src/rgw/rgw_op.cc
src/rgw/rgw_rest_swift.cc

index 003a8347889fcdd4b92367fb6040510990529451..3a9111294176209e036c1d864c150389c76a7b0c 100644 (file)
@@ -293,7 +293,7 @@ static int cls_user_list_buckets(cls_method_context_t hctx, bufferlist *in, buff
 
 #define MAX_ENTRIES 1000
   size_t max_entries = op.max_entries;
-  if (!max_entries || max_entries > MAX_ENTRIES)
+  if (max_entries > MAX_ENTRIES)
     max_entries = MAX_ENTRIES;
 
   string match_prefix;
index 24f85ac4da5f0f1a0f0f4f6178bb561b01f245b0..34335b4dd8f12d4d850db1b55ee998b82abd1353 100644 (file)
@@ -999,10 +999,7 @@ void RGWListBuckets::execute()
   do {
     RGWUserBuckets buckets;
     uint64_t read_count;
-    if (limit > 0)
-      read_count = min(limit - total_count, (uint64_t)max_buckets);
-    else
-      read_count = max_buckets;
+    read_count = min(limit - total_count, (uint64_t)max_buckets);
 
     ret = rgw_read_user_buckets(store, s->user.user_id, buckets,
                                 marker, read_count, should_get_stats());
@@ -1032,7 +1029,7 @@ void RGWListBuckets::execute()
 
     total_count += m.size();
 
-    done = (m.size() < read_count || (limit > 0 && total_count == limit));
+    done = (m.size() < read_count || total_count >= limit);
 
     if (!m.empty()) {
       send_response_data(buckets);
index fb59e4f854d8c02523302084d0c14531a9276397..31915baddce06d49c630f95e8e06448d74cb24e4 100644 (file)
 int RGWListBuckets_ObjStore_SWIFT::get_params()
 {
   marker = s->info.args.get("marker");
-  string limit_str;
-  limit_str = s->info.args.get("limit");
-  long l = strtol(limit_str.c_str(), NULL, 10);
-  if (l > (long)limit_max || l < 0)
-    return -ERR_PRECONDITION_FAILED;
 
-  limit = (uint64_t)l;
+  string limit_str = s->info.args.get("limit");
+  if (!limit_str.empty()) {
+    string err;
+    long l = strict_strtol(limit_str.c_str(), 10, &err);
+    if (!err.empty()) {
+      return -EINVAL;
+    }
+
+    if (l > (long)limit_max || l < 0) {
+      return -EINVAL;
+    }
 
-  if (limit == 0)
-    limit = limit_max;
+    limit = (uint64_t)l;
+  }
 
   need_stats = (s->format != RGW_FORMAT_PLAIN);
 
@@ -34,8 +39,9 @@ int RGWListBuckets_ObjStore_SWIFT::get_params()
     bool stats, exists;
     int r = s->info.args.get_bool("stats", &stats, &exists);
 
-    if (r < 0)
+    if (r < 0) {
       return r;
+    }
 
     if (exists) {
       need_stats = stats;