From b7ab26539a2d2805c5794c00ce31cff9a2ad4154 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Wed, 14 Jul 2021 09:17:26 -0700 Subject: [PATCH] Avoid lockdep warning about upstream inversion Some kernels have blkdev_reread_part acquire the bd_mutex and then call into drop_partitions which calls fsync_bdev which acquires s_umount. This inverts the usual pattern of deactivate_super getting s_umount and then using blkdev_put in kill_sb->put_super to drop a second device. The inversion has been fixed upstream by years of rewrites. We can't go back in time to fix the kernels that we're testing against, unfortunately, so we disable lockdep around our valid leg of the inversion that lockdep is noticing in our testing. Signed-off-by: Zach Brown --- kmod/src/super.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/kmod/src/super.c b/kmod/src/super.c index 65224dff..e205571c 100644 --- a/kmod/src/super.c +++ b/kmod/src/super.c @@ -230,7 +230,15 @@ static void scoutfs_metadev_close(struct super_block *sb) struct scoutfs_sb_info *sbi = SCOUTFS_SB(sb); if (sbi->meta_bdev) { + /* + * Some kernels have blkdev_reread_part which calls + * fsync_bdev while holding the bd_mutex which inverts + * the s_umount hold in deactivate_super and blkdev_put + * from kill_sb->put_super. + */ + lockdep_off(); blkdev_put(sbi->meta_bdev, SCOUTFS_META_BDEV_MODE); + lockdep_on(); sbi->meta_bdev = NULL; } }