]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: let object_info_t() decode const bufferlist. 39164/head
authorKefu Chai <kchai@redhat.com>
Tue, 2 Feb 2021 09:37:46 +0000 (17:37 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 2 Feb 2021 11:02:33 +0000 (19:02 +0800)
so we can decode a const bufferlist without creating a copy of it
beforehand.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/crimson/osd/replicated_recovery_backend.cc
src/osd/PrimaryLogScrub.cc
src/osd/ReplicatedBackend.cc
src/osd/osd_types.h

index ae13ad3c9779f06b22cc788c2bcb488fe0d9b8d4..95f39ec5f4581124de76712675e467efcf0a9943 100644 (file)
@@ -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,
index 39a16a3a3166fcf4c1e005dd1976ff14ea5cc0c1..db44416f9882dfb513c536dbe8628da9fa302bb4 100644 (file)
@@ -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
index 1468764c399b4fc7a297e0a9ab52c10e3a468f6f..3967ac56638a39a8e9a0dacc82567e1425f43368 100644 (file)
@@ -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;
index 2250f6f3b0ed764da8b1d81c702ea7288b6c8363..ac09fe3b6878b3bd47848db714ac6d4c093fc862 100644 (file)
@@ -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);
   }
 };