summaryrefslogtreecommitdiff
path: root/drivers/md/md.c
diff options
context:
space:
mode:
authorYu Kuai <yukuai3@huawei.com>2023-10-10 23:19:49 +0800
committerSong Liu <song@kernel.org>2023-10-10 18:49:50 -0700
commit205669f37770772c1ae8c2dac1eba6da521a8b77 (patch)
treef46ec5c4b73c7ced35847bbb2838991a437988d0 /drivers/md/md.c
parente28ca92fbb5c6ed8fac5db65e02947bf020c5b60 (diff)
md: use new apis to suspend array for sysfs apis
Convert to use new apis in following sysfs apis: - level_store - suspend_lo_store - suspend_hi_store - serialize_policy_store These are not hot path, so performance is not concerned. Signed-off-by: Yu Kuai <yukuai3@huawei.com> Signed-off-by: Song Liu <song@kernel.org> Link: https://lore.kernel.org/r/20231010151958.145896-11-yukuai1@huaweicloud.com
Diffstat (limited to 'drivers/md/md.c')
-rw-r--r--drivers/md/md.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 201de29d913c..aa08b9b78332 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -4019,7 +4019,7 @@ level_store(struct mddev *mddev, const char *buf, size_t len)
if (slen == 0 || slen >= sizeof(clevel))
return -EINVAL;
- rv = mddev_lock(mddev);
+ rv = mddev_suspend_and_lock(mddev);
if (rv)
return rv;
@@ -4112,7 +4112,6 @@ level_store(struct mddev *mddev, const char *buf, size_t len)
}
/* Looks like we have a winner */
- mddev_suspend(mddev);
mddev_detach(mddev);
spin_lock(&mddev->lock);
@@ -4198,14 +4197,13 @@ level_store(struct mddev *mddev, const char *buf, size_t len)
blk_set_stacking_limits(&mddev->queue->limits);
pers->run(mddev);
set_bit(MD_SB_CHANGE_DEVS, &mddev->sb_flags);
- mddev_resume(mddev);
if (!mddev->thread)
md_update_sb(mddev, 1);
sysfs_notify_dirent_safe(mddev->sysfs_level);
md_new_event();
rv = len;
out_unlock:
- mddev_unlock(mddev);
+ mddev_unlock_and_resume(mddev);
return rv;
}
@@ -5293,15 +5291,13 @@ suspend_lo_store(struct mddev *mddev, const char *buf, size_t len)
if (new != (sector_t)new)
return -EINVAL;
- err = mddev_lock(mddev);
+ err = __mddev_suspend(mddev, true);
if (err)
return err;
- mddev_suspend(mddev);
WRITE_ONCE(mddev->suspend_lo, new);
- mddev_resume(mddev);
+ __mddev_resume(mddev);
- mddev_unlock(mddev);
return len;
}
static struct md_sysfs_entry md_suspend_lo =
@@ -5326,15 +5322,13 @@ suspend_hi_store(struct mddev *mddev, const char *buf, size_t len)
if (new != (sector_t)new)
return -EINVAL;
- err = mddev_lock(mddev);
+ err = __mddev_suspend(mddev, true);
if (err)
return err;
- mddev_suspend(mddev);
WRITE_ONCE(mddev->suspend_hi, new);
- mddev_resume(mddev);
+ __mddev_resume(mddev);
- mddev_unlock(mddev);
return len;
}
static struct md_sysfs_entry md_suspend_hi =
@@ -5582,7 +5576,7 @@ serialize_policy_store(struct mddev *mddev, const char *buf, size_t len)
if (value == mddev->serialize_policy)
return len;
- err = mddev_lock(mddev);
+ err = mddev_suspend_and_lock(mddev);
if (err)
return err;
if (mddev->pers == NULL || (mddev->pers->level != 1)) {
@@ -5591,15 +5585,13 @@ serialize_policy_store(struct mddev *mddev, const char *buf, size_t len)
goto unlock;
}
- mddev_suspend(mddev);
if (value)
mddev_create_serial_pool(mddev, NULL, true);
else
mddev_destroy_serial_pool(mddev, NULL, true);
mddev->serialize_policy = value;
- mddev_resume(mddev);
unlock:
- mddev_unlock(mddev);
+ mddev_unlock_and_resume(mddev);
return err ?: len;
}