]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: rest handlers for mdlog and datalog list dont loop 15983/head
authorCasey Bodley <cbodley@redhat.com>
Wed, 28 Jun 2017 17:32:35 +0000 (13:32 -0400)
committerCasey Bodley <cbodley@redhat.com>
Wed, 28 Jun 2017 18:36:12 +0000 (14:36 -0400)
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 <cbodley@redhat.com>
src/rgw/rgw_rest_log.cc

index f932807cd02742645b58c20141a2fdb66a94c4f2..1dd4216bfe1e3065f64e6870f8584b6aab008c0f 100644 (file)
@@ -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() {