Skip to content

Commit 5e47f67

Browse files
rgw: prefetch data from versioned object instance head
Signed-off-by: Jane Zhu <[email protected]>
1 parent 089cd8e commit 5e47f67

16 files changed

+67
-61
lines changed

src/rgw/driver/daos/rgw_sal_daos.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ int DaosObject::modify_obj_attrs(const char* attr_name, bufferlist& attr_val,
940940
}
941941

942942
// Update object attrs
943-
set_atomic();
943+
set_atomic(true);
944944
attrs[attr_name] = attr_val;
945945

946946
ret = set_dir_entry_attrs(dpp, &ent, &attrs);

src/rgw/driver/motr/rgw_sal_motr.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,7 +1231,7 @@ int MotrObject::modify_obj_attrs(const char* attr_name, bufferlist& attr_val, op
12311231
if (r < 0) {
12321232
return r;
12331233
}
1234-
set_atomic();
1234+
set_atomic(true);
12351235
state.attrset[attr_name] = attr_val;
12361236
return set_obj_attrs(dpp, &state.attrset, nullptr, y, flags);
12371237
}
@@ -1242,7 +1242,7 @@ int MotrObject::delete_obj_attrs(const DoutPrefixProvider* dpp, const char* attr
12421242
Attrs rmattr;
12431243
bufferlist bl;
12441244

1245-
set_atomic();
1245+
set_atomic(true);
12461246
rmattr[attr_name] = bl;
12471247
return set_obj_attrs(dpp, nullptr, &rmattr, y, rgw::sal::FLAG_LOG_OP);
12481248
}

