#include "mdadm.h"
#include "dlink.h"
#include <sys/mman.h>
+#include <stdint.h>
#if ! defined(__BIG_ENDIAN) && ! defined(__LITTLE_ENDIAN)
#error no endian defined
dprintf("Called restore_backup()\n");
fdlist = xmalloc(sizeof(int) * disk_count);
+ enable_fds(next_spare);
for (i = 0; i < next_spare; i++)
fdlist[i] = -1;
for (dev = content->devs; dev; dev = dev->next) {
int d = 0;
struct mdinfo *sd;
+ enable_fds(nrdisks);
for (d = 0; d <= nrdisks; d++)
fdlist[d] = -1;
d = raid_disks;
*/
int delta_parity = 0;
+ memset(re, 0, sizeof(*re));
+
/* If a new level not explicitly given, we assume no-change */
if (info->new_level == UnSet)
info->new_level = info->array.level;
re->level = 0;
re->before.data_disks = 1;
re->after.data_disks = 1;
- re->before.layout = 0;
- re->backup_blocks = 0;
- re->parity = 0;
return NULL;
}
if (info->new_level == 1) {
/* Don't know what to do */
return "no change requested for Growing RAID1";
re->level = 1;
- re->backup_blocks = 0;
- re->parity = 0;
return NULL;
}
if (info->array.raid_disks == 2 &&
/* looks good */
re->level = 0;
- re->parity = 0;
re->before.data_disks = new_disks;
re->after.data_disks = re->before.data_disks;
- re->before.layout = 0;
- re->backup_blocks = 0;
return NULL;
case 10:
new_chunk = info->new_chunk * far;
re->level = 10;
- re->parity = 0;
re->before.layout = info->array.layout;
re->before.data_disks = info->array.raid_disks;
re->after.layout = info->new_layout;
re->after.data_disks = new_disks;
- /* For RAID10 we don't do backup, and there is
- * no need to synchronise stripes on both
+ /* For RAID10 we don't do backup but do allow reshape,
+ * so set backup_blocks to INVALID_SECTORS rather than
+ * zero.
+ * And there is no need to synchronise stripes on both
* 'old' and 'new'. So the important
* number is the minimum data_offset difference
* which is the larger of (offset copies * chunk).
*/
-
- re->backup_blocks = max(old_chunk, new_chunk) / 512;
+ re->backup_blocks = INVALID_SECTORS;
+ re->min_offset_change = max(old_chunk, new_chunk) / 512;
if (new_disks < re->before.data_disks &&
- info->space_after < re->backup_blocks)
+ info->space_after < re->min_offset_change)
/* Reduce component size by one chunk */
re->new_size = (info->component_size -
- re->backup_blocks);
+ re->min_offset_change);
else
re->new_size = info->component_size;
re->new_size = re->new_size * new_disks / copies;
return "Cannot change chunk-size with RAID0->RAID10";
/* looks good */
re->level = 10;
- re->parity = 0;
re->before.data_disks = (info->array.raid_disks +
info->delta_disks);
re->after.data_disks = re->before.data_disks;
re->before.layout = info->new_layout;
- re->backup_blocks = 0;
return NULL;
}
return "Cannot set raid_disk when "
"converting RAID5->RAID1";
re->level = 1;
- re->backup_blocks = 0;
info->new_chunk = 0;
return NULL;
default:
info->new_chunk, info->array.chunk_size,
re->after.data_disks,
re->before.data_disks);
+ re->min_offset_change = re->backup_blocks / re->before.data_disks;
re->new_size = info->component_size * re->after.data_disks;
return NULL;
struct mdinfo info;
struct mdinfo *sra;
-
if (ioctl(fd, GET_ARRAY_INFO, &array) < 0) {
- fprintf(stderr, Name ": %s is not an active md array - aborting\n",
+ pr_err("%s is not an active md array - aborting\n",
devname);
return 1;
}
- if (data_offset != INVALID_SECTORS && array.level != 10) {
+ if (data_offset != INVALID_SECTORS && array.level != 10
+ && (array.level < 4 || array.level > 6)) {
pr_err("--grow --data-offset not yet supported\n");
return 1;
}
if ((s->level == UnSet || s->level == array.level) &&
(s->layout_str == NULL) &&
(s->chunk == 0 || s->chunk == array.chunk_size) &&
+ data_offset == INVALID_SECTORS &&
(s->raiddisks == 0 || s->raiddisks == array.raid_disks)) {
/* Nothing more to do */
if (!changed && c->verbose >= 0)
return ret_val;
}
-static int raid10_reshape(char *container, int fd, char *devname,
- struct supertype *st, struct mdinfo *info,
- struct reshape *reshape,
- unsigned long long data_offset,
- int force, int verbose)
+static int set_new_data_offset(struct mdinfo *sra, struct supertype *st,
+ char *devname, int delta_disks,
+ unsigned long long data_offset,
+ unsigned long long min)
{
- /* Changing raid_disks, layout, chunksize or possibly
- * just data_offset for a RAID10.
- * We must always change data_offset. We change by at least
- * ->backup_blocks which is the largest of the old and new
- * chunk sizes.
- * If raid_disks is increasing, then data_offset must decrease
- * by at least this copy size.
- * If raid_disks is unchanged, data_offset must increase or
- * decrease by at least backup_blocks but preferably by much more.
- * We choose half of the available space.
- * If raid_disks is decreasing, data_offset must increase by
- * at least backup_blocks. To allow of this, component_size
- * must be decreased by the same amount.
- *
- * So we calculate the required minimum and direction, possibly
- * reduce the component_size, then iterate through the devices
- * and set the new_data_offset.
- * If that all works, we set chunk_size, layout, raid_disks, and start
- * 'reshape'
- */
- struct mdinfo *sra, *sd;
- unsigned long long min;
+ struct mdinfo *sd;
int dir = 0;
int err = 0;
+ unsigned long long before, after;
- sra = sysfs_read(fd, NULL,
- GET_COMPONENT|GET_DEVS|GET_OFFSET|GET_STATE|GET_CHUNK
- );
- if (!sra) {
- fprintf(stderr, Name ": %s: Cannot get array details from sysfs\n",
- devname);
- goto release;
- }
- min = reshape->backup_blocks;
-
- if (info->delta_disks)
- sysfs_set_str(sra, NULL, "reshape_direction",
- info->delta_disks < 0 ? "backwards" : "forwards");
- if (info->delta_disks < 0 &&
- info->space_after < reshape->backup_blocks) {
- int rv = sysfs_set_num(sra, NULL, "component_size",
- (sra->component_size -
- reshape->backup_blocks)/2);
- if (rv) {
- fprintf(stderr, Name ": cannot reduce component size\n");
- goto release;
- }
- }
+ /* Need to find min space before and after so same is used
+ * on all devices
+ */
+ before = UINT64_MAX;
+ after = UINT64_MAX;
for (sd = sra->devs; sd; sd = sd->next) {
char *dn;
int dfd;
dn = map_dev(sd->disk.major, sd->disk.minor, 0);
dfd = dev_open(dn, O_RDONLY);
if (dfd < 0) {
- fprintf(stderr,
- Name ": %s: cannot open component %s\n",
+ pr_err("%s: cannot open component %s\n",
devname, dn ? dn : "-unknown-");
- rv = -1;
goto release;
}
st2 = dup_super(st);
close(dfd);
if (rv) {
free(st2);
- fprintf(stderr, ": %s: cannot get superblock from %s\n",
+ pr_err("%s: cannot get superblock from %s\n",
devname, dn);
goto release;
}
st2->ss->getinfo_super(st2, &info2, NULL);
st2->ss->free_super(st2);
free(st2);
- if (info->delta_disks < 0) {
+ if (info2.space_before == 0 &&
+ info2.space_after == 0) {
+ /* Metadata doesn't support data_offset changes */
+ return 1;
+ }
+ if (before > info2.space_before)
+ before = info2.space_before;
+ if (after > info2.space_after)
+ after = info2.space_after;
+
+ if (data_offset != INVALID_SECTORS) {
+ if (dir == 0) {
+ if (info2.data_offset == data_offset) {
+ pr_err("%s: already has that data_offset\n",
+ dn);
+ goto release;
+ }
+ if (data_offset < info2.data_offset)
+ dir = -1;
+ else
+ dir = 1;
+ } else if ((data_offset <= info2.data_offset && dir == 1) ||
+ (data_offset >= info2.data_offset && dir == -1)) {
+ pr_err("%s: differing data offsets on devices make this --data-offset setting impossible\n",
+ dn);
+ goto release;
+ }
+ }
+ }
+ if (before == UINT64_MAX)
+ /* impossible really, there must be no devices */
+ return 1;
+
+ for (sd = sra->devs; sd; sd = sd->next) {
+ char *dn = map_dev(sd->disk.major, sd->disk.minor, 0);
+ unsigned long long new_data_offset;
+
+ if (delta_disks < 0) {
/* Don't need any space as array is shrinking
* just move data_offset up by min
*/
- if (data_offset == 1)
- info2.new_data_offset = info2.data_offset + min;
+ if (data_offset == INVALID_SECTORS)
+ new_data_offset = sd->data_offset + min;
else {
- if ((unsigned long long)data_offset
- < info2.data_offset + min) {
- fprintf(stderr, Name ": --data-offset too small for %s\n",
+ if (data_offset < sd->data_offset + min) {
+ pr_err("--data-offset too small for %s\n",
dn);
goto release;
}
- info2.new_data_offset = data_offset;
+ new_data_offset = data_offset;
}
- } else if (info->delta_disks > 0) {
+ } else if (delta_disks > 0) {
/* need space before */
- if (info2.space_before < min) {
- fprintf(stderr, Name ": Insufficient head-space for reshape on %s\n",
+ if (before < min) {
+ pr_err("Insufficient head-space for reshape on %s\n",
dn);
goto release;
}
- if (data_offset == 1)
- info2.new_data_offset = info2.data_offset - min;
+ if (data_offset == INVALID_SECTORS)
+ new_data_offset = sd->data_offset - min;
else {
- if ((unsigned long long)data_offset
- > info2.data_offset - min) {
- fprintf(stderr, Name ": --data-offset too large for %s\n",
+ if (data_offset > sd->data_offset - min) {
+ pr_err("--data-offset too large for %s\n",
dn);
goto release;
}
- info2.new_data_offset = data_offset;
+ new_data_offset = data_offset;
}
} else {
if (dir == 0) {
- /* can move up or down. 'data_offset'
- * might guide us, otherwise choose
- * direction with most space
+ /* can move up or down. If 'data_offset'
+ * was set we would have already decided,
+ * so just choose direction with most space.
*/
- if (data_offset == 1) {
- if (info2.space_before > info2.space_after)
- dir = -1;
- else
- dir = 1;
- } else if (data_offset < info2.data_offset)
+ if (before > after)
dir = -1;
else
dir = 1;
sysfs_set_str(sra, NULL, "reshape_direction",
dir == 1 ? "backwards" : "forwards");
}
- switch (dir) {
- case 1: /* Increase data offset */
- if (info2.space_after < min) {
- fprintf(stderr, Name ": Insufficient tail-space for reshape on %s\n",
+ if (dir > 0) {
+ /* Increase data offset */
+ if (after < min) {
+ pr_err("Insufficient tail-space for reshape on %s\n",
dn);
goto release;
}
- if (data_offset != 1 &&
- data_offset < info2.data_offset + min) {
- fprintf(stderr, Name ": --data-offset too small on %s\n",
+ if (data_offset != INVALID_SECTORS &&
+ data_offset < sd->data_offset + min) {
+ pr_err("--data-offset too small on %s\n",
dn);
goto release;
}
- if (data_offset != 1)
- info2.new_data_offset = data_offset;
+ if (data_offset != INVALID_SECTORS)
+ new_data_offset = data_offset;
else {
- unsigned long long off =
- info2.space_after / 2;
+ unsigned long long off = after / 2;
off &= ~7ULL;
if (off < min)
off = min;
- info2.new_data_offset =
- info2.data_offset + off;
+ new_data_offset =
+ sd->data_offset + off;
}
- break;
- case -1: /* Decrease data offset */
- if (info2.space_before < min) {
- fprintf(stderr, Name ": insufficient head-room on %s\n",
+ } else {
+ /* Decrease data offset */
+ if (before < min) {
+ pr_err("insufficient head-room on %s\n",
dn);
goto release;
}
- if (data_offset != 1 &&
- data_offset < info2.data_offset - min) {
- fprintf(stderr, Name ": --data-offset too small on %s\n",
+ if (data_offset != INVALID_SECTORS &&
+ data_offset < sd->data_offset - min) {
+ pr_err("--data-offset too small on %s\n",
dn);
goto release;
}
- if (data_offset != 1)
- info2.new_data_offset = data_offset;
+ if (data_offset != INVALID_SECTORS)
+ new_data_offset = data_offset;
else {
- unsigned long long off =
- info2.space_before / 2;
+ unsigned long long off = before / 2;
off &= ~7ULL;
if (off < min)
off = min;
- info2.new_data_offset =
- info2.data_offset - off;
+ new_data_offset =
+ sd->data_offset - off;
}
- break;
}
}
if (sysfs_set_num(sra, sd, "new_offset",
- info2.new_data_offset) < 0) {
+ new_data_offset) < 0) {
err = errno;
- fprintf(stderr, Name ": Cannot set new_offset for %s\n",
+ err = -1;
+ if (errno == E2BIG && data_offset != INVALID_SECTORS) {
+ pr_err("data-offset is too big for %s\n",
+ dn);
+ goto release;
+ }
+ if (sd == sra->devs &&
+ (errno == ENOENT || errno == E2BIG))
+ /* Early kernel, no 'new_offset' file,
+ * or kernel doesn't like us.
+ * For RAID5/6 this is not fatal
+ */
+ return 1;
+ pr_err("Cannot set new_offset for %s\n",
dn);
break;
}
}
+ return err;
+release:
+ return -1;
+}
+
+static int raid10_reshape(char *container, int fd, char *devname,
+ struct supertype *st, struct mdinfo *info,
+ struct reshape *reshape,
+ unsigned long long data_offset,
+ int force, int verbose)
+{
+ /* Changing raid_disks, layout, chunksize or possibly
+ * just data_offset for a RAID10.
+ * We must always change data_offset. We change by at least
+ * ->min_offset_change which is the largest of the old and new
+ * chunk sizes.
+ * If raid_disks is increasing, then data_offset must decrease
+ * by at least this copy size.
+ * If raid_disks is unchanged, data_offset must increase or
+ * decrease by at least min_offset_change but preferably by much more.
+ * We choose half of the available space.
+ * If raid_disks is decreasing, data_offset must increase by
+ * at least min_offset_change. To allow of this, component_size
+ * must be decreased by the same amount.
+ *
+ * So we calculate the required minimum and direction, possibly
+ * reduce the component_size, then iterate through the devices
+ * and set the new_data_offset.
+ * If that all works, we set chunk_size, layout, raid_disks, and start
+ * 'reshape'
+ */
+ struct mdinfo *sra;
+ unsigned long long min;
+ int err = 0;
+
+ sra = sysfs_read(fd, NULL,
+ GET_COMPONENT|GET_DEVS|GET_OFFSET|GET_STATE|GET_CHUNK
+ );
+ if (!sra) {
+ pr_err("%s: Cannot get array details from sysfs\n",
+ devname);
+ goto release;
+ }
+ min = reshape->min_offset_change;
+
+ if (info->delta_disks)
+ sysfs_set_str(sra, NULL, "reshape_direction",
+ info->delta_disks < 0 ? "backwards" : "forwards");
+ if (info->delta_disks < 0 &&
+ info->space_after < min) {
+ int rv = sysfs_set_num(sra, NULL, "component_size",
+ (sra->component_size -
+ min)/2);
+ if (rv) {
+ pr_err("cannot reduce component size\n");
+ goto release;
+ }
+ }
+ err = set_new_data_offset(sra, st, devname, info->delta_disks, data_offset,
+ min);
+ if (err == 1) {
+ pr_err("Cannot set new_data_offset: RAID10 reshape not\n");
+ cont_err("supported on this kernel\n");
+ err = -1;
+ }
+ if (err < 0)
+ goto release;
+
if (!err && sysfs_set_num(sra, NULL, "chunk_size", info->new_chunk) < 0)
err = errno;
if (!err && sysfs_set_num(sra, NULL, "layout", reshape->after.layout) < 0)
if (!err && sysfs_set_str(sra, NULL, "sync_action", "reshape") < 0)
err = errno;
if (err) {
- fprintf(stderr, Name ": Cannot set array shape for %s\n",
- devname);
- if (err == EBUSY &&
- (info->array.state & (1<<MD_SB_BITMAP_PRESENT)))
- fprintf(stderr,
- " Bitmap must be removed before"
- " shape can be changed\n");
- goto release;
+ pr_err("Cannot set array shape for %s\n",
+ devname);
+ if (err == EBUSY &&
+ (info->array.state & (1<<MD_SB_BITMAP_PRESENT)))
+ cont_err(" Bitmap must be removed before"
+ " shape can be changed\n");
+ goto release;
}
sysfs_free(sra);
return 0;
sysfs_free(sra);
}
+static void update_cache_size(char *container, struct mdinfo *sra,
+ struct mdinfo *info,
+ int disks, unsigned long long blocks)
+{
+ /* Check that the internal stripe cache is
+ * large enough, or it won't work.
+ * It must hold at least 4 stripes of the larger
+ * chunk size
+ */
+ unsigned long cache;
+ cache = max(info->array.chunk_size, info->new_chunk);
+ cache *= 4; /* 4 stripes minimum */
+ cache /= 512; /* convert to sectors */
+ /* make sure there is room for 'blocks' with a bit to spare */
+ if (cache < 16 + blocks / disks)
+ cache = 16 + blocks / disks;
+ cache /= (4096/512); /* Covert from sectors to pages */
+
+ if (sra->cache_size < cache)
+ subarray_set_num(container, sra, "stripe_cache_size",
+ cache+1);
+}
+
+static int impose_reshape(struct mdinfo *sra,
+ struct mdinfo *info,
+ struct supertype *st,
+ int fd,
+ int restart,
+ char *devname, char *container,
+ struct reshape *reshape)
+{
+ struct mdu_array_info_s array;
+
+ sra->new_chunk = info->new_chunk;
+
+ if (restart) {
+ /* for external metadata checkpoint saved by mdmon can be lost
+ * or missed /due to e.g. crash/. Check if md is not during
+ * restart farther than metadata points to.
+ * If so, this means metadata information is obsolete.
+ */
+ if (st->ss->external)
+ verify_reshape_position(info, reshape->level);
+ sra->reshape_progress = info->reshape_progress;
+ } else {
+ sra->reshape_progress = 0;
+ if (reshape->after.data_disks < reshape->before.data_disks)
+ /* start from the end of the new array */
+ sra->reshape_progress = (sra->component_size
+ * reshape->after.data_disks);
+ }
+
+ ioctl(fd, GET_ARRAY_INFO, &array);
+ if (info->array.chunk_size == info->new_chunk &&
+ reshape->before.layout == reshape->after.layout &&
+ st->ss->external == 0) {
+ /* use SET_ARRAY_INFO but only if reshape hasn't started */
+ array.raid_disks = reshape->after.data_disks + reshape->parity;
+ if (!restart &&
+ ioctl(fd, SET_ARRAY_INFO, &array) != 0) {
+ int err = errno;
+
+ pr_err("Cannot set device shape for %s: %s\n",
+ devname, strerror(errno));
+
+ if (err == EBUSY &&
+ (array.state & (1<<MD_SB_BITMAP_PRESENT)))
+ cont_err("Bitmap must be removed before"
+ " shape can be changed\n");
+
+ goto release;
+ }
+ } else if (!restart) {
+ /* set them all just in case some old 'new_*' value
+ * persists from some earlier problem.
+ */
+ int err = 0;
+ if (sysfs_set_num(sra, NULL, "chunk_size", info->new_chunk) < 0)
+ err = errno;
+ if (!err && sysfs_set_num(sra, NULL, "layout",
+ reshape->after.layout) < 0)
+ err = errno;
+ if (!err && subarray_set_num(container, sra, "raid_disks",
+ reshape->after.data_disks +
+ reshape->parity) < 0)
+ err = errno;
+ if (err) {
+ pr_err("Cannot set device shape for %s\n",
+ devname);
+
+ if (err == EBUSY &&
+ (array.state & (1<<MD_SB_BITMAP_PRESENT)))
+ cont_err("Bitmap must be removed before"
+ " shape can be changed\n");
+ goto release;
+ }
+ }
+ return 0;
+release:
+ return -1;
+}
+
static int reshape_array(char *container, int fd, char *devname,
struct supertype *st, struct mdinfo *info,
int force, struct mddev_dev *devlist,
int spares_needed;
char *msg;
int orig_level = UnSet;
- int disks, odisks;
+ int odisks;
int delayed;
struct mdu_array_info_s array;
int nrdisks;
int err;
unsigned long blocks;
- unsigned long cache;
unsigned long long array_size;
int done;
struct mdinfo *sra = NULL;
/* reshape already started. just skip to monitoring the reshape */
if (reshape.backup_blocks == 0)
return 0;
+ if (restart & RESHAPE_NO_BACKUP)
+ return 0;
goto started;
}
/* The container is frozen but the array may not be.
Manage_subdevs(devname, fd, devlist, verbose,
0,NULL, 0);
+ if (reshape.backup_blocks == 0 && data_offset)
+ reshape.backup_blocks = reshape.before.data_disks * info->array.chunk_size/512;
if (reshape.backup_blocks == 0) {
/* No restriping needed, but we might need to impose
* some more changes: layout, raid_disks, chunk_size
goto release;
}
-started:
-
if (array.level == 10) {
- /* Reshaping RAID10 does not require and data backup by
+ /* Reshaping RAID10 does not require any data backup by
* user-space. Instead it requires that the data_offset
* is changed to avoid the need for backup.
* So this is handled very separately
goto release;
}
+ if (!backup_file)
+ switch(set_new_data_offset(sra, st, devname,
+ reshape.after.data_disks - reshape.before.data_disks,
+ data_offset,
+ reshape.min_offset_change)) {
+ case -1:
+ goto release;
+ case 0:
+ /* Updated data_offset, so it's easy now */
+ update_cache_size(container, sra, info,
+ min(reshape.before.data_disks,
+ reshape.after.data_disks),
+ reshape.backup_blocks);
+
+ /* Right, everything seems fine. Let's kick things off.
+ */
+ sync_metadata(st);
+
+ if (impose_reshape(sra, info, st, fd, restart,
+ devname, container, &reshape) < 0)
+ goto release;
+ if (sysfs_set_str(sra, NULL, "sync_action", "reshape") < 0) {
+ pr_err("Failed to initiate reshape!\n");
+ goto release;
+ }
+
+ return 0;
+ case 1: /* Couldn't set data_offset, try the old way */
+ if (data_offset != INVALID_SECTORS) {
+ pr_err("Cannot update data_offset on this array\n");
+ goto release;
+ }
+ break;
+ }
+
+started:
/* Decide how many blocks (sectors) for a reshape
* unit. The number we have so far is just a minimum
*/
}
}
- /* lastly, check that the internal stripe cache is
- * large enough, or it won't work.
- * It must hold at least 4 stripes of the larger
- * chunk size
- */
- cache = max(info->array.chunk_size, info->new_chunk);
- cache *= 4; /* 4 stripes minimum */
- cache /= 512; /* convert to sectors */
- disks = min(reshape.before.data_disks, reshape.after.data_disks);
- /* make sure there is room for 'blocks' with a bit to spare */
- if (cache < 16 + blocks / disks)
- cache = 16 + blocks / disks;
- cache /= (4096/512); /* Covert from sectors to pages */
-
- if (sra->cache_size < cache)
- subarray_set_num(container, sra, "stripe_cache_size",
- cache+1);
+ update_cache_size(container, sra, info,
+ min(reshape.before.data_disks, reshape.after.data_disks),
+ blocks);
/* Right, everything seems fine. Let's kick things off.
* If only changing raid_disks, use ioctl, else use
*/
sync_metadata(st);
- sra->new_chunk = info->new_chunk;
-
- if (restart) {
- /* for external metadata checkpoint saved by mdmon can be lost
- * or missed /due to e.g. crash/. Check if md is not during
- * restart farther than metadata points to.
- * If so, this means metadata information is obsolete.
- */
- if (st->ss->external)
- verify_reshape_position(info, reshape.level);
- sra->reshape_progress = info->reshape_progress;
- } else {
- sra->reshape_progress = 0;
- if (reshape.after.data_disks < reshape.before.data_disks)
- /* start from the end of the new array */
- sra->reshape_progress = (sra->component_size
- * reshape.after.data_disks);
- }
-
- if (info->array.chunk_size == info->new_chunk &&
- reshape.before.layout == reshape.after.layout &&
- st->ss->external == 0) {
- /* use SET_ARRAY_INFO but only if reshape hasn't started */
- ioctl(fd, GET_ARRAY_INFO, &array);
- array.raid_disks = reshape.after.data_disks + reshape.parity;
- if (!restart &&
- ioctl(fd, SET_ARRAY_INFO, &array) != 0) {
- int err = errno;
-
- pr_err("Cannot set device shape for %s: %s\n",
- devname, strerror(errno));
-
- if (err == EBUSY &&
- (array.state & (1<<MD_SB_BITMAP_PRESENT)))
- cont_err("Bitmap must be removed before"
- " shape can be changed\n");
-
- goto release;
- }
- } else if (!restart) {
- /* set them all just in case some old 'new_*' value
- * persists from some earlier problem.
- */
- int err = 0;
- if (sysfs_set_num(sra, NULL, "chunk_size", info->new_chunk) < 0)
- err = errno;
- if (!err && sysfs_set_num(sra, NULL, "layout",
- reshape.after.layout) < 0)
- err = errno;
- if (!err && subarray_set_num(container, sra, "raid_disks",
- reshape.after.data_disks +
- reshape.parity) < 0)
- err = errno;
- if (err) {
- pr_err("Cannot set device shape for %s\n",
- devname);
-
- if (err == EBUSY &&
- (array.state & (1<<MD_SB_BITMAP_PRESENT)))
- cont_err("Bitmap must be removed before"
- " shape can be changed\n");
- goto release;
- }
- }
+ if (impose_reshape(sra, info, st, fd, restart,
+ devname, container, &reshape) < 0)
+ goto release;
err = start_reshape(sra, restart, reshape.before.data_disks,
reshape.after.data_disks);
close(cfd);
ret_val = reshape_container(st->container_devnm, NULL, mdfd,
st, info, 0, backup_file,
- 0, 1, freeze_reshape);
+ 0,
+ 1 | info->reshape_active,
+ freeze_reshape);
} else
ret_val = reshape_array(NULL, mdfd, "array", st, info, 1,
- NULL, 0ULL, backup_file, 0, 0, 1,
+ NULL, 0ULL, backup_file, 0, 0,
+ 1 | info->reshape_active,
freeze_reshape);
return ret_val;