From: Casey Bodley Date: Wed, 28 Jun 2017 17:32:35 +0000 (-0400) Subject: rgw: rest handlers for mdlog and datalog list dont loop X-Git-Tag: v12.1.1~242^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=d75e6b967d2ddf84d6e82c78a53061578129294a;p=ceph-ci.git rgw: rest handlers for mdlog and datalog list dont loop the do-while loops are unnecessary, because cls_log_list() will already give us the requested number of entries, unless truncated. and these rest operations return the truncated flag and last_marker, which the client side is already using to run the same loop Signed-off-by: Casey Bodley --- diff --git a/src/rgw/rgw_rest_log.cc b/src/rgw/rgw_rest_log.cc index f932807cd02..1dd4216bfe1 100644 --- a/src/rgw/rgw_rest_log.cc +++ b/src/rgw/rgw_rest_log.cc @@ -54,8 +54,7 @@ void RGWOp_MDLog_List::execute() { ut_et; void *handle; unsigned shard_id, max_entries = LOG_CLASS_LIST_MAX_ENTRIES; - unsigned left_cnt; - + shard_id = (unsigned)strict_strtol(shard.c_str(), 10, &err); if (!err.empty()) { dout(5) << "Error parsing shard_id " << shard << dendl; @@ -80,6 +79,9 @@ void RGWOp_MDLog_List::execute() { http_ret = -EINVAL; return; } + if (max_entries > LOG_CLASS_LIST_MAX_ENTRIES) { + max_entries = LOG_CLASS_LIST_MAX_ENTRIES; + } } if (period.empty()) { @@ -95,16 +97,9 @@ void RGWOp_MDLog_List::execute() { RGWMetadataLog meta_log{s->cct, store, period}; meta_log.init_list_entries(shard_id, ut_st, ut_et, marker, &handle); - left_cnt = max_entries; - - do { - http_ret = meta_log.list_entries(handle, left_cnt, entries, - &last_marker, &truncated); - if (http_ret < 0) - break; - left_cnt = max_entries - entries.size(); - } while (truncated && (left_cnt > 0)); + http_ret = meta_log.list_entries(handle, max_entries, entries, + &last_marker, &truncated); meta_log.complete_list_entries(handle); } @@ -578,7 +573,6 @@ void RGWOp_DATALog_List::execute() { real_time ut_st, ut_et; unsigned shard_id, max_entries = LOG_CLASS_LIST_MAX_ENTRIES; - unsigned left_cnt; s->info.args.get_bool("extra-info", &extra_info, false); @@ -606,25 +600,16 @@ void RGWOp_DATALog_List::execute() { http_ret = -EINVAL; return; } - } - - dout(10) << __func__ << " shard " << shard << " st " << st << " et " << et << " marker " - << marker << " max_entries "<< max_entries << dendl; - left_cnt = max_entries; + if (max_entries > LOG_CLASS_LIST_MAX_ENTRIES) { + max_entries = LOG_CLASS_LIST_MAX_ENTRIES; + } + } - do { - // Note that last_marker is updated to be the marker of the last - // entry listed - http_ret = store->data_log->list_entries(shard_id, ut_st, ut_et, - left_cnt, entries, marker, - &last_marker, &truncated); - if (http_ret < 0) - break; - - assert(max_entries >= entries.size()); - left_cnt = max_entries - entries.size(); - marker = last_marker; - } while (truncated && (left_cnt > 0)); + // Note that last_marker is updated to be the marker of the last + // entry listed + http_ret = store->data_log->list_entries(shard_id, ut_st, ut_et, + max_entries, entries, marker, + &last_marker, &truncated); } void RGWOp_DATALog_List::send_response() {