md: notify the 'degraded' sysfs attribute on failure.
authorNeilBrown <neilb@suse.de>
Sun, 8 Jan 2012 13:46:41 +0000 (00:46 +1100)
committerNeilBrown <neilb@suse.de>
Tue, 10 Jan 2012 21:35:14 +0000 (08:35 +1100)
We currently only 'notify' changes to the 'degraded' attribute
when it decreases, not when it increases.

Notifying on failure is a little awkward as it happen in
interrupt context.
So instead, notify when we remove the failed device from the array,
which is very soon afterwards.

Reported-and-tested-by: Mikhail Balabin <mbalabin@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
drivers/md/md.c

index 1c1c562f63dcf8e5a3889f66d05bf2272359cbbc..33aa06f12b87a5ba9a7f73ce15a697ac052c3b3a 100644 (file)
@@ -7383,6 +7383,7 @@ static int remove_and_add_spares(struct mddev *mddev)
 {
        struct md_rdev *rdev;
        int spares = 0;
+       int removed = 0;
 
        mddev->curr_resync_completed = 0;
 
@@ -7396,8 +7397,13 @@ static int remove_and_add_spares(struct mddev *mddev)
                                    mddev, rdev) == 0) {
                                sysfs_unlink_rdev(mddev, rdev);
                                rdev->raid_disk = -1;
+                               removed++;
                        }
                }
+       if (removed)
+               sysfs_notify(&mddev->kobj, NULL,
+                            "degraded");
+
 
        list_for_each_entry(rdev, &mddev->disks, same_set) {
                if (rdev->raid_disk >= 0 &&