From ff09bb5a57c146a17165f8df7ac20ef9ac7e8c31 Mon Sep 17 00:00:00 2001 From: "J. Eric Ivancich" Date: Tue, 3 Sep 2019 13:03:51 -0400 Subject: [PATCH] rgw: reformat some code to make it easier to read Signed-off-by: J. Eric Ivancich --- src/cls/rgw/cls_rgw.cc | 44 +++++++++++++++++++++++++------------ src/cls/rgw/cls_rgw_types.h | 3 +-- src/rgw/rgw_rados.cc | 11 +++++----- 3 files changed, 37 insertions(+), 21 deletions(-) diff --git a/src/cls/rgw/cls_rgw.cc b/src/cls/rgw/cls_rgw.cc index 30b408c84eb8b..7d56e0fea3f9f 100644 --- a/src/cls/rgw/cls_rgw.cc +++ b/src/cls/rgw/cls_rgw.cc @@ -152,15 +152,22 @@ static int log_index_operation(cls_method_context_t hctx, cls_rgw_obj_key& obj_k * UTF-8 object names can *both* preceed and follow the "ugly * namespace". */ -static int get_obj_vals(cls_method_context_t hctx, const string& start, const string& filter_prefix, - int num_entries, map *pkeys, bool *pmore) -{ - int ret = cls_cxx_map_get_vals(hctx, start, filter_prefix, num_entries, pkeys, pmore); - if (ret < 0) +static int get_obj_vals(cls_method_context_t hctx, + const string& start, + const string& filter_prefix, + int num_entries, + map *pkeys, + bool *pmore) +{ + int ret = cls_cxx_map_get_vals(hctx, start, filter_prefix, + num_entries, pkeys, pmore); + if (ret < 0) { return ret; + } - if (pkeys->empty()) + if (pkeys->empty()) { return 0; + } auto last_element = pkeys->rbegin(); if ((unsigned char)last_element->first[0] < BI_PREFIX_CHAR) { @@ -195,8 +202,9 @@ static int get_obj_vals(cls_method_context_t hctx, const string& start, const st auto upper = std::lower_bound(lower, pkeys->end(), new_start, comp); pkeys->erase(lower, upper); - if (num_entries == (int)pkeys->size() || !(*pmore)) + if (num_entries == (int)pkeys->size() || !(*pmore)) { return 0; + } if (pkeys->size() && new_start < pkeys->rbegin()->first) { new_start = pkeys->rbegin()->first; @@ -205,12 +213,15 @@ static int get_obj_vals(cls_method_context_t hctx, const string& start, const st map new_keys; /* now get some more keys */ - ret = cls_cxx_map_get_vals(hctx, new_start, filter_prefix, num_entries - pkeys->size(), &new_keys, pmore); - if (ret < 0) + ret = cls_cxx_map_get_vals(hctx, new_start, filter_prefix, + num_entries - pkeys->size(), &new_keys, pmore); + if (ret < 0) { return ret; + } pkeys->insert(std::make_move_iterator(new_keys.begin()), std::make_move_iterator(new_keys.end())); + return 0; } @@ -1339,11 +1350,15 @@ static int write_version_marker(cls_method_context_t hctx, cls_rgw_obj_key& key) } /* - * plain entries are the ones who were created when bucket was not versioned, - * if we override these objects, we need to convert these to versioned entries -- ones that have - * both data entry, and listing key. Their version is going to be empty though + * plain entries are the ones who were created when bucket was not + * versioned, if we override these objects, we need to convert these + * to versioned entries -- ones that have both data entry, and listing + * key. Their version is going to be empty though */ -static int convert_plain_entry_to_versioned(cls_method_context_t hctx, cls_rgw_obj_key& key, bool demote_current, bool instance_only) +static int convert_plain_entry_to_versioned(cls_method_context_t hctx, + cls_rgw_obj_key& key, + bool demote_current, + bool instance_only) { if (!key.instance.empty()) { return -EINVAL; @@ -1375,7 +1390,8 @@ static int convert_plain_entry_to_versioned(cls_method_context_t hctx, cls_rgw_o ret = write_obj_entries(hctx, entry, new_idx); } if (ret < 0) { - CLS_LOG(0, "ERROR: write_obj_entries new_idx=%s returned %d", new_idx.c_str(), ret); + CLS_LOG(0, "ERROR: write_obj_entries new_idx=%s returned %d", + new_idx.c_str(), ret); return ret; } } diff --git a/src/cls/rgw/cls_rgw_types.h b/src/cls/rgw/cls_rgw_types.h index b77cd3b8bde16..49add410fe00b 100644 --- a/src/cls/rgw/cls_rgw_types.h +++ b/src/cls/rgw/cls_rgw_types.h @@ -57,8 +57,7 @@ enum RGWCheckMTimeType { #define ROUND_BLOCK_SIZE 4096 -static inline uint64_t cls_rgw_get_rounded_size(uint64_t size) -{ +static inline uint64_t cls_rgw_get_rounded_size(uint64_t size) { return (size + ROUND_BLOCK_SIZE - 1) & ~(ROUND_BLOCK_SIZE - 1); } diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 3c1b18119bae8..f6c65ea95131c 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -1724,11 +1724,12 @@ int RGWRados::Bucket::update_bucket_id(const string& new_bucket_id) * is_truncated: if number of objects in the bucket is bigger than * max, then truncated. */ -int RGWRados::Bucket::List::list_objects_ordered(int64_t max_p, - vector *result, - map *common_prefixes, - bool *is_truncated, - optional_yield y) +int RGWRados::Bucket::List::list_objects_ordered( + int64_t max_p, + vector *result, + map *common_prefixes, + bool *is_truncated, + optional_yield y) { RGWRados *store = target->get_store(); CephContext *cct = store->ctx(); -- 2.39.5