mirror of
https://github.com/ceph/ceph
synced 2025-03-10 18:29:40 +00:00
rgw: cls_bucket_list_(un)ordered should clear results collection
Each call to cls_bucket_list_(un)ordered should have an empty collection to populate with results. Rather than rely on the caller to insure this, it's more reliable to have these functions do the clear. Additionally in some cases, a reserve call was added to the collection to pre-allocate the space needed for the expected number of results. This will potentially result in fewer re-allocations plus copies. Signed-off-by: J. Eric Ivancich <ivancich@redhat.com>
This commit is contained in:
parent
44a61a048a
commit
c52039a9e8
@ -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,
|
||||
|
@ -2063,6 +2063,8 @@ int RGWRados::Bucket::List::list_objects_unordered(int64_t max_p,
|
||||
|
||||
while (truncated && count <= max) {
|
||||
std::vector<rgw_bucket_dir_entry> 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<rgw_bucket_dir_entry> 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;
|
||||
|
Loading…
Reference in New Issue
Block a user