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>
This commit is contained in:
Lars Ellenberg 2010-10-06 11:46:55 +02:00 committed by Philipp Reisner
parent 004352fa60
commit 2b2bf2148f
3 changed files with 9 additions and 8 deletions

View File

@ -1230,7 +1230,7 @@ extern int drbd_send_ack(struct drbd_conf *mdev, enum drbd_packets cmd,
extern int drbd_send_ack_rp(struct drbd_conf *mdev, enum drbd_packets cmd, extern int drbd_send_ack_rp(struct drbd_conf *mdev, enum drbd_packets cmd,
struct p_block_req *rp); struct p_block_req *rp);
extern int drbd_send_ack_dp(struct drbd_conf *mdev, enum drbd_packets cmd, extern int drbd_send_ack_dp(struct drbd_conf *mdev, enum drbd_packets cmd,
struct p_data *dp); struct p_data *dp, int data_size);
extern int drbd_send_ack_ex(struct drbd_conf *mdev, enum drbd_packets cmd, extern int drbd_send_ack_ex(struct drbd_conf *mdev, enum drbd_packets cmd,
sector_t sector, int blksize, u64 block_id); sector_t sector, int blksize, u64 block_id);
extern int drbd_send_block(struct drbd_conf *mdev, enum drbd_packets cmd, extern int drbd_send_block(struct drbd_conf *mdev, enum drbd_packets cmd,

View File

@ -2193,13 +2193,14 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packets cmd,
return ok; return ok;
} }
/* dp->sector and dp->block_id already/still in network byte order,
* data_size is payload size according to dp->head,
* and may need to be corrected for digest size. */
int drbd_send_ack_dp(struct drbd_conf *mdev, enum drbd_packets cmd, int drbd_send_ack_dp(struct drbd_conf *mdev, enum drbd_packets cmd,
struct p_data *dp) struct p_data *dp, int data_size)
{ {
const int header_size = sizeof(struct p_data) data_size -= (mdev->agreed_pro_version >= 87 && mdev->integrity_r_tfm) ?
- sizeof(struct p_header80); crypto_hash_digestsize(mdev->integrity_r_tfm) : 0;
int data_size = ((struct p_header80 *)dp)->length - header_size;
return _drbd_send_ack(mdev, cmd, dp->sector, cpu_to_be32(data_size), return _drbd_send_ack(mdev, cmd, dp->sector, cpu_to_be32(data_size),
dp->block_id); dp->block_id);
} }

View File

@ -1630,7 +1630,7 @@ static int receive_RSDataReply(struct drbd_conf *mdev, enum drbd_packets cmd, un
ok = drbd_drain_block(mdev, data_size); ok = drbd_drain_block(mdev, data_size);
drbd_send_ack_dp(mdev, P_NEG_ACK, p); drbd_send_ack_dp(mdev, P_NEG_ACK, p, data_size);
} }
atomic_add(data_size >> 9, &mdev->rs_sect_in); 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
mdev->peer_seq++; mdev->peer_seq++;
spin_unlock(&mdev->peer_seq_lock); spin_unlock(&mdev->peer_seq_lock);
drbd_send_ack_dp(mdev, P_NEG_ACK, p); drbd_send_ack_dp(mdev, P_NEG_ACK, p, data_size);
atomic_inc(&mdev->current_epoch->epoch_size); atomic_inc(&mdev->current_epoch->epoch_size);
return drbd_drain_block(mdev, data_size); return drbd_drain_block(mdev, data_size);
} }