Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 9d09e663d550 ("dm: raid456 basic support")
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>

authored by

Yu Kuai and committed by
Mike Snitzer
7d5fff89 e74c874e

+5 -1
+3 -1
drivers/md/dm-raid.c
··· 3298 3298 return 0; 3299 3299 3300 3300 bad_unlock: 3301 - mddev_unlock(&rs->md); 3302 3301 md_stop(&rs->md); 3302 + mddev_unlock(&rs->md); 3303 3303 bad: 3304 3304 raid_set_free(rs); 3305 3305 ··· 3310 3310 { 3311 3311 struct raid_set *rs = ti->private; 3312 3312 3313 + mddev_lock_nointr(&rs->md); 3313 3314 md_stop(&rs->md); 3315 + mddev_unlock(&rs->md); 3314 3316 raid_set_free(rs); 3315 3317 } 3316 3318
+2
drivers/md/md.c
··· 6247 6247 6248 6248 void md_stop(struct mddev *mddev) 6249 6249 { 6250 + lockdep_assert_held(&mddev->reconfig_mutex); 6251 + 6250 6252 /* stop the array and free an attached data structures. 6251 6253 * This is called from dm-raid 6252 6254 */