From 2ec2b7e9d5b6b4f3611f639ee5d221e03de18c61 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Thu, 12 May 2016 15:19:16 -0400 Subject: [PATCH] mdadm: Make add_internal_bitmap() return 0 on success add_internal_bitmap() returned 1 on success and 0 on error which is inconsistent. This changes it to return 0 on success and use more reasonable error codes on error. Signed-off-by: Jes Sorensen --- Create.c | 6 +++--- Grow.c | 2 +- mdadm.h | 2 ++ super0.c | 4 ++-- super1.c | 10 +++++----- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Create.c b/Create.c index 717086b0..1594a391 100644 --- a/Create.c +++ b/Create.c @@ -774,9 +774,9 @@ int Create(struct supertype *st, char *mddev, st->ss->name); goto abort_locked; } - if (!st->ss->add_internal_bitmap(st, &s->bitmap_chunk, - c->delay, s->write_behind, - bitmapsize, 1, major_num)) { + if (st->ss->add_internal_bitmap(st, &s->bitmap_chunk, + c->delay, s->write_behind, + bitmapsize, 1, major_num)) { pr_err("Given bitmap chunk size not supported.\n"); goto abort_locked; } diff --git a/Grow.c b/Grow.c index 580c13e1..cdd9d05b 100755 --- a/Grow.c +++ b/Grow.c @@ -423,7 +423,7 @@ int Grow_addbitmap(char *devname, int fd, struct context *c, struct shape *s) continue; rv = st->ss->load_super(st, fd2, NULL); if (!rv) { - if (st->ss->add_internal_bitmap( + if (!st->ss->add_internal_bitmap( st, &s->bitmap_chunk, c->delay, s->write_behind, bitmapsize, offset_setable, major)) diff --git a/mdadm.h b/mdadm.h index d209488b..b8705854 100755 --- a/mdadm.h +++ b/mdadm.h @@ -896,6 +896,8 @@ extern struct superswitch { * created, in which case data_size may be updated, or it might * already exist. Metadata handler can know if init_super * has been called, but not write_init_super. + * 0: Success + * -Exxxx: On error */ int (*add_internal_bitmap)(struct supertype *st, int *chunkp, int delay, int write_behind, diff --git a/super0.c b/super0.c index 6fc1ac4f..467a3737 100644 --- a/super0.c +++ b/super0.c @@ -1139,7 +1139,7 @@ static int add_internal_bitmap0(struct supertype *st, int *chunkp, if (chunk < 64*1024*1024) chunk = 64*1024*1024; } else if ((unsigned long long)chunk < min_chunk) - return 0; /* chunk size too small */ + return -EINVAL; /* chunk size too small */ sb->state |= (1<sync_size = __cpu_to_le64(size); bms->write_behind = __cpu_to_le32(write_behind); *chunkp = chunk; - return 1; + return 0; } static int locate_bitmap0(struct supertype *st, int fd, int node_num) diff --git a/super1.c b/super1.c index fa933676..6bf95234 100644 --- a/super1.c +++ b/super1.c @@ -2270,7 +2270,7 @@ add_internal_bitmap1(struct supertype *st, } break; default: - return 0; + return -ENOSPC; } room -= bbl_size; @@ -2280,7 +2280,7 @@ add_internal_bitmap1(struct supertype *st, if (room <= 1) /* No room for a bitmap */ - return 0; + return -ENOSPC; max_bits = (room * 512 - sizeof(bitmap_super_t)) * 8; @@ -2298,9 +2298,9 @@ add_internal_bitmap1(struct supertype *st, if (chunk < 64*1024*1024) chunk = 64*1024*1024; } else if (chunk < min_chunk) - return 0; /* chunk size too small */ + return -EINVAL; /* chunk size too small */ if (chunk == 0) /* rounding problem */ - return 0; + return -EINVAL; if (offset == 0) { /* start bitmap on a 4K boundary with enough space for @@ -2336,7 +2336,7 @@ add_internal_bitmap1(struct supertype *st, } *chunkp = chunk; - return 1; + return 0; } static int locate_bitmap1(struct supertype *st, int fd, int node_num) -- 2.39.2