From: Yehuda Sadeh Date: Thu, 30 Apr 2015 15:37:42 +0000 (-0700) Subject: Merge pull request #4241 from rzarzynski/wip-11285 X-Git-Tag: v9.0.1~48 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3842b63a621c2937331e3dc0bb5d26f65459ba6f;p=ceph.git Merge pull request #4241 from rzarzynski/wip-11285 rgw: rectify broken statistics on Swift account listing. Reviewed-by: Yehuda Sadeh --- 3842b63a621c2937331e3dc0bb5d26f65459ba6f diff --cc src/rgw/rgw_op.cc index 2319bbf132599,1a79589da70b5..35c27d8edbb71 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@@ -999,20 -999,14 +999,15 @@@ void RGWListBuckets::execute( do { RGWUserBuckets buckets; uint64_t read_count; - if (limit > 0) + if (limit >= 0) { read_count = min(limit - total_count, (uint64_t)max_buckets); - else + } else { read_count = max_buckets; + } ret = rgw_read_user_buckets(store, s->user.user_id, buckets, - marker, read_count, should_get_stats()); + marker, read_count, should_get_stats(), 0); - if (!started) { - send_response_begin(buckets.count() > 0); - started = true; - } - if (ret < 0) { /* hmm.. something wrong here.. the user was authenticated, so it should exist */ @@@ -1030,11 -1024,15 +1025,15 @@@ marker = iter->first; } buckets_count += m.size(); - total_count += m.size(); - done = (m.size() < read_count || (limit > 0 && total_count == limit)); + done = (m.size() < read_count || (limit >= 0 && total_count >= (uint64_t)limit)); + if (!started) { + send_response_begin(buckets.count() > 0); + started = true; + } + if (!m.empty()) { send_response_data(buckets); diff --cc src/rgw/rgw_rest_swift.cc index e66955d28b7ab,7e667943202d4..c3d09e43ab4aa --- a/src/rgw/rgw_rest_swift.cc +++ b/src/rgw/rgw_rest_swift.cc @@@ -17,24 -17,17 +17,22 @@@ 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 (limit == 0) - limit = limit_max; + if (l > (long)limit_max || l < 0) { + return -EINVAL; + } + + limit = (uint64_t)l; + } - need_stats = (s->format != RGW_FORMAT_PLAIN); - if (need_stats) { bool stats, exists; int r = s->info.args.get_bool("stats", &stats, &exists);