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 <Jes.Sorensen@redhat.com>
This commit is contained in:
Jes Sorensen 2016-05-12 15:19:16 -04:00
parent c152f3610f
commit 2ec2b7e9d5
5 changed files with 13 additions and 11 deletions

View File

@ -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;
}

2
Grow.c
View File

@ -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))

View File

@ -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,

View File

@ -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<<MD_SB_BITMAP_PRESENT);
@ -1153,7 +1153,7 @@ static int add_internal_bitmap0(struct supertype *st, int *chunkp,
bms->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)

View File

@ -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)