dcavalca / rpms / mdadm

Forked from rpms/mdadm 3 years ago
Clone

Blame SOURCES/Add-force-flag1-to-hot_remove_disk.patch

2c1b57
From 1ab9ed2afb7ca50c4f922a0b85c4e6631becde02 Mon Sep 17 00:00:00 2001
2c1b57
From: NeilBrown <neilb@suse.com>
2c1b57
Date: Mon, 27 Mar 2017 14:36:56 +1100
2c1b57
Subject: [RHEL7.5 PATCH 023/169] Add 'force' flag to *hot_remove_disk().
2c1b57
2c1b57
In rare circumstances, the short period that *hot_remove_disk()
2c1b57
waits isn't long enough to IO to complete.  This particularly happens
2c1b57
when a device is failing and many retries are still happening.
2c1b57
2c1b57
We don't want to increase the normal wait time for "mdadm --remove"
2c1b57
as that might be use just to test if a device is active or not, and a
2c1b57
delay would be problematic.
2c1b57
So allow "--force" to mean that mdadm should try extra hard for a
2c1b57
--remove to complete, waiting up to 5 seconds.
2c1b57
2c1b57
Note that this patch fixes a comment which claim the previous
2c1b57
wait time was half a second, where it was really 50msec.
2c1b57
2c1b57
Signed-off-by: NeilBrown <neilb@suse.com>
2c1b57
Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2c1b57
---
2c1b57
 Grow.c   |  2 +-
2c1b57
 Manage.c | 10 +++++-----
2c1b57
 mdadm.h  |  4 ++--
2c1b57
 util.c   | 10 +++++-----
2c1b57
 4 files changed, 13 insertions(+), 13 deletions(-)
2c1b57
2c1b57
diff --git a/Grow.c b/Grow.c
2c1b57
index 218a706..e22661c 100755
2c1b57
--- a/Grow.c
2c1b57
+++ b/Grow.c
2c1b57
@@ -2749,7 +2749,7 @@ static int impose_level(int fd, int level, char *devname, int verbose)
2c1b57
 				continue;
2c1b57
 			ioctl(fd, SET_DISK_FAULTY,
2c1b57
 			      makedev(disk.major, disk.minor));
2c1b57
-			hot_remove_disk(fd, makedev(disk.major, disk.minor));
2c1b57
+			hot_remove_disk(fd, makedev(disk.major, disk.minor), 1);
2c1b57
 		}
2c1b57
 	}
2c1b57
 	c = map_num(pers, level);
2c1b57
diff --git a/Manage.c b/Manage.c
2c1b57
index edf5798..55218d9 100644
2c1b57
--- a/Manage.c
2c1b57
+++ b/Manage.c
2c1b57
@@ -1110,7 +1110,7 @@ int Manage_add(int fd, int tfd, struct mddev_dev *dv,
2c1b57
 }
2c1b57
 
