Skip to content

Commit 16b44ff

Browse files
authored
Merge pull request ceph#60157 from soumyakoduri/wip-skoduri-lc-nullinstance
rgw/lc: Fix issues with non-current objects with instance empty Reviewed-by: Casey Bodley <[email protected]>
2 parents e7d047a + 60149ad commit 16b44ff

File tree

5 files changed

+30
-8
lines changed

5 files changed

+30
-8
lines changed

src/rgw/driver/rados/rgw_lc_tier.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@ WRITE_CLASS_ENCODER(rgw_lc_multipart_upload_info)
7777

7878
static inline string get_key_instance(const rgw_obj_key& key)
7979
{
80-
if (!key.instance.empty() &&
81-
!key.have_null_instance()) {
80+
// if non-current entry, add versionID to the
81+
// transitioned object name including "null".
82+
if (!key.instance.empty()) {
8283
return "-" + key.instance;
8384
}
8485
return "";

src/rgw/driver/rados/rgw_rados.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5089,7 +5089,7 @@ int RGWRados::copy_obj_data(RGWObjectCtx& obj_ctx,
50895089

50905090
int RGWRados::transition_obj(RGWObjectCtx& obj_ctx,
50915091
RGWBucketInfo& bucket_info,
5092-
const rgw_obj& obj,
5092+
rgw_obj obj,
50935093
const rgw_placement_rule& placement_rule,
50945094
const real_time& mtime,
50955095
uint64_t olh_epoch,
@@ -5120,6 +5120,11 @@ int RGWRados::transition_obj(RGWObjectCtx& obj_ctx,
51205120
return -ECANCELED;
51215121
}
51225122

5123+
// bi expects empty instance for the entries created when bucket versioning
5124+
// is not enabled or suspended.
5125+
if (obj.key.instance == "null") {
5126+
obj.key.instance.clear();
5127+
}
51235128
attrs.erase(RGW_ATTR_ID_TAG);
51245129
attrs.erase(RGW_ATTR_TAIL_TAG);
51255130

src/rgw/driver/rados/rgw_rados.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1234,7 +1234,7 @@ class RGWRados
12341234

12351235
int transition_obj(RGWObjectCtx& obj_ctx,
12361236
RGWBucketInfo& bucket_info,
1237-
const rgw_obj& obj,
1237+
rgw_obj obj,
12381238
const rgw_placement_rule& placement_rule,
12391239
const real_time& mtime,
12401240
uint64_t olh_epoch,

src/rgw/driver/rados/rgw_sal_rados.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2792,6 +2792,13 @@ int RadosObject::write_cloud_tier(const DoutPrefixProvider* dpp,
27922792
{
27932793
rgw::sal::RadosPlacementTier* rtier = static_cast<rgw::sal::RadosPlacementTier*>(tier);
27942794
map<string, bufferlist> attrs = get_attrs();
2795+
rgw_obj_key& obj_key = get_key();
2796+
// bi expects empty instance for the entries created when bucket versioning
2797+
// is not enabled or suspended.
2798+
if (obj_key.instance == "null") {
2799+
obj_key.instance.clear();
2800+
}
2801+
27952802
RGWRados::Object op_target(store->getRados(), bucket->get_info(), *rados_ctx, get_obj());
27962803
RGWRados::Object::Write obj_op(&op_target);
27972804

src/rgw/rgw_lc.cc

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,14 @@ struct lc_op_ctx {
495495
octx(env.driver), dpp(dpp), wq(wq)
496496
{
497497
obj = bucket->get_object(o.key);
498+
/* once bucket versioning is enabled, the non-current entries with
499+
* instance empty should have instance set to "null" to be able
500+
* to correctly read its olh version entry.
501+
*/
502+
if (o.key.instance.empty() && bucket->versioned() && !o.is_current()) {
503+
rgw_obj_key& obj_key = obj->get_key();
504+
obj_key.instance = "null";
505+
}
498506
}
499507

500508
bool next_has_same_name(const std::string& key_name) {
@@ -1355,9 +1363,9 @@ class LCOpAction_Transition : public LCOpAction {
13551363
int delete_tier_obj(lc_op_ctx& oc) {
13561364
int ret = 0;
13571365

1358-
/* If bucket is versioned, create delete_marker for current version
1366+
/* If bucket has versioning enabled, create delete_marker for current version
13591367
*/
1360-
if (! oc.bucket->versioned()) {
1368+
if (! oc.bucket->versioning_enabled()) {
13611369
ret =
13621370
remove_expired_obj(oc.dpp, oc, true, {rgw::notify::ObjectTransition});
13631371
ldpp_dout(oc.dpp, 20) << "delete_tier_obj Object(key:" << oc.o.key
@@ -1387,9 +1395,10 @@ class LCOpAction_Transition : public LCOpAction {
13871395

13881396
int transition_obj_to_cloud(lc_op_ctx& oc) {
13891397
int ret{0};
1390-
/* If CurrentVersion object, remove it & create delete marker */
1398+
/* If CurrentVersion object & bucket has versioning enabled, remove it &
1399+
* create delete marker */
13911400
bool delete_object = (!oc.tier->retain_head_object() ||
1392-
(oc.o.is_current() && oc.bucket->versioned()));
1401+
(oc.o.is_current() && oc.bucket->versioning_enabled()));
13931402

13941403
/* notifications */
13951404
auto& bucket = oc.bucket;

0 commit comments

Comments
 (0)