From f5e166fee3be2ccdce3def28edc7a771fc84df9f Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Tue, 7 Jun 2005 23:03:46 +0000 Subject: Support --grow --bitmap=internal Adding a filebased bitmap is not yet supported, and this code is still under development. Signed-off-by: Neil Brown --- Grow.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) (limited to 'Grow.c') diff --git a/Grow.c b/Grow.c index 41c7dc0..817a17a 100644 --- a/Grow.c +++ b/Grow.c @@ -191,3 +191,86 @@ int Grow_Add_device(char *devname, int fd, char *newdev) return 0; } + +int Grow_addbitmap(char *devname, int fd, char *file, int chunk, int delay) +{ + /* + * First check that array doesn't have a bitmap + * Then create the bitmap + * Then add it + * + * For internal bitmaps, we need to check the version, + * find all the active devices, and write the bitmap block + * to all devices + */ + mdu_bitmap_file_t bmf; + mdu_array_info_t array; + struct supertype *st; + + if (ioctl(fd, GET_BITMAP_FILE, &bmf) != 0) { + if (errno == ENOMEM) + fprintf(stderr, Name ": Memory allocation failure.\n"); + else + fprintf(stderr, Name ": bitmaps not supported by this kernel.\n"); + return 1; + } + if (bmf.pathname[0]) { + fprintf(stderr, Name ": %s already has a bitmap (%s)\n", + devname, bmf.pathname); + return 1; + } + if (ioctl(fd, GET_ARRAY_INFO, &array) != 0) { + fprintf(stderr, Name ": cannot get array status for %s\n", devname); + return 1; + } + if (array.state & (1<ss->load_super(st, fd2, &super, NULL)==0) { + st->ss->add_internal_bitmap(super, + chunk, delay, + array.size); + st->ss->write_bitmap(st, fd2, super); + } + close(fd2); + } + } + array.state |= (1<