md: update superblock after changing rdev flags in state_store
[ Upstream commit 8b9e2291e355a0eafdd5b1e21a94a6659f24b351 ] When the in memory flag is changed, we need to persist the change in the rdev superblock flags. This is needed for "writemostly" and "failfast". Reviewed-by: Li Feng <fengli@smartx.com> Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Song Liu <songliubraving@fb.com> Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
b34ea3c91e
commit
2338c35017
|
@ -3024,7 +3024,11 @@ state_store(struct md_rdev *rdev, const char *buf, size_t len)
|
||||||
* -write_error - clears WriteErrorSeen
|
* -write_error - clears WriteErrorSeen
|
||||||
* {,-}failfast - set/clear FailFast
|
* {,-}failfast - set/clear FailFast
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
struct mddev *mddev = rdev->mddev;
|
||||||
int err = -EINVAL;
|
int err = -EINVAL;
|
||||||
|
bool need_update_sb = false;
|
||||||
|
|
||||||
if (cmd_match(buf, "faulty") && rdev->mddev->pers) {
|
if (cmd_match(buf, "faulty") && rdev->mddev->pers) {
|
||||||
md_error(rdev->mddev, rdev);
|
md_error(rdev->mddev, rdev);
|
||||||
if (test_bit(Faulty, &rdev->flags))
|
if (test_bit(Faulty, &rdev->flags))
|
||||||
|
@ -3039,7 +3043,6 @@ state_store(struct md_rdev *rdev, const char *buf, size_t len)
|
||||||
if (rdev->raid_disk >= 0)
|
if (rdev->raid_disk >= 0)
|
||||||
err = -EBUSY;
|
err = -EBUSY;
|
||||||
else {
|
else {
|
||||||
struct mddev *mddev = rdev->mddev;
|
|
||||||
err = 0;
|
err = 0;
|
||||||
if (mddev_is_clustered(mddev))
|
if (mddev_is_clustered(mddev))
|
||||||
err = md_cluster_ops->remove_disk(mddev, rdev);
|
err = md_cluster_ops->remove_disk(mddev, rdev);
|
||||||
|
@ -3056,10 +3059,12 @@ state_store(struct md_rdev *rdev, const char *buf, size_t len)
|
||||||
} else if (cmd_match(buf, "writemostly")) {
|
} else if (cmd_match(buf, "writemostly")) {
|
||||||
set_bit(WriteMostly, &rdev->flags);
|
set_bit(WriteMostly, &rdev->flags);
|
||||||
mddev_create_serial_pool(rdev->mddev, rdev, false);
|
mddev_create_serial_pool(rdev->mddev, rdev, false);
|
||||||
|
need_update_sb = true;
|
||||||
err = 0;
|
err = 0;
|
||||||
} else if (cmd_match(buf, "-writemostly")) {
|
} else if (cmd_match(buf, "-writemostly")) {
|
||||||
mddev_destroy_serial_pool(rdev->mddev, rdev, false);
|
mddev_destroy_serial_pool(rdev->mddev, rdev, false);
|
||||||
clear_bit(WriteMostly, &rdev->flags);
|
clear_bit(WriteMostly, &rdev->flags);
|
||||||
|
need_update_sb = true;
|
||||||
err = 0;
|
err = 0;
|
||||||
} else if (cmd_match(buf, "blocked")) {
|
} else if (cmd_match(buf, "blocked")) {
|
||||||
set_bit(Blocked, &rdev->flags);
|
set_bit(Blocked, &rdev->flags);
|
||||||
|
@ -3085,9 +3090,11 @@ state_store(struct md_rdev *rdev, const char *buf, size_t len)
|
||||||
err = 0;
|
err = 0;
|
||||||
} else if (cmd_match(buf, "failfast")) {
|
} else if (cmd_match(buf, "failfast")) {
|
||||||
set_bit(FailFast, &rdev->flags);
|
set_bit(FailFast, &rdev->flags);
|
||||||
|
need_update_sb = true;
|
||||||
err = 0;
|
err = 0;
|
||||||
} else if (cmd_match(buf, "-failfast")) {
|
} else if (cmd_match(buf, "-failfast")) {
|
||||||
clear_bit(FailFast, &rdev->flags);
|
clear_bit(FailFast, &rdev->flags);
|
||||||
|
need_update_sb = true;
|
||||||
err = 0;
|
err = 0;
|
||||||
} else if (cmd_match(buf, "-insync") && rdev->raid_disk >= 0 &&
|
} else if (cmd_match(buf, "-insync") && rdev->raid_disk >= 0 &&
|
||||||
!test_bit(Journal, &rdev->flags)) {
|
!test_bit(Journal, &rdev->flags)) {
|
||||||
|
@ -3166,6 +3173,8 @@ state_store(struct md_rdev *rdev, const char *buf, size_t len)
|
||||||
clear_bit(ExternalBbl, &rdev->flags);
|
clear_bit(ExternalBbl, &rdev->flags);
|
||||||
err = 0;
|
err = 0;
|
||||||
}
|
}
|
||||||
|
if (need_update_sb)
|
||||||
|
md_update_sb(mddev, 1);
|
||||||
if (!err)
|
if (!err)
|
||||||
sysfs_notify_dirent_safe(rdev->sysfs_state);
|
sysfs_notify_dirent_safe(rdev->sysfs_state);
|
||||||
return err ? err : len;
|
return err ? err : len;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user