src/rgw/driver/rados/rgw_cr_rados.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ int RGWAsyncRemoveObj::_send_request(const DoutPrefixProvider *dpp)
911911
{
912912
ldpp_dout(dpp, 0) << __func__ << "(): deleting obj=" << obj << dendl;
913913

914-
obj->set_atomic();
914+
obj->set_atomic(true);
915915

916916
int ret = obj->load_obj_state(dpp, null_yield);
917917
if (ret < 0) {

src/rgw/driver/rados/rgw_lc_tier.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ static int cloud_tier_plain_transfer(RGWLCCloudTierCtx& tier_ctx) {
924924

925925
rgw_obj dest_obj(dest_bucket, rgw_obj_key(target_obj_name));
926926

927-
tier_ctx.obj->set_atomic();
927+
tier_ctx.obj->set_atomic(true);
928928

929929
/* Prepare Read from source */
930930
/* TODO: Define readf, writef as stack variables. For some reason,
@@ -968,7 +968,7 @@ static int cloud_tier_send_multipart_part(RGWLCCloudTierCtx& tier_ctx,
968968

969969
rgw_obj dest_obj(dest_bucket, rgw_obj_key(target_obj_name));
970970

971-
tier_ctx.obj->set_atomic();
971+
tier_ctx.obj->set_atomic(true);
972972

973973
/* TODO: Define readf, writef as stack variables. For some reason,
974974
* when used as stack variables (esp., readf), the transition seems to

src/rgw/driver/rados/rgw_putobj_processor.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ int AtomicObjectProcessor::complete(
394394
return r;
395395
}
396396

397-
obj_ctx.set_atomic(head_obj);
397+
obj_ctx.set_atomic(head_obj, true);
398398

399399
RGWRados::Object op_target(store, bucket_info, obj_ctx, head_obj);
400400

@@ -768,7 +768,7 @@ int AppendObjectProcessor::complete(
768768
if (r < 0) {
769769
return r;
770770
}
771-
obj_ctx.set_atomic(head_obj);
771+
obj_ctx.set_atomic(head_obj, true);
772772
RGWRados::Object op_target(store, bucket_info, obj_ctx, head_obj);
773773
//For Append obj, disable versioning
774774
op_target.set_versioning_disabled(true);

src/rgw/driver/rados/rgw_rados.cc

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,10 @@ void RGWObjectCtx::set_compressed(const rgw_obj& obj) {
252252
objs_state[obj].state.compressed = true;
253253
}
254254

255-
void RGWObjectCtx::set_atomic(const rgw_obj& obj) {
255+
void RGWObjectCtx::set_atomic(const rgw_obj& obj, bool atomic) {
256256
std::unique_lock wl{lock};
257257
assert (!obj.empty());
258-
objs_state[obj].state.is_atomic = true;
258+
objs_state[obj].state.is_atomic = atomic;
259259
}
260260
void RGWObjectCtx::set_prefetch_data(const rgw_obj& obj) {
261261
std::unique_lock wl{lock};
@@ -2959,7 +2959,7 @@ int RGWRados::swift_versioning_copy(RGWObjectCtx& obj_ctx,
29592959
return 0;
29602960
}
29612961

2962-
obj_ctx.set_atomic(obj);
2962+
obj_ctx.set_atomic(obj, true);
29632963

29642964
RGWObjState * state = nullptr;
29652965
RGWObjManifest *manifest = nullptr;
@@ -2999,7 +2999,7 @@ int RGWRados::swift_versioning_copy(RGWObjectCtx& obj_ctx,
29992999
gen_rand_obj_instance_name(&dest_obj);
30003000
}
30013001

3002-
obj_ctx.set_atomic(dest_obj);
3002+
obj_ctx.set_atomic(dest_obj, true);
30033003

30043004
rgw_zone_id no_zone;
30053005

@@ -3100,8 +3100,8 @@ int RGWRados::swift_versioning_restore(RGWObjectCtx& obj_ctx,
31003100
gen_rand_obj_instance_name(&obj);
31013101
}
31023102

3103-
obj_ctx.set_atomic(archive_obj);
3104-
obj_ctx.set_atomic(obj);
3103+
obj_ctx.set_atomic(archive_obj, true);
3104+
obj_ctx.set_atomic(obj, true);
31053105

31063106
jspan_context no_trace{false, false};
31073107

@@ -5223,7 +5223,7 @@ int RGWRados::transition_obj(RGWObjectCtx& obj_ctx,
52235223
real_time read_mtime;
52245224
uint64_t obj_size;
52255225

5226-
obj_ctx.set_atomic(obj);
5226+
obj_ctx.set_atomic(obj, true);
52275227
RGWRados::Object op_target(this, bucket_info, obj_ctx, obj);
52285228
RGWRados::Object::Read read_op(&op_target);
52295229

@@ -6018,7 +6018,7 @@ static int resync_encrypted_multipart(const DoutPrefixProvider* dpp,
60186018
const RGWObjState& state)
60196019
{
60206020
// only overwrite if the tag hasn't changed
6021-
obj_ctx.set_atomic(state.obj);
6021+
obj_ctx.set_atomic(state.obj, true);
60226022

60236023
// make a tiny adjustment to the existing mtime so that fetch_remote_obj()
60246024
// won't return ERR_NOT_MODIFIED when resyncing the object
@@ -6572,6 +6572,11 @@ int RGWRados::get_olh_target_state(const DoutPrefixProvider *dpp, RGWObjectCtx&
65726572
return r;
65736573
}
65746574

6575+
// if prefetch was requested, apply it to the target too
6576+
if (olh_state->prefetch_data) {
6577+
obj_ctx.set_prefetch_data(target);
6578+
}
6579+
65756580
return get_obj_state(dpp, &obj_ctx, bucket_info, target, psm, false, y);
65766581
}
65776582

src/rgw/driver/rados/rgw_rados.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ class RGWObjectCtx {
208208
RGWObjStateManifest *get_state(const rgw_obj& obj);
209209

210210
void set_compressed(const rgw_obj& obj);
211-
void set_atomic(const rgw_obj& obj);
211+
void set_atomic(const rgw_obj& obj, bool atomic);
212212
void set_prefetch_data(const rgw_obj& obj);
213213
void invalidate(const rgw_obj& obj);
214214
};
@@ -1457,9 +1457,9 @@ int restore_obj_from_cloud(RGWLCCloudTierCtx& tier_ctx,
14571457
int append_async(const DoutPrefixProvider *dpp, rgw_raw_obj& obj, size_t size, bufferlist& bl);
14581458

14591459
public:
1460-
void set_atomic(void *ctx, const rgw_obj& obj) {
1460+
void set_atomic(void *ctx, const rgw_obj& obj, bool atomic) {
14611461
RGWObjectCtx *rctx = static_cast<RGWObjectCtx *>(ctx);
1462-
rctx->set_atomic(obj);
1462+
rctx->set_atomic(obj, atomic);
14631463
}
14641464
void set_prefetch_data(void *ctx, const rgw_obj& obj) {
14651465
RGWObjectCtx *rctx = static_cast<RGWObjectCtx *>(ctx);

src/rgw/driver/rados/rgw_sal_rados.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,7 +1240,7 @@ int RadosBucket::commit_logging_object(const std::string& obj_name, optional_yie
12401240
}
12411241

12421242
RGWObjectCtx obj_ctx(store);
1243-
obj_ctx.set_atomic(head_obj);
1243+
obj_ctx.set_atomic(head_obj, true);
12441244
const auto& bucket_info = get_info();
12451245
RGWRados::Object rgw_head_obj(store->getRados(),
12461246
bucket_info,
@@ -2739,7 +2739,7 @@ int RadosObject::modify_obj_attrs(const char* attr_name, bufferlist& attr_val, o
27392739

27402740
/* Temporarily set target */
27412741
state.obj = target;
2742-
set_atomic();
2742+
set_atomic(true);
27432743
state.attrset[attr_name] = attr_val;
27442744
r = set_obj_attrs(dpp, &state.attrset, nullptr, y, flags);
27452745
/* Restore target */
@@ -2753,7 +2753,7 @@ int RadosObject::delete_obj_attrs(const DoutPrefixProvider* dpp, const char* att
27532753
Attrs rmattr;
27542754
bufferlist bl;
27552755

2756-
set_atomic();
2756+
set_atomic(true);
27572757
rmattr[attr_name] = bl;
27582758
return set_obj_attrs(dpp, nullptr, &rmattr, y, rgw::sal::FLAG_LOG_OP);
27592759
}
@@ -2905,7 +2905,7 @@ int RadosObject::chown(User& new_user, const DoutPrefixProvider* dpp, optional_y
29052905
bl.clear();
29062906
encode(policy, bl);
29072907

2908-
set_atomic();
2908+
set_atomic(true);
29092909
map<string, bufferlist> attrs;
29102910
attrs[RGW_ATTR_ACL] = bl;
29112911
r = set_obj_attrs(dpp, &attrs, nullptr, y, rgw::sal::FLAG_LOG_OP);
@@ -3110,7 +3110,7 @@ int RadosObject::set_cloud_restore_status(const DoutPrefixProvider* dpp,
31103110
rgw::sal::RGWRestoreStatus restore_status)
31113111
{
31123112
int ret = 0;
3113-
set_atomic();
3113+
set_atomic(true);
31143114

31153115
bufferlist bl;
31163116
using ceph::encode;
@@ -3152,7 +3152,7 @@ int RadosObject::handle_obj_expiry(const DoutPrefixProvider* dpp, optional_yield
31523152
obj_key.instance.clear();
31533153
}
31543154

3155-
set_atomic();
3155+
set_atomic(true);
31563156
map<string, bufferlist> attrs = get_attrs();
31573157
RGWRados::Object op_target(store->getRados(), bucket->get_info(), *rados_ctx, get_obj());
31583158
RGWRados::Object::Write obj_op(&op_target);
@@ -3264,7 +3264,7 @@ int RadosObject::write_cloud_tier(const DoutPrefixProvider* dpp,
32643264
RGWRados::Object op_target(store->getRados(), bucket->get_info(), *rados_ctx, get_obj());
32653265
RGWRados::Object::Write obj_op(&op_target);
32663266

3267-
set_atomic();
3267+
set_atomic(true);
32683268
obj_op.meta.modify_tail = true;
32693269
obj_op.meta.flags = PUT_OBJ_CREATE;
32703270
obj_op.meta.category = RGWObjCategory::CloudTiered;
@@ -4194,7 +4194,7 @@ int RadosMultipartUpload::complete(const DoutPrefixProvider *dpp,
41944194
attrs[RGW_ATTR_COMPRESSION] = tmp;
41954195
}
41964196

4197-
target_obj->set_atomic();
4197+
target_obj->set_atomic(true);
41984198

41994199
const RGWBucketInfo& bucket_info = target_obj->get_bucket()->get_info();
42004200
RGWRados::Object op_target(store->getRados(), bucket_info,

src/rgw/driver/rados/rgw_sal_rados.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -585,9 +585,9 @@ class RadosObject : public StoreObject {
585585
const DoutPrefixProvider* dpp, optional_yield y) override;
586586
virtual RGWAccessControlPolicy& get_acl(void) override { return acls; }
587587
virtual int set_acl(const RGWAccessControlPolicy& acl) override { acls = acl; return 0; }
588-
virtual void set_atomic() override {
589-
rados_ctx->set_atomic(state.obj);
590-
StoreObject::set_atomic();
588+
virtual void set_atomic(bool atomic) override {
589+
rados_ctx->set_atomic(state.obj, atomic);
590+
StoreObject::set_atomic(atomic);
591591
}
592592
virtual void set_prefetch_data() override {
593593
rados_ctx->set_prefetch_data(state.obj);

0 commit comments

Comments
 (0)