SHA256
1
0
forked from pool/mdadm
mdadm/0008-Retry-HOT_REMOVE_DISK-a-few-times.patch
Neil Brown 35f025d42c - New upstream release 4.0
Multiple bugfixes and various enhancements
  including IMSM support for bad blocks and 4K block devices.
  (FATE#321941)
- 0001-Generic-support-for-consistency-policy-and-PPL.patch
- 0002-Detail-show-consistency-policy.patch
- 0003-imsm-PPL-support.patch
- 0004-super1-PPL-support.patch
- 0005-Add-ppl-and-no-ppl-options-for-update.patch
- 0006-Grow-support-consistency-policy-change.patch
   Add support for Partial Parity Logs
   (FATE#321941)
- 0007-udev-md-raid-assembly.rules-Skip-non-ready-devices.patch
   (bsc#956236)
- 0008-Retry-HOT_REMOVE_DISK-a-few-times.patch
   (bsc#808647)
- 0009-Introduce-sys_hot_remove_disk.patch
   (bsc#974154)
- 0010-Add-force-flag-to-hot_remove_disk.patch
   (bsc#808647)
- 0011-Detail-handle-non-existent-arrays-better.patch
   (bsc#966773)

OBS-URL: https://build.opensuse.org/package/show/Base:System/mdadm?expand=0&rev=147
2017-03-27 03:26:19 +00:00

106 lines
3.2 KiB
Diff

From 3494e6b41659393c7cb97c48b45d2b1a05c6faf0 Mon Sep 17 00:00:00 2001
From: NeilBrown <neilb@suse.com>
Date: Mon, 27 Mar 2017 12:48:06 +1100
Subject: [PATCH] Retry HOT_REMOVE_DISK a few times.
HOT_REMOVE_DISK can fail with EBUSY if there are outstanding
IO request that have not completed yet. It can sometimes
be helpful to wait a little while for these to complete.
We already do this in impose_level() when reshaping a device,
but not in Manage.c in response to an explicit --remove request.
So create hot_remove_disk() to central this code, and call it
where-ever it makes sense to wait for a HOT_REMOVE_DISK to succeed.
Signed-off-by: NeilBrown <neilb@suse.com>
---
Grow.c | 9 +--------
Manage.c | 4 ++--
mdadm.h | 1 +
util.c | 18 ++++++++++++++++++
4 files changed, 22 insertions(+), 10 deletions(-)
--- a/Grow.c
+++ b/Grow.c
@@ -2921,7 +2921,6 @@ static int impose_level(int fd, int leve
for (d = 0, found = 0;
d < MAX_DISKS && found < array.nr_disks;
d++) {
- int cnt;
mdu_disk_info_t disk;
disk.number = d;
if (ioctl(fd, GET_DISK_INFO, &disk) < 0)
@@ -2935,13 +2934,7 @@ static int impose_level(int fd, int leve
continue;
ioctl(fd, SET_DISK_FAULTY,
makedev(disk.major, disk.minor));
- cnt = 5;
- while (ioctl(fd, HOT_REMOVE_DISK,
- makedev(disk.major, disk.minor)) < 0
- && errno == EBUSY
- && cnt--) {
- usleep(10000);
- }
+ hot_remove_disk(fd, makedev(disk.major, disk.minor));
}
}
c = map_num(pers, level);
--- a/Manage.c
+++ b/Manage.c
@@ -1183,7 +1183,7 @@ int Manage_remove(struct supertype *tst,
else
err = 0;
} else {
- err = ioctl(fd, HOT_REMOVE_DISK, rdev);
+ err = hot_remove_disk(fd, rdev);
if (err && errno == ENODEV) {
/* Old kernels rejected this if no personality
* is registered */
@@ -1607,7 +1607,7 @@ int Manage_subdevs(char *devname, int fd
if (dv->disposition == 'F')
/* Need to remove first */
- ioctl(fd, HOT_REMOVE_DISK, rdev);
+ hot_remove_disk(fd, rdev);
/* Make sure it isn't in use (in 2.6 or later) */
tfd = dev_open(dv->devname, O_RDONLY|O_EXCL);
if (tfd >= 0) {
--- a/mdadm.h
+++ b/mdadm.h
@@ -1500,6 +1500,7 @@ extern int add_disk(int mdfd, struct sup
struct mdinfo *sra, struct mdinfo *info);
extern int remove_disk(int mdfd, struct supertype *st,
struct mdinfo *sra, struct mdinfo *info);
+extern int hot_remove_disk(int mdfd, unsigned long dev);
extern int set_array_info(int mdfd, struct supertype *st, struct mdinfo *info);
unsigned long long min_recovery_start(struct mdinfo *array);
--- a/util.c
+++ b/util.c
@@ -1795,6 +1795,24 @@ int remove_disk(int mdfd, struct superty
return rv;
}
+int hot_remove_disk(int mdfd, unsigned long dev)
+{
+ int cnt = 5;
+ int ret;
+
+ /* HOT_REMOVE_DISK can fail with EBUSY if there are
+ * outstanding IO requests to the device.
+ * In this case, it can be helpful to wait a little while,
+ * up to half a second, for that IO to flush.
+ */
+ while ((ret = ioctl(mdfd, HOT_REMOVE_DISK, dev)) == -1 &&
+ errno == EBUSY &&
+ cnt-- > 0)
+ usleep(10000);
+
+ return ret;
+}
+
int set_array_info(int mdfd, struct supertype *st, struct mdinfo *info)
{
/* Initialise kernel's knowledge of array.