From ed6ef38291eb02fcc6fb3a6817b1fbd6678598f3 Mon Sep 17 00:00:00 2001 From: "J. Eric Ivancich" Date: Tue, 6 Aug 2019 13:33:15 -0400 Subject: [PATCH] rgw: clean-up error handling with rgw-admin --reset-stats Made error messages more consistent. Errored out when --reset-stats was used in conjunction with --sync-stats since the latter does a superset of the former. Signed-off-by: J. Eric Ivancich (cherry picked from commit 05ad6cd2aaf1d8923f0341aef275260104bb70f2) --- src/cls/user/cls_user.cc | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/cls/user/cls_user.cc b/src/cls/user/cls_user.cc index 17e394b67b10a..e80e6e231c270 100644 --- a/src/cls/user/cls_user.cc +++ b/src/cls/user/cls_user.cc @@ -370,11 +370,12 @@ static int cls_user_get_header(cls_method_context_t hctx, bufferlist *in, buffer return 0; } -/// A method to reset the user.buckets header stats in accordance to the values -/// seen in the user.buckets omap keys. This will not be equivalent to --sync-stats -/// which requires comparing the values with actual bucket meta stats supplied -/// by RGW -static int cls_user_reset_stats(cls_method_context_t hctx, bufferlist *in, bufferlist *out /*ignore*/) +/// A method to reset the user.buckets header stats in accordance to +/// the values seen in the user.buckets omap keys. This is not be +/// equivalent to --sync-stats which also re-calculates the stats for +/// each bucket. +static int cls_user_reset_stats(cls_method_context_t hctx, + bufferlist *in, bufferlist *out /*ignore*/) { cls_user_reset_stats_op op; @@ -382,27 +383,33 @@ static int cls_user_reset_stats(cls_method_context_t hctx, bufferlist *in, buffe auto bliter = in->cbegin(); decode(op, bliter); } catch (buffer::error& err) { - CLS_LOG(0, "ERROR: cls_user_reset_op(): failed to decode op"); + CLS_LOG(0, "ERROR: %s failed to decode op", __func__); return -EINVAL; } + cls_user_header header; bool truncated = false; string from_index, prefix; do { map keys; - int rc = cls_cxx_map_get_vals(hctx, from_index, prefix, MAX_ENTRIES, &keys, &truncated); - - if (rc < 0) + int rc = cls_cxx_map_get_vals(hctx, from_index, prefix, MAX_ENTRIES, + &keys, &truncated); + if (rc < 0) { + CLS_LOG(0, "ERROR: %s failed to retrieve omap key-values", __func__); return rc; + } + CLS_LOG(20, "%s: read %lu key-values, truncated=%d", + __func__, keys.size(), truncated); - for (const auto&kv : keys){ + for (const auto& kv : keys) { cls_user_bucket_entry e; try { auto bl = kv.second; auto bliter = bl.cbegin(); decode(e, bliter); } catch (buffer::error& err) { - CLS_LOG(0, "ERROR: failed to decode bucket entry for %s", kv.first.c_str()); + CLS_LOG(0, "ERROR: %s failed to decode bucket entry for %s", + __func__, kv.first.c_str()); return -EIO; } add_header_stats(&header.stats, e); @@ -413,6 +420,7 @@ static int cls_user_reset_stats(cls_method_context_t hctx, bufferlist *in, buffe header.last_stats_update = op.time; encode(header, bl); + CLS_LOG(20, "%s: updating header", __func__); return cls_cxx_map_write_header(hctx, &bl); } -- 2.39.5