|
|
3c4af5 |
From 77b72fa828132a35c8b2e08d3fb07eea80b11895 Mon Sep 17 00:00:00 2001
|
|
|
3c4af5 |
From: allenpeng <allenpeng@synology.com>
|
|
|
3c4af5 |
Date: Fri, 12 Jun 2020 17:00:39 +0800
|
|
|
3c4af5 |
Subject: [PATCH 086/108] mdadm/Grow: prevent md's fd from being occupied
|
|
|
3c4af5 |
during delayed time
|
|
|
3c4af5 |
|
|
|
3c4af5 |
If we start reshaping on md which shares sub-devices with another
|
|
|
3c4af5 |
resyncing md, it may be forced to wait for others to complete. mdadm
|
|
|
3c4af5 |
occupies the md's fd during this time, which causes the md can not be
|
|
|
3c4af5 |
stopped and the filesystem can not be mounted on the md. We can close
|
|
|
3c4af5 |
md's fd earlier to solve this problem.
|
|
|
3c4af5 |
|
|
|
3c4af5 |
Reproducible Steps:
|
|
|
3c4af5 |
|
|
|
3c4af5 |
1. create two partitions on sda, sdb, sdc, sdd
|
|
|
3c4af5 |
2. create raid1 with sda1, sdb1
|
|
|
3c4af5 |
mdadm -C /dev/md1 --assume-clean -l1 -n2 /dev/sda1 /dev/sdb1
|
|
|
3c4af5 |
3. create raid5 with sda2, sdb2, sdc2
|
|
|
3c4af5 |
mdadm -C /dev/md2 --assume-clean -l5 -n3 /dev/sda2 /dev/sdb2 /dev/sdc2
|
|
|
3c4af5 |
4. start resync at md1
|
|
|
3c4af5 |
echo repair > /sys/block/md1/md/sync_action
|
|
|
3c4af5 |
5. reshape raid5 to raid6
|
|
|
3c4af5 |
mdadm -a /dev/md2 /dev/sdd2
|
|
|
3c4af5 |
mdadm --grow /dev/md2 -n4 -l6 --backup-file=/root/md2-backup
|
|
|
3c4af5 |
|
|
|
3c4af5 |
Now mdadm is occupying the fd of md2, causing md2 unable to be stopped
|
|
|
3c4af5 |
|
|
|
3c4af5 |
6.Try to stop md2, an error message shows
|
|
|
3c4af5 |
mdadm -S /dev/md2
|
|
|
3c4af5 |
mdadm: Cannot get exclusive access to /dev/md3:Perhaps a running process,
|
|
|
3c4af5 |
mounted filesystem or active volume group?
|
|
|
3c4af5 |
|
|
|
3c4af5 |
Reviewed-by: Alex Wu <alexwu@synology.com>
|
|
|
3c4af5 |
Reviewed-by: BingJing Chang <bingjingc@synology.com>
|
|
|
3c4af5 |
Reviewed-by: Danny Shih <dannyshih@synology.com>
|
|
|
3c4af5 |
Signed-off-by: ChangSyun Peng <allenpeng@synology.com>
|
|
|
3c4af5 |
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
|
|
|
3c4af5 |
---
|
|
|
3c4af5 |
Grow.c | 2 +-
|
|
|
3c4af5 |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
3c4af5 |
|
|
|
3c4af5 |
diff --git a/Grow.c b/Grow.c
|
|
|
3c4af5 |
index 764374f..57db7d4 100644
|
|
|
3c4af5 |
--- a/Grow.c
|
|
|
3c4af5 |
+++ b/Grow.c
|
|
|
3c4af5 |
@@ -3517,6 +3517,7 @@ started:
|
|
|
3c4af5 |
return 0;
|
|
|
3c4af5 |
}
|
|
|
3c4af5 |
|
|
|
3c4af5 |
+ close(fd);
|
|
|
3c4af5 |
/* Now we just need to kick off the reshape and watch, while
|
|
|
3c4af5 |
* handling backups of the data...
|
|
|
3c4af5 |
* This is all done by a forked background process.
|
|
|
3c4af5 |
@@ -3569,7 +3570,6 @@ started:
|
|
|
3c4af5 |
mdstat_wait(30 - (delayed-1) * 25);
|
|
|
3c4af5 |
} while (delayed);
|
|
|
3c4af5 |
mdstat_close();
|
|
|
3c4af5 |
- close(fd);
|
|
|
3c4af5 |
if (check_env("MDADM_GROW_VERIFY"))
|
|
|
3c4af5 |
fd = open(devname, O_RDONLY | O_DIRECT);
|
|
|
3c4af5 |
else
|
|
|
3c4af5 |
--
|
|
|
3c4af5 |
2.7.5
|
|
|
3c4af5 |
|