Fix up calls to unfrozen at end of reshape.

1/ don't pass 'frozen' as an arg to unfreeze - just use it
   to conditionally call 'unfreeze'.

2/ Always unfreeze at end of reshape_container

3/ Only unfreeze at end of reshape_array if not 'forked'.  So when
   reshape_array is called from reshape_container it doesn't unfreeze,
   but when called directly.

Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
NeilBrown 2011-01-13 10:39:34 +11:00
parent 04c3c51413
commit 9202b8eb6a
1 changed files with 9 additions and 14 deletions

23
Grow.c
View File

@ -530,12 +530,8 @@ static int freeze(struct supertype *st)
}
}
static void unfreeze(struct supertype *st, int frozen)
static void unfreeze(struct supertype *st)
{
/* If 'frozen' is 1, unfreeze the array */
if (frozen <= 0)
return;
if (st->ss->external)
return unfreeze_container(st);
else {
@ -1551,6 +1547,7 @@ int Grow_reshape(char *devname, int fd, int quiet, char *backup_file,
*/
rv = reshape_container(container, fd, devname, st, &info,
force, backup_file, quiet);
frozen = 0;
} else {
/* Impose these changes on a single array. First
* check that the metadata is OK with the change. */
@ -1565,11 +1562,11 @@ int Grow_reshape(char *devname, int fd, int quiet, char *backup_file,
sync_metadata(st);
rv = reshape_array(container, fd, devname, st, &info, force,
backup_file, quiet, 0);
frozen = 0;
}
/* reshape_* released the array */
return rv;
release:
unfreeze(st, frozen);
if (frozen > 0)
unfreeze(st);
return rv;
}
@ -1593,7 +1590,6 @@ static int reshape_array(char *container, int fd, char *devname,
int d;
int nrdisks;
int err;
int frozen;
unsigned long blocks;
unsigned long cache;
unsigned long long array_size;
@ -2024,12 +2020,9 @@ static int reshape_array(char *container, int fd, char *devname,
abort_reshape(sra);
break;
default:
/* The child will take care of unfreezing the array */
frozen = 0;
break;
return 0;
}
release:
if (!rv) {
if (container)
@ -2049,7 +2042,8 @@ static int reshape_array(char *container, int fd, char *devname,
if (c && sysfs_set_str(sra, NULL, "level", c) == 0)
fprintf(stderr, Name ": aborting level change\n");
}
unfreeze(st, frozen);
if (!forked)
unfreeze(st);
return rv;
}
@ -2139,6 +2133,7 @@ int reshape_container(char *container, int cfd, char *devname,
if (rv)
break;
}
unfreeze(st);
sysfs_free(cc);
exit(0);
}