diff mbox series

[5/5] fs: assert that open_mutex isn't held over holder ops

Message ID 20231017184823.1383356-6-hch@lst.de (mailing list archive)
State New, archived
Headers show
Series [1/5] block: simplify bdev_del_partition() | expand

Commit Message

Christoph Hellwig Oct. 17, 2023, 6:48 p.m. UTC
From: Christian Brauner <brauner@kernel.org>

With recent block level changes we should never be in a situation where
we hold disk->open_mutex when calling into these helpers. So assert that
in the code.

Signed-off-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/super.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Ming Lei Oct. 18, 2023, 9:53 a.m. UTC | #1
On Tue, Oct 17, 2023 at 08:48:23PM +0200, Christoph Hellwig wrote:
> From: Christian Brauner <brauner@kernel.org>
> 
> With recent block level changes we should never be in a situation where
> we hold disk->open_mutex when calling into these helpers. So assert that
> in the code.
> 
> Signed-off-by: Christian Brauner <brauner@kernel.org>
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Reviewed-by: Ming Lei <ming.lei@redhat.com>

thanks,
Ming
Jan Kara Oct. 19, 2023, 8:43 a.m. UTC | #2
On Tue 17-10-23 20:48:23, Christoph Hellwig wrote:
> From: Christian Brauner <brauner@kernel.org>
> 
> With recent block level changes we should never be in a situation where
> we hold disk->open_mutex when calling into these helpers. So assert that
> in the code.
> 
> Signed-off-by: Christian Brauner <brauner@kernel.org>
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Looks good to me. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/super.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/fs/super.c b/fs/super.c
> index 26b96191e9b3ca..ce54cfcecaa156 100644
> --- a/fs/super.c
> +++ b/fs/super.c
> @@ -1443,6 +1443,7 @@ static void fs_bdev_mark_dead(struct block_device *bdev, bool surprise)
>  
>  	/* bd_holder_lock ensures that the sb isn't freed */
>  	lockdep_assert_held(&bdev->bd_holder_lock);
> +	lockdep_assert_not_held(&bdev->bd_disk->open_mutex);
>  
>  	if (!super_lock_shared_active(sb))
>  		return;
> @@ -1462,6 +1463,7 @@ static void fs_bdev_sync(struct block_device *bdev)
>  	struct super_block *sb = bdev->bd_holder;
>  
>  	lockdep_assert_held(&bdev->bd_holder_lock);
> +	lockdep_assert_not_held(&bdev->bd_disk->open_mutex);
>  
>  	if (!super_lock_shared_active(sb))
>  		return;
> -- 
> 2.39.2
>
diff mbox series

Patch

diff --git a/fs/super.c b/fs/super.c
index 26b96191e9b3ca..ce54cfcecaa156 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -1443,6 +1443,7 @@  static void fs_bdev_mark_dead(struct block_device *bdev, bool surprise)
 
 	/* bd_holder_lock ensures that the sb isn't freed */
 	lockdep_assert_held(&bdev->bd_holder_lock);
+	lockdep_assert_not_held(&bdev->bd_disk->open_mutex);
 
 	if (!super_lock_shared_active(sb))
 		return;
@@ -1462,6 +1463,7 @@  static void fs_bdev_sync(struct block_device *bdev)
 	struct super_block *sb = bdev->bd_holder;
 
 	lockdep_assert_held(&bdev->bd_holder_lock);
+	lockdep_assert_not_held(&bdev->bd_disk->open_mutex);
 
 	if (!super_lock_shared_active(sb))
 		return;