diff mbox series

xfs: simplify the local variables assignment

Message ID 1650382606-22553-1-git-send-email-kaixuxia@tencent.com (mailing list archive)
State New, archived
Headers show
Series xfs: simplify the local variables assignment | expand

Commit Message

Kaixu Xia April 19, 2022, 3:36 p.m. UTC
From: Kaixu Xia <kaixuxia@tencent.com>

Get the struct inode pointer from iocb->ki_filp->f_mapping->host directly
and the other variables are unnecessary, so simplify the local variables
assignment.

Signed-off-by: Kaixu Xia <kaixuxia@tencent.com>
---
 fs/xfs/xfs_file.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

Comments

Darrick J. Wong April 19, 2022, 5:13 p.m. UTC | #1
On Tue, Apr 19, 2022 at 11:36:46PM +0800, xiakaixu1987@gmail.com wrote:
> From: Kaixu Xia <kaixuxia@tencent.com>
> 
> Get the struct inode pointer from iocb->ki_filp->f_mapping->host directly
> and the other variables are unnecessary, so simplify the local variables
> assignment.
> 
> Signed-off-by: Kaixu Xia <kaixuxia@tencent.com>

Assuming this compiles on the maintainer's for-next branch, I think
you're correct that @file and @mapping are no longer needed.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
>  fs/xfs/xfs_file.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
> index 5bddb1e9e0b3..691e98fe4eee 100644
> --- a/fs/xfs/xfs_file.c
> +++ b/fs/xfs/xfs_file.c
> @@ -694,9 +694,7 @@ xfs_file_buffered_write(
>  	struct kiocb		*iocb,
>  	struct iov_iter		*from)
>  {
> -	struct file		*file = iocb->ki_filp;
> -	struct address_space	*mapping = file->f_mapping;
> -	struct inode		*inode = mapping->host;
> +	struct inode		*inode = iocb->ki_filp->f_mapping->host;
>  	struct xfs_inode	*ip = XFS_I(inode);
>  	ssize_t			ret;
>  	bool			cleared_space = false;
> @@ -767,9 +765,7 @@ xfs_file_write_iter(
>  	struct kiocb		*iocb,
>  	struct iov_iter		*from)
>  {
> -	struct file		*file = iocb->ki_filp;
> -	struct address_space	*mapping = file->f_mapping;
> -	struct inode		*inode = mapping->host;
> +	struct inode		*inode = iocb->ki_filp->f_mapping->host;
>  	struct xfs_inode	*ip = XFS_I(inode);
>  	ssize_t			ret;
>  	size_t			ocount = iov_iter_count(from);
> -- 
> 2.27.0
>
Christoph Hellwig April 24, 2022, 5:30 a.m. UTC | #2
Looks good:

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

Patch

diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index 5bddb1e9e0b3..691e98fe4eee 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -694,9 +694,7 @@  xfs_file_buffered_write(
 	struct kiocb		*iocb,
 	struct iov_iter		*from)
 {
-	struct file		*file = iocb->ki_filp;
-	struct address_space	*mapping = file->f_mapping;
-	struct inode		*inode = mapping->host;
+	struct inode		*inode = iocb->ki_filp->f_mapping->host;
 	struct xfs_inode	*ip = XFS_I(inode);
 	ssize_t			ret;
 	bool			cleared_space = false;
@@ -767,9 +765,7 @@  xfs_file_write_iter(
 	struct kiocb		*iocb,
 	struct iov_iter		*from)
 {
-	struct file		*file = iocb->ki_filp;
-	struct address_space	*mapping = file->f_mapping;
-	struct inode		*inode = mapping->host;
+	struct inode		*inode = iocb->ki_filp->f_mapping->host;
 	struct xfs_inode	*ip = XFS_I(inode);
 	ssize_t			ret;
 	size_t			ocount = iov_iter_count(from);