int Assemble(struct supertype *st, char *mddev,
struct mddev_ident *ident,
- struct mddev_dev *devlist, char *backup_file,
+ struct mddev_dev *devlist,
+ char *backup_file, int invalid_backup,
int readonly, int runstop,
char *update, char *homehost, int require_homehost,
int verbose, int force)
} else
fdlist[i] = -1;
}
- if (!err)
- err = Grow_restart(st, content, fdlist, bestcnt, backup_file, verbose > 0);
+ if (!err) {
+ err = Grow_restart(st, content, fdlist, bestcnt,
+ backup_file, verbose > 0);
+ if (err && invalid_backup) {
+ if (verbose > 0)
+ fprintf(stderr, Name ": continuing"
+ " without restoring backup\n");
+ err = 0;
+ }
+ }
while (i>0) {
i--;
if (fdlist[i]>=0) close(fdlist[i]);
bsb.devstart2 = blocks;
backup_fd = open(backup_file, O_RDWR|O_CREAT, S_IRUSR | S_IWUSR);
+ if (backup_fd < 0) {
+ fprintf(stderr, Name ": Cannot open backup file %s\n",
+ backup_file ?: "- no backup-file given");
+ return 1;
+ }
backup_list[0] = backup_fd;
backup_offsets[0] = 8 * 512;
fds = malloc(odisks * sizeof(fds[0]));
/* For Grow */
{"backup-file", 1,0, BackupFile},
+ {"invalid-backup",0,0,InvalidBackup},
{"array-size", 1, 0, 'Z'},
/* For Incremental */
.BR \-\-backup\-file=
If
.B \-\-backup\-file
-was used to grow the number of raid-devices in a RAID5, and the system
-crashed during the critical section, then the same
+was used while reshaping an array (e.g. changing number of devices or
+chunk size) and the system crashed during the critical section, then the same
.B \-\-backup\-file
must be presented to
.B \-\-assemble
to allow possibly corrupted data to be restored.
+.TP
+.BR \-\-invalid\-backup
+If the file needed for the above option is not available for any
+reason an empty file can be given together with this option to
+indicate that the backup file is invalid. In this case the data that
+was being rearranged at the time of the crash could be irrecoverably
+lost, but the rest of the array may still be recoverable. This option
+should only be used as a last resort if there is no way to recover the
+backup file.
+
+
.TP
.BR \-U ", " \-\-update=
Update the superblock on each device while assembling the array. The
int bitmap_fd = -1;
char *bitmap_file = NULL;
char *backup_file = NULL;
+ int invalid_backup = 0;
int bitmap_chunk = UnSet;
int SparcAdjust = 0;
struct mddev_dev *devlist = NULL;
backup_file = optarg;
continue;
+ case O(ASSEMBLE, InvalidBackup):
+ /* Acknowledge that the backupfile is invalid, but ask
+ * to continue anyway
+ */
+ invalid_backup = 1;
+ continue;
+
case O(BUILD,'b'):
case O(BUILD,Bitmap):
case O(CREATE,'b'):
if (array_ident->autof == 0)
array_ident->autof = autof;
rv |= Assemble(ss, devlist->devname, array_ident,
- NULL, backup_file,
+ NULL, backup_file, invalid_backup,
readonly, runstop, update,
homehost, require_homehost,
verbose-quiet, force);
}
} else if (!scan)
rv = Assemble(ss, devlist->devname, &ident,
- devlist->next, backup_file,
+ devlist->next, backup_file, invalid_backup,
readonly, runstop, update,
homehost, require_homehost,
verbose-quiet, force);
if (array_ident->autof == 0)
array_ident->autof = autof;
rv |= Assemble(ss, dv->devname, array_ident,
- NULL, backup_file,
+ NULL, backup_file, invalid_backup,
readonly, runstop, update,
homehost, require_homehost,
verbose-quiet, force);
r = Assemble(ss, a->devname,
a,
- NULL, NULL,
+ NULL, NULL, 0,
readonly, runstop, NULL,
homehost, require_homehost,
verbose-quiet, force);
do {
rv2 = Assemble(ss, NULL,
&ident,
- devlist, NULL,
+ devlist, NULL, 0,
readonly, runstop, NULL,
homehost, require_homehost,
verbose-quiet, force);
do {
acnt = 0;
do {
- rv2 = Assemble(ss, NULL,
- &ident,
- NULL, NULL,
- readonly, runstop, "homehost",
- homehost, require_homehost,
- verbose-quiet, force);
+ rv2 = Assemble(
+ ss, NULL,
+ &ident,
+ NULL, NULL, 0,
+ readonly, runstop,
+ "homehost",
+ homehost,
+ require_homehost,
+ verbose-quiet, force);
if (rv2==0) {
cnt++;
acnt++;
Fork,
Bitmap,
RebuildMapOpt,
+ InvalidBackup,
};
/* structures read from config file */
extern int Assemble(struct supertype *st, char *mddev,
struct mddev_ident *ident,
- struct mddev_dev *devlist, char *backup_file,
+ struct mddev_dev *devlist,
+ char *backup_file, int invalid_backup,
int readonly, int runstop,
char *update, char *homehost, int require_homehost,
int verbose, int force);