aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/drbd/drbd_main.c
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruen@linbit.com>2010-12-11 12:51:50 -0500
committerPhilipp Reisner <philipp.reisner@linbit.com>2011-03-10 05:36:32 -0500
commitf70af118e3f3638698ac08959a41b9f9fe7237c8 (patch)
treed77e797811b0b27fa19254127b60de3f67d2ed47 /drivers/block/drbd/drbd_main.c
parent78fcbdae224469cb48767fa29ca41f1d5890e57c (diff)
drbd: send_bitmap_rle_or_plain: Get rid of ugly and useless enum
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com> Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Diffstat (limited to 'drivers/block/drbd/drbd_main.c')
-rw-r--r--drivers/block/drbd/drbd_main.c33
1 files changed, 21 insertions, 12 deletions
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
index 7eb447d20cce..7c72595b7ff0 100644
--- a/drivers/block/drbd/drbd_main.c
+++ b/drivers/block/drbd/drbd_main.c
@@ -2140,9 +2140,15 @@ int fill_bitmap_rle_bits(struct drbd_conf *mdev,
2140 return len; 2140 return len;
2141} 2141}
2142 2142
2143enum { OK, FAILED, DONE } 2143/**
2144 * send_bitmap_rle_or_plain
2145 *
2146 * Return 0 when done, 1 when another iteration is needed, and a negative error
2147 * code upon failure.
2148 */
2149static int
2144send_bitmap_rle_or_plain(struct drbd_conf *mdev, 2150send_bitmap_rle_or_plain(struct drbd_conf *mdev,
2145 struct p_header80 *h, struct bm_xfer_ctx *c) 2151 struct p_header80 *h, struct bm_xfer_ctx *c)
2146{ 2152{
2147 struct p_compressed_bm *p = (void*)h; 2153 struct p_compressed_bm *p = (void*)h;
2148 unsigned long num_words; 2154 unsigned long num_words;
@@ -2152,7 +2158,7 @@ send_bitmap_rle_or_plain(struct drbd_conf *mdev,
2152 len = fill_bitmap_rle_bits(mdev, p, c); 2158 len = fill_bitmap_rle_bits(mdev, p, c);
2153 2159
2154 if (len < 0) 2160 if (len < 0)
2155 return FAILED; 2161 return -EIO;
2156 2162
2157 if (len) { 2163 if (len) {
2158 DCBP_set_code(p, RLE_VLI_Bits); 2164 DCBP_set_code(p, RLE_VLI_Bits);
@@ -2182,11 +2188,14 @@ send_bitmap_rle_or_plain(struct drbd_conf *mdev,
2182 if (c->bit_offset > c->bm_bits) 2188 if (c->bit_offset > c->bm_bits)
2183 c->bit_offset = c->bm_bits; 2189 c->bit_offset = c->bm_bits;
2184 } 2190 }
2185 ok = ok ? ((len == 0) ? DONE : OK) : FAILED; 2191 if (ok) {
2186 2192 if (len == 0) {
2187 if (ok == DONE) 2193 INFO_bm_xfer_stats(mdev, "send", c);
2188 INFO_bm_xfer_stats(mdev, "send", c); 2194 return 0;
2189 return ok; 2195 } else
2196 return 1;
2197 }
2198 return -EIO;
2190} 2199}
2191 2200
2192/* See the comment at receive_bitmap() */ 2201/* See the comment at receive_bitmap() */
@@ -2194,7 +2203,7 @@ int _drbd_send_bitmap(struct drbd_conf *mdev)
2194{ 2203{
2195 struct bm_xfer_ctx c; 2204 struct bm_xfer_ctx c;
2196 struct p_header80 *p; 2205 struct p_header80 *p;
2197 int ret; 2206 int err;
2198 2207
2199 ERR_IF(!mdev->bitmap) return false; 2208 ERR_IF(!mdev->bitmap) return false;
2200 2209
@@ -2229,11 +2238,11 @@ int _drbd_send_bitmap(struct drbd_conf *mdev)
2229 }; 2238 };
2230 2239
2231 do { 2240 do {
2232 ret = send_bitmap_rle_or_plain(mdev, p, &c); 2241 err = send_bitmap_rle_or_plain(mdev, p, &c);
2233 } while (ret == OK); 2242 } while (err > 0);
2234 2243
2235 free_page((unsigned long) p); 2244 free_page((unsigned long) p);
2236 return (ret == DONE); 2245 return err == 0;
2237} 2246}
2238 2247
2239int drbd_send_bitmap(struct drbd_conf *mdev) 2248int drbd_send_bitmap(struct drbd_conf *mdev)