From: Kefu Chai Date: Tue, 2 Feb 2021 09:37:46 +0000 (+0800) Subject: osd: let object_info_t() decode const bufferlist. X-Git-Tag: v17.1.0~3039^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4e76cdb468b866a926f6a4b4f98e60573019ee12;p=ceph.git osd: let object_info_t() decode const bufferlist. so we can decode a const bufferlist without creating a copy of it beforehand. Signed-off-by: Kefu Chai --- diff --git a/src/crimson/osd/replicated_recovery_backend.cc b/src/crimson/osd/replicated_recovery_backend.cc index ae13ad3c9779..95f39ec5f458 100644 --- a/src/crimson/osd/replicated_recovery_backend.cc +++ b/src/crimson/osd/replicated_recovery_backend.cc @@ -926,8 +926,7 @@ ReplicatedRecoveryBackend::prep_push_target( if (!complete || !recovery_info.object_exist) { t->remove(coll->get_cid(), target_oid); t->touch(coll->get_cid(), target_oid); - bufferlist bv = attrs.at(OI_ATTR); - object_info_t oi(bv); + object_info_t oi(attrs.at(OI_ATTR)); t->set_alloc_hint(coll->get_cid(), target_oid, oi.expected_object_size, oi.expected_write_size, diff --git a/src/osd/PrimaryLogScrub.cc b/src/osd/PrimaryLogScrub.cc index 39a16a3a3166..db44416f9882 100644 --- a/src/osd/PrimaryLogScrub.cc +++ b/src/osd/PrimaryLogScrub.cc @@ -282,8 +282,7 @@ void PrimaryLogScrub::scrub_snapshot_metadata(ScrubMap& scrubmap, bufferlist bv; bv.push_back(p->second.attrs[OI_ATTR]); try { - oi = object_info_t(); // Initialize optional<> before decode into it - oi->decode(bv); + oi = object_info_t(bv); } catch (ceph::buffer::error& e) { oi = std::nullopt; m_osds->clog->error() << mode << " " << info.pgid << " " << soid diff --git a/src/osd/ReplicatedBackend.cc b/src/osd/ReplicatedBackend.cc index 1468764c399b..3967ac56638a 100644 --- a/src/osd/ReplicatedBackend.cc +++ b/src/osd/ReplicatedBackend.cc @@ -1623,8 +1623,7 @@ void ReplicatedBackend::submit_push_data( if (!complete) { t->remove(coll, ghobject_t(target_oid)); t->touch(coll, ghobject_t(target_oid)); - bufferlist bv = attrs.at(OI_ATTR); - object_info_t oi(bv); + object_info_t oi(attrs.at(OI_ATTR)); t->set_alloc_hint(coll, ghobject_t(target_oid), oi.expected_object_size, oi.expected_write_size, @@ -1633,8 +1632,7 @@ void ReplicatedBackend::submit_push_data( if (!recovery_info.object_exist) { t->remove(coll, ghobject_t(target_oid)); t->touch(coll, ghobject_t(target_oid)); - bufferlist bv = attrs.at(OI_ATTR); - object_info_t oi(bv); + object_info_t oi(attrs.at(OI_ATTR)); t->set_alloc_hint(coll, ghobject_t(target_oid), oi.expected_object_size, oi.expected_write_size, @@ -2048,10 +2046,8 @@ int ReplicatedBackend::build_push_op(const ObjectRecoveryInfo &recovery_info, } // Debug - bufferlist bv = out_op->attrset[OI_ATTR]; try { - auto bliter = bv.cbegin(); - decode(oi, bliter); + oi.decode(out_op->attrset[OI_ATTR]); } catch (...) { dout(0) << __func__ << ": bad object_info_t: " << recovery_info.soid << dendl; return -EINVAL; diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index 2250f6f3b0ed..ac09fe3b6878 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -5896,7 +5896,7 @@ struct object_info_t { alloc_hint_flags(0) {} - explicit object_info_t(ceph::buffer::list& bl) { + explicit object_info_t(const ceph::buffer::list& bl) { decode(bl); } };