aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/drbd/drbd_receiver.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/block/drbd/drbd_receiver.c')
-rw-r--r--drivers/block/drbd/drbd_receiver.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
index 40fe7199d5f7..74ed3ac263f3 100644
--- a/drivers/block/drbd/drbd_receiver.c
+++ b/drivers/block/drbd/drbd_receiver.c
@@ -3660,16 +3660,19 @@ static int receive_sync_uuid(struct drbd_tconn *tconn, struct packet_info *pi)
3660 * code upon failure. 3660 * code upon failure.
3661 */ 3661 */
3662static int 3662static int
3663receive_bitmap_plain(struct drbd_conf *mdev, unsigned int data_size, 3663receive_bitmap_plain(struct drbd_conf *mdev, unsigned int size,
3664 struct p_header *h, struct bm_xfer_ctx *c) 3664 struct p_header *h, struct bm_xfer_ctx *c)
3665{ 3665{
3666 unsigned long *buffer = (unsigned long *)h->payload; 3666 unsigned long *buffer = (unsigned long *)h->payload;
3667 unsigned num_words = min_t(size_t, BM_PACKET_WORDS, c->bm_words - c->word_offset); 3667 unsigned int data_size = DRBD_SOCKET_BUFFER_SIZE -
3668 unsigned want = num_words * sizeof(long); 3668 drbd_header_size(mdev->tconn);
3669 unsigned int num_words = min_t(size_t, data_size / sizeof(unsigned long),
3670 c->bm_words - c->word_offset);
3671 unsigned int want = num_words * sizeof(unsigned long);
3669 int err; 3672 int err;
3670 3673
3671 if (want != data_size) { 3674 if (want != size) {
3672 dev_err(DEV, "%s:want (%u) != data_size (%u)\n", __func__, want, data_size); 3675 dev_err(DEV, "%s:want (%u) != size (%u)\n", __func__, want, size);
3673 return -EIO; 3676 return -EIO;
3674 } 3677 }
3675 if (want == 0) 3678 if (want == 0)
@@ -3796,11 +3799,13 @@ void INFO_bm_xfer_stats(struct drbd_conf *mdev,
3796 const char *direction, struct bm_xfer_ctx *c) 3799 const char *direction, struct bm_xfer_ctx *c)
3797{ 3800{
3798 /* what would it take to transfer it "plaintext" */ 3801 /* what would it take to transfer it "plaintext" */
3799 unsigned plain = sizeof(struct p_header) * 3802 unsigned int header_size = drbd_header_size(mdev->tconn);
3800 ((c->bm_words+BM_PACKET_WORDS-1)/BM_PACKET_WORDS+1) 3803 unsigned int data_size = DRBD_SOCKET_BUFFER_SIZE - header_size;
3801 + c->bm_words * sizeof(long); 3804 unsigned int plain =
3802 unsigned total = c->bytes[0] + c->bytes[1]; 3805 header_size * (DIV_ROUND_UP(c->bm_words, data_size) + 1) +
3803 unsigned r; 3806 c->bm_words * sizeof(unsigned long);
3807 unsigned int total = c->bytes[0] + c->bytes[1];
3808 unsigned int r;
3804 3809
3805 /* total can not be zero. but just in case: */ 3810 /* total can not be zero. but just in case: */
3806 if (total == 0) 3811 if (total == 0)
@@ -3862,7 +3867,7 @@ static int receive_bitmap(struct drbd_tconn *tconn, struct packet_info *pi)
3862 * and the feature is enabled! */ 3867 * and the feature is enabled! */
3863 struct p_compressed_bm *p; 3868 struct p_compressed_bm *p;
3864 3869
3865 if (pi->size > BM_PACKET_PAYLOAD_BYTES) { 3870 if (pi->size > DRBD_SOCKET_BUFFER_SIZE - drbd_header_size(tconn)) {
3866 dev_err(DEV, "ReportCBitmap packet too large\n"); 3871 dev_err(DEV, "ReportCBitmap packet too large\n");
3867 err = -EIO; 3872 err = -EIO;
3868 goto out; 3873 goto out;
@@ -3885,7 +3890,7 @@ static int receive_bitmap(struct drbd_tconn *tconn, struct packet_info *pi)
3885 } 3890 }
3886 3891
3887 c.packets[pi->cmd == P_BITMAP]++; 3892 c.packets[pi->cmd == P_BITMAP]++;
3888 c.bytes[pi->cmd == P_BITMAP] += sizeof(struct p_header) + pi->size; 3893 c.bytes[pi->cmd == P_BITMAP] += drbd_header_size(tconn) + pi->size;
3889 3894
3890 if (err <= 0) { 3895 if (err <= 0) {
3891 if (err < 0) 3896 if (err < 0)