Commit f8e3a825 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Dave Chinner

xfs: factor our a helper to calculate the EOF alignment

And drop the pointless mp argument to xfs_iomap_eof_align_last_fsb,
while we're at it.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
parent e9c49736
...@@ -70,15 +70,13 @@ xfs_bmbt_to_iomap( ...@@ -70,15 +70,13 @@ xfs_bmbt_to_iomap(
iomap->bdev = xfs_find_bdev_for_inode(VFS_I(ip)); iomap->bdev = xfs_find_bdev_for_inode(VFS_I(ip));
} }
STATIC int static xfs_extlen_t
xfs_iomap_eof_align_last_fsb( xfs_eof_alignment(
xfs_mount_t *mp, struct xfs_inode *ip,
xfs_inode_t *ip, xfs_extlen_t extsize)
xfs_extlen_t extsize,
xfs_fileoff_t *last_fsb)
{ {
xfs_extlen_t align = 0; struct xfs_mount *mp = ip->i_mount;
int eof, error; xfs_extlen_t align = 0;
if (!XFS_IS_REALTIME_INODE(ip)) { if (!XFS_IS_REALTIME_INODE(ip)) {
/* /*
...@@ -109,8 +107,21 @@ xfs_iomap_eof_align_last_fsb( ...@@ -109,8 +107,21 @@ xfs_iomap_eof_align_last_fsb(
align = extsize; 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) { if (align) {
xfs_fileoff_t new_last_fsb = roundup_64(*last_fsb, 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); error = xfs_bmap_eof(ip, new_last_fsb, XFS_DATA_FORK, &eof);
if (error) if (error)
return error; return error;
...@@ -180,7 +191,7 @@ xfs_iomap_write_direct( ...@@ -180,7 +191,7 @@ xfs_iomap_write_direct(
*/ */
ASSERT(XFS_IFORK_PTR(ip, XFS_DATA_FORK)->if_flags & ASSERT(XFS_IFORK_PTR(ip, XFS_DATA_FORK)->if_flags &
XFS_IFEXTENTS); 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) if (error)
goto out_unlock; goto out_unlock;
} else { } else {
...@@ -638,7 +649,7 @@ xfs_iomap_write_delay( ...@@ -638,7 +649,7 @@ xfs_iomap_write_delay(
} }
if (prealloc || extsz) { 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) if (error)
return error; return error;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment