From: Casey Bodley Date: Sun, 19 Feb 2023 22:47:43 +0000 (-0500) Subject: rgw/rados: don't use attrset[] to create entries that don't exist X-Git-Tag: v18.1.0~8^2~9 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3e22cb4eaa47f6c7c5ceba0bfe7afaa60cbb4c5d;p=ceph.git rgw/rados: don't use attrset[] to create entries that don't exist Signed-off-by: Casey Bodley (cherry picked from commit 33273476730c70f4a5103151c36947030f11348e) --- diff --git a/src/rgw/driver/rados/rgw_rados.cc b/src/rgw/driver/rados/rgw_rados.cc index 83238e8e49b0..57ea3621a056 100644 --- a/src/rgw/driver/rados/rgw_rados.cc +++ b/src/rgw/driver/rados/rgw_rados.cc @@ -5586,14 +5586,16 @@ int RGWRados::get_obj_state_impl(const DoutPrefixProvider *dpp, RGWObjectCtx *rc it.copy(bl.length(), s->shadow_obj); s->shadow_obj[bl.length()] = '\0'; } - s->obj_tag = s->attrset[RGW_ATTR_ID_TAG]; + if (iter = s->attrset.find(RGW_ATTR_ID_TAG); iter != s->attrset.end()) { + s->obj_tag = iter->second; + } auto ttiter = s->attrset.find(RGW_ATTR_TAIL_TAG); if (ttiter != s->attrset.end()) { s->tail_tag = s->attrset[RGW_ATTR_TAIL_TAG]; } - bufferlist manifest_bl = s->attrset[RGW_ATTR_MANIFEST]; - if (manifest_bl.length()) { + if (iter = s->attrset.find(RGW_ATTR_MANIFEST); iter != s->attrset.end()) { + bufferlist manifest_bl = iter->second; auto miter = manifest_bl.cbegin(); try { sm->manifest.emplace(); @@ -6041,14 +6043,20 @@ int RGWRados::set_attrs(const DoutPrefixProvider *dpp, void *ctx, RGWBucketInfo& r = rgw_rados_operate(dpp, ioctx, ref.obj.oid, &op, null_yield); if (state) { if (r >= 0) { - bufferlist acl_bl = attrs[RGW_ATTR_ACL]; - bufferlist etag_bl = attrs[RGW_ATTR_ETAG]; - bufferlist content_type_bl = attrs[RGW_ATTR_CONTENT_TYPE]; - string etag = rgw_bl_str(etag_bl); - string content_type = rgw_bl_str(content_type_bl); + bufferlist acl_bl; + if (iter = attrs.find(RGW_ATTR_ACL); iter != attrs.end()) { + acl_bl = iter->second; + } + std::string etag; + if (iter = attrs.find(RGW_ATTR_ETAG); iter != attrs.end()) { + etag = rgw_bl_str(iter->second); + } + std::string content_type; + if (iter = attrs.find(RGW_ATTR_CONTENT_TYPE); iter != attrs.end()) { + content_type = rgw_bl_str(iter->second); + } string storage_class; - auto iter = attrs.find(RGW_ATTR_STORAGE_CLASS); - if (iter != attrs.end()) { + if (iter = attrs.find(RGW_ATTR_STORAGE_CLASS); iter != attrs.end()) { storage_class = rgw_bl_str(iter->second); } uint64_t epoch = ioctx.get_last_version();