aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/drbd
diff options
context:
space:
mode:
authorLars Ellenberg <lars.ellenberg@linbit.com>2010-10-06 05:46:55 -0400
committerPhilipp Reisner <philipp.reisner@linbit.com>2010-10-14 12:38:45 -0400
commit2b2bf2148fd46874ee72a877c951e5c6675d1caa (patch)
tree15ec40dd736c5e7cf833deb61b6770d562fa11b5 /drivers/block/drbd
parent004352fa60345e499379af310de73a2df1a5762a (diff)
drbd: drbd_send_ack_dp must not rely on header information
drbd commit 17c854fea474a5eb3cfa12e4fb019e46debbc4ec drbd: receiving of big packets, for payloads between 64kByte and 4GByte introduced a new on-the-wire packet header format. We must no longer assume either format, but use the result of whatever drbd_recv_header has decoded. Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com> Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Diffstat (limited to 'drivers/block/drbd')
-rw-r--r--drivers/block/drbd/drbd_int.h2
-rw-r--r--drivers/block/drbd/drbd_main.c11
-rw-r--r--drivers/block/drbd/drbd_receiver.c4
3 files changed, 9 insertions, 8 deletions
diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
index 1680939de101..8ab6fed39539 100644
--- a/drivers/block/drbd/drbd_int.h
+++ b/drivers/block/drbd/drbd_int.h
@@ -1230,7 +1230,7 @@ extern int drbd_send_ack(struct drbd_conf *mdev, enum drbd_packets cmd,
1230extern int drbd_send_ack_rp(struct drbd_conf *mdev, enum drbd_packets cmd, 1230extern int drbd_send_ack_rp(struct drbd_conf *mdev, enum drbd_packets cmd,
1231 struct p_block_req *rp); 1231 struct p_block_req *rp);
1232extern int drbd_send_ack_dp(struct drbd_conf *mdev, enum drbd_packets cmd, 1232extern int drbd_send_ack_dp(struct drbd_conf *mdev, enum drbd_packets cmd,
1233 struct p_data *dp); 1233 struct p_data *dp, int data_size);
1234extern int drbd_send_ack_ex(struct drbd_conf *mdev, enum drbd_packets cmd, 1234extern int drbd_send_ack_ex(struct drbd_conf *mdev, enum drbd_packets cmd,
1235 sector_t sector, int blksize, u64 block_id); 1235 sector_t sector, int blksize, u64 block_id);
1236extern int drbd_send_block(struct drbd_conf *mdev, enum drbd_packets cmd, 1236extern int drbd_send_block(struct drbd_conf *mdev, enum drbd_packets cmd,
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
index e1f2c2e54f5f..accb37d1215f 100644
--- a/drivers/block/drbd/drbd_main.c
+++ b/drivers/block/drbd/drbd_main.c
@@ -2193,13 +2193,14 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packets cmd,
2193 return ok; 2193 return ok;
2194} 2194}
2195 2195
2196/* dp->sector and dp->block_id already/still in network byte order,
2197 * data_size is payload size according to dp->head,
2198 * and may need to be corrected for digest size. */
2196int drbd_send_ack_dp(struct drbd_conf *mdev, enum drbd_packets cmd, 2199int drbd_send_ack_dp(struct drbd_conf *mdev, enum drbd_packets cmd,
2197 struct p_data *dp) 2200 struct p_data *dp, int data_size)
2198{ 2201{
2199 const int header_size = sizeof(struct p_data) 2202 data_size -= (mdev->agreed_pro_version >= 87 && mdev->integrity_r_tfm) ?
2200 - sizeof(struct p_header80); 2203 crypto_hash_digestsize(mdev->integrity_r_tfm) : 0;
2201 int data_size = ((struct p_header80 *)dp)->length - header_size;
2202
2203 return _drbd_send_ack(mdev, cmd, dp->sector, cpu_to_be32(data_size), 2204 return _drbd_send_ack(mdev, cmd, dp->sector, cpu_to_be32(data_size),
2204 dp->block_id); 2205 dp->block_id);
2205} 2206}
diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
index b5d3fa6c7a8b..45a2d610ca1d 100644
--- a/drivers/block/drbd/drbd_receiver.c
+++ b/drivers/block/drbd/drbd_receiver.c
@@ -1630,7 +1630,7 @@ static int receive_RSDataReply(struct drbd_conf *mdev, enum drbd_packets cmd, un
1630 1630
1631 ok = drbd_drain_block(mdev, data_size); 1631 ok = drbd_drain_block(mdev, data_size);
1632 1632
1633 drbd_send_ack_dp(mdev, P_NEG_ACK, p); 1633 drbd_send_ack_dp(mdev, P_NEG_ACK, p, data_size);
1634 } 1634 }
1635 1635
1636 atomic_add(data_size >> 9, &mdev->rs_sect_in); 1636 atomic_add(data_size >> 9, &mdev->rs_sect_in);
@@ -1787,7 +1787,7 @@ static int receive_Data(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned
1787 mdev->peer_seq++; 1787 mdev->peer_seq++;
1788 spin_unlock(&mdev->peer_seq_lock); 1788 spin_unlock(&mdev->peer_seq_lock);
1789 1789
1790 drbd_send_ack_dp(mdev, P_NEG_ACK, p); 1790 drbd_send_ack_dp(mdev, P_NEG_ACK, p, data_size);
1791 atomic_inc(&mdev->current_epoch->epoch_size); 1791 atomic_inc(&mdev->current_epoch->epoch_size);
1792 return drbd_drain_block(mdev, data_size); 1792 return drbd_drain_block(mdev, data_size);
1793 } 1793 }