diff options
author | Andreas Gruenbacher <agruen@linbit.com> | 2011-03-30 10:00:17 -0400 |
---|---|---|
committer | Philipp Reisner <philipp.reisner@linbit.com> | 2012-11-08 10:45:10 -0500 |
commit | 0c8e36d9b843be56e4e43d4ef3c3eb6a97205599 (patch) | |
tree | 5f593c0b3c4a4052382fa2d23dff87281786e2ad /drivers/block/drbd/drbd_main.c | |
parent | e658983af6e62304be785cd6b0ae756723057395 (diff) |
drbd: Introduce protocol version 100 headers
The 8 byte header finally becomes too small. With the protocol 100 header we
have 16 bit for the volume number, proper 32 bit for the data length, and
32 bit for further extensions in the future.
Previous versions of drbd are using version 80 headers for all packets
short enough for protocol 80. They support both header versions in
worker context, but only version 80 headers in asynchronous context.
For backwards compatibility, continue to use version 80 headers for
short packets before protocol version 100.
From protocol version 100 on, use the same header version for all
packets.
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Diffstat (limited to 'drivers/block/drbd/drbd_main.c')
-rw-r--r-- | drivers/block/drbd/drbd_main.c | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index b9dcc50135c4..5d9112cefcd7 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c | |||
@@ -698,9 +698,15 @@ void drbd_thread_current_set_cpu(struct drbd_thread *thi) | |||
698 | */ | 698 | */ |
699 | unsigned int drbd_header_size(struct drbd_tconn *tconn) | 699 | unsigned int drbd_header_size(struct drbd_tconn *tconn) |
700 | { | 700 | { |
701 | BUILD_BUG_ON(sizeof(struct p_header80) != sizeof(struct p_header95)); | 701 | if (tconn->agreed_pro_version >= 100) { |
702 | BUILD_BUG_ON(!IS_ALIGNED(sizeof(struct p_header80), 8)); | 702 | BUILD_BUG_ON(!IS_ALIGNED(sizeof(struct p_header100), 8)); |
703 | return sizeof(struct p_header80); | 703 | return sizeof(struct p_header100); |
704 | } else { | ||
705 | BUILD_BUG_ON(sizeof(struct p_header80) != | ||
706 | sizeof(struct p_header95)); | ||
707 | BUILD_BUG_ON(!IS_ALIGNED(sizeof(struct p_header80), 8)); | ||
708 | return sizeof(struct p_header80); | ||
709 | } | ||
704 | } | 710 | } |
705 | 711 | ||
706 | static unsigned int prepare_header80(struct p_header80 *h, enum drbd_packet cmd, int size) | 712 | static unsigned int prepare_header80(struct p_header80 *h, enum drbd_packet cmd, int size) |
@@ -719,10 +725,24 @@ static unsigned int prepare_header95(struct p_header95 *h, enum drbd_packet cmd, | |||
719 | return sizeof(struct p_header95); | 725 | return sizeof(struct p_header95); |
720 | } | 726 | } |
721 | 727 | ||
722 | static unsigned int prepare_header(struct drbd_tconn *tconn, int vnr, void *buffer, | 728 | static unsigned int prepare_header100(struct p_header100 *h, enum drbd_packet cmd, |
723 | enum drbd_packet cmd, int size) | 729 | int size, int vnr) |
730 | { | ||
731 | h->magic = cpu_to_be32(DRBD_MAGIC_100); | ||
732 | h->volume = cpu_to_be16(vnr); | ||
733 | h->command = cpu_to_be16(cmd); | ||
734 | h->length = cpu_to_be32(size); | ||
735 | h->pad = 0; | ||
736 | return sizeof(struct p_header100); | ||
737 | } | ||
738 | |||
739 | static unsigned int prepare_header(struct drbd_tconn *tconn, int vnr, | ||
740 | void *buffer, enum drbd_packet cmd, int size) | ||
724 | { | 741 | { |
725 | if (tconn->agreed_pro_version >= 95) | 742 | if (tconn->agreed_pro_version >= 100) |
743 | return prepare_header100(buffer, cmd, size, vnr); | ||
744 | else if (tconn->agreed_pro_version >= 95 && | ||
745 | size > DRBD_MAX_SIZE_H80_PACKET) | ||
726 | return prepare_header95(buffer, cmd, size); | 746 | return prepare_header95(buffer, cmd, size); |
727 | else | 747 | else |
728 | return prepare_header80(buffer, cmd, size); | 748 | return prepare_header80(buffer, cmd, size); |