diff mbox

[2/4] xfs: factor our a helper to calculate the EOF alignment

Message ID 1471816273-28940-3-git-send-email-hch@lst.de (mailing list archive)
State Accepted
Headers show

Commit Message

Christoph Hellwig Aug. 21, 2016, 9:51 p.m. UTC
And drop the pointless mp argument to xfs_iomap_eof_align_last_fsb,
while we're at it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_iomap.c | 31 +++++++++++++++++++++----------
 1 file changed, 21 insertions(+), 10 deletions(-)

Comments

Brian Foster Aug. 25, 2016, 12:38 p.m. UTC | #1
On Sun, Aug 21, 2016 at 11:51:11PM +0200, Christoph Hellwig wrote:
> And drop the pointless mp argument to xfs_iomap_eof_align_last_fsb,
> while we're at it.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  fs/xfs/xfs_iomap.c | 31 +++++++++++++++++++++----------
>  1 file changed, 21 insertions(+), 10 deletions(-)
> 
> diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
> index ba3592f..918511a 100644
> --- a/fs/xfs/xfs_iomap.c
> +++ b/fs/xfs/xfs_iomap.c
> @@ -70,15 +70,13 @@ xfs_bmbt_to_iomap(
>  	iomap->bdev = xfs_find_bdev_for_inode(VFS_I(ip));
>  }
>  
> -STATIC int
> -xfs_iomap_eof_align_last_fsb(
> -	xfs_mount_t	*mp,
> -	xfs_inode_t	*ip,
> -	xfs_extlen_t	extsize,
> -	xfs_fileoff_t	*last_fsb)
> +static xfs_extlen_t
> +xfs_eof_alignment(
> +	struct xfs_inode	*ip,
> +	xfs_extlen_t		extsize)
>  {
> -	xfs_extlen_t	align = 0;
> -	int		eof, error;
> +	struct xfs_mount	*mp = ip->i_mount;
> +	xfs_extlen_t		align = 0;
>  
>  	if (!XFS_IS_REALTIME_INODE(ip)) {
>  		/*
> @@ -109,8 +107,21 @@ xfs_iomap_eof_align_last_fsb(
>  			align = extsize;
>  	}
>  
> +	return align;
> +}
> +
> +STATIC int
> +xfs_iomap_eof_align_last_fsb(
> +	struct xfs_inode	*ip,
> +	xfs_extlen_t		extsize,
> +	xfs_fileoff_t		*last_fsb)
> +{
> +	xfs_extlen_t		align = xfs_eof_alignment(ip, extsize);
> +
>  	if (align) {
>  		xfs_fileoff_t	new_last_fsb = roundup_64(*last_fsb, align);
> +		int		eof, error;
> +
>  		error = xfs_bmap_eof(ip, new_last_fsb, XFS_DATA_FORK, &eof);
>  		if (error)
>  			return error;
> @@ -180,7 +191,7 @@ xfs_iomap_write_direct(
>  		 */
>  		ASSERT(XFS_IFORK_PTR(ip, XFS_DATA_FORK)->if_flags &
>  								XFS_IFEXTENTS);
> -		error = xfs_iomap_eof_align_last_fsb(mp, ip, extsz, &last_fsb);
> +		error = xfs_iomap_eof_align_last_fsb(ip, extsz, &last_fsb);
>  		if (error)
>  			goto out_unlock;
>  	} else {
> @@ -638,7 +649,7 @@ retry:
>  	}
>  
>  	if (prealloc || extsz) {
> -		error = xfs_iomap_eof_align_last_fsb(mp, ip, extsz, &last_fsb);
> +		error = xfs_iomap_eof_align_last_fsb(ip, extsz, &last_fsb);
>  		if (error)
>  			return error;
>  	}
> -- 
> 2.1.4
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
diff mbox

Patch

diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index ba3592f..918511a 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -70,15 +70,13 @@  xfs_bmbt_to_iomap(
 	iomap->bdev = xfs_find_bdev_for_inode(VFS_I(ip));
 }
 
-STATIC int
-xfs_iomap_eof_align_last_fsb(
-	xfs_mount_t	*mp,
-	xfs_inode_t	*ip,
-	xfs_extlen_t	extsize,
-	xfs_fileoff_t	*last_fsb)
+static xfs_extlen_t
+xfs_eof_alignment(
+	struct xfs_inode	*ip,
+	xfs_extlen_t		extsize)
 {
-	xfs_extlen_t	align = 0;
-	int		eof, error;
+	struct xfs_mount	*mp = ip->i_mount;
+	xfs_extlen_t		align = 0;
 
 	if (!XFS_IS_REALTIME_INODE(ip)) {
 		/*
@@ -109,8 +107,21 @@  xfs_iomap_eof_align_last_fsb(
 			align = extsize;
 	}
 
+	return align;
+}
+
+STATIC int
+xfs_iomap_eof_align_last_fsb(
+	struct xfs_inode	*ip,
+	xfs_extlen_t		extsize,
+	xfs_fileoff_t		*last_fsb)
+{
+	xfs_extlen_t		align = xfs_eof_alignment(ip, extsize);
+
 	if (align) {
 		xfs_fileoff_t	new_last_fsb = roundup_64(*last_fsb, align);
+		int		eof, error;
+
 		error = xfs_bmap_eof(ip, new_last_fsb, XFS_DATA_FORK, &eof);
 		if (error)
 			return error;
@@ -180,7 +191,7 @@  xfs_iomap_write_direct(
 		 */
 		ASSERT(XFS_IFORK_PTR(ip, XFS_DATA_FORK)->if_flags &
 								XFS_IFEXTENTS);
-		error = xfs_iomap_eof_align_last_fsb(mp, ip, extsz, &last_fsb);
+		error = xfs_iomap_eof_align_last_fsb(ip, extsz, &last_fsb);
 		if (error)
 			goto out_unlock;
 	} else {
@@ -638,7 +649,7 @@  retry:
 	}
 
 	if (prealloc || extsz) {
-		error = xfs_iomap_eof_align_last_fsb(mp, ip, extsz, &last_fsb);
+		error = xfs_iomap_eof_align_last_fsb(ip, extsz, &last_fsb);
 		if (error)
 			return error;
 	}