Skip to content

Commit 7d5fff8

Browse files
YuKuai-huaweiMike Snitzer
authored andcommitted
dm raid: protect md_stop() with 'reconfig_mutex'
__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 <[email protected]> Signed-off-by: Mike Snitzer <[email protected]>
1 parent e74c874 commit 7d5fff8

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

drivers/md/dm-raid.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3298,8 +3298,8 @@ static int raid_ctr(struct dm_target *ti, unsigned int argc, char **argv)
32983298
return 0;
32993299

33003300
bad_unlock:
3301-
mddev_unlock(&rs->md);
33023301
md_stop(&rs->md);
3302+
mddev_unlock(&rs->md);
33033303
bad:
33043304
raid_set_free(rs);
33053305

@@ -3310,7 +3310,9 @@ static void raid_dtr(struct dm_target *ti)
33103310
{
33113311
struct raid_set *rs = ti->private;
33123312

3313+
mddev_lock_nointr(&rs->md);
33133314
md_stop(&rs->md);
3315+
mddev_unlock(&rs->md);
33143316
raid_set_free(rs);
33153317
}
33163318

drivers/md/md.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6247,6 +6247,8 @@ static void __md_stop(struct mddev *mddev)
62476247

62486248
void md_stop(struct mddev *mddev)
62496249
{
6250+
lockdep_assert_held(&mddev->reconfig_mutex);
6251+
62506252
/* stop the array and free an attached data structures.
62516253
* This is called from dm-raid
62526254
*/

0 commit comments

Comments
 (0)