2c1b57
 int Manage_remove(struct supertype *tst, int fd, struct mddev_dev *dv,
2c1b57
-		  int sysfd, unsigned long rdev, int verbose, char *devname)
2c1b57
+		  int sysfd, unsigned long rdev, int force, int verbose, char *devname)
2c1b57
 {
2c1b57
 	int lfd = -1;
2c1b57
 	int err;
2c1b57
@@ -1177,9 +1177,9 @@ int Manage_remove(struct supertype *tst, int fd, struct mddev_dev *dv,
2c1b57
 		/* device has been removed and we don't know
2c1b57
 		 * the major:minor number
2c1b57
 		 */
2c1b57
-		err = sys_hot_remove_disk(sysfd);
2c1b57
+		err = sys_hot_remove_disk(sysfd, force);
2c1b57
 	} else {
2c1b57
-		err = hot_remove_disk(fd, rdev);
2c1b57
+		err = hot_remove_disk(fd, rdev, force);
2c1b57
 		if (err && errno == ENODEV) {
2c1b57
 			/* Old kernels rejected this if no personality
2c1b57
 			 * is registered */
2c1b57
@@ -1603,7 +1603,7 @@ int Manage_subdevs(char *devname, int fd,
2c1b57
 
2c1b57
 			if (dv->disposition == 'F')
2c1b57
 				/* Need to remove first */
2c1b57
-				hot_remove_disk(fd, rdev);
2c1b57
+				hot_remove_disk(fd, rdev, force);
2c1b57
 			/* Make sure it isn't in use (in 2.6 or later) */
2c1b57
 			tfd = dev_open(dv->devname, O_RDONLY|O_EXCL);
2c1b57
 			if (tfd >= 0) {
2c1b57
@@ -1645,7 +1645,7 @@ int Manage_subdevs(char *devname, int fd,
2c1b57
 				rv = -1;
2c1b57
 			} else
2c1b57
 				rv = Manage_remove(tst, fd, dv, sysfd,
2c1b57
-						   rdev, verbose,
2c1b57
+						   rdev, verbose, force,
2c1b57
 						   devname);
2c1b57
 			if (sysfd >= 0)
2c1b57
 				close(sysfd);
2c1b57
diff --git a/mdadm.h b/mdadm.h
2c1b57
index b855d24..cebc0c0 100644
2c1b57
--- a/mdadm.h
2c1b57
+++ b/mdadm.h
2c1b57
@@ -1476,8 +1476,8 @@ extern int add_disk(int mdfd, struct supertype *st,
2c1b57
 		    struct mdinfo *sra, struct mdinfo *info);
2c1b57
 extern int remove_disk(int mdfd, struct supertype *st,
2c1b57
 		       struct mdinfo *sra, struct mdinfo *info);
2c1b57
-extern int hot_remove_disk(int mdfd, unsigned long dev);
2c1b57
-extern int sys_hot_remove_disk(int statefd);
2c1b57
+extern int hot_remove_disk(int mdfd, unsigned long dev, int force);
2c1b57
+extern int sys_hot_remove_disk(int statefd, int force);
2c1b57
 extern int set_array_info(int mdfd, struct supertype *st, struct mdinfo *info);
2c1b57
 unsigned long long min_recovery_start(struct mdinfo *array);
2c1b57
 
2c1b57
diff --git a/util.c b/util.c
2c1b57
index b718531..683c869 100644
2c1b57
--- a/util.c
2c1b57
+++ b/util.c
2c1b57
@@ -1795,15 +1795,15 @@ int remove_disk(int mdfd, struct supertype *st,
2c1b57
 	return rv;
2c1b57
 }
2c1b57
 
2c1b57
-int hot_remove_disk(int mdfd, unsigned long dev)
2c1b57
+int hot_remove_disk(int mdfd, unsigned long dev, int force)
2c1b57
 {
2c1b57
-	int cnt = 5;
2c1b57
+	int cnt = force ? 500 : 5;
2c1b57
 	int ret;
2c1b57
 
2c1b57
 	/* HOT_REMOVE_DISK can fail with EBUSY if there are
2c1b57
 	 * outstanding IO requests to the device.
2c1b57
 	 * In this case, it can be helpful to wait a little while,
2c1b57
-	 * up to half a second, for that IO to flush.
2c1b57
+	 * up to 5 seconds if 'force' is set, or 50 msec if not.
2c1b57
 	 */
2c1b57
 	while ((ret = ioctl(mdfd, HOT_REMOVE_DISK, dev)) == -1 &&
2c1b57
 	       errno == EBUSY &&
2c1b57
@@ -1813,9 +1813,9 @@ int hot_remove_disk(int mdfd, unsigned long dev)
2c1b57
 	return ret;
2c1b57
 }
2c1b57
 
2c1b57
-int sys_hot_remove_disk(int statefd)
2c1b57
+int sys_hot_remove_disk(int statefd, int force)
2c1b57
 {
2c1b57
-	int cnt = 5;
2c1b57
+	int cnt = force ? 500 : 5;
2c1b57
 	int ret;
2c1b57
 
2c1b57
 	while ((ret = write(statefd, "remove", 6)) == -1 &&
2c1b57
-- 
2c1b57
2.7.4
2c1b57