]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Merge pull request #4241 from rzarzynski/wip-11285
authorYehuda Sadeh <yehuda@redhat.com>
Thu, 30 Apr 2015 15:37:42 +0000 (08:37 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Thu, 30 Apr 2015 15:37:42 +0000 (08:37 -0700)
rgw: rectify broken statistics on Swift account listing.

Reviewed-by: Yehuda Sadeh <yehuda@redhat.com>
1  2 
src/rgw/rgw_op.cc
src/rgw/rgw_rest_swift.cc

index 2319bbf132599727c46e8ca78f92d3a627584883,1a79589da70b5ff435f8144834335ee31b1521d0..35c27d8edbb716fe8602a28995dd4db967ccdaf6
@@@ -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 */
        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);
  
index e66955d28b7ab986178b7f1adb2517737be71fb4,7e667943202d41e62a3b0d40758fb567e57495ce..c3d09e43ab4aa7aa63f5270f44aa0da726c577d8
  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);