Commit 5dc39c9e authored by Yu Kuai's avatar Yu Kuai Committed by Zheng Qixing
Browse files

md: restore 'noio_flag' for the last mddev_resume()

mainline inclusion
from mainline-v6.6-rc1
commit e24ed043
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IAMIV7
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e24ed04389f9619e0aaef615a8948633c182a8b0



-------------------------------------------------

memalloc_noio_save() is called for the first mddev_suspend(), and
repeated mddev_suspend() only increase 'suspended'. However,
memalloc_noio_restore() is also called for the first mddev_resume(),
which means that memory reclaim will be enabled before the last
mddev_resume() is called, while the array is still suspended.

Fix this problem by restore 'noio_flag' for the last mddev_resume().

Fixes: 78f57ef9 ("md: use memalloc scope APIs in mddev_suspend()/mddev_resume()")
Signed-off-by: default avatarYu Kuai <yukuai3@huawei.com>
Link: https://lore.kernel.org/r/20230628012931.88911-3-yukuai1@huaweicloud.com


Signed-off-by: default avatarSong Liu <song@kernel.org>

Conflicts:
           drivers/md/md.c
[The modifications made in commit 72adae23 ("md: Change active_io to percpu")
are related to performance optimization and involve multiple parts.
The conflict here is only due to inconsistencies in the context.]
Signed-off-by: default avatarZheng Qixing <zhengqixing@huawei.com>
parent f7cda317
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -520,11 +520,13 @@ EXPORT_SYMBOL_GPL(mddev_suspend);

void mddev_resume(struct mddev *mddev)
{
	/* entred the memalloc scope from mddev_suspend() */
	memalloc_noio_restore(mddev->noio_flag);
	lockdep_assert_held(&mddev->reconfig_mutex);
	if (--mddev->suspended)
		return;

	/* entred the memalloc scope from mddev_suspend() */
	memalloc_noio_restore(mddev->noio_flag);

	wake_up(&mddev->sb_wait);
	mddev->pers->quiesce(mddev, 0);