Skip to content

Commit

Permalink
dm raid: protect md_stop() with 'reconfig_mutex'
Browse files Browse the repository at this point in the history
[ Upstream commit 7d5fff8 ]

__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: 9d09e66 ("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>
  • Loading branch information
Yu Kuai authored and gregkh committed Aug 3, 2023
1 parent e08db3f commit ce11421
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/md/dm-raid.c
Original file line number Diff line number Diff line change
Expand Up @@ -3301,8 +3301,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);

Expand All @@ -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);
}

Expand Down
2 changes: 2 additions & 0 deletions drivers/md/md.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit ce11421

Please sign in to comment.