From 7306514a813661b77bfcbfc6f534dbabbdd3aa78 Mon Sep 17 00:00:00 2001 From: Mark Kogan Date: Mon, 25 Sep 2017 09:53:00 +0300 Subject: [PATCH] rgw: update the usage read iterator in truncated scenario Fixes: http://tracker.ceph.com/issues/21196 Signed-off-by: Mark Kogan --- src/cls/rgw/cls_rgw.cc | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/cls/rgw/cls_rgw.cc b/src/cls/rgw/cls_rgw.cc index 2da985ac80f..f4a4f1a88ab 100644 --- a/src/cls/rgw/cls_rgw.cc +++ b/src/cls/rgw/cls_rgw.cc @@ -2895,9 +2895,7 @@ static int usage_iterate_range(cls_method_context_t hctx, uint64_t start, uint64 bool by_user = !user.empty(); uint32_t i = 0; string user_key; - - if (truncated) - *truncated = false; + bool truncated_status = false; if (!by_user) { usage_record_prefix_by_time(end, end_key); @@ -2917,11 +2915,14 @@ static int usage_iterate_range(cls_method_context_t hctx, uint64_t start, uint64 } CLS_LOG(20, "usage_iterate_range start_key=%s", start_key.c_str()); - int ret = cls_cxx_map_get_vals(hctx, start_key, filter_prefix, max_entries, &keys, truncated); + int ret = cls_cxx_map_get_vals(hctx, start_key, filter_prefix, max_entries, &keys, &truncated_status); if (ret < 0) return ret; - + if (truncated) { + *truncated = truncated_status; + } + map::iterator iter = keys.begin(); if (iter == keys.end()) return 0; @@ -2934,11 +2935,17 @@ static int usage_iterate_range(cls_method_context_t hctx, uint64_t start, uint64 if (!by_user && key.compare(end_key) >= 0) { CLS_LOG(20, "usage_iterate_range reached key=%s, done", key.c_str()); + if (truncated_status) { + key_iter = key; + } return 0; } if (by_user && key.compare(0, user_key.size(), user_key) != 0) { CLS_LOG(20, "usage_iterate_range reached key=%s, done", key.c_str()); + if (truncated_status) { + key_iter = key; + } return 0; }