diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/block/drbd/drbd_int.h | 39 | ||||
-rw-r--r-- | drivers/block/drbd/drbd_main.c | 25 | ||||
-rw-r--r-- | drivers/block/drbd/drbd_receiver.c | 21 |
3 files changed, 39 insertions, 46 deletions
diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h index d3acc1597dc7..c1eb4462096e 100644 --- a/drivers/block/drbd/drbd_int.h +++ b/drivers/block/drbd/drbd_int.h | |||
@@ -541,45 +541,6 @@ struct p_delay_probe93 { | |||
541 | u32 offset; /* usecs the probe got sent after the reference time point */ | 541 | u32 offset; /* usecs the probe got sent after the reference time point */ |
542 | } __packed; | 542 | } __packed; |
543 | 543 | ||
544 | /* DCBP: Drbd Compressed Bitmap Packet ... */ | ||
545 | static inline enum drbd_bitmap_code | ||
546 | DCBP_get_code(struct p_compressed_bm *p) | ||
547 | { | ||
548 | return (enum drbd_bitmap_code)(p->encoding & 0x0f); | ||
549 | } | ||
550 | |||
551 | static inline void | ||
552 | DCBP_set_code(struct p_compressed_bm *p, enum drbd_bitmap_code code) | ||
553 | { | ||
554 | BUG_ON(code & ~0xf); | ||
555 | p->encoding = (p->encoding & ~0xf) | code; | ||
556 | } | ||
557 | |||
558 | static inline int | ||
559 | DCBP_get_start(struct p_compressed_bm *p) | ||
560 | { | ||
561 | return (p->encoding & 0x80) != 0; | ||
562 | } | ||
563 | |||
564 | static inline void | ||
565 | DCBP_set_start(struct p_compressed_bm *p, int set) | ||
566 | { | ||
567 | p->encoding = (p->encoding & ~0x80) | (set ? 0x80 : 0); | ||
568 | } | ||
569 | |||
570 | static inline int | ||
571 | DCBP_get_pad_bits(struct p_compressed_bm *p) | ||
572 | { | ||
573 | return (p->encoding >> 4) & 0x7; | ||
574 | } | ||
575 | |||
576 | static inline void | ||
577 | DCBP_set_pad_bits(struct p_compressed_bm *p, int n) | ||
578 | { | ||
579 | BUG_ON(n & ~0x7); | ||
580 | p->encoding = (p->encoding & (~0x7 << 4)) | (n << 4); | ||
581 | } | ||
582 | |||
583 | /* one bitmap packet, including the p_header, | 544 | /* one bitmap packet, including the p_header, |
584 | * should fit within one _architecture independend_ page. | 545 | * should fit within one _architecture independend_ page. |
585 | * so we need to use the fixed size 4KiB page size | 546 | * so we need to use the fixed size 4KiB page size |
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index 076ccb52e812..dbe5c638723f 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c | |||
@@ -1029,6 +1029,23 @@ int conn_send_sr_reply(struct drbd_tconn *tconn, enum drbd_state_rv retcode) | |||
1029 | return !conn_send_cmd(tconn, 0, &tconn->meta, cmd, &p.head, sizeof(p)); | 1029 | return !conn_send_cmd(tconn, 0, &tconn->meta, cmd, &p.head, sizeof(p)); |
1030 | } | 1030 | } |
1031 | 1031 | ||
1032 | static void dcbp_set_code(struct p_compressed_bm *p, enum drbd_bitmap_code code) | ||
1033 | { | ||
1034 | BUG_ON(code & ~0xf); | ||
1035 | p->encoding = (p->encoding & ~0xf) | code; | ||
1036 | } | ||
1037 | |||
1038 | static void dcbp_set_start(struct p_compressed_bm *p, int set) | ||
1039 | { | ||
1040 | p->encoding = (p->encoding & ~0x80) | (set ? 0x80 : 0); | ||
1041 | } | ||
1042 | |||
1043 | static void dcbp_set_pad_bits(struct p_compressed_bm *p, int n) | ||
1044 | { | ||
1045 | BUG_ON(n & ~0x7); | ||
1046 | p->encoding = (p->encoding & (~0x7 << 4)) | (n << 4); | ||
1047 | } | ||
1048 | |||
1032 | int fill_bitmap_rle_bits(struct drbd_conf *mdev, | 1049 | int fill_bitmap_rle_bits(struct drbd_conf *mdev, |
1033 | struct p_compressed_bm *p, | 1050 | struct p_compressed_bm *p, |
1034 | struct bm_xfer_ctx *c) | 1051 | struct bm_xfer_ctx *c) |
@@ -1073,12 +1090,12 @@ int fill_bitmap_rle_bits(struct drbd_conf *mdev, | |||
1073 | if (rl == 0) { | 1090 | if (rl == 0) { |
1074 | /* the first checked bit was set, | 1091 | /* the first checked bit was set, |
1075 | * store start value, */ | 1092 | * store start value, */ |
1076 | DCBP_set_start(p, 1); | 1093 | dcbp_set_start(p, 1); |
1077 | /* but skip encoding of zero run length */ | 1094 | /* but skip encoding of zero run length */ |
1078 | toggle = !toggle; | 1095 | toggle = !toggle; |
1079 | continue; | 1096 | continue; |
1080 | } | 1097 | } |
1081 | DCBP_set_start(p, 0); | 1098 | dcbp_set_start(p, 0); |
1082 | } | 1099 | } |
1083 | 1100 | ||
1084 | /* paranoia: catch zero runlength. | 1101 | /* paranoia: catch zero runlength. |
@@ -1118,7 +1135,7 @@ int fill_bitmap_rle_bits(struct drbd_conf *mdev, | |||
1118 | bm_xfer_ctx_bit_to_word_offset(c); | 1135 | bm_xfer_ctx_bit_to_word_offset(c); |
1119 | 1136 | ||
1120 | /* store pad_bits */ | 1137 | /* store pad_bits */ |
1121 | DCBP_set_pad_bits(p, (8 - bs.cur.bit) & 0x7); | 1138 | dcbp_set_pad_bits(p, (8 - bs.cur.bit) & 0x7); |
1122 | 1139 | ||
1123 | return len; | 1140 | return len; |
1124 | } | 1141 | } |
@@ -1143,7 +1160,7 @@ send_bitmap_rle_or_plain(struct drbd_conf *mdev, | |||
1143 | return -EIO; | 1160 | return -EIO; |
1144 | 1161 | ||
1145 | if (len) { | 1162 | if (len) { |
1146 | DCBP_set_code(p, RLE_VLI_Bits); | 1163 | dcbp_set_code(p, RLE_VLI_Bits); |
1147 | err = _drbd_send_cmd(mdev, mdev->tconn->data.socket, | 1164 | err = _drbd_send_cmd(mdev, mdev->tconn->data.socket, |
1148 | P_COMPRESSED_BITMAP, h, | 1165 | P_COMPRESSED_BITMAP, h, |
1149 | sizeof(*p) + len, 0); | 1166 | sizeof(*p) + len, 0); |
diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c index 27d4a4520641..1fd871bc889e 100644 --- a/drivers/block/drbd/drbd_receiver.c +++ b/drivers/block/drbd/drbd_receiver.c | |||
@@ -3600,6 +3600,21 @@ receive_bitmap_plain(struct drbd_conf *mdev, unsigned int data_size, | |||
3600 | return 1; | 3600 | return 1; |
3601 | } | 3601 | } |
3602 | 3602 | ||
3603 | static enum drbd_bitmap_code dcbp_get_code(struct p_compressed_bm *p) | ||
3604 | { | ||
3605 | return (enum drbd_bitmap_code)(p->encoding & 0x0f); | ||
3606 | } | ||
3607 | |||
3608 | static int dcbp_get_start(struct p_compressed_bm *p) | ||
3609 | { | ||
3610 | return (p->encoding & 0x80) != 0; | ||
3611 | } | ||
3612 | |||
3613 | static int dcbp_get_pad_bits(struct p_compressed_bm *p) | ||
3614 | { | ||
3615 | return (p->encoding >> 4) & 0x7; | ||
3616 | } | ||
3617 | |||
3603 | /** | 3618 | /** |
3604 | * recv_bm_rle_bits | 3619 | * recv_bm_rle_bits |
3605 | * | 3620 | * |
@@ -3618,11 +3633,11 @@ recv_bm_rle_bits(struct drbd_conf *mdev, | |||
3618 | u64 tmp; | 3633 | u64 tmp; |
3619 | unsigned long s = c->bit_offset; | 3634 | unsigned long s = c->bit_offset; |
3620 | unsigned long e; | 3635 | unsigned long e; |
3621 | int toggle = DCBP_get_start(p); | 3636 | int toggle = dcbp_get_start(p); |
3622 | int have; | 3637 | int have; |
3623 | int bits; | 3638 | int bits; |
3624 | 3639 | ||
3625 | bitstream_init(&bs, p->code, len, DCBP_get_pad_bits(p)); | 3640 | bitstream_init(&bs, p->code, len, dcbp_get_pad_bits(p)); |
3626 | 3641 | ||
3627 | bits = bitstream_get_bits(&bs, &look_ahead, 64); | 3642 | bits = bitstream_get_bits(&bs, &look_ahead, 64); |
3628 | if (bits < 0) | 3643 | if (bits < 0) |
@@ -3677,7 +3692,7 @@ decode_bitmap_c(struct drbd_conf *mdev, | |||
3677 | struct bm_xfer_ctx *c, | 3692 | struct bm_xfer_ctx *c, |
3678 | unsigned int len) | 3693 | unsigned int len) |
3679 | { | 3694 | { |
3680 | if (DCBP_get_code(p) == RLE_VLI_Bits) | 3695 | if (dcbp_get_code(p) == RLE_VLI_Bits) |
3681 | return recv_bm_rle_bits(mdev, p, c, len); | 3696 | return recv_bm_rle_bits(mdev, p, c, len); |
3682 | 3697 | ||
3683 | /* other variants had been implemented for evaluation, | 3698 | /* other variants had been implemented for evaluation, |