Skip to content

Commit de55616

Browse files
authored
Merge pull request ceph#53607 from cfsnyder/wip-cfsnyder-bucket-check-bug
rgw: fix radosgw-admin bucket check stat calculation bug Reviewed-by: Casey Bodley <[email protected]>
2 parents 935c513 + 32fb6a1 commit de55616

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

qa/workunits/rgw/test_rgw_bucket_check.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,15 @@ def main():
5353
ok_keys = ['a', 'b', 'c', 'd']
5454
unlinked_keys = ['c', 'd', 'e', 'f']
5555
ok_objs = put_objects(bucket, ok_keys)
56-
56+
57+
# TESTCASE 'recalculated bucket check stats are correct'
58+
log.debug('TEST: recalculated bucket check stats are correct\n')
59+
exec_cmd(f'radosgw-admin bucket check --fix --bucket {BUCKET_NAME}')
60+
out = exec_cmd(f'radosgw-admin bucket stats --bucket {BUCKET_NAME}')
61+
json_out = json.loads(out)
62+
log.debug(json_out['usage'])
63+
assert json_out['usage']['rgw.main']['num_objects'] == 6
64+
5765
# TESTCASE 'bucket check unlinked does not report normal entries'
5866
log.debug('TEST: bucket check unlinked does not report normal entries\n')
5967
out = exec_cmd(f'radosgw-admin bucket check unlinked --bucket {BUCKET_NAME} --min-age-hours 0 --dump-keys')

src/cls/rgw/cls_rgw.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3090,7 +3090,7 @@ static int check_index(cls_method_context_t hctx,
30903090
return -EIO;
30913091
}
30923092

3093-
if (entry.exists && entry.key.instance.empty()) {
3093+
if (entry.exists && entry.flags == 0) {
30943094
rgw_bucket_category_stats& stats = calc_header->stats[entry.meta.category];
30953095
stats.num_entries++;
30963096
stats.total_size += entry.meta.accounted_size;

src/cls/rgw/cls_rgw_types.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ bool rgw_cls_bi_entry::get_info(cls_rgw_obj_key *key,
403403
accounted_stats->total_size_rounded += cls_rgw_get_rounded_size(entry.meta.accounted_size);
404404
accounted_stats->actual_size += entry.meta.size;
405405
if (type == BIIndexType::Plain) {
406-
return entry.exists && entry.key.instance.empty();
406+
return entry.exists && entry.flags == 0;
407407
} else if (type == BIIndexType::Instance) {
408408
return entry.exists;
409409
}

src/rgw/driver/rados/rgw_bucket.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,6 +1211,8 @@ int RGWBucketAdminOp::check_index(rgw::sal::Driver* driver, RGWBucketAdminOpStat
12111211
Formatter *formatter = flusher.get_formatter();
12121212
flusher.start(0);
12131213

1214+
formatter->open_object_section("bucket_check");
1215+
12141216
ret = bucket.check_bad_index_multipart(op_state, flusher, dpp, y);
12151217
if (ret < 0)
12161218
return ret;
@@ -1226,6 +1228,8 @@ int RGWBucketAdminOp::check_index(rgw::sal::Driver* driver, RGWBucketAdminOpStat
12261228
return ret;
12271229

12281230
dump_index_check(existing_stats, calculated_stats, formatter);
1231+
1232+
formatter->close_section();
12291233
flusher.flush();
12301234

12311235
return 0;

0 commit comments

Comments
 (0)