|
|
7bdf8f |
commit 8800f85381d0cd9689dee62bbbdafdb359100389
|
|
|
7bdf8f |
Author: Xiao Ni <xni@redhat.com>
|
|
|
7bdf8f |
Date: Thu Jun 16 09:41:02 2016 +0800
|
|
|
7bdf8f |
|
|
|
7bdf8f |
MDADM:Check mdinfo->reshape_active more times before calling Grow_continue
|
|
|
7bdf8f |
|
|
|
7bdf8f |
When reshaping a 3 drives raid5 to 4 drives raid5, there is a chance that
|
|
|
7bdf8f |
it can't start the reshape. If the disks are not enough to have spaces for
|
|
|
7bdf8f |
relocating the data_offset, it needs to call start_reshape and then run
|
|
|
7bdf8f |
mdadm --grow --continue by systemd. But mdadm --grow --continue fails
|
|
|
7bdf8f |
because it checkes that info->reshape_active is 0.
|
|
|
7bdf8f |
|
|
|
7bdf8f |
The info->reshape_active is got from the superblock of underlying devices.
|
|
|
7bdf8f |
Function start_reshape write reshape to /sys/../sync_action. Before writing
|
|
|
7bdf8f |
latest superblock to underlying devices, mdadm --grow --continue is called.
|
|
|
7bdf8f |
There is a chance info->reshape_active is 0. We should wait for superblock
|
|
|
7bdf8f |
updating more time before calling Grow_continue.
|
|
|
7bdf8f |
|
|
|
7bdf8f |
Signed-off-by: Xiao Ni <xni@redhat.com>
|
|
|
7bdf8f |
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
|
|
|
7bdf8f |
|
|
|
7bdf8f |
diff --git a/Grow.c b/Grow.c
|
|
|
7bdf8f |
index f184d9c..628f0e7 100755
|
|
|
7bdf8f |
--- a/Grow.c
|
|
|
7bdf8f |
+++ b/Grow.c
|
|
|
7bdf8f |
@@ -4788,6 +4788,7 @@ int Grow_continue_command(char *devname, int fd,
|
|
|
7bdf8f |
dprintf("Grow continue is run for ");
|
|
|
7bdf8f |
if (st->ss->external == 0) {
|
|
|
7bdf8f |
int d;
|
|
|
7bdf8f |
+ int cnt = 5;
|
|
|
7bdf8f |
dprintf_cont("native array (%s)\n", devname);
|
|
|
7bdf8f |
if (ioctl(fd, GET_ARRAY_INFO, &array.array) < 0) {
|
|
|
7bdf8f |
pr_err("%s is not an active md array - aborting\n", devname);
|
|
|
7bdf8f |
@@ -4799,36 +4800,42 @@ int Grow_continue_command(char *devname, int fd,
|
|
|
7bdf8f |
* FIXME we should really get what we need from
|
|
|
7bdf8f |
* sysfs
|
|
|
7bdf8f |
*/
|
|
|
7bdf8f |
- for (d = 0; d < MAX_DISKS; d++) {
|
|
|
7bdf8f |
- mdu_disk_info_t disk;
|
|
|
7bdf8f |
- char *dv;
|
|
|
7bdf8f |
- int err;
|
|
|
7bdf8f |
- disk.number = d;
|
|
|
7bdf8f |
- if (ioctl(fd, GET_DISK_INFO, &disk) < 0)
|
|
|
7bdf8f |
- continue;
|
|
|
7bdf8f |
- if (disk.major == 0 && disk.minor == 0)
|
|
|
7bdf8f |
- continue;
|
|
|
7bdf8f |
- if ((disk.state & (1 << MD_DISK_ACTIVE)) == 0)
|
|
|
7bdf8f |
- continue;
|
|
|
7bdf8f |
- dv = map_dev(disk.major, disk.minor, 1);
|
|
|
7bdf8f |
- if (!dv)
|
|
|
7bdf8f |
- continue;
|
|
|
7bdf8f |
- fd2 = dev_open(dv, O_RDONLY);
|
|
|
7bdf8f |
- if (fd2 < 0)
|
|
|
7bdf8f |
- continue;
|
|
|
7bdf8f |
- err = st->ss->load_super(st, fd2, NULL);
|
|
|
7bdf8f |
- close(fd2);
|
|
|
7bdf8f |
- if (err)
|
|
|
7bdf8f |
- continue;
|
|
|
7bdf8f |
- break;
|
|
|
7bdf8f |
- }
|
|
|
7bdf8f |
- if (d == MAX_DISKS) {
|
|
|
7bdf8f |
- pr_err("Unable to load metadata for %s\n",
|
|
|
7bdf8f |
- devname);
|
|
|
7bdf8f |
- ret_val = 1;
|
|
|
7bdf8f |
- goto Grow_continue_command_exit;
|
|
|
7bdf8f |
- }
|
|
|
7bdf8f |
- st->ss->getinfo_super(st, content, NULL);
|
|
|
7bdf8f |
+ do {
|
|
|
7bdf8f |
+ for (d = 0; d < MAX_DISKS; d++) {
|
|
|
7bdf8f |
+ mdu_disk_info_t disk;
|
|
|
7bdf8f |
+ char *dv;
|
|
|
7bdf8f |
+ int err;
|
|
|
7bdf8f |
+ disk.number = d;
|
|
|
7bdf8f |
+ if (ioctl(fd, GET_DISK_INFO, &disk) < 0)
|
|
|
7bdf8f |
+ continue;
|
|
|
7bdf8f |
+ if (disk.major == 0 && disk.minor == 0)
|
|
|
7bdf8f |
+ continue;
|
|
|
7bdf8f |
+ if ((disk.state & (1 << MD_DISK_ACTIVE)) == 0)
|
|
|
7bdf8f |
+ continue;
|
|
|
7bdf8f |
+ dv = map_dev(disk.major, disk.minor, 1);
|
|
|
7bdf8f |
+ if (!dv)
|
|
|
7bdf8f |
+ continue;
|
|
|
7bdf8f |
+ fd2 = dev_open(dv, O_RDONLY);
|
|
|
7bdf8f |
+ if (fd2 < 0)
|
|
|
7bdf8f |
+ continue;
|
|
|
7bdf8f |
+ err = st->ss->load_super(st, fd2, NULL);
|
|
|
7bdf8f |
+ close(fd2);
|
|
|
7bdf8f |
+ if (err)
|
|
|
7bdf8f |
+ continue;
|
|
|
7bdf8f |
+ break;
|
|
|
7bdf8f |
+ }
|
|
|
7bdf8f |
+ if (d == MAX_DISKS) {
|
|
|
7bdf8f |
+ pr_err("Unable to load metadata for %s\n",
|
|
|
7bdf8f |
+ devname);
|
|
|
7bdf8f |
+ ret_val = 1;
|
|
|
7bdf8f |
+ goto Grow_continue_command_exit;
|
|
|
7bdf8f |
+ }
|
|
|
7bdf8f |
+ st->ss->getinfo_super(st, content, NULL);
|
|
|
7bdf8f |
+ if (!content->reshape_active)
|
|
|
7bdf8f |
+ sleep(3);
|
|
|
7bdf8f |
+ else
|
|
|
7bdf8f |
+ break;
|
|
|
7bdf8f |
+ } while (cnt-- > 0);
|
|
|
7bdf8f |
} else {
|
|
|
7bdf8f |
char *container;
|
|
|
7bdf8f |
|