[-next,3/3] md/dm-raid: protect md_stop() with 'reconfig_mutex'
Commit Message
From: Yu Kuai <yukuai3@huawei.com>
__md_stop_writes() and __md_stop() will modify many fields that is
protected by 'reconfig_mutex', and all the callers will grab
'reconfig_mtuex' expect for md_stop().
Fixes: 9d09e663d550 ("dm: raid456 basic support")
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/dm-raid.c | 4 +++-
drivers/md/md.c | 2 ++
2 files changed, 5 insertions(+), 1 deletion(-)
@@ -3298,8 +3298,8 @@ static int raid_ctr(struct dm_target *ti, unsigned int argc, char **argv)
return 0;
bad_unlock:
- mddev_unlock(&rs->md);
md_stop(&rs->md);
+ mddev_unlock(&rs->md);
bad:
raid_set_free(rs);
@@ -3310,7 +3310,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);
}
@@ -6290,6 +6290,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
*/