Skip to content

Commit 8407601

Browse files
authored
Merge pull request ceph#62903 from jzhu116-bloomberg/wip-70992
rgw: prefetch data from versioned object instance head Reviewed-by: Casey Bodley <[email protected]>
2 parents ee51bf8 + 5e47f67 commit 8407601

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
@@ -1238,7 +1238,7 @@ int MotrObject::modify_obj_attrs(const char* attr_name, bufferlist& attr_val, op
12381238
if (r < 0) {
12391239
return r;
12401240
}
1241-
set_atomic();
1241+
set_atomic(true);
12421242
state.attrset[attr_name] = attr_val;
12431243
return set_obj_attrs(dpp, &state.attrset, nullptr, y, flags);
12441244
}
@@ -1249,7 +1249,7 @@ int MotrObject::delete_obj_attrs(const DoutPrefixProvider* dpp, const char* attr
12491249
Attrs rmattr;
12501250
bufferlist bl;
12511251

1252-
set_atomic();
1252+
set_atomic(true);
12531253
rmattr[attr_name] = bl;
12541254
return set_obj_attrs(dpp, nullptr, &rmattr, y, rgw::sal::FLAG_LOG_OP);
12551255
}

src/rgw/driver/rados/rgw_cr_rados.cc

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

916-
obj->set_atomic();
916+
obj->set_atomic(true);
917917

