Skip to content

Commit 8fd7be5

Browse files
committed
rgw/cloud-restore: Handle "null" instance non-current objects
During restore, if the object instance is "null", clear it while updating bi entry. Signed-off-by: Soumya Koduri <[email protected]>
1 parent cef383b commit 8fd7be5

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

src/rgw/driver/rados/rgw_rados.cc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5266,8 +5266,16 @@ int RGWRados::restore_obj_from_cloud(RGWLCCloudTierCtx& tier_ctx,
52665266
auto aio = rgw::make_throttle(cct->_conf->rgw_put_obj_min_window_size, y);
52675267
using namespace rgw::putobj;
52685268
jspan_context no_trace{false, false};
5269+
5270+
// bi expects empty instance for the entries created when
5271+
// bucket versioning is not enabled or suspended.
5272+
rgw_obj dest_obj_bi = dest_obj;
5273+
if (dest_obj_bi.key.instance == "null") {
5274+
dest_obj_bi.key.instance.clear();
5275+
}
5276+
52695277
rgw::putobj::AtomicObjectProcessor processor(aio.get(), this, dest_bucket_info, nullptr,
5270-
owner, obj_ctx, dest_obj, olh_epoch, tag, dpp, y, no_trace);
5278+
owner, obj_ctx, dest_obj_bi, olh_epoch, tag, dpp, y, no_trace);
52715279

52725280
void (*progress_cb)(off_t, void *) = NULL;
52735281
void *progress_data = NULL;

src/rgw/driver/rados/rgw_sal_rados.cc

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3081,18 +3081,32 @@ int RadosObject::set_cloud_restore_status(const DoutPrefixProvider* dpp,
30813081
*/
30823082
int RadosObject::handle_obj_expiry(const DoutPrefixProvider* dpp, optional_yield y) {
30833083
int ret = 0;
3084+
3085+
/* once bucket versioning is enabled, the non-current entries with
3086+
* instance empty should have instance set to "null" to be able
3087+
* to correctly read its olh version entry.
3088+
*/
3089+
rgw_obj_key& obj_key = get_key();
3090+
rgw::sal::Bucket* bucket = get_bucket();
3091+
3092+
if (obj_key.instance.empty() && bucket->versioned()) {
3093+
obj_key.instance = "null";
3094+
}
3095+
30843096
real_time read_mtime;
30853097
std::unique_ptr<rgw::sal::Object::ReadOp> read_op(get_read_op());
30863098
read_op->params.lastmod = &read_mtime;
3087-
ldpp_dout(dpp, 20) << "Entering handle_obj_expiry Obj:" << get_key() << dendl;
3088-
30893099
ret = read_op->prepare(y, dpp);
30903100
if (ret < 0) {
30913101
ldpp_dout(dpp, -1) << "handle_obj_expiry Obj:" << get_key() <<
30923102
", read_op failed ret=" << ret << dendl;
30933103
return ret;
30943104
}
30953105

3106+
if (obj_key.instance == "null") {
3107+
obj_key.instance.clear();
3108+
}
3109+
30963110
set_atomic();
30973111
map<string, bufferlist> attrs = get_attrs();
30983112
RGWRados::Object op_target(store->getRados(), bucket->get_info(), *rados_ctx, get_obj());

0 commit comments

Comments
 (0)