From: Radoslaw Zarzynski Date: Tue, 19 Feb 2019 16:13:32 +0000 (+0100) Subject: msg/async, v2: get rid of magic numbers for alignment. X-Git-Tag: v14.1.1~157^2~13 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7adfc3102fb1ba90515c42efe0057cc8e302a70f;p=ceph-ci.git msg/async, v2: get rid of magic numbers for alignment. Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/msg/async/ProtocolV2.cc b/src/msg/async/ProtocolV2.cc index c4ec5017433..3236daa3fc2 100644 --- a/src/msg/async/ProtocolV2.cc +++ b/src/msg/async/ProtocolV2.cc @@ -206,7 +206,8 @@ public: ceph::bufferlist &get_buffer() { fill_preamble({ - segment_t{ payload.length() - FRAME_PREAMBLE_SIZE, 1 } + segment_t{ payload.length() - FRAME_PREAMBLE_SIZE, + segment_t::DEFAULT_ALIGNMENT } }, {}); return payload; } @@ -376,7 +377,8 @@ struct SignedEncryptedFrame : public PayloadFrame { // FIXME: plainsize -> ciphersize; for AES-GCM they are equall apart // from auth tag size this->fill_preamble({ - segment_t{ this->payload.length() - FRAME_PREAMBLE_SIZE, 16 } + segment_t{ this->payload.length() - FRAME_PREAMBLE_SIZE, + segment_t::DEFAULT_ALIGNMENT } }, {}); if (protocol.session_stream_handlers.tx) { @@ -405,7 +407,7 @@ struct SignedEncryptedFrame : public PayloadFrame { ceph::bufferlist plain_bl = \ protocol.session_stream_handlers.rx->authenticated_decrypt_update_final( - std::move(bl), 8); + std::move(bl), ProtocolV2::segment_t::DEFAULT_ALIGNMENT); ceph_assert(plain_bl.length() + 16 == length); this->decode_frame(plain_bl.c_str(), plain_bl.length()); } @@ -557,9 +559,10 @@ struct MessageHeaderFrame { // FIXME: plainsize -> ciphersize; for AES-GCM they are equall apart from auth tag size fill_preamble({ - segment_t{ this->payload.length() - FRAME_PREAMBLE_SIZE, 8 }, - segment_t{ front_len, 8 }, - segment_t{ middle_len, 8 }, + segment_t{ this->payload.length() - FRAME_PREAMBLE_SIZE, + segment_t::DEFAULT_ALIGNMENT }, + segment_t{ front_len, segment_t::DEFAULT_ALIGNMENT }, + segment_t{ middle_len, segment_t::DEFAULT_ALIGNMENT }, segment_t{ data_len, segment_t::DEFERRED_ALLOCATION }, }, {}); } diff --git a/src/msg/async/ProtocolV2.h b/src/msg/async/ProtocolV2.h index 99637b042bd..00b8e3bdd5e 100644 --- a/src/msg/async/ProtocolV2.h +++ b/src/msg/async/ProtocolV2.h @@ -107,7 +107,12 @@ private: public: struct segment_t { + // TODO: this will be dropped with support for `allocation policies`. + // We need them because of the rx_buffers zero-copy optimization. static constexpr __le16 DEFERRED_ALLOCATION { 0x0000 }; + + static constexpr __le16 DEFAULT_ALIGNMENT = sizeof(void*); + __le32 length; __le16 alignment; } __attribute__((packed));