From: liuchang0812 Date: Wed, 5 Apr 2017 12:06:11 +0000 (+0800) Subject: rgw: use is_truncated to judge whether get all bucket already X-Git-Tag: v12.0.2~109^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7a3fbbfac662e437d79590fdc65cc3480bf31a39;p=ceph.git rgw: use is_truncated to judge whether get all bucket already That use is_truncated is simple and avoid nessesary list. We have to iterate 11 times initially if there is 100 buckets and iter_max_bucket is 10. We only need 10 times now. Signed-off-by: liuchang0812 --- diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc index e9221783e528..02b05c485b76 100644 --- a/src/rgw/rgw_bucket.cc +++ b/src/rgw/rgw_bucket.cc @@ -444,7 +444,6 @@ void check_bad_user_bucket_mapping(RGWRados *store, const rgw_user& user_id, bool fix) { RGWUserBuckets user_buckets; - bool done; bool is_truncated; string marker; @@ -496,8 +495,7 @@ void check_bad_user_bucket_mapping(RGWRados *store, const rgw_user& user_id, } } } - done = (buckets.size() < max_entries); - } while (!done); + } while (is_truncated); } static bool bucket_object_check_filter(const string& oid) @@ -1431,7 +1429,6 @@ int RGWBucketAdminOp::info(RGWRados *store, RGWBucketAdminOpState& op_state, RGWUserBuckets buckets; string marker; - bool done; bool is_truncated; do { @@ -1455,8 +1452,7 @@ int RGWBucketAdminOp::info(RGWRados *store, RGWBucketAdminOpState& op_state, } flusher.flush(); - done = (m.size() < max_entries); - } while (!done); + } while (is_truncated); formatter->close_section(); } else if (!bucket_name.empty()) { diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index a4572dd3a947..441ca6be0dff 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -1620,7 +1620,7 @@ void RGWListBuckets::execute() map::reverse_iterator riter = m.rbegin(); marker = riter->first; } - } while (!done); + } while (is_truncated && !done); send_end: if (!started) { @@ -1701,7 +1701,6 @@ int RGWStatAccount::verify_permission() void RGWStatAccount::execute() { string marker; - bool done; bool is_truncated; uint64_t max_buckets = s->cct->_conf->rgw_list_buckets_max_chunk; @@ -1729,9 +1728,8 @@ void RGWStatAccount::execute() } buckets_count += m.size(); - done = (m.size() < max_buckets); } - } while (!done); + } while (is_truncated); } int RGWGetBucketVersioning::verify_permission() diff --git a/src/rgw/rgw_user.cc b/src/rgw/rgw_user.cc index 0a8a6250cceb..94e40698c849 100644 --- a/src/rgw/rgw_user.cc +++ b/src/rgw/rgw_user.cc @@ -45,7 +45,6 @@ int rgw_user_sync_all_stats(RGWRados *store, const rgw_user& user_id) { CephContext *cct = store->ctx(); size_t max_entries = cct->_conf->rgw_list_buckets_max_chunk; - bool done; bool is_truncated; string marker; int ret; @@ -79,8 +78,7 @@ int rgw_user_sync_all_stats(RGWRados *store, const rgw_user& user_id) return ret; } } - done = (buckets.size() < max_entries); - } while (!done); + } while (is_truncated); ret = store->complete_sync_user_stats(user_id); if (ret < 0) { @@ -2030,7 +2028,6 @@ int RGWUser::execute_remove(RGWUserAdminOpState& op_state, std::string *err_msg) return -ENOENT; } - bool done; bool is_truncated; string marker; CephContext *cct = store->ctx(); @@ -2061,8 +2058,7 @@ int RGWUser::execute_remove(RGWUserAdminOpState& op_state, std::string *err_msg) marker = it->first; } - done = (m.size() < max_buckets); - } while (!done); + } while (is_truncated); ret = rgw_delete_user(store, user_info, op_state.objv); if (ret < 0) { @@ -2193,7 +2189,6 @@ int RGWUser::execute_modify(RGWUserAdminOpState& op_state, std::string *err_msg) return -EINVAL; } - bool done; bool is_truncated; string marker; CephContext *cct = store->ctx(); @@ -2223,8 +2218,7 @@ int RGWUser::execute_modify(RGWUserAdminOpState& op_state, std::string *err_msg) return ret; } - done = (m.size() < max_buckets); - } while (!done); + } while (is_truncated); } op_state.set_user_info(user_info);