]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
msg/async, v2: get rid of magic numbers for alignment.
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Tue, 19 Feb 2019 16:13:32 +0000 (17:13 +0100)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Thu, 21 Feb 2019 22:31:02 +0000 (23:31 +0100)
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/msg/async/ProtocolV2.cc
src/msg/async/ProtocolV2.h

index c4ec5017433cab04828eab4a625b877bcd66fc65..3236daa3fc2cc2dde8f36347492b74c3d02b80a8 100644 (file)
@@ -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<T, Args...> {
     // 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<T, Args...> {
 
     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 },
     }, {});
   }
index 99637b042bd54a49632ca142e28d2ef7b14948a2..00b8e3bdd5e511dd3c5eb8bb44e1ac420485a611 100644 (file)
@@ -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));