mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 14:11:52 +00:00
md: use new apis to suspend array for ioctls involed array reconfiguration
'reconfig_mutex' will be grabbed before these ioctls, suspend array before holding the lock, so that io won't concurrent with array reconfiguration through ioctls. This is 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-13-yukuai1@huaweicloud.com
This commit is contained in:
parent
cfa078c8b8
commit
1b0a2d950e
@ -7215,7 +7215,6 @@ static int set_bitmap_file(struct mddev *mddev, int fd)
|
||||
struct bitmap *bitmap;
|
||||
|
||||
bitmap = md_bitmap_create(mddev, -1);
|
||||
mddev_suspend(mddev);
|
||||
if (!IS_ERR(bitmap)) {
|
||||
mddev->bitmap = bitmap;
|
||||
err = md_bitmap_load(mddev);
|
||||
@ -7225,11 +7224,8 @@ static int set_bitmap_file(struct mddev *mddev, int fd)
|
||||
md_bitmap_destroy(mddev);
|
||||
fd = -1;
|
||||
}
|
||||
mddev_resume(mddev);
|
||||
} else if (fd < 0) {
|
||||
mddev_suspend(mddev);
|
||||
md_bitmap_destroy(mddev);
|
||||
mddev_resume(mddev);
|
||||
}
|
||||
}
|
||||
if (fd < 0) {
|
||||
@ -7518,7 +7514,6 @@ static int update_array_info(struct mddev *mddev, mdu_array_info_t *info)
|
||||
mddev->bitmap_info.space =
|
||||
mddev->bitmap_info.default_space;
|
||||
bitmap = md_bitmap_create(mddev, -1);
|
||||
mddev_suspend(mddev);
|
||||
if (!IS_ERR(bitmap)) {
|
||||
mddev->bitmap = bitmap;
|
||||
rv = md_bitmap_load(mddev);
|
||||
@ -7526,7 +7521,6 @@ static int update_array_info(struct mddev *mddev, mdu_array_info_t *info)
|
||||
rv = PTR_ERR(bitmap);
|
||||
if (rv)
|
||||
md_bitmap_destroy(mddev);
|
||||
mddev_resume(mddev);
|
||||
} else {
|
||||
/* remove the bitmap */
|
||||
if (!mddev->bitmap) {
|
||||
@ -7551,9 +7545,7 @@ static int update_array_info(struct mddev *mddev, mdu_array_info_t *info)
|
||||
module_put(md_cluster_mod);
|
||||
mddev->safemode_delay = DEFAULT_SAFEMODE_DELAY;
|
||||
}
|
||||
mddev_suspend(mddev);
|
||||
md_bitmap_destroy(mddev);
|
||||
mddev_resume(mddev);
|
||||
mddev->bitmap_info.offset = 0;
|
||||
}
|
||||
}
|
||||
@ -7624,6 +7616,20 @@ static inline bool md_ioctl_valid(unsigned int cmd)
|
||||
}
|
||||
}
|
||||
|
||||
static bool md_ioctl_need_suspend(unsigned int cmd)
|
||||
{
|
||||
switch (cmd) {
|
||||
case ADD_NEW_DISK:
|
||||
case HOT_ADD_DISK:
|
||||
case HOT_REMOVE_DISK:
|
||||
case SET_BITMAP_FILE:
|
||||
case SET_ARRAY_INFO:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static int __md_set_array_info(struct mddev *mddev, void __user *argp)
|
||||
{
|
||||
mdu_array_info_t info;
|
||||
@ -7756,7 +7762,8 @@ static int md_ioctl(struct block_device *bdev, blk_mode_t mode,
|
||||
if (!md_is_rdwr(mddev))
|
||||
flush_work(&mddev->sync_work);
|
||||
|
||||
err = mddev_lock(mddev);
|
||||
err = md_ioctl_need_suspend(cmd) ? mddev_suspend_and_lock(mddev) :
|
||||
mddev_lock(mddev);
|
||||
if (err) {
|
||||
pr_debug("md: ioctl lock interrupted, reason %d, cmd %d\n",
|
||||
err, cmd);
|
||||
@ -7884,7 +7891,10 @@ unlock:
|
||||
if (mddev->hold_active == UNTIL_IOCTL &&
|
||||
err != -EINVAL)
|
||||
mddev->hold_active = 0;
|
||||
mddev_unlock(mddev);
|
||||
|
||||
md_ioctl_need_suspend(cmd) ? mddev_unlock_and_resume(mddev) :
|
||||
mddev_unlock(mddev);
|
||||
|
||||
out:
|
||||
if(did_set_md_closing)
|
||||
clear_bit(MD_CLOSING, &mddev->flags);
|
||||
|
Loading…
Reference in New Issue
Block a user