diff options
author | Yehuda Sadeh <yehuda@inktank.com> | 2013-04-26 12:33:03 -0700 |
---|---|---|
committer | Yehuda Sadeh <yehuda@inktank.com> | 2013-04-26 12:33:03 -0700 |
commit | 56ac098b88962a0cbeddfd0fc6cecf03dc4e1df0 (patch) | |
tree | a89be55f1dd35ca6b7b3f2acf8e1d76569f09175 | |
parent | a92b4c7558d936591ca9d7320042b54a68b2962b (diff) | |
parent | c880e9578ed5382d212dc23e1e507e6034cffb5c (diff) | |
download | ceph-56ac098b88962a0cbeddfd0fc6cecf03dc4e1df0.tar.gz |
Merge branch 'wip-4760' into next
-rw-r--r-- | src/rgw/rgw_formats.cc | 15 | ||||
-rw-r--r-- | src/rgw/rgw_formats.h | 1 | ||||
-rw-r--r-- | src/rgw/rgw_op.cc | 40 | ||||
-rw-r--r-- | src/rgw/rgw_op.h | 6 | ||||
-rw-r--r-- | src/rgw/rgw_rest_s3.cc | 2 | ||||
-rw-r--r-- | src/rgw/rgw_rest_s3.h | 7 | ||||
-rw-r--r-- | src/rgw/rgw_rest_swift.cc | 8 | ||||
-rw-r--r-- | src/rgw/rgw_rest_swift.h | 2 |
8 files changed, 43 insertions, 38 deletions
diff --git a/src/rgw/rgw_formats.cc b/src/rgw/rgw_formats.cc index 61d4d04c7a4..66704c4f5bb 100644 --- a/src/rgw/rgw_formats.cc +++ b/src/rgw/rgw_formats.cc @@ -36,18 +36,25 @@ void RGWFormatter_Plain::flush(ostream& os) if (!buf) return; - os << buf; - os.flush(); - reset(); + if (len) { + os << buf << "\n"; + os.flush(); + } + + reset_buf(); } -void RGWFormatter_Plain::reset() +void RGWFormatter_Plain::reset_buf() { free(buf); buf = NULL; len = 0; max_len = 0; +} +void RGWFormatter_Plain::reset() +{ + reset_buf(); stack.clear(); min_stack_level = 0; } diff --git a/src/rgw/rgw_formats.h b/src/rgw/rgw_formats.h index 29767851d5f..0ae917fe7d1 100644 --- a/src/rgw/rgw_formats.h +++ b/src/rgw/rgw_formats.h @@ -17,6 +17,7 @@ struct plain_stack_entry { * There is a much better way to do this. */ class RGWFormatter_Plain : public Formatter { + void reset_buf(); public: RGWFormatter_Plain(); virtual ~RGWFormatter_Plain(); diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 77d5af73a77..0c157c561fb 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -661,35 +661,31 @@ void RGWListBuckets::execute() do { RGWUserBuckets buckets; - uint64_t read_count = min(limit - total_count, max_buckets); + uint64_t read_count; + if (limit > 0) + read_count = min(limit - total_count, (uint64_t)max_buckets); + else + read_count = max_buckets; + ret = rgw_read_user_buckets(store, s->user.user_id, buckets, marker, read_count, should_get_stats()); if (!started) { - send_response_begin(); + send_response_begin(buckets.count() > 0); started = true; } if (ret < 0) { /* hmm.. something wrong here.. the user was authenticated, so it - should exist, just try to recreate */ + should exist */ ldout(s->cct, 10) << "WARNING: failed on rgw_get_user_buckets uid=" << s->user.user_id << dendl; - - /* - - on a second thought, this is probably a bug and we should fail - - rgw_put_user_buckets(s->user.user_id, buckets); - ret = 0; - - */ break; } map<string, RGWBucketEnt>& m = buckets.get_buckets(); total_count += m.size(); - done = (m.size() < read_count); + done = (m.size() < read_count || (limit > 0 && total_count == limit)); if (m.size()) { send_response_data(buckets); @@ -701,7 +697,7 @@ void RGWListBuckets::execute() send_end: if (!started) { - send_response_begin(); + send_response_begin(false); } send_response_end(); } @@ -723,18 +719,8 @@ void RGWStatAccount::execute() ret = rgw_read_user_buckets(store, s->user.user_id, buckets, marker, max_buckets, true); if (ret < 0) { /* hmm.. something wrong here.. the user was authenticated, so it - should exist, just try to recreate */ + should exist */ ldout(s->cct, 10) << "WARNING: failed on rgw_get_user_buckets uid=" << s->user.user_id << dendl; - - /* - - on a second thought, this is probably a bug and we should fail - - rgw_put_user_buckets(s->user.user_id, buckets); - ret = 0; - - */ - break; } else { map<string, RGWBucketEnt>& m = buckets.get_buckets(); @@ -744,8 +730,10 @@ void RGWStatAccount::execute() buckets_size += bucket.size; buckets_size_rounded += bucket.size_rounded; buckets_objcount += bucket.count; + + marker = iter->first; } - buckets_count = m.size(); + buckets_count += m.size(); done = (m.size() < max_buckets); } diff --git a/src/rgw/rgw_op.h b/src/rgw/rgw_op.h index 16e8f348778..b3e8c86e3f0 100644 --- a/src/rgw/rgw_op.h +++ b/src/rgw/rgw_op.h @@ -121,6 +121,8 @@ public: virtual const char *name() { return "get_obj"; } }; +#define RGW_LIST_BUCKETS_LIMIT_MAX 10000 + class RGWListBuckets : public RGWOp { protected: int ret; @@ -131,14 +133,14 @@ protected: public: RGWListBuckets() : ret(0), sent_data(false) { - limit = limit_max = 10000; + limit = limit_max = RGW_LIST_BUCKETS_LIMIT_MAX; } int verify_permission(); void execute(); virtual int get_params() = 0; - virtual void send_response_begin() = 0; + virtual void send_response_begin(bool has_buckets) = 0; virtual void send_response_data(RGWUserBuckets& buckets) = 0; virtual void send_response_end() = 0; virtual void send_response() {} diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index 6866d17e8aa..38fab1bd2c1 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -156,7 +156,7 @@ send_data: return 0; } -void RGWListBuckets_ObjStore_S3::send_response_begin() +void RGWListBuckets_ObjStore_S3::send_response_begin(bool has_buckets) { if (ret) set_req_state_err(s, ret); diff --git a/src/rgw/rgw_rest_s3.h b/src/rgw/rgw_rest_s3.h index 16325978a7a..ea8e5edc2cb 100644 --- a/src/rgw/rgw_rest_s3.h +++ b/src/rgw/rgw_rest_s3.h @@ -25,8 +25,11 @@ public: RGWListBuckets_ObjStore_S3() {} ~RGWListBuckets_ObjStore_S3() {} - int get_params() { return 0; } - virtual void send_response_begin(); + int get_params() { + limit = 0; /* no limit */ + return 0; + } + virtual void send_response_begin(bool has_buckets); virtual void send_response_data(RGWUserBuckets& buckets); virtual void send_response_end(); }; diff --git a/src/rgw/rgw_rest_swift.cc b/src/rgw/rgw_rest_swift.cc index 635bd2e7a01..f656bfb6821 100644 --- a/src/rgw/rgw_rest_swift.cc +++ b/src/rgw/rgw_rest_swift.cc @@ -43,10 +43,14 @@ int RGWListBuckets_ObjStore_SWIFT::get_params() return 0; } -void RGWListBuckets_ObjStore_SWIFT::send_response_begin() +void RGWListBuckets_ObjStore_SWIFT::send_response_begin(bool has_buckets) { - if (ret) + if (ret) { + set_req_state_err(s, ret); + } else if (!has_buckets && s->format == RGW_FORMAT_PLAIN) { + ret = STATUS_NO_CONTENT; set_req_state_err(s, ret); + } dump_errno(s); end_header(s); diff --git a/src/rgw/rgw_rest_swift.h b/src/rgw/rgw_rest_swift.h index e721f1cd1c1..e4b6f0bccee 100644 --- a/src/rgw/rgw_rest_swift.h +++ b/src/rgw/rgw_rest_swift.h @@ -20,7 +20,7 @@ public: ~RGWListBuckets_ObjStore_SWIFT() {} int get_params(); - void send_response_begin(); + void send_response_begin(bool has_buckets); void send_response_data(RGWUserBuckets& buckets); void send_response_end(); |