diff options
author | Neil Brown <neilb@suse.de> | 2006-03-27 08:38:46 +0200 |
---|---|---|
committer | Neil Brown <neilb@suse.de> | 2006-03-27 08:38:46 +0200 |
commit | 06b0d786758c63004f69948895527ca63c371525 (patch) | |
tree | 0030aa59bbe307c2f53de7761ca2fd7f736406b1 /mdadm.c | |
parent | Remove ident arg from getinfo_super; (diff) | |
download | mdadm-06b0d786758c63004f69948895527ca63c371525.tar.xz mdadm-06b0d786758c63004f69948895527ca63c371525.zip |
Allow resize to backup to a file.
To support resizing an array without a spare, mdadm now understands
--backup-file=
which should point to a file for storing a backup of critical data.
This can be given to --grow which will create the file, or
--assemble which will restore from the file if needed.
Signed-off-by: Neil Brown <neilb@suse.de>
Diffstat (limited to 'mdadm.c')
-rw-r--r-- | mdadm.c | 44 |
1 files changed, 37 insertions, 7 deletions
@@ -62,6 +62,7 @@ int main(int argc, char *argv[]) int write_behind = 0; int bitmap_fd = -1; char *bitmap_file = NULL; + char *backup_file = NULL; int bitmap_chunk = UnSet; int SparcAdjust = 0; mddev_dev_t devlist = NULL; @@ -769,6 +770,18 @@ int main(int argc, char *argv[]) ident.bitmap_fd = bitmap_fd; /* for Assemble */ continue; + case O(ASSEMBLE, 7): + case O(GROW, 7): + /* Specify a file into which grow might place a backup, + * or from which assemble might recover a backup + */ + if (backup_file) { + fprintf(stderr, Name ": backup file already specified, rejecting %s\n", optarg); + exit(2); + } + backup_file = optarg; + continue; + case O(GROW,'b'): case O(BUILD,'b'): case O(CREATE,'b'): /* here we create the bitmap */ @@ -812,8 +825,13 @@ int main(int argc, char *argv[]) /* We have now processed all the valid options. Anything else is * an error */ - fprintf(stderr, Name ": option %c not valid in %s mode\n", - opt, map_num(modes, mode)); + if (option_index > 0) + fprintf(stderr, Name ":option --%s not valid in %s mode\n", + long_options[option_index].name, + map_num(modes, mode)); + else + fprintf(stderr, Name ": option -%c not valid in %s mode\n", + opt, map_num(modes, mode)); exit(2); } @@ -927,20 +945,24 @@ int main(int argc, char *argv[]) rv |= 1; else { rv |= Assemble(ss, devlist->devname, mdfd, array_ident, configfile, - NULL, + NULL, backup_file, readonly, runstop, update, verbose-quiet, force); close(mdfd); } } } else if (!scan) rv = Assemble(ss, devlist->devname, mdfd, &ident, configfile, - devlist->next, + devlist->next, backup_file, readonly, runstop, update, verbose-quiet, force); else if (devs_found>0) { if (update && devs_found > 1) { fprintf(stderr, Name ": can only update a single array at a time\n"); exit(1); } + if (backup_file && devs_found > 1) { + fprintf(stderr, Name ": can only assemble a single array when providing a backup file.\n"); + exit(1); + } for (dv = devlist ; dv ; dv=dv->next) { mddev_ident_t array_ident = conf_get_ident(configfile, dv->devname); if (array_ident == NULL) { @@ -956,7 +978,7 @@ int main(int argc, char *argv[]) continue; } rv |= Assemble(ss, dv->devname, mdfd, array_ident, configfile, - NULL, + NULL, backup_file, readonly, runstop, update, verbose-quiet, force); close(mdfd); } @@ -966,6 +988,14 @@ int main(int argc, char *argv[]) fprintf(stderr, Name ": No arrays found in config file\n"); rv = 1; } else + if (update) { + fprintf(stderr, Name ": --update not meaningful with a --scan assembly.\n"); + exit(1); + } + if (backup_file) { + fprintf(stderr, Name ": --backup_file not meaningful with a --scan assembly.\n"); + exit(1); + } for (; array_list; array_list = array_list->next) { mdu_array_info_t array; mdfd = open_mddev(array_list->devname, @@ -980,7 +1010,7 @@ int main(int argc, char *argv[]) else rv |= Assemble(ss, array_list->devname, mdfd, array_list, configfile, - NULL, + NULL, NULL, readonly, runstop, NULL, verbose-quiet, force); close(mdfd); } @@ -1155,7 +1185,7 @@ int main(int argc, char *argv[]) } else if (layout != UnSet) rv = Manage_reconfig(devlist->devname, mdfd, layout); else if (size >= 0 || raiddisks) - rv = Grow_reshape(devlist->devname, mdfd, quiet, + rv = Grow_reshape(devlist->devname, mdfd, quiet, backup_file, size, level, layout, chunk, raiddisks); else if (bitmap_file) { if (delay == 0) delay = DEFAULT_BITMAP_DELAY; |