diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index ff7da8e27c3..99285b44443 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -6762,6 +6762,8 @@ next: uint16_t expansion_factor = 1; while (is_truncated) { RGWRados::ent_map_t result; + result.reserve(NUM_ENTRIES); + int r = store->getRados()->cls_bucket_list_ordered( bucket_info, RGW_NO_SHARD, marker, empty_prefix, empty_delimiter, diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 89faeaaa6b2..3f6c32c8d48 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -2063,6 +2063,8 @@ int RGWRados::Bucket::List::list_objects_unordered(int64_t max_p, while (truncated && count <= max) { std::vector ent_list; + ent_list.reserve(read_ahead); + int r = store->cls_bucket_list_unordered(target->get_bucket_info(), shard_id, cur_marker, @@ -4476,13 +4478,16 @@ int RGWRados::transition_obj(RGWObjectCtx& obj_ctx, int RGWRados::check_bucket_empty(RGWBucketInfo& bucket_info, optional_yield y) { + constexpr uint NUM_ENTRIES = 1000u; + rgw_obj_index_key marker; string prefix; bool is_truncated; do { std::vector ent_list; - constexpr uint NUM_ENTRIES = 1000u; + ent_list.reserve(NUM_ENTRIES); + int r = cls_bucket_list_unordered(bucket_info, RGW_NO_SHARD, marker, @@ -4493,15 +4498,17 @@ int RGWRados::check_bucket_empty(RGWBucketInfo& bucket_info, optional_yield y) &is_truncated, &marker, y); - if (r < 0) + if (r < 0) { return r; + } string ns; for (auto const& dirent : ent_list) { rgw_obj_key obj; - if (rgw_obj_key::oid_to_key_in_ns(dirent.key.name, &obj, ns)) + if (rgw_obj_key::oid_to_key_in_ns(dirent.key.name, &obj, ns)) { return -ENOTEMPTY; + } } } while (is_truncated); @@ -8200,6 +8207,8 @@ int RGWRados::cls_bucket_list_ordered(RGWBucketInfo& bucket_info, ", list_versions=" << list_versions << ", expansion_factor=" << expansion_factor << dendl; + m.clear(); + RGWSI_RADOS::Pool index_pool; // key - oid (for different shards if there is any) // value - list result for the corresponding oid (shard), it is filled by @@ -8422,7 +8431,7 @@ int RGWRados::cls_bucket_list_ordered(RGWBucketInfo& bucket_info, count << ", which is truncated" << dendl; } - if (last_entry_visited != nullptr) { + if (last_entry_visited != nullptr && last_entry) { // since we'll not need this any more, might as well move it... *last_entry = std::move(last_entry_visited->key); ldout(cct, 20) << "RGWRados::" << __func__ << @@ -8451,6 +8460,7 @@ int RGWRados::cls_bucket_list_unordered(RGWBucketInfo& bucket_info, " start_after " << start_after.name << "[" << start_after.instance << "] num_entries " << num_entries << dendl; + ent_list.clear(); static MultipartMetaFilter multipart_meta_filter; *is_truncated = false;