Skip to content

Commit 8de64f3

Browse files
authored
Merge pull request ceph#58567 from ivancich/wip-reshard-cleanups
rgw: add reshard status to bucket stats plus minor misc items Reviewed-by: Anthony D'Atri <[email protected]>
2 parents 5d6a81f + 258734d commit 8de64f3

File tree

3 files changed

+35
-26
lines changed

3 files changed

+35
-26
lines changed

doc/man/8/radosgw-admin.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ as follows:
9696
Invoke with --marker to resume if the command is interrupted.
9797

9898
:command:`bucket stats`
99-
Returns bucket statistics.
99+
List bucket statistics plus other internal information about a bucket.
100100

101101
:command:`bucket rm`
102102
Remove a bucket.

src/rgw/driver/rados/rgw_bucket.cc

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,7 +1455,7 @@ static int bucket_stats(rgw::sal::Driver* driver,
14551455

14561456
const RGWBucketInfo& bucket_info = bucket->get_info();
14571457

1458-
const auto& index = bucket->get_info().get_current_index();
1458+
const auto& index = bucket_info.get_current_index();
14591459
if (is_layout_indexless(index)) {
14601460
cerr << "error, indexless buckets do not maintain stats; bucket=" <<
14611461
bucket->get_name() << std::endl;
@@ -1480,25 +1480,26 @@ static int bucket_stats(rgw::sal::Driver* driver,
14801480
bucket->versioned()
14811481
? (bucket->versioning_enabled() ? "enabled" : "suspended")
14821482
: "off");
1483-
formatter->dump_string("zonegroup", bucket->get_info().zonegroup);
1484-
formatter->dump_string("placement_rule", bucket->get_info().placement_rule.to_str());
1483+
formatter->dump_string("zonegroup", bucket_info.zonegroup);
1484+
formatter->dump_string("placement_rule", bucket_info.placement_rule.to_str());
14851485
::encode_json("explicit_placement", bucket->get_key().explicit_placement, formatter);
14861486
formatter->dump_string("id", bucket->get_bucket_id());
14871487
formatter->dump_string("marker", bucket->get_marker());
1488-
formatter->dump_stream("index_type") << bucket->get_info().layout.current_index.layout.type;
1489-
formatter->dump_int("index_generation", bucket->get_info().layout.current_index.gen);
1488+
formatter->dump_stream("index_type") << bucket_info.layout.current_index.layout.type;
1489+
formatter->dump_int("index_generation", bucket_info.layout.current_index.gen);
14901490
formatter->dump_int("num_shards",
1491-
bucket->get_info().layout.current_index.layout.normal.num_shards);
1491+
bucket_info.layout.current_index.layout.normal.num_shards);
1492+
formatter->dump_string("reshard_status", to_string(bucket_info.reshard_status));
14921493
formatter->dump_bool("object_lock_enabled", bucket_info.obj_lock_enabled());
14931494
formatter->dump_bool("mfa_enabled", bucket_info.mfa_enabled());
1494-
::encode_json("owner", bucket->get_info().owner, formatter);
1495+
::encode_json("owner", bucket_info.owner, formatter);
14951496
formatter->dump_string("ver", bucket_ver);
14961497
formatter->dump_string("master_ver", master_ver);
14971498
ut.gmtime(formatter->dump_stream("mtime"));
14981499
ctime_ut.gmtime(formatter->dump_stream("creation_time"));
14991500
formatter->dump_string("max_marker", max_marker);
15001501
dump_bucket_usage(stats, formatter);
1501-
encode_json("bucket_quota", bucket->get_info().quota, formatter);
1502+
encode_json("bucket_quota", bucket_info.quota, formatter);
15021503

15031504
// bucket tags
15041505
auto iter = bucket->get_attrs().find(RGW_ATTR_TAGS);

src/rgw/driver/rados/rgw_reshard.cc

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ static int init_target_layout(rgw::sal::RadosStore* store,
415415
RGWBucketInfo& bucket_info,
416416
std::map<std::string, bufferlist>& bucket_attrs,
417417
ReshardFaultInjector& fault,
418-
uint32_t new_num_shards,
418+
const uint32_t new_num_shards,
419419
const DoutPrefixProvider* dpp, optional_yield y)
420420
{
421421
auto prev = bucket_info.layout; // make a copy for cleanup
@@ -591,7 +591,7 @@ static int init_reshard(rgw::sal::RadosStore* store,
591591
RGWBucketInfo& bucket_info,
592592
std::map<std::string, bufferlist>& bucket_attrs,
593593
ReshardFaultInjector& fault,
594-
uint32_t new_num_shards,
594+
const uint32_t new_num_shards,
595595
const DoutPrefixProvider *dpp, optional_yield y)
596596
{
597597
if (new_num_shards == 0) {
@@ -617,6 +617,7 @@ static int init_reshard(rgw::sal::RadosStore* store,
617617
revert_target_layout(store, bucket_info, bucket_attrs, fault, dpp, y);
618618
return ret;
619619
}
620+
620621
return 0;
621622
} // init_reshard
622623

@@ -884,7 +885,7 @@ int RGWBucketReshardLock::renew(const Clock::time_point& now) {
884885

885886
int RGWBucketReshard::do_reshard(const rgw::bucket_index_layout_generation& current,
886887
const rgw::bucket_index_layout_generation& target,
887-
int max_entries,
888+
int max_op_entries, // max num to process per op
888889
bool verbose,
889890
ostream *out,
890891
Formatter *formatter,
@@ -898,9 +899,9 @@ int RGWBucketReshard::do_reshard(const rgw::bucket_index_layout_generation& curr
898899
/* update bucket info -- in progress*/
899900
list<rgw_cls_bi_entry> entries;
900901

901-
if (max_entries < 0) {
902+
if (max_op_entries <= 0) {
902903
ldpp_dout(dpp, 0) << __func__ <<
903-
": can't reshard, negative max_entries" << dendl;
904+
": can't reshard, non-positive max_op_entries" << dendl;
904905
return -EINVAL;
905906
}
906907

@@ -926,7 +927,9 @@ int RGWBucketReshard::do_reshard(const rgw::bucket_index_layout_generation& curr
926927
const std::string null_object_filter; // empty string since we're not filtering by object
927928
while (is_truncated) {
928929
entries.clear();
929-
int ret = store->getRados()->bi_list(dpp, bucket_info, i, null_object_filter, marker, max_entries, &entries, &is_truncated, y);
930+
int ret = store->getRados()->bi_list(
931+
dpp, bucket_info, i, null_object_filter, marker, max_op_entries,
932+
&entries, &is_truncated, y);
930933
if (ret == -ENOENT) {
931934
ldpp_dout(dpp, 1) << "WARNING: " << __func__ << " failed to find shard "
932935
<< i << ", skipping" << dendl;
@@ -1032,7 +1035,7 @@ int RGWBucketReshard::get_status(const DoutPrefixProvider *dpp, list<cls_rgw_buc
10321035

10331036
int RGWBucketReshard::execute(int num_shards,
10341037
ReshardFaultInjector& fault,
1035-
int max_op_entries,
1038+
int max_op_entries, // max num to process per op
10361039
const cls_rgw_reshard_initiator initiator,
10371040
const DoutPrefixProvider *dpp,
10381041
optional_yield y,
@@ -1309,7 +1312,7 @@ void RGWReshardWait::stop()
13091312
}
13101313

13111314
int RGWReshard::process_entry(const cls_rgw_reshard_entry& entry,
1312-
int max_entries,
1315+
int max_op_entries, // max num to process per op
13131316
const DoutPrefixProvider* dpp,
13141317
optional_yield y)
13151318
{
@@ -1462,7 +1465,7 @@ int RGWReshard::process_entry(const cls_rgw_reshard_entry& entry,
14621465
RGWBucketReshard br(store, bucket_info, bucket_attrs, nullptr);
14631466

14641467
ReshardFaultInjector f; // no fault injected
1465-
ret = br.execute(entry.new_num_shards, f, max_entries, entry.initiator,
1468+
ret = br.execute(entry.new_num_shards, f, max_op_entries, entry.initiator,
14661469
dpp, y, false, nullptr, nullptr, this);
14671470
if (ret < 0) {
14681471
ldpp_dout(dpp, 0) << __func__ <<
@@ -1481,10 +1484,14 @@ int RGWReshard::process_entry(const cls_rgw_reshard_entry& entry,
14811484

14821485
int RGWReshard::process_single_logshard(int logshard_num, const DoutPrefixProvider *dpp, optional_yield y)
14831486
{
1484-
string marker;
1485-
bool truncated = true;
1487+
std::string marker;
1488+
bool is_truncated = true;
14861489

1487-
constexpr uint32_t max_entries = 1000;
1490+
// This is the number to request per op, whether it's reshard queue
1491+
// entries or bucket index entries. Should not be confused with the
1492+
// number of entries we allow in a bucket index shard. This value is
1493+
// passed in and used deeper into the call chain as well.
1494+
constexpr uint32_t max_op_entries = 1000;
14881495

14891496
string logshard_oid;
14901497
get_logshard_oid(logshard_num, &logshard_oid);
@@ -1500,15 +1507,15 @@ int RGWReshard::process_single_logshard(int logshard_num, const DoutPrefixProvid
15001507

15011508
do {
15021509
std::list<cls_rgw_reshard_entry> entries;
1503-
ret = list(dpp, logshard_num, marker, max_entries, entries, &truncated);
1510+
ret = list(dpp, logshard_num, marker, max_op_entries, entries, &is_truncated);
15041511
if (ret < 0) {
15051512
ldpp_dout(dpp, 10) << "cannot list all reshards in logshard oid=" <<
15061513
logshard_oid << dendl;
15071514
continue;
15081515
}
15091516

1510-
for(auto& entry : entries) { // logshard entries
1511-
process_entry(entry, max_entries, dpp, y);
1517+
for(const auto& entry : entries) { // logshard entries
1518+
process_entry(entry, max_op_entries, dpp, y);
15121519

15131520
Clock::time_point now = Clock::now();
15141521
if (logshard_lock.should_renew(now)) {
@@ -1520,7 +1527,7 @@ int RGWReshard::process_single_logshard(int logshard_num, const DoutPrefixProvid
15201527

15211528
entry.get_key(&marker);
15221529
} // entry for loop
1523-
} while (truncated);
1530+
} while (is_truncated);
15241531

15251532
logshard_lock.unlock();
15261533
return 0;
@@ -1592,8 +1599,9 @@ void *RGWReshard::ReshardWorker::entry() {
15921599
utime_t start = ceph_clock_now();
15931600
reshard->process_all_logshards(this, null_yield);
15941601

1595-
if (reshard->going_down())
1602+
if (reshard->going_down()) {
15961603
break;
1604+
}
15971605

15981606
utime_t end = ceph_clock_now();
15991607
utime_t elapsed = end - start;

0 commit comments

Comments
 (0)