summaryrefslogtreecommitdiff
path: root/drivers/md
diff options
context:
space:
mode:
authorYu Kuai <yukuai3@huawei.com>2023-07-08 12:21:53 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-08-03 11:24:05 +0300
commitce114218f74e8189aa0da94ca6811af64b6b7ca6 (patch)
treec02d75b302f5da1df2c299e97599f2244a33c33c /drivers/md
parente08db3f85df2a5b31361f253b75074ef334448e9 (diff)
downloadlinux-ce114218f74e8189aa0da94ca6811af64b6b7ca6.tar.xz
dm raid: protect md_stop() with 'reconfig_mutex'
[ Upstream commit 7d5fff8982a2199d49ec067818af7d84d4f95ca0 ] __md_stop_writes() and __md_stop() will modify many fields that are protected by 'reconfig_mutex', and all the callers will grab 'reconfig_mutex' except for md_stop(). Also, update md_stop() to make certain 'reconfig_mutex' is held using lockdep_assert_held(). Fixes: 9d09e663d550 ("dm: raid456 basic support") Signed-off-by: Yu Kuai <yukuai3@huawei.com> Signed-off-by: Mike Snitzer <snitzer@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/dm-raid.c4
-rw-r--r--drivers/md/md.c2
2 files changed, 5 insertions, 1 deletions
diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
index c3736d1f7231..4b7528dc2fd0 100644
--- a/drivers/md/dm-raid.c
+++ b/drivers/md/dm-raid.c
@@ -3301,8 +3301,8 @@ size_check:
return 0;
bad_unlock:
- mddev_unlock(&rs->md);
md_stop(&rs->md);
+ mddev_unlock(&rs->md);
bad:
raid_set_free(rs);
@@ -3313,7 +3313,9 @@ static void raid_dtr(struct dm_target *ti)
{
struct raid_set *rs = ti->private;
+ mddev_lock_nointr(&rs->md);
md_stop(&rs->md);
+ mddev_unlock(&rs->md);
raid_set_free(rs);
}
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 829e1bd9bcbf..45daba0eb931 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -6269,6 +6269,8 @@ static void __md_stop(struct mddev *mddev)
void md_stop(struct mddev *mddev)
{
+ lockdep_assert_held(&mddev->reconfig_mutex);
+
/* stop the array and free an attached data structures.
* This is called from dm-raid
*/