]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/dbstore: DBObject state initialization
authorSoumya Koduri <skoduri@redhat.com>
Mon, 11 Apr 2022 08:36:59 +0000 (14:06 +0530)
committerSoumya Koduri <skoduri@redhat.com>
Tue, 19 Apr 2022 07:53:09 +0000 (13:23 +0530)
Initialize & store 'state' part of DBObject to be
referenced by callers of 'get_obj_state'.

Signed-off-by: Soumya Koduri <skoduri@redhat.com>
src/rgw/store/dbstore/common/dbstore.cc
src/rgw/store/dbstore/common/dbstore.h

index 262b978c4bfd218d21c39d9107cf7b4d5cb913e7..b42f9b3b081d900950565ad81d133e9a86504a80 100644 (file)
@@ -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<string, bufferlist>::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)
index 698291bad5d6f1f96b1598a00a91ab25d00d081e..da7c3a970adbfaf816f1ae139079485bde83fc34 100644 (file)
@@ -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) {}