918918
int ret = obj->load_obj_state(dpp, null_yield);
919919
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
@@ -922,7 +922,7 @@ static int cloud_tier_plain_transfer(RGWLCCloudTierCtx& tier_ctx) {
922922

923923
rgw_obj dest_obj(dest_bucket, rgw_obj_key(target_obj_name));
924924

925-
tier_ctx.obj->set_atomic();
925+
tier_ctx.obj->set_atomic(true);
926926

927927
/* Prepare Read from source */
928928
/* TODO: Define readf, writef as stack variables. For some reason,
@@ -966,7 +966,7 @@ static int cloud_tier_send_multipart_part(RGWLCCloudTierCtx& tier_ctx,
966966

967967
rgw_obj dest_obj(dest_bucket, rgw_obj_key(target_obj_name));
968968

969-
tier_ctx.obj->set_atomic();
969+
tier_ctx.obj->set_atomic(true);
970970

971971
/* TODO: Define readf, writef as stack variables. For some reason,
972972
* 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

@@ -5294,7 +5294,7 @@ int RGWRados::transition_obj(RGWObjectCtx& obj_ctx,
52945294
real_time read_mtime;
52955295
uint64_t obj_size;
52965296

5297-
obj_ctx.set_atomic(obj);
5297+
obj_ctx.set_atomic(obj, true);
52985298
RGWRados::Object op_target(this, bucket_info, obj_ctx, obj);
52995299
RGWRados::Object::Read read_op(&op_target);
53005300

@@ -6095,7 +6095,7 @@ static int resync_encrypted_multipart(const DoutPrefixProvider* dpp,
60956095
const RGWObjState& state)
60966096
{
60976097
// only overwrite if the tag hasn't changed
6098-
obj_ctx.set_atomic(state.obj);
6098+
obj_ctx.set_atomic(state.obj, true);
60996099

61006100
// make a tiny adjustment to the existing mtime so that fetch_remote_obj()
61016101
// won't return ERR_NOT_MODIFIED when resyncing the object
@@ -6649,6 +6649,11 @@ int RGWRados::get_olh_target_state(const DoutPrefixProvider *dpp, RGWObjectCtx&
66496649
return r;
66506650
}
66516651

6652+
// if prefetch was requested, apply it to the target too
6653+
if (olh_state->prefetch_data) {
6654+
obj_ctx.set_prefetch_data(target);
6655+
}
6656+
66526657
return get_obj_state(dpp, &obj_ctx, bucket_info, target, psm, false, y);
66536658
}
66546659

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
};
@@ -1459,9 +1459,9 @@ int restore_obj_from_cloud(RGWLCCloudTierCtx& tier_ctx,
14591459
int append_async(const DoutPrefixProvider *dpp, rgw_raw_obj& obj, size_t size, bufferlist& bl);
14601460

14611461
public:
1462-
void set_atomic(void *ctx, const rgw_obj& obj) {
1462+
void set_atomic(void *ctx, const rgw_obj& obj, bool atomic) {
14631463
RGWObjectCtx *rctx = static_cast<RGWObjectCtx *>(ctx);
1464-
rctx->set_atomic(obj);
1464+
rctx->set_atomic(obj, atomic);
14651465
}
14661466
void set_prefetch_data(void *ctx, const rgw_obj& obj) {
14671467
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
@@ -1247,7 +1247,7 @@ int RadosBucket::commit_logging_object(const std::string& obj_name, optional_yie
12471247
}
12481248

12491249
RGWObjectCtx obj_ctx(store);
1250-
obj_ctx.set_atomic(head_obj);
1250+
obj_ctx.set_atomic(head_obj, true);
12511251
const auto& bucket_info = get_info();
12521252
RGWRados::Object rgw_head_obj(store->getRados(),
12531253
bucket_info,
@@ -2746,7 +2746,7 @@ int RadosObject::modify_obj_attrs(const char* attr_name, bufferlist& attr_val, o
27462746

27472747
/* Temporarily set target */
27482748
state.obj = target;
2749-
set_atomic();
2749+
set_atomic(true);
27502750
state.attrset[attr_name] = attr_val;
27512751
r = set_obj_attrs(dpp, &state.attrset, nullptr, y, flags);
27522752
/* Restore target */
@@ -2760,7 +2760,7 @@ int RadosObject::delete_obj_attrs(const DoutPrefixProvider* dpp, const char* att
27602760
Attrs rmattr;
27612761
bufferlist bl;
27622762

2763-
set_atomic();
2763+
set_atomic(true);
27642764
rmattr[attr_name] = bl;
27652765
return set_obj_attrs(dpp, nullptr, &rmattr, y, rgw::sal::FLAG_LOG_OP);
27662766
}
@@ -2912,7 +2912,7 @@ int RadosObject::chown(User& new_user, const DoutPrefixProvider* dpp, optional_y
29122912
bl.clear();
29132913
encode(policy, bl);
29142914

2915-
set_atomic();
2915+
set_atomic(true);
29162916
map<string, bufferlist> attrs;
29172917
attrs[RGW_ATTR_ACL] = bl;
29182918
r = set_obj_attrs(dpp, &attrs, nullptr, y, rgw::sal::FLAG_LOG_OP);
@@ -3117,7 +3117,7 @@ int RadosObject::set_cloud_restore_status(const DoutPrefixProvider* dpp,
31173117
rgw::sal::RGWRestoreStatus restore_status)
31183118
{
31193119
int ret = 0;
3120-
set_atomic();
3120+
set_atomic(true);
31213121

31223122
bufferlist bl;
31233123
using ceph::encode;
@@ -3159,7 +3159,7 @@ int RadosObject::handle_obj_expiry(const DoutPrefixProvider* dpp, optional_yield
31593159
obj_key.instance.clear();
31603160
}
31613161

3162-
set_atomic();
3162+
set_atomic(true);
31633163
map<string, bufferlist> attrs = get_attrs();
31643164
RGWRados::Object op_target(store->getRados(), bucket->get_info(), *rados_ctx, get_obj());
31653165
RGWRados::Object::Write obj_op(&op_target);
@@ -3271,7 +3271,7 @@ int RadosObject::write_cloud_tier(const DoutPrefixProvider* dpp,
32713271
RGWRados::Object op_target(store->getRados(), bucket->get_info(), *rados_ctx, get_obj());
32723272
RGWRados::Object::Write obj_op(&op_target);
32733273

3274-
set_atomic();
3274+
set_atomic(true);
32753275
obj_op.meta.modify_tail = true;
32763276
obj_op.meta.flags = PUT_OBJ_CREATE;
32773277
obj_op.meta.category = RGWObjCategory::CloudTiered;
@@ -4201,7 +4201,7 @@ int RadosMultipartUpload::complete(const DoutPrefixProvider *dpp,
42014201
attrs[RGW_ATTR_COMPRESSION] = tmp;
42024202
}
42034203

4204-
target_obj->set_atomic();
4204+
target_obj->set_atomic(true);
42054205

42064206
const RGWBucketInfo& bucket_info = target_obj->get_bucket()->get_info();
42074207
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)