diff --git a/Create.c b/Create.c index 717086b..1594a39 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 580c13e..cdd9d05 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 d209488..b870585 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 6fc1ac4..467a373 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 fa93367..6bf9523 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)