]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cls/rgw: bi_list() fix is_truncated returned param
authorYehuda Sadeh <yehuda@redhat.com>
Wed, 28 Sep 2016 17:41:45 +0000 (10:41 -0700)
committerRobin H. Johnson <robin.johnson@dreamhost.com>
Thu, 9 Feb 2017 22:37:05 +0000 (14:37 -0800)
is_truncated was never set. Also, make sure that we don't return
more entries than requested.

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
(cherry picked from commit 47f422a4e0382d53023af6f651433011606b8625)
See: http://tracker.ceph.com/issues/17556
See: https://github.com/ceph/ceph/pull/11368
Signed-off-by: Robin H. Johnson <robin.johnson@dreamhost.com>
src/cls/rgw/cls_rgw.cc

index 89e531ace9495a686b4e1fc1d3c8a732be1f9a28..58247b54ee3f0d85e5472f20776b5b55de488867 100644 (file)
@@ -2333,6 +2333,9 @@ static int list_plain_entries(cls_method_context_t hctx, const string& name, con
 
       entries->push_back(entry);
       count++;
+      if (count >= (int)max) {
+        return count;
+      }
       start_key = entry.idx;
     }
   } while (!keys.empty());
@@ -2514,7 +2517,7 @@ static int rgw_bi_list_op(cls_method_context_t hctx, bufferlist *in, bufferlist
 #define MAX_BI_LIST_ENTRIES 1000
   int32_t max = (op.max < MAX_BI_LIST_ENTRIES ? op.max : MAX_BI_LIST_ENTRIES) + 1; /* one extra entry for identifying truncation */
   string start_key = op.marker;
-  int ret = list_plain_entries(hctx, op.name, op.marker, max, &op_ret.entries);
+  int ret = list_plain_entries(hctx, op.name, op.marker, max, &op_ret.entries) + 1; /* one extra entry for identifying truncation */
   if (ret < 0) {
     CLS_LOG(0, "ERROR: %s(): list_plain_entries retured ret=%d", __func__, ret);
     return ret;
@@ -2529,12 +2532,22 @@ static int rgw_bi_list_op(cls_method_context_t hctx, bufferlist *in, bufferlist
     return ret;
   }
 
+  count += ret;
+
   ret = list_olh_entries(hctx, op.name, op.marker, max - count, &op_ret.entries);
   if (ret < 0) {
     CLS_LOG(0, "ERROR: %s(): list_instance_entries retured ret=%d", __func__, ret);
     return ret;
   }
 
+  count += ret;
+
+  op_ret.is_truncated = (count >= max);
+  while (count >= max) {
+    op_ret.entries.pop_back();
+    count--;
+  }
+
   ::encode(op_ret, *out);
 
   return 0;