diff mbox series

[RFC,2/6] xfs: simplify device handling

Message ID 20231024-vfs-super-rework-v1-2-37a8aa697148@kernel.org (mailing list archive)
State New, archived
Headers show
Series fs,block: yield devices | expand

Commit Message

Christian Brauner Oct. 24, 2023, 2:53 p.m. UTC
We removed all codepaths where s_umount is taken beneath open_mutex and
bd_holder_lock so don't make things more complicated than they need to
be and hold s_umount over block device opening.

Signed-off-by: Christian Brauner <brauner@kernel.org>
---
 fs/xfs/xfs_super.c | 19 +++----------------
 1 file changed, 3 insertions(+), 16 deletions(-)

Comments

Jan Kara Oct. 25, 2023, 3:30 p.m. UTC | #1
On Tue 24-10-23 16:53:40, Christian Brauner wrote:
> We removed all codepaths where s_umount is taken beneath open_mutex and
> bd_holder_lock so don't make things more complicated than they need to
> be and hold s_umount over block device opening.
> 
> Signed-off-by: Christian Brauner <brauner@kernel.org>

Looks good. Feel free to add:

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

								Honza

> ---
>  fs/xfs/xfs_super.c | 19 +++----------------
>  1 file changed, 3 insertions(+), 16 deletions(-)
> 
> diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
> index f0ae07828153..84107d162e41 100644
> --- a/fs/xfs/xfs_super.c
> +++ b/fs/xfs/xfs_super.c
> @@ -437,19 +437,13 @@ xfs_open_devices(
>  	struct bdev_handle	*logdev_handle = NULL, *rtdev_handle = NULL;
>  	int			error;
>  
> -	/*
> -	 * blkdev_put() can't be called under s_umount, see the comment
> -	 * in get_tree_bdev() for more details
> -	 */
> -	up_write(&sb->s_umount);
> -
>  	/*
>  	 * Open real time and log devices - order is important.
>  	 */
>  	if (mp->m_logname) {
>  		error = xfs_blkdev_get(mp, mp->m_logname, &logdev_handle);
>  		if (error)
> -			goto out_relock;
> +			return error;
>  	}
>  
>  	if (mp->m_rtname) {
> @@ -492,10 +486,7 @@ xfs_open_devices(
>  			bdev_release(logdev_handle);
>  	}
>  
> -	error = 0;
> -out_relock:
> -	down_write(&sb->s_umount);
> -	return error;
> +	return 0;
>  
>   out_free_rtdev_targ:
>  	if (mp->m_rtdev_targp)
> @@ -508,7 +499,7 @@ xfs_open_devices(
>   out_close_logdev:
>  	if (logdev_handle)
>  		bdev_release(logdev_handle);
> -	goto out_relock;
> +	return error;
>  }
>  
>  /*
> @@ -758,10 +749,6 @@ static void
>  xfs_mount_free(
>  	struct xfs_mount	*mp)
>  {
> -	/*
> -	 * Free the buftargs here because blkdev_put needs to be called outside
> -	 * of sb->s_umount, which is held around the call to ->put_super.
> -	 */
>  	if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp)
>  		xfs_free_buftarg(mp->m_logdev_targp);
>  	if (mp->m_rtdev_targp)
> 
> -- 
> 2.34.1
>
Christoph Hellwig Oct. 27, 2023, 6:42 a.m. UTC | #2
Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index f0ae07828153..84107d162e41 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -437,19 +437,13 @@  xfs_open_devices(
 	struct bdev_handle	*logdev_handle = NULL, *rtdev_handle = NULL;
 	int			error;
 
-	/*
-	 * blkdev_put() can't be called under s_umount, see the comment
-	 * in get_tree_bdev() for more details
-	 */
-	up_write(&sb->s_umount);
-
 	/*
 	 * Open real time and log devices - order is important.
 	 */
 	if (mp->m_logname) {
 		error = xfs_blkdev_get(mp, mp->m_logname, &logdev_handle);
 		if (error)
-			goto out_relock;
+			return error;
 	}
 
 	if (mp->m_rtname) {
@@ -492,10 +486,7 @@  xfs_open_devices(
 			bdev_release(logdev_handle);
 	}
 
-	error = 0;
-out_relock:
-	down_write(&sb->s_umount);
-	return error;
+	return 0;
 
  out_free_rtdev_targ:
 	if (mp->m_rtdev_targp)
@@ -508,7 +499,7 @@  xfs_open_devices(
  out_close_logdev:
 	if (logdev_handle)
 		bdev_release(logdev_handle);
-	goto out_relock;
+	return error;
 }
 
 /*
@@ -758,10 +749,6 @@  static void
 xfs_mount_free(
 	struct xfs_mount	*mp)
 {
-	/*
-	 * Free the buftargs here because blkdev_put needs to be called outside
-	 * of sb->s_umount, which is held around the call to ->put_super.
-	 */
 	if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp)
 		xfs_free_buftarg(mp->m_logdev_targp);
 	if (mp->m_rtdev_targp)