Skip to contentSkip to conversation

drbd: part 10 of adding multiple volume support to drbd

RFC In review Philipp Reisner 2 participants 23 messages Sep 23, 2011 – Sep 28, 2011

Subsystems (2)
lore
Share & tools
lore

Philipp Reisner

author maintainer
#0 lore raw

cover drbd: part 10 of adding multiple volume support to drbd

This the first request for review of drbd-8.4. The complete set has 478 patches. This is the tenth installment containing 10 patches.

The whole set is available here:
git://git.drbd.org/linux-2.6-drbd.git for-jens

and is jens_for-3.2_drivers...for-jens
and this part is a56df23^...ee04546

This patch series contains:
* Introduces header 100, which allows 16 bit volume numbers.

author maintainer
#1 lore raw

PATCH 1/10 drbd: drbd_send_ping(), drbd_send_ping(): Return 0 upon success and an error code otherwise

From: Andreas Gruenbacher <[email protected]>

---
 drivers/block/drbd/drbd_main.c     |    4 ++--
 drivers/block/drbd/drbd_receiver.c |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/block/drbd/drbd_main.c +2 -2
index a6459f7..7d7b30c 100644
@@ -768,13 +768,13 @@ int conn_send_cmd2(struct drbd_tconn *tconn, enum drbd_packet cmd, char *data,
 int drbd_send_ping(struct drbd_tconn *tconn)
 {
 	struct p_header h;
-	return !conn_send_cmd(tconn, 0, &tconn->meta, P_PING, &h, sizeof(h));
+	return conn_send_cmd(tconn, 0, &tconn->meta, P_PING, &h, sizeof(h));
 }
 
 int drbd_send_ping_ack(struct drbd_tconn *tconn)
 {
 	struct p_header h;
-	return !conn_send_cmd(tconn, 0, &tconn->meta, P_PING_ACK, &h, sizeof(h));
+	return conn_send_cmd(tconn, 0, &tconn->meta, P_PING_ACK, &h, sizeof(h));
 }
 
 int drbd_send_sync_param(struct drbd_conf *mdev)
drivers/block/drbd/drbd_receiver.c +2 -2
index 6e6b829..6879082 100644
@@ -4501,7 +4501,7 @@ static int got_RqSReply(struct drbd_tconn *tconn, struct packet_info *pi)
 
 static int got_Ping(struct drbd_tconn *tconn, struct packet_info *pi)
 {
-	return drbd_send_ping_ack(tconn);
+	return !drbd_send_ping_ack(tconn);
 
 }
 
@@ -4854,7 +4854,7 @@ int drbd_asender(struct drbd_thread *thi)
 	while (get_t_state(thi) == RUNNING) {
 		drbd_thread_current_set_cpu(thi);
 		if (test_and_clear_bit(SEND_PING, &tconn->flags)) {
-			if (!drbd_send_ping(tconn)) {
+			if (drbd_send_ping(tconn)) {
 				conn_err(tconn, "drbd_send_ping has failed\n");
 				goto reconnect;
 			}
Signature · 1 line
1.7.4.1
author maintainer
#2 lore raw

PATCH 2/10 drbd: Introduce new primitives for sending commands

In reply to Philipp Reisner

From: Andreas Gruenbacher <[email protected]>

---
 drivers/block/drbd/drbd_int.h  |    9 +++++
 drivers/block/drbd/drbd_main.c |   64 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 73 insertions(+), 0 deletions(-)
drivers/block/drbd/drbd_int.h +9 -0
index 912ee5e..d61819f 100644
@@ -1903,6 +1903,15 @@ static inline int drbd_send_short_cmd(struct drbd_conf *mdev,
 	return drbd_send_cmd(mdev, &mdev->tconn->data, cmd, &h, sizeof(h));
 }
 
+extern void *conn_prepare_command(struct drbd_tconn *, struct drbd_socket *);
+extern void *drbd_prepare_command(struct drbd_conf *, struct drbd_socket *);
+extern int conn_send_command(struct drbd_tconn *, struct drbd_socket *,
+			     enum drbd_packet, unsigned int, void *,
+			     unsigned int);
+extern int drbd_send_command(struct drbd_conf *, struct drbd_socket *,
+			     enum drbd_packet, unsigned int, void *,
+			     unsigned int);
+
 extern int drbd_send_ping(struct drbd_tconn *tconn);
 extern int drbd_send_ping_ack(struct drbd_tconn *tconn);
 
drivers/block/drbd/drbd_main.c +64 -0

70 lines not on this page · raw message

Signature · 1 line
1.7.4.1
author maintainer
#3 lore raw

PATCH 3/10 drbd: Introduce drbd_header_size()

In reply to Philipp Reisner

From: Andreas Gruenbacher <[email protected]>

---
 drivers/block/drbd/drbd_int.h      |    2 ++
 drivers/block/drbd/drbd_main.c     |   14 ++++++++++++++
 drivers/block/drbd/drbd_receiver.c |    9 +++++----
 3 files changed, 21 insertions(+), 4 deletions(-)
drivers/block/drbd/drbd_int.h +2 -0
index d61819f..29db016 100644
@@ -315,6 +315,8 @@ struct p_header {
 	u8	  payload[0];
 };
 
+extern unsigned int drbd_header_size(struct drbd_tconn *tconn);
+
 /*
  * short commands, packets without payload, plain p_header:
  *   P_PING
drivers/block/drbd/drbd_main.c +14 -0
index c8384cd..b291d73 100644
@@ -689,6 +689,20 @@ void drbd_thread_current_set_cpu(struct drbd_thread *thi)
 }
 #endif
 
+/**
+ * drbd_header_size  -  size of a packet header
+ *
+ * The header size is a multiple of 8, so any payload following the header is
+ * word aligned on 64-bit architectures.  (The bitmap send and receive code
+ * relies on this.)
+ */
+unsigned int drbd_header_size(struct drbd_tconn *tconn)
+{
+	BUILD_BUG_ON(sizeof(struct p_header80) != sizeof(struct p_header95));
+	BUILD_BUG_ON(!IS_ALIGNED(sizeof(struct p_header80), 8));
+	return sizeof(struct p_header80);
+}
+
 static void prepare_header80(struct p_header80 *h, enum drbd_packet cmd, int size)
 {
 	h->magic   = cpu_to_be32(DRBD_MAGIC);
drivers/block/drbd/drbd_receiver.c +5 -4
index 6879082..ceca24f 100644
@@ -998,7 +998,7 @@ static int drbd_recv_header(struct drbd_tconn *tconn, struct packet_info *pi)
 	struct p_header *h = tconn->data.rbuf;
 	int err;
 
-	err = drbd_recv_all_warn(tconn, h, sizeof(*h));
+	err = drbd_recv_all_warn(tconn, h, drbd_header_size(tconn));
 	if (err)
 		return err;
 
@@ -4845,7 +4845,8 @@ int drbd_asender(struct drbd_thread *thi)
 	int rv;
 	void *buf    = h;
 	int received = 0;
-	int expect   = sizeof(struct p_header);
+	unsigned int header_size = drbd_header_size(tconn);
+	int expect   = header_size;
 	int ping_timeout_active = 0;
 
 	current->policy = SCHED_RR;  /* Make this a realtime task! */
@@ -4929,7 +4930,7 @@ int drbd_asender(struct drbd_thread *thi)
 				goto disconnect;
 			}
 			expect = cmd->pkt_size;
-			if (pi.size != expect - sizeof(struct p_header)) {
+			if (pi.size != expect - header_size) {
 				conn_err(tconn, "Wrong packet size on meta (c: %d, l: %d)\n",
 					pi.cmd, pi.size);
 				goto reconnect;
@@ -4953,7 +4954,7 @@ int drbd_asender(struct drbd_thread *thi)
 
 			buf	 = h;
 			received = 0;
-			expect	 = sizeof(struct p_header);
+			expect	 = header_size;
 			cmd	 = NULL;
 		}
 	}
Signature · 1 line
1.7.4.1
author maintainer
#4 lore raw

PATCH 4/10 drbd: Replace and remove old primitives

In reply to Philipp Reisner

From: Andreas Gruenbacher <[email protected]>

---
 drivers/block/drbd/drbd_int.h      |   45 +----
 drivers/block/drbd/drbd_main.c     |  502 ++++++++++++++++--------------------
 drivers/block/drbd/drbd_receiver.c |   86 ++++---
 drivers/block/drbd/drbd_worker.c   |   24 +-
 4 files changed, 294 insertions(+), 363 deletions(-)
drivers/block/drbd/drbd_int.h +1 -44
index 29db016..e5dc772 100644
@@ -1060,22 +1060,6 @@ static inline struct drbd_conf *vnr_to_mdev(struct drbd_tconn *tconn, int vnr)
 	return (struct drbd_conf *)idr_find(&tconn->volumes, vnr);
 }
 
-static inline int drbd_get_data_sock(struct drbd_tconn *tconn)
-{
-	mutex_lock(&tconn->data.mutex);
-	if (!tconn->data.socket) {
-		/* Disconnected.  */
-		mutex_unlock(&tconn->data.mutex);
-		return -EIO;
-	}
-	return 0;
-}
-
-static inline void drbd_put_data_sock(struct drbd_tconn *tconn)
-{
-	mutex_unlock(&tconn->data.mutex);
-}
-
 /*
  * function declarations
  *************************/
@@ -1118,13 +1102,6 @@ extern int _conn_send_state_req(struct drbd_tconn *, int vnr, enum drbd_packet c
 				union drbd_state, union drbd_state);
 extern int _drbd_send_state(struct drbd_conf *mdev);
 extern int drbd_send_state(struct drbd_conf *mdev);
-extern int _conn_send_cmd(struct drbd_tconn *tconn, int vnr, struct drbd_socket *sock,
-			  enum drbd_packet cmd, struct p_header *h, size_t size,
-			  unsigned msg_flags);
-extern int conn_send_cmd(struct drbd_tconn *tconn, int vnr, struct drbd_socket *sock,
-			 enum drbd_packet cmd, struct p_header *h, size_t size);
-extern int conn_send_cmd2(struct drbd_tconn *tconn, enum drbd_packet cmd,
-			  char *data, size_t size);
 extern int drbd_send_sync_param(struct drbd_conf *mdev);
 extern void drbd_send_b_ack(struct drbd_conf *mdev, u32 barrier_nr,
 			    u32 set_size);
@@ -1149,7 +1126,7 @@ extern int drbd_send_ov_request(struct drbd_conf *mdev,sector_t sector,int size)
 
 extern int drbd_send_bitmap(struct drbd_conf *mdev);
 extern void drbd_send_sr_reply(struct drbd_conf *mdev, enum drbd_state_rv retcode);
-extern int conn_send_sr_reply(struct drbd_tconn *tconn, enum drbd_state_rv retcode);
+extern void conn_send_sr_reply(struct drbd_tconn *tconn, enum drbd_state_rv retcode);
 extern void drbd_free_bc(struct drbd_backing_dev *ldev);
 extern void drbd_mdev_cleanup(struct drbd_conf *mdev);
 void drbd_print_uuids(struct drbd_conf *mdev, const char *text);
@@ -1885,26 +1862,6 @@ static inline void request_ping(struct drbd_tconn *tconn)
 	wake_asender(tconn);
 }
 
-static inline int _drbd_send_cmd(struct drbd_conf *mdev, struct drbd_socket *sock,
-				  enum drbd_packet cmd, struct p_header *h, size_t size,
-				  unsigned msg_flags)
-{
-	return _conn_send_cmd(mdev->tconn, mdev->vnr, sock, cmd, h, size, msg_flags);
-}
-
-static inline int drbd_send_cmd(struct drbd_conf *mdev, struct drbd_socket *sock,
-				enum drbd_packet cmd, struct p_header *h, size_t size)
-{
-	return conn_send_cmd(mdev->tconn, mdev->vnr, sock, cmd, h, size);
-}
-
-static inline int drbd_send_short_cmd(struct drbd_conf *mdev,
-				      enum drbd_packet cmd)
-{
-	struct p_header h;
-	return drbd_send_cmd(mdev, &mdev->tconn->data, cmd, &h, sizeof(h));
-}
-
 extern void *conn_prepare_command(struct drbd_tconn *, struct drbd_socket *);
 extern void *drbd_prepare_command(struct drbd_conf *, struct drbd_socket *);
 extern int conn_send_command(struct drbd_tconn *, struct drbd_socket *,
drivers/block/drbd/drbd_main.c +228 -274

746 lines not on this page · raw message

drivers/block/drbd/drbd_receiver.c +52 -34

152 lines not on this page · raw message

drivers/block/drbd/drbd_worker.c +13 -11
index 8059ea3..6feaa4a 100644
@@ -1193,10 +1193,10 @@ int w_prev_work_done(struct drbd_work *w, int cancel)
 
 int w_send_barrier(struct drbd_work *w, int cancel)
 {
+	struct drbd_socket *sock;
 	struct drbd_tl_epoch *b = container_of(w, struct drbd_tl_epoch, w);
 	struct drbd_conf *mdev = w->mdev;
-	struct p_barrier *p = mdev->tconn->data.sbuf;
-	int err = 0;
+	struct p_barrier *p;
 
 	/* really avoid racing with tl_clear.  w.cb may have been referenced
 	 * just before it was reassigned and re-queued, so double check that.
@@ -1210,26 +1210,28 @@ int w_send_barrier(struct drbd_work *w, int cancel)
 	if (cancel)
 		return 0;
 
-	err = drbd_get_data_sock(mdev->tconn);
-	if (err)
-		return err;
+	sock = &mdev->tconn->data;
+	p = drbd_prepare_command(mdev, sock);
+	if (!p)
+		return -EIO;
 	p->barrier = b->br_number;
 	/* inc_ap_pending was done where this was queued.
 	 * dec_ap_pending will be done in got_BarrierAck
 	 * or (on connection loss) in w_clear_epoch.  */
-	err = _drbd_send_cmd(mdev, &mdev->tconn->data, P_BARRIER,
-			     &p->head, sizeof(*p), 0);
-	drbd_put_data_sock(mdev->tconn);
-
-	return err;
+	return drbd_send_command(mdev, sock, P_BARRIER, sizeof(*p), NULL, 0);
 }
 
 int w_send_write_hint(struct drbd_work *w, int cancel)
 {
 	struct drbd_conf *mdev = w->mdev;
+	struct drbd_socket *sock;
+
 	if (cancel)
 		return 0;
-	return drbd_send_short_cmd(mdev, P_UNPLUG_REMOTE);
+	sock = &mdev->tconn->data;
+	if (!drbd_prepare_command(mdev, sock))
+		return -EIO;
+	return drbd_send_command(mdev, sock, P_UNPLUG_REMOTE, sizeof(struct p_header), NULL, 0);
 }
 
 int w_send_out_of_sync(struct drbd_work *w, int cancel)
Signature · 1 line
1.7.4.1
author maintainer
#7 lore raw

PATCH 5/10 drbd: Remove now-unused int_dig_out buffer

In reply to Philipp Reisner

From: Andreas Gruenbacher <[email protected]>

---
 drivers/block/drbd/drbd_int.h  |    1 -
 drivers/block/drbd/drbd_main.c |    1 -
 drivers/block/drbd/drbd_nl.c   |    9 ---------
 3 files changed, 0 insertions(+), 11 deletions(-)
drivers/block/drbd/drbd_int.h +0 -1
index e5dc772..c58b327 100644
@@ -893,7 +893,6 @@ struct drbd_tconn {			/* is a resource from the config file */
 	struct crypto_hash *integrity_r_tfm; /* to be used by the receiver thread */
 	struct crypto_hash *csums_tfm;
 	struct crypto_hash *verify_tfm;
-	void *int_dig_out;
 	void *int_dig_in;
 	void *int_dig_vv;
 
drivers/block/drbd/drbd_main.c +0 -1
index 4aec4af..9e94ead 100644
@@ -2380,7 +2380,6 @@ void drbd_free_tconn(struct drbd_tconn *tconn)
 	drbd_free_socket(&tconn->meta);
 	drbd_free_socket(&tconn->data);
 	kfree(tconn->name);
-	kfree(tconn->int_dig_out);
 	kfree(tconn->int_dig_in);
 	kfree(tconn->int_dig_vv);
 	kfree(tconn);
drivers/block/drbd/drbd_nl.c +0 -9
index 02d4224..4b60673 100644
@@ -1835,7 +1835,6 @@ int drbd_adm_connect(struct sk_buff *skb, struct genl_info *info)
 	struct crypto_hash *tfm = NULL;
 	struct crypto_hash *integrity_w_tfm = NULL;
 	struct crypto_hash *integrity_r_tfm = NULL;
-	void *int_dig_out = NULL;
 	void *int_dig_in = NULL;
 	void *int_dig_vv = NULL;
 	struct drbd_tconn *oconn;
@@ -2009,11 +2008,6 @@ int drbd_adm_connect(struct sk_buff *skb, struct genl_info *info)
 	/* allocation not in the IO path, cqueue thread context */
 	if (integrity_w_tfm) {
 		i = crypto_hash_digestsize(integrity_w_tfm);
-		int_dig_out = kmalloc(i, GFP_KERNEL);
-		if (!int_dig_out) {
-			retcode = ERR_NOMEM;
-			goto fail;
-		}
 		int_dig_in = kmalloc(i, GFP_KERNEL);
 		if (!int_dig_in) {
 			retcode = ERR_NOMEM;
@@ -2044,10 +2038,8 @@ int drbd_adm_connect(struct sk_buff *skb, struct genl_info *info)
 	crypto_free_hash(tconn->integrity_r_tfm);
 	tconn->integrity_r_tfm = integrity_r_tfm;
 
-	kfree(tconn->int_dig_out);
 	kfree(tconn->int_dig_in);
 	kfree(tconn->int_dig_vv);
-	tconn->int_dig_out=int_dig_out;
 	tconn->int_dig_in=int_dig_in;
 	tconn->int_dig_vv=int_dig_vv;
 	retcode = _conn_request_state(tconn, NS(conn, C_UNCONNECTED), CS_VERBOSE);
@@ -2063,7 +2055,6 @@ int drbd_adm_connect(struct sk_buff *skb, struct genl_info *info)
 	return 0;
 
 fail:
-	kfree(int_dig_out);
 	kfree(int_dig_in);
 	kfree(int_dig_vv);
 	crypto_free_hash(tfm);
Signature · 1 line
1.7.4.1
author maintainer
#8 lore raw

PATCH 6/10 drbd: Remove some fixed header size assumptions

In reply to Philipp Reisner

From: Andreas Gruenbacher <[email protected]>

---
 drivers/block/drbd/drbd_int.h      |   15 +++------------
 drivers/block/drbd/drbd_main.c     |   25 +++++++++++++++----------
 drivers/block/drbd/drbd_receiver.c |   29 +++++++++++++++++------------
 3 files changed, 35 insertions(+), 34 deletions(-)
drivers/block/drbd/drbd_int.h +3 -12
index c58b327..d8e63c4 100644
@@ -543,19 +543,10 @@ struct p_delay_probe93 {
 	u32     offset;  /* usecs the probe got sent after the reference time point */
 } __packed;
 
-/* one bitmap packet, including the p_header,
- * should fit within one _architecture independend_ page.
- * so we need to use the fixed size 4KiB page size
- * most architectures have used for a long time.
+/*
+ * Bitmap packets need to fit within a single page on the sender and receiver,
+ * so we are limited to 4 KiB (and not to PAGE_SIZE, which can be bigger).
  */
-#define BM_PACKET_PAYLOAD_BYTES (4096 - sizeof(struct p_header))
-#define BM_PACKET_WORDS (BM_PACKET_PAYLOAD_BYTES/sizeof(long))
-#define BM_PACKET_VLI_BYTES_MAX (4096 - sizeof(struct p_compressed_bm))
-#if (PAGE_SIZE < 4096)
-/* drbd_send_bitmap / receive_bitmap would break horribly */
-#error "PAGE_SIZE too small"
-#endif
-
 #define DRBD_SOCKET_BUFFER_SIZE 4096
 
 /**********************************************************************/
drivers/block/drbd/drbd_main.c +15 -10
index 9e94ead..ee45370 100644
@@ -1082,8 +1082,9 @@ static void dcbp_set_pad_bits(struct p_compressed_bm *p, int n)
 }
 
 int fill_bitmap_rle_bits(struct drbd_conf *mdev,
-	struct p_compressed_bm *p,
-	struct bm_xfer_ctx *c)
+			 struct p_compressed_bm *p,
+			 unsigned int size,
+			 struct bm_xfer_ctx *c)
 {
 	struct bitstream bs;
 	unsigned long plain_bits;
@@ -1102,8 +1103,8 @@ int fill_bitmap_rle_bits(struct drbd_conf *mdev,
 		return 0; /* nothing to do. */
 
 	/* use at most thus many bytes */
-	bitstream_init(&bs, p->code, BM_PACKET_VLI_BYTES_MAX, 0);
-	memset(p->code, 0, BM_PACKET_VLI_BYTES_MAX);
+	bitstream_init(&bs, p->code, size, 0);
+	memset(p->code, 0, size);
 	/* plain bits covered in this code string */
 	plain_bits = 0;
 
@@ -1185,11 +1186,11 @@ static int
 send_bitmap_rle_or_plain(struct drbd_conf *mdev, struct bm_xfer_ctx *c)
 {
 	struct drbd_socket *sock = &mdev->tconn->data;
+	unsigned int header_size = drbd_header_size(mdev->tconn);
 	struct p_compressed_bm *p = sock->sbuf;
-	unsigned long num_words;
 	int len, err;
 
-	len = fill_bitmap_rle_bits(mdev, p, c);
+	len = fill_bitmap_rle_bits(mdev, p, DRBD_SOCKET_BUFFER_SIZE - sizeof(*p) /* FIXME */, c);
 	if (len < 0)
 		return -EIO;
 
@@ -1206,9 +1207,14 @@ send_bitmap_rle_or_plain(struct drbd_conf *mdev, struct bm_xfer_ctx *c)
 	} else {
 		/* was not compressible.
 		 * send a buffer full of plain text bits instead. */
+		unsigned int data_size;
+		unsigned long num_words;
 		struct p_header *h = sock->sbuf;
-		num_words = min_t(size_t, BM_PACKET_WORDS, c->bm_words - c->word_offset);
-		len = num_words * sizeof(long);
+
+		data_size = DRBD_SOCKET_BUFFER_SIZE - header_size;
+		num_words = min_t(size_t, data_size / sizeof(unsigned long),
+				  c->bm_words - c->word_offset);
+		len = num_words * sizeof(unsigned long);
 		if (len)
 			drbd_bm_get_lel(mdev, c->word_offset, num_words,
 					(unsigned long *)h->payload);
@@ -1218,7 +1224,7 @@ send_bitmap_rle_or_plain(struct drbd_conf *mdev, struct bm_xfer_ctx *c)
 		c->bit_offset = c->word_offset * BITS_PER_LONG;
 
 		c->packets[1]++;
-		c->bytes[1] += sizeof(struct p_header80) + len;
+		c->bytes[1] += header_size + len;
 
 		if (c->bit_offset > c->bm_bits)
 			c->bit_offset = c->bm_bits;
@@ -2526,7 +2532,6 @@ int __init drbd_init(void)
 {
 	int err;
 
-	BUILD_BUG_ON(sizeof(struct p_header80) != sizeof(struct p_header95));
 	BUILD_BUG_ON(sizeof(struct p_connection_features) != 80);
 
 	if (minor_count < DRBD_MINOR_COUNT_MIN || minor_count > DRBD_MINOR_COUNT_MAX) {
drivers/block/drbd/drbd_receiver.c +17 -12
index 1270af3..d0d1924 100644
@@ -3663,16 +3663,19 @@ static int receive_sync_uuid(struct drbd_tconn *tconn, struct packet_info *pi)
  * code upon failure.
  */
 static int
-receive_bitmap_plain(struct drbd_conf *mdev, unsigned int data_size,
+receive_bitmap_plain(struct drbd_conf *mdev, unsigned int size,
 		     struct p_header *h, struct bm_xfer_ctx *c)
 {
 	unsigned long *buffer = (unsigned long *)h->payload;
-	unsigned num_words = min_t(size_t, BM_PACKET_WORDS, c->bm_words - c->word_offset);
-	unsigned want = num_words * sizeof(long);
+	unsigned int data_size = DRBD_SOCKET_BUFFER_SIZE -
+				 drbd_header_size(mdev->tconn);
+	unsigned int num_words = min_t(size_t, data_size / sizeof(unsigned long),
+				       c->bm_words - c->word_offset);
+	unsigned int want = num_words * sizeof(unsigned long);
 	int err;
 
-	if (want != data_size) {
-		dev_err(DEV, "%s:want (%u) != data_size (%u)\n", __func__, want, data_size);
+	if (want != size) {
+		dev_err(DEV, "%s:want (%u) != size (%u)\n", __func__, want, size);
 		return -EIO;
 	}
 	if (want == 0)
@@ -3799,11 +3802,13 @@ void INFO_bm_xfer_stats(struct drbd_conf *mdev,
 		const char *direction, struct bm_xfer_ctx *c)
 {
 	/* what would it take to transfer it "plaintext" */
-	unsigned plain = sizeof(struct p_header) *
-		((c->bm_words+BM_PACKET_WORDS-1)/BM_PACKET_WORDS+1)
-		+ c->bm_words * sizeof(long);
-	unsigned total = c->bytes[0] + c->bytes[1];
-	unsigned r;
+	unsigned int header_size = drbd_header_size(mdev->tconn);
+	unsigned int data_size = DRBD_SOCKET_BUFFER_SIZE - header_size;
+	unsigned int plain =
+		header_size * (DIV_ROUND_UP(c->bm_words, data_size) + 1) +
+		c->bm_words * sizeof(unsigned long);
+	unsigned int total = c->bytes[0] + c->bytes[1];
+	unsigned int r;
 
 	/* total can not be zero. but just in case: */
 	if (total == 0)
@@ -3865,7 +3870,7 @@ static int receive_bitmap(struct drbd_tconn *tconn, struct packet_info *pi)
 			 * and the feature is enabled! */
 			struct p_compressed_bm *p;
 
-			if (pi->size > BM_PACKET_PAYLOAD_BYTES) {
+			if (pi->size > DRBD_SOCKET_BUFFER_SIZE - drbd_header_size(tconn)) {
 				dev_err(DEV, "ReportCBitmap packet too large\n");
 				err = -EIO;
 				goto out;
@@ -3888,7 +3893,7 @@ static int receive_bitmap(struct drbd_tconn *tconn, struct packet_info *pi)
 		}
 
 		c.packets[pi->cmd == P_BITMAP]++;
-		c.bytes[pi->cmd == P_BITMAP] += sizeof(struct p_header) + pi->size;
+		c.bytes[pi->cmd == P_BITMAP] += drbd_header_size(tconn) + pi->size;
 
 		if (err <= 0) {
 			if (err < 0)
Signature · 1 line
1.7.4.1
author maintainer
#9 lore raw

PATCH 7/10 drbd: Remove headers from on-the-wire data structures (struct p_*)

In reply to Philipp Reisner

From: Andreas Gruenbacher <[email protected]>

---
 drivers/block/drbd/drbd_int.h      |   45 ----------
 drivers/block/drbd/drbd_main.c     |   44 +++++-----
 drivers/block/drbd/drbd_receiver.c |  171 ++++++++++++++++++------------------
 drivers/block/drbd/drbd_worker.c   |    2 +-
 4 files changed, 108 insertions(+), 154 deletions(-)
drivers/block/drbd/drbd_int.h +0 -45
index d8e63c4..9868518 100644
@@ -307,32 +307,8 @@ struct p_header95 {
 	u32	  vol_n_len;	/* big endian: high byte = volume; remaining 24 bit = length */
 } __packed;
 
-struct p_header {
-	union {
-		struct p_header80 h80;
-		struct p_header95 h95;
-	};
-	u8	  payload[0];
-};
-
 extern unsigned int drbd_header_size(struct drbd_tconn *tconn);
 
-/*
- * short commands, packets without payload, plain p_header:
- *   P_PING
- *   P_PING_ACK
- *   P_BECOME_SYNC_TARGET
- *   P_BECOME_SYNC_SOURCE
- *   P_UNPLUG_REMOTE
- */
-
-/*
- * commands with out-of-struct payload:
- *   P_BITMAP    (no additional fields)
- *   P_DATA, P_DATA_REPLY (see p_data)
- *   P_COMPRESSED_BITMAP (see receive_compressed_bitmap)
- */
-
 /* these defines must not be changed without changing the protocol version */
 #define DP_HARDBARRIER	      1 /* depricated */
 #define DP_RW_SYNC	      2 /* equals REQ_SYNC    */
@@ -343,7 +319,6 @@ extern unsigned int drbd_header_size(struct drbd_tconn *tconn);
 #define DP_DISCARD           64 /* equals REQ_DISCARD */
 
 struct p_data {
-	struct p_header head;
 	u64	    sector;    /* 64 bits sector number */
 	u64	    block_id;  /* to identify the request in protocol B&C */
 	u32	    seq_num;
@@ -359,7 +334,6 @@ struct p_data {
  *   P_DATA_REQUEST, P_RS_DATA_REQUEST
  */
 struct p_block_ack {
-	struct p_header head;
 	u64	    sector;
 	u64	    block_id;
 	u32	    blksize;
@@ -367,7 +341,6 @@ struct p_block_ack {
 } __packed;
 
 struct p_block_req {
-	struct p_header head;
 	u64 sector;
 	u64 block_id;
 	u32 blksize;
@@ -384,7 +357,6 @@ struct p_block_req {
  */
 
 struct p_connection_features {
-	struct p_header head;   /* Note: vnr will be ignored */
 	u32 protocol_min;
 	u32 feature_flags;
 	u32 protocol_max;
@@ -396,22 +368,18 @@ struct p_connection_features {
 	u32 _pad;
 	u64 reserverd[7];
 } __packed;
-/* 80 bytes, FIXED for the next century */
 
 struct p_barrier {
-	struct p_header head;
 	u32 barrier;	/* barrier number _handle_ only */
 	u32 pad;	/* to multiple of 8 Byte */
 } __packed;
 
 struct p_barrier_ack {
-	struct p_header head;
 	u32 barrier;
 	u32 set_size;
 } __packed;
 
 struct p_rs_param {
-	struct p_header head;
 	u32 rate;
 
 	      /* Since protocol version 88 and higher. */
@@ -419,7 +387,6 @@ struct p_rs_param {
 } __packed;
 
 struct p_rs_param_89 {
-	struct p_header head;
 	u32 rate;
         /* protocol version 89: */
 	char verify_alg[SHARED_SECRET_MAX];
@@ -427,7 +394,6 @@ struct p_rs_param_89 {
 } __packed;
 
 struct p_rs_param_95 {
-	struct p_header head;
 	u32 rate;
 	char verify_alg[SHARED_SECRET_MAX];
 	char csums_alg[SHARED_SECRET_MAX];
@@ -443,7 +409,6 @@ enum drbd_conn_flags {
 };
 
 struct p_protocol {
-	struct p_header head;
 	u32 protocol;
 	u32 after_sb_0p;
 	u32 after_sb_1p;
@@ -457,17 +422,14 @@ struct p_protocol {
 } __packed;
 
 struct p_uuids {
-	struct p_header head;
 	u64 uuid[UI_EXTENDED_SIZE];
 } __packed;
 
 struct p_rs_uuid {
-	struct p_header head;
 	u64	    uuid;
 } __packed;
 
 struct p_sizes {
-	struct p_header head;
 	u64	    d_size;  /* size of disk */
 	u64	    u_size;  /* user requested size */
 	u64	    c_size;  /* current exported size */
@@ -477,18 +439,15 @@ struct p_sizes {
 } __packed;
 
 struct p_state {
-	struct p_header head;
 	u32	    state;
 } __packed;
 
 struct p_req_state {
-	struct p_header head;
 	u32	    mask;
 	u32	    val;
 } __packed;
 
 struct p_req_state_reply {
-	struct p_header head;
 	u32	    retcode;
 } __packed;
 
@@ -503,14 +462,12 @@ struct p_drbd06_param {
 } __packed;
 
 struct p_discard {
-	struct p_header head;
 	u64	    block_id;
 	u32	    seq_num;
 	u32	    pad;
 } __packed;
 
 struct p_block_desc {
-	struct p_header head;
 	u64 sector;
 	u32 blksize;
 	u32 pad;	/* to multiple of 8 Byte */
@@ -526,7 +483,6 @@ enum drbd_bitmap_code {
 };
 
 struct p_compressed_bm {
-	struct p_header head;
 	/* (encoding & 0x0f): actual encoding, see enum drbd_bitmap_code
 	 * (encoding & 0x80): polarity (set/unset) of first runlength
 	 * ((encoding >> 4) & 0x07): pad_bits, number of trailing zero bits
@@ -538,7 +494,6 @@ struct p_compressed_bm {
 } __packed;
 
 struct p_delay_probe93 {
-	struct p_header head;
 	u32     seq_num; /* sequence number to match the two probe packets */
 	u32     offset;  /* usecs the probe got sent after the reference time point */
 } __packed;
drivers/block/drbd/drbd_main.c +21 -23

119 lines not on this page · raw message

drivers/block/drbd/drbd_receiver.c +86 -85

493 lines not on this page · raw message

drivers/block/drbd/drbd_worker.c +1 -1
index 6feaa4a..3c7b6d7 100644
@@ -1231,7 +1231,7 @@ int w_send_write_hint(struct drbd_work *w, int cancel)
 	sock = &mdev->tconn->data;
 	if (!drbd_prepare_command(mdev, sock))
 		return -EIO;
-	return drbd_send_command(mdev, sock, P_UNPLUG_REMOTE, sizeof(struct p_header), NULL, 0);
+	return drbd_send_command(mdev, sock, P_UNPLUG_REMOTE, 0, NULL, 0);
 }
 
 int w_send_out_of_sync(struct drbd_work *w, int cancel)
Signature · 1 line
1.7.4.1
author maintainer
#12 lore raw

PATCH 8/10 drbd: Introduce protocol version 100 headers

In reply to Philipp Reisner

From: Andreas Gruenbacher <[email protected]>

---
 drivers/block/drbd/drbd_int.h      |    8 ++++++++
 drivers/block/drbd/drbd_main.c     |   31 +++++++++++++++++++++++++------
 drivers/block/drbd/drbd_receiver.c |   14 ++++++++++++--
 include/linux/drbd.h               |    1 +
 4 files changed, 46 insertions(+), 8 deletions(-)
drivers/block/drbd/drbd_int.h +8 -0
index 9868518..7d679c5 100644
@@ -307,6 +307,14 @@ struct p_header95 {
 	u32	  vol_n_len;	/* big endian: high byte = volume; remaining 24 bit = length */
 } __packed;
 
+struct p_header100 {
+	u32	  magic;
+	u16	  volume;
+	u16	  command;
+	u32	  length;
+	u32	  pad;
+} __packed;
+
 extern unsigned int drbd_header_size(struct drbd_tconn *tconn);
 
 /* these defines must not be changed without changing the protocol version */
drivers/block/drbd/drbd_main.c +25 -6
index 34cdb97..3310986 100644
@@ -698,9 +698,15 @@ void drbd_thread_current_set_cpu(struct drbd_thread *thi)
  */
 unsigned int drbd_header_size(struct drbd_tconn *tconn)
 {
-	BUILD_BUG_ON(sizeof(struct p_header80) != sizeof(struct p_header95));
-	BUILD_BUG_ON(!IS_ALIGNED(sizeof(struct p_header80), 8));
-	return sizeof(struct p_header80);
+	if (tconn->agreed_pro_version >= 100) {
+		BUILD_BUG_ON(!IS_ALIGNED(sizeof(struct p_header100), 8));
+		return sizeof(struct p_header100);
+	} else {
+		BUILD_BUG_ON(sizeof(struct p_header80) !=
+			     sizeof(struct p_header95));
+		BUILD_BUG_ON(!IS_ALIGNED(sizeof(struct p_header80), 8));
+		return sizeof(struct p_header80);
+	}
 }
 
 static unsigned int prepare_header80(struct p_header80 *h, enum drbd_packet cmd, int size)
@@ -719,10 +725,23 @@ static unsigned int prepare_header95(struct p_header95 *h, enum drbd_packet cmd,
 	return sizeof(struct p_header95);
 }
 
-static unsigned int prepare_header(struct drbd_tconn *tconn, int vnr, void *buffer,
-				   enum drbd_packet cmd, int size)
+static unsigned int prepare_header100(struct p_header100 *h, enum drbd_packet cmd,
+				      int size, int vnr)
+{
+	h->magic = cpu_to_be32(DRBD_MAGIC_100);
+	h->volume = cpu_to_be16(vnr);
+	h->command = cpu_to_be16(cmd);
+	h->length = cpu_to_be32(size);
+	h->pad = 0;
+	return sizeof(struct p_header100);
+}
+
+static unsigned int prepare_header(struct drbd_tconn *tconn, int vnr,
+				   void *buffer, enum drbd_packet cmd, int size)
 {
-	if (tconn->agreed_pro_version >= 95)
+	if (tconn->agreed_pro_version >= 100)
+		return prepare_header100(buffer, cmd, size, vnr);
+	else if (tconn->agreed_pro_version >= 95)
 		return prepare_header95(buffer, cmd, size, vnr);
 	else
 		return prepare_header80(buffer, cmd, size);
drivers/block/drbd/drbd_receiver.c +12 -2
index 0b0f453..de09cc1 100644
@@ -983,8 +983,18 @@ static int decode_header(struct drbd_tconn *tconn, void *header, struct packet_i
 {
 	unsigned int header_size = drbd_header_size(tconn);
 
-	if (header_size == sizeof(struct p_header95) &&
-	    *(__be16 *)header == cpu_to_be16(DRBD_MAGIC_BIG)) {
+	if (header_size == sizeof(struct p_header100) &&
+	    *(__be32 *)header == cpu_to_be32(DRBD_MAGIC_100)) {
+		struct p_header100 *h = header;
+		if (h->pad != 0) {
+			conn_err(tconn, "Header padding is not zero\n");
+			return -EINVAL;
+		}
+		pi->vnr = be16_to_cpu(h->volume);
+		pi->cmd = be16_to_cpu(h->command);
+		pi->size = be32_to_cpu(h->length);
+	} else if (header_size == sizeof(struct p_header95) &&
+		   *(__be16 *)header == cpu_to_be16(DRBD_MAGIC_BIG)) {
 		struct p_header95 *h = header;
 		u32 vol_n_len;
 
include/linux/drbd.h +1 -0
index 60d3088..fe8d6ba 100644
@@ -341,6 +341,7 @@ enum drbd_timeout_flag {
 
 #define DRBD_MAGIC 0x83740267
 #define DRBD_MAGIC_BIG 0x835a
+#define DRBD_MAGIC_100 0x8620ec20
 
 /* how I came up with this magic?
  * base64 decode "actlog==" ;) */
Signature · 1 line
1.7.4.1
author maintainer
#15 lore raw

PATCH 9/10 drbd: Remove volume numbers from struct p_header95

In reply to Philipp Reisner

From: Andreas Gruenbacher <[email protected]>

---
 drivers/block/drbd/drbd_int.h      |    2 +-
 drivers/block/drbd/drbd_main.c     |    6 +++---
 drivers/block/drbd/drbd_receiver.c |    7 ++-----
 3 files changed, 6 insertions(+), 9 deletions(-)
drivers/block/drbd/drbd_int.h +1 -1
index 7d679c5..8f67093 100644
@@ -304,7 +304,7 @@ struct p_header80 {
 struct p_header95 {
 	u16	  magic;	/* use DRBD_MAGIC_BIG here */
 	u16	  command;
-	u32	  vol_n_len;	/* big endian: high byte = volume; remaining 24 bit = length */
+	u32	  length;
 } __packed;
 
 struct p_header100 {
drivers/block/drbd/drbd_main.c +3 -3
index 3310986..99b467e 100644
@@ -717,11 +717,11 @@ static unsigned int prepare_header80(struct p_header80 *h, enum drbd_packet cmd,
 	return sizeof(struct p_header80);
 }
 
-static unsigned int prepare_header95(struct p_header95 *h, enum drbd_packet cmd, int size, int vnr)
+static unsigned int prepare_header95(struct p_header95 *h, enum drbd_packet cmd, int size)
 {
 	h->magic   = cpu_to_be16(DRBD_MAGIC_BIG);
 	h->command = cpu_to_be16(cmd);
-	h->vol_n_len = cpu_to_be32(vnr << 24 | size);
+	h->length = cpu_to_be32(size);
 	return sizeof(struct p_header95);
 }
 
@@ -742,7 +742,7 @@ static unsigned int prepare_header(struct drbd_tconn *tconn, int vnr,
 	if (tconn->agreed_pro_version >= 100)
 		return prepare_header100(buffer, cmd, size, vnr);
 	else if (tconn->agreed_pro_version >= 95)
-		return prepare_header95(buffer, cmd, size, vnr);
+		return prepare_header95(buffer, cmd, size);
 	else
 		return prepare_header80(buffer, cmd, size);
 }
drivers/block/drbd/drbd_receiver.c +2 -5
index de09cc1..7539253 100644
@@ -996,12 +996,9 @@ static int decode_header(struct drbd_tconn *tconn, void *header, struct packet_i
 	} else if (header_size == sizeof(struct p_header95) &&
 		   *(__be16 *)header == cpu_to_be16(DRBD_MAGIC_BIG)) {
 		struct p_header95 *h = header;
-		u32 vol_n_len;
-
 		pi->cmd = be16_to_cpu(h->command);
-		vol_n_len = be32_to_cpu(h->vol_n_len);
-		pi->size = vol_n_len & 0x00ffffff;
-		pi->vnr  = vol_n_len >> 24;
+		pi->size = be32_to_cpu(h->length);
+		pi->vnr = 0;
 	} else if (header_size == sizeof(struct p_header80) &&
 		   *(__be32 *)header == cpu_to_be32(DRBD_MAGIC)) {
 		struct p_header80 *h = header;
Signature · 1 line
1.7.4.1
author maintainer
#21 lore raw

PATCH 10/10 drbd: For protocol versions before 100, use mixed header versions

In reply to Philipp Reisner

From: Andreas Gruenbacher <[email protected]>

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.

---
 drivers/block/drbd/drbd_main.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/block/drbd/drbd_main.c +2 -1
index 99b467e..6afcfab 100644
@@ -741,7 +741,8 @@ static unsigned int prepare_header(struct drbd_tconn *tconn, int vnr,
 {
 	if (tconn->agreed_pro_version >= 100)
 		return prepare_header100(buffer, cmd, size, vnr);
-	else if (tconn->agreed_pro_version >= 95)
+	else if (tconn->agreed_pro_version >= 95 &&
+		 size > DRBD_MAX_SIZE_H80_PACKET)
 		return prepare_header95(buffer, cmd, size);
 	else
 		return prepare_header80(buffer, cmd, size);
Signature · 1 line
1.7.4.1
#22 lore raw

Re: [PATCH 10/10] drbd: For protocol versions before 100, use mixed header versions

Quoted 8 lines · Philipp Reisner

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.

If I understand it correctly, this patch fixes a backwards compat bug in code introduced 2 patches earlier:
[PATCH 08/10] drbd: Introduce protocol version 100 headers

Therefore this patch (and its commit message) should just be rolled into that one to prevent the bug in the first place.

Cheers,
Kyle Moffett

#16 lore raw

Re: [PATCH 09/10] drbd: Remove volume numbers from struct p_header95

In reply to Philipp Reisner

Hi!

Quoted 5 lines · Philipp Reisner

From: Andreas Gruenbacher <[email protected]>

---

[...snip...]

Quoted 7 lines
drivers/block/drbd/drbd_main.c +0 -0
index 3310986..99b467e 100644
@@ -717,11 +717,11 @@ static unsigned int prepare_header80(struct p_header80 *h, enum drbd_packet cmd,
        return sizeof(struct p_header80);
  }

drivers/block/drbd/drbd_main.c static unsigned int prepare_header80(struct p_header80 *h, enum drbd_packet cmd, · line 726

Quoted 10 lines
drivers/block/drbd/drbd_main.c +2 -2
 
-static unsigned int prepare_header95(struct p_header95 *h, enum drbd_packet cmd, int size, int vnr)
+static unsigned int prepare_header95(struct p_header95 *h, enum drbd_packet cmd, int size)
  {
        h->magic   = cpu_to_be16(DRBD_MAGIC_BIG);
        h->command = cpu_to_be16(cmd);
-       h->vol_n_len = cpu_to_be32(vnr << 24 | size);
+       h->length = cpu_to_be32(size);
        return sizeof(struct p_header95);
  }

This patch needs a commit message indicating why it does not break compatibility. If you are guaranteed that the "vnr" passed into prepare_header95 is always zero, then you should indicate why that is true.

Cheers,
Kyle Moffett

#5 lore raw

Re: [PATCH 04/10] drbd: Replace and remove old primitives

In reply to Philipp Reisner

Hi!

Quoted 10 lines · Philipp Reisner

From: Andreas Gruenbacher <[email protected]>

---
 drivers/block/drbd/drbd_int.h      |   45 +---- drivers/block/drbd/drbd_main.c     |  502 ++++++++++++++++-------------------- drivers/block/drbd/drbd_receiver.c |   86 ++++--- drivers/block/drbd/drbd_worker.c   |   24 +-

 4 files changed, 294 insertions(+), 363 deletions(-)

I'm afraid this commit is waaaaay too large and complicated to have a one-line commit message.

You should either split this up into more pieces or you should write a detailed log indicated what this is supposed to be doing and why it is OK. (Or both).

Cheers,
Kyle Moffett

#10 lore raw

Re: [PATCH 07/10] drbd: Remove headers from on-the-wire data structures (struct p_*)

In reply to Philipp Reisner

Hi!

Quoted 9 lines · Philipp Reisner

From: Andreas Gruenbacher <[email protected]>

---
 drivers/block/drbd/drbd_int.h      |   45 ---------- drivers/block/drbd/drbd_main.c     |   44 +++++----- drivers/block/drbd/drbd_receiver.c |  171 ++++++++++++++++++------------------ drivers/block/drbd/drbd_worker.c   |    2 +-

This commit is kind of borderline too-big for just a one-line commit message.

It is admittedly very simple (changing the same pointer math in ~50 places), but it needs a bit more explanation about why it's helpful or necessary.

I *think* it's because the protocol-100 code will use a different-sized header, but that needs to be actually explained somewhere.

Cheers,
Kyle Moffett

#13 lore raw

Re: [PATCH 08/10] drbd: Introduce protocol version 100 headers

In reply to Philipp Reisner

Hi!

Quoted 19 lines · Philipp Reisner

From: Andreas Gruenbacher <[email protected]>

---
 drivers/block/drbd/drbd_int.h      |    8 ++++++++ drivers/block/drbd/drbd_main.c     |   31 +++++++++++++++++++++++++------ drivers/block/drbd/drbd_receiver.c |   14 ++++++++++++-- include/linux/drbd.h               |    1 +

 4 files changed, 46 insertions(+), 8 deletions(-)
drivers/block/drbd/drbd_int.h +0 -0
index 9868518..7d679c5 100644
@@ -307,6 +307,14 @@ struct p_header95 {

       u32       vol_n_len;    /* big endian: high byte = volume; remaining 24 bit = length */ } __packed;

drivers/block/drbd/drbd_int.h struct p_header95 { · line 317

Quoted 8 lines
drivers/block/drbd/drbd_int.h +8 -0
+struct p_header100 {
+       u32       magic;
+       u16       volume;
+       u16       command;
+       u32       length;
+       u32       pad;
+} __packed;
+

This commit also needs additional log message text, specifically something that indicates what is new and different between the protocol 95 and protocol 100 headers. (IE: Why was the change made?)

Cheers,
Kyle Moffett

author maintainer
#6 lore raw

Re: [PATCH 04/10] drbd: Replace and remove old primitives

In reply to Kyle Moffett

Am Freitag, 23. September 2011, 19:33:45 schrieb Kyle Moffett:

Quoted 17 lines

Hi!

On Fri, Sep 23, 2011 at 10:31, Philipp Reisner

Quoted 11 lines · <[email protected]> wrote:

From: Andreas Gruenbacher <[email protected]>

---
 drivers/block/drbd/drbd_int.h      |   45 +----
 drivers/block/drbd/drbd_main.c     |  502
++++++++++++++++-------------------- drivers/block/drbd/drbd_receiver.c
|   86 ++++---
 drivers/block/drbd/drbd_worker.c   |   24 +-
 4 files changed, 294 insertions(+), 363 deletions(-)
Quoted 7 lines

I'm afraid this commit is waaaaay too large and complicated to have a one-line commit message.

You should either split this up into more pieces or you should write a detailed log indicated what this is supposed to be doing and why it is OK. (Or both).

I updated the patch to the following commit message:

Author: Andreas Gruenbacher <[email protected]>
Date:   Mon Mar 28 14:23:08 2011 +0200

drbd: Replace and remove old primitives

Centralize sock->mutex locking and unlocking in [drbd|conn]_prepare_command() and [drbd|conn]_send_comman().

Therefore all *_send_* functions are touched to use these primitives instead of drbd_get_data_sock()/drbd_put_data_sock() and former helper functions.

That change makes the *_send_* functions more standardized.

The complete, updated set is available at:
git://git.drbd.org/linux-2.6-drbd.git for-jens

Best,
Phil

Signature · 6 lines
: Dipl-Ing Philipp Reisner
: LINBIT | Your Way to High Availability
: Tel: +43-1-8178292-50, Fax: +43-1-8178292-82
: http://www.linbit.com

DRBD(R) and LINBIT(R) are registered trademarks of LINBIT, Austria.
author maintainer
#17 lore raw

Re: [PATCH 09/10] drbd: Remove volume numbers from struct p_header95

In reply to Kyle Moffett

Am Freitag, 23. September 2011, 19:28:24 schrieb Kyle Moffett:

Quoted 21 lines

Hi!

On Fri, Sep 23, 2011 at 10:31, Philipp Reisner

Quoted 5 lines · <[email protected]> wrote:

From: Andreas Gruenbacher <[email protected]>

---

[...snip...]

Quoted 8 lines
(quoted diff) +0 -0

b/drivers/block/drbd/drbd_main.c index 3310986..99b467e 100644

drivers/block/drbd/drbd_main.c +0 -0
@@ -717,11 +717,11 @@ static unsigned int prepare_header80(struct
 p_header80 *h, enum drbd_packet cmd, return sizeof(struct p_header80);
 }
 
Quoted 15 lines

drivers/block/drbd/drbd_main.c static unsigned int prepare_header80(struct p_header80 *h, enum drbd_packet cmd, · line 726

Quoted 9 lines
drivers/block/drbd/drbd_main.c +0 -1
-static unsigned int prepare_header95(struct p_header95 *h, enum

drbd_packet cmd, int size, int vnr) +static unsigned int

prepare_header95(struct p_header95 *h, enum drbd_packet cmd, int size) {
       h->magic   = cpu_to_be16(DRBD_MAGIC_BIG);
       h->command = cpu_to_be16(cmd);
drivers/block/drbd/drbd_main.c +1 -1
-       h->vol_n_len = cpu_to_be32(vnr << 24 | size);
+       h->length = cpu_to_be32(size);
       return sizeof(struct p_header95);
 }

This patch needs a commit message indicating why it does not break compatibility. If you are guaranteed that the "vnr" passed into prepare_header95 is always zero, then you should indicate why that is true.

Here is the commit message for that one. The alternative is to merge that to patch 'drbd: Use new header layout, and send volume IOs'. ( Which is patch number 236, i.e. outside of this (10th) posting of
DRBD-8.4 patches. It was posted on August 25.
See https://lkml.org/lkml/2011/8/25/322 )

Author: Andreas Gruenbacher <[email protected]>
Date:   Tue Mar 22 13:17:47 2011 +0100

drbd: Remove volume numbers from struct p_header95

Remove the temporal 8 bit volume number form header 95. All connections that support multiple volumes are new using protocol 100 with header 100.

Best,
Phil

Signature · 6 lines
: Dipl-Ing Philipp Reisner
: LINBIT | Your Way to High Availability
: Tel: +43-1-8178292-50, Fax: +43-1-8178292-82
: http://www.linbit.com

DRBD(R) and LINBIT(R) are registered trademarks of LINBIT, Austria.
author maintainer
#11 lore raw

Re: [PATCH 07/10] drbd: Remove headers from on-the-wire data structures (struct p_*)

In reply to Kyle Moffett

Am Freitag, 23. September 2011, 19:38:15 schrieb Kyle Moffett:

Quoted 19 lines

Hi!

On Fri, Sep 23, 2011 at 10:31, Philipp Reisner

Quoted 10 lines · <[email protected]> wrote:

From: Andreas Gruenbacher <[email protected]>

---
 drivers/block/drbd/drbd_int.h      |   45 ----------
 drivers/block/drbd/drbd_main.c     |   44 +++++-----
 drivers/block/drbd/drbd_receiver.c |  171

++++++++++++++++++------------------ drivers/block/drbd/drbd_worker.c
| 2 +-

This commit is kind of borderline too-big for just a one-line commit message.

Quoted 7 lines

It is admittedly very simple (changing the same pointer math in ~50 places), but it needs a bit more explanation about why it's helpful or necessary.

I *think* it's because the protocol-100 code will use a different-sized header, but that needs to be actually explained somewhere.

I updated the patch to carry the following commit message:

Author: Andreas Gruenbacher <[email protected]>
Date:   Wed Mar 30 12:54:42 2011 +0200

drbd: Remove headers from on-the-wire data structures (struct p_*)

Prepare the introduction of the protocol 100 headers. The actual protocol header is removed for the packet declarations. I.e. allow us to use the packets with different headers.

Best,
Phil

Signature · 6 lines
: Dipl-Ing Philipp Reisner
: LINBIT | Your Way to High Availability
: Tel: +43-1-8178292-50, Fax: +43-1-8178292-82
: http://www.linbit.com

DRBD(R) and LINBIT(R) are registered trademarks of LINBIT, Austria.
author maintainer
#14 lore raw

Re: [PATCH 08/10] drbd: Introduce protocol version 100 headers

In reply to Kyle Moffett

Am Freitag, 23. September 2011, 19:42:52 schrieb Kyle Moffett:

Quoted 25 lines

Hi!

On Fri, Sep 23, 2011 at 10:31, Philipp Reisner

Quoted 20 lines · <[email protected]> wrote:

From: Andreas Gruenbacher <[email protected]>

---
 drivers/block/drbd/drbd_int.h      |    8 ++++++++
 drivers/block/drbd/drbd_main.c     |   31
+++++++++++++++++++++++++------ drivers/block/drbd/drbd_receiver.c |  
14 ++++++++++++--
 include/linux/drbd.h               |    1 +
 4 files changed, 46 insertions(+), 8 deletions(-)
(quoted diff) +0 -0

b/drivers/block/drbd/drbd_int.h index 9868518..7d679c5 100644

drivers/block/drbd/drbd_int.h +0 -0
@@ -307,6 +307,14 @@ struct p_header95 {
       u32       vol_n_len;    /* big endian: high byte = volume;
 remaining 24 bit = length */ } __packed;
 
Quoted 14 lines

drivers/block/drbd/drbd_int.h struct p_header95 { · line 317

Quoted 8 lines
drivers/block/drbd/drbd_int.h +8 -0
+struct p_header100 {
+       u32       magic;
+       u16       volume;
+       u16       command;
+       u32       length;
+       u32       pad;
+} __packed;
+

This commit also needs additional log message text, specifically something that indicates what is new and different between the protocol 95 and protocol 100 headers. (IE: Why was the change made?)

I merged patch 10/10 to this one. The updated, and merged commit message is:

Author: Andreas Gruenbacher <[email protected]>
Date:   Wed Mar 30 16:00:17 2011 +0200

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.

Best,
Phil

Signature · 6 lines
: Dipl-Ing Philipp Reisner
: LINBIT | Your Way to High Availability
: Tel: +43-1-8178292-50, Fax: +43-1-8178292-82
: http://www.linbit.com

DRBD(R) and LINBIT(R) are registered trademarks of LINBIT, Austria.
#18 lore raw

Re: [PATCH 09/10] drbd: Remove volume numbers from struct p_header95

In reply to Philipp Reisner
Quoted 31 lines · Philipp Reisner

Am Freitag, 23. September 2011, 19:28:24 schrieb Kyle Moffett:

Quoted 9 lines · Philipp Reisner
Quoted 8 lines
(quoted diff) +0 -0

b/drivers/block/drbd/drbd_main.c index 3310986..99b467e 100644

drivers/block/drbd/drbd_main.c +0 -0
@@ -717,11 +717,11 @@ static unsigned int prepare_header80(struct
 p_header80 *h, enum drbd_packet cmd, return sizeof(struct p_header80);
  }
 
Quoted 14 lines
Quoted 9 lines
drivers/block/drbd/drbd_main.c +0 -1
-static unsigned int prepare_header95(struct p_header95 *h, enum

drbd_packet cmd, int size, int vnr) +static unsigned int prepare_header95(struct p_header95 *h, enum drbd_packet cmd, int size) { h->magic   = cpu_to_be16(DRBD_MAGIC_BIG);
       h->command = cpu_to_be16(cmd);
-       h->vol_n_len = cpu_to_be32(vnr << 24 | size);
+       h->length = cpu_to_be32(size);
       return sizeof(struct p_header95);
 }

This patch needs a commit message indicating why it does not break compatibility.  If you are guaranteed that the "vnr" passed into prepare_header95 is always zero, then you should indicate why that is true.

Here is the commit message for that one. The alternative is to merge that to patch 'drbd: Use new header layout, and send volume IOs'. ( Which is patch number 236, i.e. outside of this (10th) posting of DRBD-8.4 patches. It was posted on August 25.
 See https://lkml.org/lkml/2011/8/25/322 )

Quoted 7 lines

Author: Andreas Gruenbacher <[email protected]>
Date:   Tue Mar 22 13:17:47 2011 +0100

   drbd: Remove volume numbers from struct p_header95

   Remove the temporal 8 bit volume number form header 95. All connections that support multiple volumes are new using protocol 100 with header 100.

So my concern is that this effectively ignores an old field in header95, so an old DRBD trying to talk about multiple volumes to a new DRBD using header95 is going to get its volume number ignored, right?

This means that old-DRBD and new-DRBD cannot communicate about multiple volumes over one connection at all. That needs to be made an explicit part of this commit message and the rationale explained in detail.

In particular, you need to make sure to describe what negotiation mechanism prevents multiple-volume-header95 messages from being sent to a version of DRBD including this commit. If that behavior (IE: a negotiation change) is part of another commit, then this is small enough that I would merge it with that other commit, but it still needs comments about why version interoperability will not break.

It seems to me like DRBD has historically not been terribly strict with backwards-compatibility to very old versions, but now that it is in the upstream kernel that is a very serious concern. With an out-of-tree module you have a lot more control over exactly which version you are running, but when it's in-tree you are stuck with whatever your vendor's kernel version is (for the most part). Any time you change or break backwards compatibility there needs to be at the very *least* a detailed comment indicating why it needs to be broken and exactly how you avoid additional complications from that.

Cheers,
Kyle Moffett

author maintainer
#19 lore raw

Re: [PATCH 09/10] drbd: Remove volume numbers from struct p_header95

Am Mittwoch, 28. September 2011, 06:26:45 schrieb Kyle Moffett:

Quoted 5 lines

On Tue, Sep 27, 2011 at 05:34, Philipp Reisner

Quoted 2 lines · <[email protected]> wrote:

Am Freitag, 23. September 2011, 19:28:24 schrieb Kyle Moffett:

Quoted 1 line

On Fri, Sep 23, 2011 at 10:31, Philipp Reisner

Quoted 55 lines · <[email protected]> wrote:
Quoted 29 lines
Quoted 8 lines
Quoted 8 lines
(quoted diff) +0 -0

b/drivers/block/drbd/drbd_main.c index 3310986..99b467e 100644

drivers/block/drbd/drbd_main.c +0 -0
@@ -717,11 +717,11 @@ static unsigned int prepare_header80(struct
 p_header80 *h, enum drbd_packet cmd, return sizeof(struct p_header80);
 }
 
Quoted 14 lines

drivers/block/drbd/drbd_main.c static unsigned int prepare_header80(struct p_header80 *h, enum drbd_packet cmd, · line 726

Quoted 9 lines
drivers/block/drbd/drbd_main.c +0 -1
-static unsigned int prepare_header95(struct p_header95 *h, enum

drbd_packet cmd, int size, int vnr) +static unsigned int prepare_header95(struct p_header95 *h, enum drbd_packet cmd, int size)

{ h->magic   = cpu_to_be16(DRBD_MAGIC_BIG);
       h->command = cpu_to_be16(cmd);
drivers/block/drbd/drbd_main.c +1 -1
-       h->vol_n_len = cpu_to_be32(vnr << 24 | size);
+       h->length = cpu_to_be32(size);
       return sizeof(struct p_header95);
 }

This patch needs a commit message indicating why it does not break compatibility. If you are guaranteed that the "vnr" passed into prepare_header95 is always zero, then you should indicate why that is true.

Here is the commit message for that one. The alternative is to merge that to patch 'drbd: Use new header layout, and send volume IOs'. ( Which is patch number 236, i.e. outside of this (10th) posting of
DRBD-8.4 patches. It was posted on August 25.
See https://lkml.org/lkml/2011/8/25/322 )

Quoted 8 lines
Author: Andreas Gruenbacher <[email protected]>
Date:   Tue Mar 22 13:17:47 2011 +0100

drbd: Remove volume numbers from struct p_header95

Remove the temporal 8 bit volume number form header 95. All
connections that support multiple volumes are new using protocol 100 with header 100.

So my concern is that this effectively ignores an old field in header95, so an old DRBD trying to talk about multiple volumes to a new DRBD using header95 is going to get its volume number ignored, right?

This means that old-DRBD and new-DRBD cannot communicate about multiple volumes over one connection at all. That needs to be made an explicit part of this commit message and the rationale explained in detail.

In particular, you need to make sure to describe what negotiation mechanism prevents multiple-volume-header95 messages from being sent to a version of DRBD including this commit. If that behavior (IE: a negotiation change) is part of another commit, then this is small enough that I would merge it with that other commit, but it still needs comments about why version interoperability will not break.

Quoted 10 lines

It seems to me like DRBD has historically not been terribly strict with backwards-compatibility to very old versions, but now that it is in the upstream kernel that is a very serious concern. With an out-of-tree module you have a lot more control over exactly which version you are running, but when it's in-tree you are stuck with whatever your vendor's kernel version is (for the most part). Any time you change or break backwards compatibility there needs to be at the very *least* a detailed comment indicating why it needs to be broken and exactly how you avoid additional complications from that.

Hi,

Well, the last time we broke the on-the-wire compatibility was in January 2007, with the release of drbd-8.0.0. Since then all newer releases can connect to drbd-8.0.0 and every release in between. (Side node: The 8.0 code was also the code we submitted for inclusion into mainline for the first time back in 2007)

What happened here in this patch set is, that first (with patch #236) the volume number gets introduced in the highest byte of the length (since the bio size only needs 20 bits currently that is valid). Later on the protocol 100 header gets implemented, and the volume number field in header 95 is removed again.

So the header 95 with volume numbers is a temporal thing, that happened during development. It was never in a released version.

Ok, to put an end to this discussion:
I changed patch #236 to never introduce that field into header 95. As a consequence this patch 'drbd: Remove volume numbers from struct p_header95' turns into the removal of outdated comments. See the follow-up mail.

Best,
Phil

Signature · 6 lines
: Dipl-Ing Philipp Reisner
: LINBIT | Your Way to High Availability
: Tel: +43-1-8178292-50, Fax: +43-1-8178292-82
: http://www.linbit.com

DRBD(R) and LINBIT(R) are registered trademarks of LINBIT, Austria.
author maintainer
#20 lore raw

PATCH 9/9 drbd: Removed outdated comments and code that envisioned VNRs in header 95

From: Andreas Gruenbacher <[email protected]>

Since have now header 100, that has space for 16 bit volume numbers, the high byte of the length in header 95 is no longer reserved for 8 bit volume numbers.

---
 drivers/block/drbd/drbd_int.h      |    2 +-
 drivers/block/drbd/drbd_main.c     |    2 +-
 drivers/block/drbd/drbd_receiver.c |    5 ++---
 3 files changed, 4 insertions(+), 5 deletions(-)
drivers/block/drbd/drbd_int.h +1 -1
index 2fcf370..8f67093 100644
@@ -304,7 +304,7 @@ struct p_header80 {
 struct p_header95 {
 	u16	  magic;	/* use DRBD_MAGIC_BIG here */
 	u16	  command;
-	u32	  length;	/* Use only 24 bits of that. Ignore the highest 8 bit. */
+	u32	  length;
 } __packed;
 
 struct p_header100 {
drivers/block/drbd/drbd_main.c +1 -1
index 2c75a03..6afcfab 100644
@@ -721,7 +721,7 @@ static unsigned int prepare_header95(struct p_header95 *h, enum drbd_packet cmd,
 {
 	h->magic   = cpu_to_be16(DRBD_MAGIC_BIG);
 	h->command = cpu_to_be16(cmd);
-	h->length  = cpu_to_be32(size);
+	h->length = cpu_to_be32(size);
 	return sizeof(struct p_header95);
 }
 
drivers/block/drbd/drbd_receiver.c +2 -3
index 80bbc55..7539253 100644
@@ -996,10 +996,9 @@ static int decode_header(struct drbd_tconn *tconn, void *header, struct packet_i
 	} else if (header_size == sizeof(struct p_header95) &&
 		   *(__be16 *)header == cpu_to_be16(DRBD_MAGIC_BIG)) {
 		struct p_header95 *h = header;
-
 		pi->cmd = be16_to_cpu(h->command);
-		pi->size = be32_to_cpu(h->length) & 0x00ffffff;
-		pi->vnr  = 0;
+		pi->size = be32_to_cpu(h->length);
+		pi->vnr = 0;
 	} else if (header_size == sizeof(struct p_header80) &&
 		   *(__be32 *)header == cpu_to_be32(DRBD_MAGIC)) {
 		struct p_header80 *h = header;
Signature · 1 line
1.7.4.1