瀏覽代碼

Make sure all changes to md/degraded are notified.

When a device fails, when a spare is activated, when
an array is reshaped, or when an array is started,
the extent to which the array is degraded can change.

Signed-off-by: Neil Brown <neilb@suse.de>
Neil Brown 17 年之前
父節點
當前提交
a99ac97113
共有 2 個文件被更改,包括 12 次插入1 次删除
  1. 7 0
      Documentation/md.txt
  2. 5 1
      drivers/md/md.c

+ 7 - 0
Documentation/md.txt

@@ -392,6 +392,13 @@ also have
       achieved. In that case, the transition to "recover" isn't
       achieved. In that case, the transition to "recover" isn't
       notified, but the transition away is.
       notified, but the transition away is.
 
 
+   degraded
+      This contains a count of the number of devices by which the
+      arrays is degraded.  So an optimal array with show '0'.  A
+      single failed/missing drive will show '1', etc.
+      This file responds to select/poll, any increase or decrease
+      in the count of missing devices will trigger an event.
+
    mismatch_count
    mismatch_count
       When performing 'check' and 'repair', and possibly when
       When performing 'check' and 'repair', and possibly when
       performing 'resync', md will count the number of errors that are
       performing 'resync', md will count the number of errors that are

+ 5 - 1
drivers/md/md.c

@@ -2969,6 +2969,7 @@ action_store(mddev_t *mddev, const char *page, size_t len)
 		err = mddev->pers->start_reshape(mddev);
 		err = mddev->pers->start_reshape(mddev);
 		if (err)
 		if (err)
 			return err;
 			return err;
+		sysfs_notify(&mddev->kobj, NULL, "degraded");
 	} else {
 	} else {
 		if (cmd_match(page, "check"))
 		if (cmd_match(page, "check"))
 			set_bit(MD_RECOVERY_CHECK, &mddev->recovery);
 			set_bit(MD_RECOVERY_CHECK, &mddev->recovery);
@@ -3686,6 +3687,7 @@ static int do_md_run(mddev_t * mddev)
 	md_new_event(mddev);
 	md_new_event(mddev);
 	sysfs_notify(&mddev->kobj, NULL, "array_state");
 	sysfs_notify(&mddev->kobj, NULL, "array_state");
 	sysfs_notify(&mddev->kobj, NULL, "sync_action");
 	sysfs_notify(&mddev->kobj, NULL, "sync_action");
+	sysfs_notify(&mddev->kobj, NULL, "degraded");
 	kobject_uevent(&mddev->gendisk->dev.kobj, KOBJ_CHANGE);
 	kobject_uevent(&mddev->gendisk->dev.kobj, KOBJ_CHANGE);
 	return 0;
 	return 0;
 }
 }
@@ -6049,7 +6051,9 @@ void md_check_recovery(mddev_t *mddev)
 			if (!test_bit(MD_RECOVERY_INTR, &mddev->recovery)) {
 			if (!test_bit(MD_RECOVERY_INTR, &mddev->recovery)) {
 				/* success...*/
 				/* success...*/
 				/* activate any spares */
 				/* activate any spares */
-				mddev->pers->spare_active(mddev);
+				if (mddev->pers->spare_active(mddev))
+					sysfs_notify(&mddev->kobj, NULL,
+						     "degraded");
 			}
 			}
 			md_update_sb(mddev, 1);
 			md_update_sb(mddev, 1);