Commit f70af118 authored by Andreas Gruenbacher's avatar Andreas Gruenbacher Committed by Philipp Reisner

drbd: send_bitmap_rle_or_plain: Get rid of ugly and useless enum

Signed-off-by: default avatarPhilipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: default avatarLars Ellenberg <lars.ellenberg@linbit.com>
parent 78fcbdae
...@@ -2140,9 +2140,15 @@ int fill_bitmap_rle_bits(struct drbd_conf *mdev, ...@@ -2140,9 +2140,15 @@ int fill_bitmap_rle_bits(struct drbd_conf *mdev,
return len; return len;
} }
enum { OK, FAILED, DONE } /**
* send_bitmap_rle_or_plain
*
* Return 0 when done, 1 when another iteration is needed, and a negative error
* code upon failure.
*/
static int
send_bitmap_rle_or_plain(struct drbd_conf *mdev, send_bitmap_rle_or_plain(struct drbd_conf *mdev,
struct p_header80 *h, struct bm_xfer_ctx *c) struct p_header80 *h, struct bm_xfer_ctx *c)
{ {
struct p_compressed_bm *p = (void*)h; struct p_compressed_bm *p = (void*)h;
unsigned long num_words; unsigned long num_words;
...@@ -2152,7 +2158,7 @@ send_bitmap_rle_or_plain(struct drbd_conf *mdev, ...@@ -2152,7 +2158,7 @@ send_bitmap_rle_or_plain(struct drbd_conf *mdev,
len = fill_bitmap_rle_bits(mdev, p, c); len = fill_bitmap_rle_bits(mdev, p, c);
if (len < 0) if (len < 0)
return FAILED; return -EIO;
if (len) { if (len) {
DCBP_set_code(p, RLE_VLI_Bits); DCBP_set_code(p, RLE_VLI_Bits);
...@@ -2182,11 +2188,14 @@ send_bitmap_rle_or_plain(struct drbd_conf *mdev, ...@@ -2182,11 +2188,14 @@ send_bitmap_rle_or_plain(struct drbd_conf *mdev,
if (c->bit_offset > c->bm_bits) if (c->bit_offset > c->bm_bits)
c->bit_offset = c->bm_bits; c->bit_offset = c->bm_bits;
} }
ok = ok ? ((len == 0) ? DONE : OK) : FAILED; if (ok) {
if (len == 0) {
if (ok == DONE) INFO_bm_xfer_stats(mdev, "send", c);
INFO_bm_xfer_stats(mdev, "send", c); return 0;
return ok; } else
return 1;
}
return -EIO;
} }
/* See the comment at receive_bitmap() */ /* See the comment at receive_bitmap() */
...@@ -2194,7 +2203,7 @@ int _drbd_send_bitmap(struct drbd_conf *mdev) ...@@ -2194,7 +2203,7 @@ int _drbd_send_bitmap(struct drbd_conf *mdev)
{ {
struct bm_xfer_ctx c; struct bm_xfer_ctx c;
struct p_header80 *p; struct p_header80 *p;
int ret; int err;
ERR_IF(!mdev->bitmap) return false; ERR_IF(!mdev->bitmap) return false;
...@@ -2229,11 +2238,11 @@ int _drbd_send_bitmap(struct drbd_conf *mdev) ...@@ -2229,11 +2238,11 @@ int _drbd_send_bitmap(struct drbd_conf *mdev)
}; };
do { do {
ret = send_bitmap_rle_or_plain(mdev, p, &c); err = send_bitmap_rle_or_plain(mdev, p, &c);
} while (ret == OK); } while (err > 0);
free_page((unsigned long) p); free_page((unsigned long) p);
return (ret == DONE); return err == 0;
} }
int drbd_send_bitmap(struct drbd_conf *mdev) int drbd_send_bitmap(struct drbd_conf *mdev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment