From 61ede7086975b20495e4091d2487f7698c7adf83 Mon Sep 17 00:00:00 2001 From: Soumya Koduri Date: Mon, 11 Apr 2022 14:06:59 +0530 Subject: [PATCH] rgw/dbstore: DBObject state initialization Initialize & store 'state' part of DBObject to be referenced by callers of 'get_obj_state'. Signed-off-by: Soumya Koduri --- src/rgw/store/dbstore/common/dbstore.cc | 16 ++++++---------- src/rgw/store/dbstore/common/dbstore.h | 4 ++-- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/rgw/store/dbstore/common/dbstore.cc b/src/rgw/store/dbstore/common/dbstore.cc index 262b978c4bf..b42f9b3b081 100644 --- a/src/rgw/store/dbstore/common/dbstore.cc +++ b/src/rgw/store/dbstore/common/dbstore.cc @@ -1226,6 +1226,7 @@ int DB::Object::get_obj_state(const DoutPrefixProvider *dpp, /* XXX: For now use state->shadow_obj to store ObjectID string */ s->shadow_obj = params.op.obj.obj_id; + *state = &obj_state; **state = *s; if (follow_olh && params.op.obj.state.obj.key.instance.empty()) { @@ -1249,8 +1250,7 @@ int DB::Object::get_state(const DoutPrefixProvider *dpp, RGWObjState **pstate, b int DB::Object::Read::get_attr(const DoutPrefixProvider *dpp, const char *name, bufferlist& dest) { - RGWObjState base_state; - RGWObjState *state = &base_state; + RGWObjState *state; int r = source->get_state(dpp, &state, true); if (r < 0) return r; @@ -1271,8 +1271,7 @@ int DB::Object::Read::prepare(const DoutPrefixProvider *dpp) map::iterator iter; - RGWObjState base_state; - RGWObjState *astate = &base_state; + RGWObjState *astate; /* XXX Read obj_id too */ int r = source->get_state(dpp, &astate, true); @@ -1360,8 +1359,7 @@ int DB::Object::Read::read(int64_t ofs, int64_t end, bufferlist& bl, const DoutP bufferlist read_bl; uint64_t max_chunk_size = store->get_max_chunk_size(); - RGWObjState base_state; - RGWObjState *astate = &base_state; + RGWObjState *astate; int r = source->get_state(dpp, &astate, true); if (r < 0) return r; @@ -1497,8 +1495,7 @@ int DB::Object::iterate_obj(const DoutPrefixProvider *dpp, { DB *store = get_store(); uint64_t len; - RGWObjState base_state; - RGWObjState *astate = &base_state; + RGWObjState *astate; int r = get_state(dpp, &astate, true); if (r < 0) { @@ -1752,8 +1749,7 @@ int DB::Object::Write::write_meta(const DoutPrefixProvider *dpp, uint64_t size, int DB::Object::Delete::delete_obj(const DoutPrefixProvider *dpp) { int ret = 0; DB *store = target->get_store(); - RGWObjState base_state; - RGWObjState *astate = &base_state; + RGWObjState *astate; int r = target->get_state(dpp, &astate, true); if (r < 0) diff --git a/src/rgw/store/dbstore/common/dbstore.h b/src/rgw/store/dbstore/common/dbstore.h index 698291bad5d..da7c3a970ad 100644 --- a/src/rgw/store/dbstore/common/dbstore.h +++ b/src/rgw/store/dbstore/common/dbstore.h @@ -1743,7 +1743,7 @@ class DB { RGWBucketInfo bucket_info; rgw_obj obj; - RGWObjState *state; + RGWObjState obj_state; std::string obj_id; bool versioning_disabled; @@ -1753,7 +1753,7 @@ class DB { public: Object(DB *_store, const RGWBucketInfo& _bucket_info, const rgw_obj& _obj) : store(_store), bucket_info(_bucket_info), obj(_obj), - state(NULL), versioning_disabled(false), + versioning_disabled(false), bs_initialized(false) {} Object(DB *_store, const RGWBucketInfo& _bucket_info, const rgw_obj& _obj, const std::string& _obj_id) : store(_store), bucket_info(_bucket_info), obj(_obj), obj_id(_obj_id) {} -- 2.47.3