Commit d7a9d443 authored by NeilBrown's avatar NeilBrown

md: add 'write_error' flag to component devices.

If a device has ever seen a write error, we will want to handle
known-bad-blocks differently.
So create an appropriate state flag and export it via sysfs.
Signed-off-by: default avatarNeilBrown <neilb@suse.de>
Reviewed-by: default avatarNamhyung Kim <namhyung@gmail.com>
parent 06f60385
...@@ -2516,6 +2516,10 @@ state_show(mdk_rdev_t *rdev, char *page) ...@@ -2516,6 +2516,10 @@ state_show(mdk_rdev_t *rdev, char *page)
len += sprintf(page+len, "%sspare", sep); len += sprintf(page+len, "%sspare", sep);
sep = ","; sep = ",";
} }
if (test_bit(WriteErrorSeen, &rdev->flags)) {
len += sprintf(page+len, "%swrite_error", sep);
sep = ",";
}
return len+sprintf(page+len, "\n"); return len+sprintf(page+len, "\n");
} }
...@@ -2530,6 +2534,8 @@ state_store(mdk_rdev_t *rdev, const char *buf, size_t len) ...@@ -2530,6 +2534,8 @@ state_store(mdk_rdev_t *rdev, const char *buf, size_t len)
* blocked - sets the Blocked flag * blocked - sets the Blocked flag
* -blocked - clears the Blocked flag * -blocked - clears the Blocked flag
* insync - sets Insync providing device isn't active * insync - sets Insync providing device isn't active
* write_error - sets WriteErrorSeen
* -write_error - clears WriteErrorSeen
*/ */
int err = -EINVAL; int err = -EINVAL;
if (cmd_match(buf, "faulty") && rdev->mddev->pers) { if (cmd_match(buf, "faulty") && rdev->mddev->pers) {
...@@ -2565,6 +2571,12 @@ state_store(mdk_rdev_t *rdev, const char *buf, size_t len) ...@@ -2565,6 +2571,12 @@ state_store(mdk_rdev_t *rdev, const char *buf, size_t len)
} else if (cmd_match(buf, "insync") && rdev->raid_disk == -1) { } else if (cmd_match(buf, "insync") && rdev->raid_disk == -1) {
set_bit(In_sync, &rdev->flags); set_bit(In_sync, &rdev->flags);
err = 0; err = 0;
} else if (cmd_match(buf, "write_error")) {
set_bit(WriteErrorSeen, &rdev->flags);
err = 0;
} else if (cmd_match(buf, "-write_error")) {
clear_bit(WriteErrorSeen, &rdev->flags);
err = 0;
} }
if (!err) if (!err)
sysfs_notify_dirent_safe(rdev->sysfs_state); sysfs_notify_dirent_safe(rdev->sysfs_state);
......
...@@ -84,6 +84,9 @@ struct mdk_rdev_s ...@@ -84,6 +84,9 @@ struct mdk_rdev_s
#define Blocked 8 /* An error occurred on an externally #define Blocked 8 /* An error occurred on an externally
* managed array, don't allow writes * managed array, don't allow writes
* until it is cleared */ * until it is cleared */
#define WriteErrorSeen 9 /* A write error has been seen on this
* device
*/
wait_queue_head_t blocked_wait; wait_queue_head_t blocked_wait;
int desc_nr; /* descriptor index in the superblock */ int desc_nr; /* descriptor index in the superblock */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment