[PATCH] md: Allow the write_mostly flag to be set via sysfs

It appears in /sys/mdX/md/dev-YYY/state
and can be set or cleared by writing 'writemostly' or '-writemostly'
respectively.

Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
NeilBrown 2006-06-26 00:28:01 -07:00 committed by Linus Torvalds
parent a94213b1fa
commit f655675b3f
2 changed files with 17 additions and 0 deletions

View File

@ -309,6 +309,9 @@ Each directory contains:
faulty - device has been kicked from active use due to faulty - device has been kicked from active use due to
a detected fault a detected fault
in_sync - device is a fully in-sync member of the array in_sync - device is a fully in-sync member of the array
writemostly - device will only be subject to read
requests if there are no other options.
This applies only to raid1 arrays.
spare - device is working, but not a full member. spare - device is working, but not a full member.
This includes spares that are in the process This includes spares that are in the process
of being recoverred to of being recoverred to
@ -316,6 +319,8 @@ Each directory contains:
This can be written to. This can be written to.
Writing "faulty" simulates a failure on the device. Writing "faulty" simulates a failure on the device.
Writing "remove" removes the device from the array. Writing "remove" removes the device from the array.
Writing "writemostly" sets the writemostly flag.
Writing "-writemostly" clears the writemostly flag.
errors errors
An approximate count of read errors that have been detected on An approximate count of read errors that have been detected on

View File

@ -1737,6 +1737,10 @@ state_show(mdk_rdev_t *rdev, char *page)
len += sprintf(page+len, "%sin_sync",sep); len += sprintf(page+len, "%sin_sync",sep);
sep = ","; sep = ",";
} }
if (test_bit(WriteMostly, &rdev->flags)) {
len += sprintf(page+len, "%swrite_mostly",sep);
sep = ",";
}
if (!test_bit(Faulty, &rdev->flags) && if (!test_bit(Faulty, &rdev->flags) &&
!test_bit(In_sync, &rdev->flags)) { !test_bit(In_sync, &rdev->flags)) {
len += sprintf(page+len, "%sspare", sep); len += sprintf(page+len, "%sspare", sep);
@ -1751,6 +1755,8 @@ state_store(mdk_rdev_t *rdev, const char *buf, size_t len)
/* can write /* can write
* faulty - simulates and error * faulty - simulates and error
* remove - disconnects the device * remove - disconnects the device
* writemostly - sets write_mostly
* -writemostly - clears write_mostly
*/ */
int err = -EINVAL; int err = -EINVAL;
if (cmd_match(buf, "faulty") && rdev->mddev->pers) { if (cmd_match(buf, "faulty") && rdev->mddev->pers) {
@ -1766,6 +1772,12 @@ state_store(mdk_rdev_t *rdev, const char *buf, size_t len)
md_new_event(mddev); md_new_event(mddev);
err = 0; err = 0;
} }
} else if (cmd_match(buf, "writemostly")) {
set_bit(WriteMostly, &rdev->flags);
err = 0;
} else if (cmd_match(buf, "-writemostly")) {
clear_bit(WriteMostly, &rdev->flags);
err = 0;
} }
return err ? err : len; return err ? err : len;
} }