[PATCH] for Multiple Device driver - md.c (kernel 2.4.12)

From: gaby@applianceware.com
Date: Thu Oct 11 2001 - 20:23:53 EST


My name is Jean-Gabriel Rican and I have a kernel problem.

There is a slight limitation in the Multiple Devices driver that I would
like to address here.

Suppose you can hot-swap a hard disk in a system.
Now if you have a degraded Software RAID device (for example a RAID-5 with
one disk failed) and you replace the failed disk on-the-fly you cannot
start reconstruction (with raidhotadd) of the Software RAID device with
the replaced disk because it says it is BUSY.

The solution is to stop the RAID device (raidstop) and [re-]start it with

This is an inconvenient because if the RAID device is mounted somewhere it
should be first umounted before stopping, user access to the device would
be interrupted and so on. And it is even worse when the RAID has the root
file system on it and you cannot umount it.

My solution and patch to the kernel driver md.c is to remove the drive
from the RAID array if it is faulty and then import it later.
I tested it thoroughly and it seems to work well.
Kernel version is 2.4.12 (latest).

So I submit this patch and hope that it will be accepted.
I have to specify that I am not [yet] member in Linux Kernel Mailing

Thank you,
Jean-Gabriel RICAN

This is the patch:

--- drivers/md/md.c.orig Wed Oct 3 22:27:48 2001
+++ drivers/md/md.c Thu Oct 11 10:56:45 2001
@@ -2388,9 +2388,18 @@

         rdev = find_rdev(mddev, dev);
- if (rdev)
+ if (rdev && !rdev->faulty)
                 return -EBUSY;

+ if (rdev && rdev->faulty) {
+ err = hot_remove_disk(mddev, dev);
+ if (err == -EBUSY)
+ return -EBUSY;
+ if (err) {
+ MD_BUG();
+ return -EINVAL;
+ }
+ }
         err = md_import_device (dev, 0);
         if (err) {
                 printk(KERN_WARNING "md: error, md_import_device() returned %d\n", err);


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

This archive was generated by hypermail 2b29 : Mon Oct 15 2001 - 21:00:43 EST