From: J. Eric Ivancich Date: Tue, 6 Aug 2019 17:33:15 +0000 (-0400) Subject: rgw: clean-up error handling with rgw-admin --reset-stats X-Git-Tag: v14.2.5~129^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ed6ef38291eb02fcc6fb3a6817b1fbd6678598f3;p=ceph.git 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) --- diff --git a/src/cls/user/cls_user.cc b/src/cls/user/cls_user.cc index 17e394b67b10..e80e6e231c27 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); }