Skip to content

Commit 63899d5

Browse files
authored
Merge pull request ceph#57377 from dang/wip-dang-obj-state
RGW: Remove RGWObjState and get_obj_state()/put_obj_state() from the SAL API
2 parents 11d962d + 7d4c878 commit 63899d5

26 files changed

+285
-283
lines changed

src/rgw/driver/d4n/rgw_sal_d4n.cc

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -255,28 +255,29 @@ int D4NFilterObject::get_obj_attrs(optional_yield y, const DoutPrefixProvider* d
255255
} else {
256256
/* Set metadata locally */
257257
RGWQuotaInfo quota_info;
258-
RGWObjState* astate;
259-
this->get_obj_state(dpp, &astate, y);
258+
this->load_obj_state(dpp, y);
260259

261260
for (auto it = attrs.begin(); it != attrs.end(); ++it) {
262261
if (it->second.length() > 0) {
263262
if (it->first == "mtime") {
264-
parse_time(it->second.c_str(), &astate->mtime);
263+
ceph::real_time mtime;
264+
parse_time(it->second.c_str(), &mtime);
265+
this->set_mtime(mtime);
265266
attrs.erase(it->first);
266267
} else if (it->first == "object_size") {
267268
this->set_obj_size(std::stoull(it->second.c_str()));
268269
attrs.erase(it->first);
269270
} else if (it->first == "accounted_size") {
270-
astate->accounted_size = std::stoull(it->second.c_str());
271+
this->set_accounted_size(std::stoull(it->second.c_str()));
271272
attrs.erase(it->first);
272273
} else if (it->first == "epoch") {
273-
astate->epoch = std::stoull(it->second.c_str());
274+
this->set_epoch(std::stoull(it->second.c_str()));
274275
attrs.erase(it->first);
275276
} else if (it->first == "version_id") {
276277
this->set_instance(it->second.c_str());
277278
attrs.erase(it->first);
278279
} else if (it->first == "this_zone_short_id") {
279-
astate->zone_short_id = static_cast<uint32_t>(std::stoul(it->second.c_str()));
280+
this->set_short_zone_id(static_cast<uint32_t>(std::stoul(it->second.c_str())));
280281
attrs.erase(it->first);
281282
} else if (it->first == "user_quota.max_size") {
282283
quota_info.max_size = std::stoull(it->second.c_str());
@@ -293,8 +294,6 @@ int D4NFilterObject::get_obj_attrs(optional_yield y, const DoutPrefixProvider* d
293294
}
294295
}
295296

296-
this->set_obj_state(*astate);
297-
298297
/* Set attributes locally */
299298
if (this->set_attrs(attrs) < 0) {
300299
ldpp_dout(dpp, 10) << "D4NFilterObject::" << __func__ << "(): D4NFilterObject set_attrs method failed." << dendl;
@@ -390,29 +389,29 @@ int D4NFilterObject::D4NFilterReadOp::prepare(optional_yield y, const DoutPrefix
390389
ldpp_dout(dpp, 10) << "D4NFilterObject::D4NFilterReadOp::" << __func__ << "(): CacheDriver get_attrs method failed." << dendl;
391390
} else {
392391
/* Set metadata locally */
393-
RGWObjState* astate;
394392
RGWQuotaInfo quota_info;
395-
source->get_obj_state(dpp, &astate, y);
393+
source->load_obj_state(dpp, y);
396394

397395
for (auto& attr : attrs) {
398396
if (attr.second.length() > 0) {
399397
if (attr.first == "mtime") {
400-
parse_time(attr.second.c_str(), &astate->mtime);
401-
attrs.erase(attr.first);
398+
ceph::real_time mtime;
399+
parse_time(attr.second.c_str(), &mtime);
400+
source->set_mtime(mtime);
402401
} else if (attr.first == "object_size") {
403402
source->set_obj_size(std::stoull(attr.second.c_str()));
404403
attrs.erase(attr.first);
405404
} else if (attr.first == "accounted_size") {
406-
astate->accounted_size = std::stoull(attr.second.c_str());
405+
source->set_accounted_size(std::stoull(attr.second.c_str()));
407406
attrs.erase(attr.first);
408407
} else if (attr.first == "epoch") {
409-
astate->epoch = std::stoull(attr.second.c_str());
408+
source->set_epoch(std::stoull(attr.second.c_str()));
410409
attrs.erase(attr.first);
411410
} else if (attr.first == "version_id") {
412411
source->set_instance(attr.second.c_str());
413412
attrs.erase(attr.first);
414413
} else if (attr.first == "source_zone_short_id") {
415-
astate->zone_short_id = static_cast<uint32_t>(std::stoul(attr.second.c_str()));
414+
source->set_short_zone_id(static_cast<uint32_t>(std::stoul(attr.second.c_str())));
416415
attrs.erase(attr.first);
417416
} else if (attr.first == "user_quota.max_size") {
418417
quota_info.max_size = std::stoull(attr.second.c_str());
@@ -426,7 +425,6 @@ int D4NFilterObject::D4NFilterReadOp::prepare(optional_yield y, const DoutPrefix
426425
ldpp_dout(dpp, 20) << "D4NFilterObject::D4NFilterReadOp::" << __func__ << "(): Unexpected attribute; not locally set." << dendl;
427426
}
428427
}
429-
source->set_obj_state(*astate);
430428

431429
/* Set attributes locally */
432430
if (source->set_attrs(attrs) < 0)
@@ -435,14 +433,12 @@ int D4NFilterObject::D4NFilterReadOp::prepare(optional_yield y, const DoutPrefix
435433
}
436434

437435
//versioned objects have instance set to versionId, and get_oid() returns oid containing instance, hence using id tag as version for non versioned objects only
438-
if (! this->source->have_instance()) {
439-
RGWObjState* state = nullptr;
440-
if (this->source->get_obj_state(dpp, &state, y) == 0) {
441-
auto it = state->attrset.find(RGW_ATTR_ID_TAG);
442-
if (it != state->attrset.end()) {
443-
bufferlist bl = it->second;
444-
this->source->set_object_version(bl.c_str());
445-
ldpp_dout(dpp, 20) << __func__ << "id tag version is: " << this->source->get_object_version() << dendl;
436+
if (! source->have_instance()) {
437+
if (source->load_obj_state(dpp, y) == 0) {
438+
bufferlist bl;
439+
if (source->get_attr(RGW_ATTR_ID_TAG, bl)) {
440+
source->set_object_version(bl.c_str());
441+
ldpp_dout(dpp, 20) << __func__ << "id tag version is: " << source->get_object_version() << dendl;
446442
} else {
447443
ldpp_dout(dpp, 20) << __func__ << "Failed to find id tag" << dendl;
448444
}
@@ -942,22 +938,21 @@ int D4NFilterWriter::complete(size_t accounted_size, const std::string& etag,
942938
rgw::sal::Attrs baseAttrs = obj->get_attrs();
943939
rgw::sal::Attrs attrs_temp = baseAttrs;
944940
buffer::list bl;
945-
RGWObjState* astate;
946-
obj->get_obj_state(save_dpp, &astate, rctx.y);
941+
obj->load_obj_state(save_dpp, rctx.y);
947942

948943
bl.append(to_iso_8601(obj->get_mtime()));
949944
baseAttrs.insert({"mtime", bl});
950945
bl.clear();
951946

952-
bl.append(std::to_string(obj->get_obj_size()));
947+
bl.append(std::to_string(obj->get_size()));
953948
baseAttrs.insert({"object_size", bl});
954949
bl.clear();
955950

956951
bl.append(std::to_string(accounted_size));
957952
baseAttrs.insert({"accounted_size", bl});
958953
bl.clear();
959954

960-
bl.append(std::to_string(astate->epoch));
955+
bl.append(std::to_string(obj->get_epoch()));
961956
baseAttrs.insert({"epoch", bl});
962957
bl.clear();
963958

@@ -973,7 +968,7 @@ int D4NFilterWriter::complete(size_t accounted_size, const std::string& etag,
973968

974969
auto iter = attrs_temp.find(RGW_ATTR_SOURCE_ZONE);
975970
if (iter != attrs_temp.end()) {
976-
bl.append(std::to_string(astate->zone_short_id));
971+
bl.append(std::to_string(obj->get_short_zone_id()));
977972
baseAttrs.insert({"source_zone_short_id", bl});
978973
bl.clear();
979974
} else {

src/rgw/driver/daos/rgw_sal_daos.cc

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -868,13 +868,11 @@ std::unique_ptr<LuaManager> DaosStore::get_lua_manager(const DoutPrefixProvider
868868
return std::make_unique<DaosLuaManager>(this, dpp, luarocks_path);
869869
}
870870

871-
int DaosObject::get_obj_state(const DoutPrefixProvider* dpp,
872-
RGWObjState** _state, optional_yield y,
873-
bool follow_olh) {
871+
int DaosObject::load_obj_state(const DoutPrefixProvider* dpp,
872+
optional_yield y, bool follow_olh) {
874873
// Get object's metadata (those stored in rgw_bucket_dir_entry)
875-
ldpp_dout(dpp, 20) << "DEBUG: get_obj_state" << dendl;
874+
ldpp_dout(dpp, 20) << "DEBUG: load_obj_state" << dendl;
876875
rgw_bucket_dir_entry ent;
877-
*_state = &state; // state is required even if a failure occurs
878876

879877
int ret = get_dir_entry_attrs(dpp, &ent);
880878
if (ret != 0) {
@@ -1158,7 +1156,7 @@ std::unique_ptr<Object::DeleteOp> DaosObject::get_delete_op() {
11581156

11591157
DaosObject::DaosDeleteOp::DaosDeleteOp(DaosObject* _source) : source(_source) {}
11601158

1161-
// Implementation of DELETE OBJ also requires DaosObject::get_obj_state()
1159+
// Implementation of DELETE OBJ also requires DaosObject::load_obj_state()
11621160
// to retrieve and set object's state from object's metadata.
11631161
//
11641162
// TODO:

src/rgw/driver/daos/rgw_sal_daos.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,8 +617,8 @@ class DaosObject : public StoreObject {
617617
return 0;
618618
}
619619

620-
virtual int get_obj_state(const DoutPrefixProvider* dpp, RGWObjState** state,
621-
optional_yield y, bool follow_olh = true) override;
620+
virtual int load_obj_state(const DoutPrefixProvider *dpp, optional_yield y,
621+
bool follow_olh = true) override;
622622
virtual int set_obj_attrs(const DoutPrefixProvider* dpp, Attrs* setattrs,
623623
Attrs* delattrs, optional_yield y) override;
624624
virtual int get_obj_attrs(optional_yield y, const DoutPrefixProvider* dpp,

src/rgw/driver/motr/rgw_sal_motr.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,7 @@ std::unique_ptr<LuaManager> MotrStore::get_lua_manager(const DoutPrefixProvider
11261126
return std::make_unique<MotrLuaManager>(this, dpp, luarocks_path);
11271127
}
11281128

1129-
int MotrObject::get_obj_state(const DoutPrefixProvider* dpp, RGWObjState **_state, optional_yield y, bool follow_olh)
1129+
int MotrObject::load_obj_state(const DoutPrefixProvider* dpp, optional_yield y, bool follow_olh)
11301130
{
11311131
// Get object's metadata (those stored in rgw_bucket_dir_entry).
11321132
bufferlist bl;
@@ -1393,7 +1393,7 @@ int MotrObject::MotrReadOp::prepare(optional_yield y, const DoutPrefixProvider*
13931393
}
13941394

13951395
// Skip opening an empty object.
1396-
if(source->get_obj_size() == 0)
1396+
if(source->get_size() == 0)
13971397
return 0;
13981398

13991399
// Open the object here.
@@ -1449,7 +1449,7 @@ MotrObject::MotrDeleteOp::MotrDeleteOp(MotrObject *_source) :
14491449
source(_source)
14501450
{ }
14511451

1452-
// Implementation of DELETE OBJ also requires MotrObject::get_obj_state()
1452+
// Implementation of DELETE OBJ also requires MotrObject::load_obj_state()
14531453
// to retrieve and set object's state from object's metadata.
14541454
//
14551455
// TODO:

src/rgw/driver/motr/rgw_sal_motr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ class MotrObject : public StoreObject {
676676
const DoutPrefixProvider* dpp, optional_yield y) override;
677677
virtual RGWAccessControlPolicy& get_acl(void) override { return acls; }
678678
virtual int set_acl(const RGWAccessControlPolicy& acl) override { acls = acl; return 0; }
679-
virtual int get_obj_state(const DoutPrefixProvider* dpp, RGWObjState **state, optional_yield y, bool follow_olh = true) override;
679+
virtual int load_obj_state(const DoutPrefixProvider* dpp, optional_yield y, bool follow_olh = true) override;
680680
virtual int set_obj_attrs(const DoutPrefixProvider* dpp, Attrs* setattrs, Attrs* delattrs, optional_yield y) override;
681681
virtual int get_obj_attrs(optional_yield y, const DoutPrefixProvider* dpp, rgw_obj* target_obj = NULL) override;
682682
virtual int modify_obj_attrs(const char* attr_name, bufferlist& attr_val, optional_yield y, const DoutPrefixProvider* dpp) override;

0 commit comments

Comments
 (0)