From 8fac0577f01646cb8a768c0830a884f74c63a18c Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Mon, 30 Jan 2006 23:23:45 +0000 Subject: Stuff like.. - report Intent Bitmap in --detail - report internal bitmap in --examine - pass' --force through to --grow --bitmap - support v.large arrays in --grow --bitmap Signed-off-by: Neil Brown --- Grow.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'Grow.c') diff --git a/Grow.c b/Grow.c index e218eb1..9e8e217 100644 --- a/Grow.c +++ b/Grow.c @@ -192,7 +192,7 @@ 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, int write_behind) +int Grow_addbitmap(char *devname, int fd, char *file, int chunk, int delay, int write_behind, int force) { /* * First check that array doesn't have a bitmap @@ -208,7 +208,7 @@ int Grow_addbitmap(char *devname, int fd, char *file, int chunk, int delay, int struct supertype *st; int major = BITMAP_MAJOR_HI; int vers = md_get_version(fd); - unsigned long long bitmapsize; + unsigned long long bitmapsize, array_size; if (vers < 9003) { major = BITMAP_MAJOR_HOSTENDIAN; @@ -255,7 +255,22 @@ int Grow_addbitmap(char *devname, int fd, char *file, int chunk, int delay, int devname); return 1; } - bitmapsize = array.size * 2; + bitmapsize = array.size; + bitmapsize <<= 1; +#ifdef BLKGETSIZE64 + if (ioctl(fd, BLKGETSIZE64, &array_size) == 0 && + array_size > (0x7fffffffULL<<9)) { + /* Array is big enough that we cannot trust array.size + * try other approaches + */ + bitmapsize = get_component_size(fd); + } +#endif + if (bitmapsize == 0) { + fprintf(stderr, Name ": Cannot reliably determine size of array to create bitmap - sorry.\n"); + return 1; + } + if (array.level == 10) { int ncopies = (array.layout&255)*(array.layout>>8); bitmapsize = bitmapsize * array.raid_disks / ncopies; @@ -343,13 +358,13 @@ int Grow_addbitmap(char *devname, int fd, char *file, int chunk, int delay, int fprintf(stderr, Name ": cannot find UUID for array!\n"); return 1; } - if (CreateBitmap(file, 0, (char*)uuid, chunk, + if (CreateBitmap(file, force, (char*)uuid, chunk, delay, write_behind, bitmapsize, major)) { return 1; } bitmap_fd = open(file, O_RDWR); if (bitmap_fd < 0) { - fprintf(stderr, Name ": weird: %s cannot be openned\n", + fprintf(stderr, Name ": weird: %s cannot be opened\n", file); return 1; } -- cgit