]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
mdadm: allow build to use --size
authorPaul Clements <paul.clements@steeleye.com>
Wed, 11 Feb 2009 18:49:26 +0000 (13:49 -0500)
committerNeilBrown <neilb@suse.de>
Tue, 21 Apr 2009 05:36:13 +0000 (15:36 +1000)
This patch enables the --size parameter for build operations.

Without this, if you have a raid1, for instance, where the 2 disks are
not the exact same size, and you need to build the array but one of the
disks is not available right at the moment (maybe it's USB and it's
unplugged, or maybe it's a network disk and it's unavailable), then you
have to play some weird games to get the array to size correctly (that
is, to the size of the smaller of the two components or less).

There may be other uses for this too...

--
Paul

Signed-off-by: NeilBrown <neilb@suse.de>
Build.c
mdadm.c
mdadm.h

diff --git a/Build.c b/Build.c
index 1e213ce438e7729bbc5272223de619b7369a626c..21fe2a51d3fd0b25d1ed5712b69de39818b8ca61 100644 (file)
--- a/Build.c
+++ b/Build.c
@@ -36,7 +36,8 @@
 int Build(char *mddev, int mdfd, int chunk, int level, int layout,
          int raiddisks,
          mddev_dev_t devlist, int assume_clean,
-         char *bitmap_file, int bitmap_chunk, int write_behind, int delay, int verbose)
+         char *bitmap_file, int bitmap_chunk, int write_behind, int delay,
+         int verbose, unsigned long long size)
 {
        /* Build a linear or raid0 arrays without superblocks
         * We cannot really do any checks, we just do it.
@@ -57,7 +58,6 @@ int Build(char *mddev, int mdfd, int chunk, int level, int layout,
        int subdevs = 0, missing_disks = 0;
        mddev_dev_t dv;
        int bitmap_fd;
-       unsigned long long size = ~0ULL;
        unsigned long long bitmapsize;
 
        /* scan all devices, make sure they really are block devices */
@@ -119,7 +119,7 @@ int Build(char *mddev, int mdfd, int chunk, int level, int layout,
        if (vers >= 9000) {
                mdu_array_info_t array;
                array.level = level;
-               array.size = 0;
+               array.size = size;
                array.nr_disks = raiddisks;
                array.raid_disks = raiddisks;
                array.md_minor = 0;
@@ -178,7 +178,7 @@ int Build(char *mddev, int mdfd, int chunk, int level, int layout,
                    (size == 0 || dsize < size))
                                size = dsize;
                close(fd);
-               if (vers>= 9000) {
+               if (vers >= 9000) {
                        mdu_disk_info_t disk;
                        disk.number = i;
                        disk.raid_disk = i;
diff --git a/mdadm.c b/mdadm.c
index 6609bf22452f7802d280bc56ffcec5a8858d9045..e889b9c2714fcbf17b0409dd3bd7183e130ea2e4 100644 (file)
--- a/mdadm.c
+++ b/mdadm.c
@@ -367,7 +367,8 @@ int main(int argc, char *argv[])
 
 
                case O(GROW,'z'):
-               case O(CREATE,'z'): /* size */
+               case O(CREATE,'z'):
+               case O(BUILD,'z'): /* size */
                        if (size >= 0) {
                                fprintf(stderr, Name ": size may only be specified once. "
                                        "Second value is %s.\n", optarg);
@@ -1161,7 +1162,8 @@ int main(int argc, char *argv[])
                }
                rv = Build(devlist->devname, mdfd, chunk, level, layout,
                           raiddisks, devlist->next, assume_clean,
-                          bitmap_file, bitmap_chunk, write_behind, delay, verbose-quiet);
+                          bitmap_file, bitmap_chunk, write_behind, delay,
+                          verbose-quiet, size);
                break;
        case CREATE:
                if (delay == 0) delay = DEFAULT_BITMAP_DELAY;
diff --git a/mdadm.h b/mdadm.h
index 0d5c721125b5b5c3e04e4ee81b4f1351c63565ca..0eb8f399a3ed738e271d3a0ae2879fe84e305218 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -443,7 +443,8 @@ extern int Assemble(struct supertype *st, char *mddev, int mdfd,
 extern int Build(char *mddev, int mdfd, int chunk, int level, int layout,
                 int raiddisks,
                 mddev_dev_t devlist, int assume_clean,
-                char *bitmap_file, int bitmap_chunk, int write_behind, int delay, int verbose);
+                char *bitmap_file, int bitmap_chunk, int write_behind,
+                int delay, int verbose, unsigned long long size);
 
 
 extern int Create(struct supertype *st, char *mddev, int mdfd,