From 9e997263afd9a4030c9396e784646f5a24acfe51 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Mon, 1 Feb 2021 12:04:36 -0500 Subject: [PATCH] rgw: reshard adds a log layout for the new index Signed-off-by: Casey Bodley --- src/rgw/rgw_bucket.cc | 4 +--- src/rgw/rgw_bucket_layout.cc | 4 +--- src/rgw/rgw_bucket_layout.h | 4 ++-- src/rgw/rgw_common.cc | 4 ++-- src/rgw/rgw_reshard.cc | 3 +++ 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc index ba1819088d8d1..726a628da6eb2 100644 --- a/src/rgw/rgw_bucket.cc +++ b/src/rgw/rgw_bucket.cc @@ -2293,9 +2293,7 @@ void init_default_bucket_layout(CephContext *cct, rgw::BucketLayout& layout, } if (layout.current_index.layout.type == rgw::BucketIndexType::Normal) { - layout.logs.push_back(log_layout_from_index( - layout.current_index.gen, - layout.current_index.layout.normal)); + layout.logs.push_back(log_layout_from_index(0, layout.current_index)); } } diff --git a/src/rgw/rgw_bucket_layout.cc b/src/rgw/rgw_bucket_layout.cc index 85002ba9cb7da..22d75d0d30d3d 100644 --- a/src/rgw/rgw_bucket_layout.cc +++ b/src/rgw/rgw_bucket_layout.cc @@ -146,9 +146,7 @@ void decode(BucketLayout& l, bufferlist::const_iterator& bl) l.logs.clear(); // initialize the log layout to match the current index layout if (l.current_index.layout.type == BucketIndexType::Normal) { - const auto gen = l.current_index.gen; - const auto& index = l.current_index.layout.normal; - l.logs.push_back(log_layout_from_index(gen, index)); + l.logs.push_back(log_layout_from_index(0, l.current_index)); } } else { decode(l.logs, bl); diff --git a/src/rgw/rgw_bucket_layout.h b/src/rgw/rgw_bucket_layout.h index b5f0bacb512bf..09bbd1c142c05 100644 --- a/src/rgw/rgw_bucket_layout.h +++ b/src/rgw/rgw_bucket_layout.h @@ -115,9 +115,9 @@ void decode(bucket_log_layout_generation& l, bufferlist::const_iterator& bl); // return a log layout that shares its layout with the index inline bucket_log_layout_generation log_layout_from_index( - uint64_t gen, const bucket_index_normal_layout& index) + uint64_t gen, const bucket_index_layout_generation& index) { - return {gen, {BucketLogType::InIndex, {gen, index}}}; + return {gen, {BucketLogType::InIndex, {index.gen, index.layout.normal}}}; } inline auto matches_gen(uint64_t gen) diff --git a/src/rgw/rgw_common.cc b/src/rgw/rgw_common.cc index 9e614bd1ed7e1..7ce7354b44e9e 100644 --- a/src/rgw/rgw_common.cc +++ b/src/rgw/rgw_common.cc @@ -2302,7 +2302,7 @@ void RGWBucketInfo::decode(bufferlist::const_iterator& bl) { if (layout.logs.empty() && layout.current_index.layout.type == rgw::BucketIndexType::Normal) { - layout.logs.push_back(rgw::log_layout_from_index(0, layout.current_index.layout.normal)); + layout.logs.push_back(rgw::log_layout_from_index(0, layout.current_index)); } DECODE_FINISH(bl); } @@ -2396,7 +2396,7 @@ void RGWBucketInfo::generate_test_instances(list& o) l.current_index.layout.normal.num_shards = 11; l.logs.push_back(log_layout_from_index( l.current_index.gen, - l.current_index.layout.normal)); + l.current_index)); }; diff --git a/src/rgw/rgw_reshard.cc b/src/rgw/rgw_reshard.cc index cc04673c63d80..a882c5ef661a0 100644 --- a/src/rgw/rgw_reshard.cc +++ b/src/rgw/rgw_reshard.cc @@ -452,6 +452,9 @@ static int commit_reshard(rgw::sal::RadosStore* store, layout.current_index = std::move(*layout.target_index); layout.target_index = std::nullopt; layout.resharding = rgw::BucketReshardState::None; + // add the in-index log layout + const auto next_log_gen = layout.logs.back().gen + 1; + layout.logs.push_back(log_layout_from_index(next_log_gen, layout.current_index)); int ret = fault.check("commit_target_layout"); if (ret == 0) { // no fault injected, write the bucket instance metadata -- 2.39.5