diff options
author | Christoph Hellwig <hch@lst.de> | 2016-09-18 21:09:28 -0400 |
---|---|---|
committer | Dave Chinner <david@fromorbit.com> | 2016-09-18 21:09:28 -0400 |
commit | f8e3a8257538af8dbdd15d098c0cfba6ccbabe7a (patch) | |
tree | 760a12f5d4064d713c80c837f9c733c91552c467 | |
parent | e9c4973638beff4b346d802fd9443975b041035d (diff) |
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: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
-rw-r--r-- | fs/xfs/xfs_iomap.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index ba3592f3b98c..918511ae115c 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c | |||
@@ -70,15 +70,13 @@ xfs_bmbt_to_iomap( | |||
70 | iomap->bdev = xfs_find_bdev_for_inode(VFS_I(ip)); | 70 | iomap->bdev = xfs_find_bdev_for_inode(VFS_I(ip)); |
71 | } | 71 | } |
72 | 72 | ||
73 | STATIC int | 73 | static xfs_extlen_t |
74 | xfs_iomap_eof_align_last_fsb( | 74 | xfs_eof_alignment( |
75 | xfs_mount_t *mp, | 75 | struct xfs_inode *ip, |
76 | xfs_inode_t *ip, | 76 | xfs_extlen_t extsize) |
77 | xfs_extlen_t extsize, | ||
78 | xfs_fileoff_t *last_fsb) | ||
79 | { | 77 | { |
80 | xfs_extlen_t align = 0; | 78 | struct xfs_mount *mp = ip->i_mount; |
81 | int eof, error; | 79 | xfs_extlen_t align = 0; |
82 | 80 | ||
83 | if (!XFS_IS_REALTIME_INODE(ip)) { | 81 | if (!XFS_IS_REALTIME_INODE(ip)) { |
84 | /* | 82 | /* |
@@ -109,8 +107,21 @@ xfs_iomap_eof_align_last_fsb( | |||
109 | align = extsize; | 107 | align = extsize; |
110 | } | 108 | } |
111 | 109 | ||
110 | return align; | ||
111 | } | ||
112 | |||
113 | STATIC int | ||
114 | xfs_iomap_eof_align_last_fsb( | ||
115 | struct xfs_inode *ip, | ||
116 | xfs_extlen_t extsize, | ||
117 | xfs_fileoff_t *last_fsb) | ||
118 | { | ||
119 | xfs_extlen_t align = xfs_eof_alignment(ip, extsize); | ||
120 | |||
112 | if (align) { | 121 | if (align) { |
113 | xfs_fileoff_t new_last_fsb = roundup_64(*last_fsb, align); | 122 | xfs_fileoff_t new_last_fsb = roundup_64(*last_fsb, align); |
123 | int eof, error; | ||
124 | |||
114 | error = xfs_bmap_eof(ip, new_last_fsb, XFS_DATA_FORK, &eof); | 125 | error = xfs_bmap_eof(ip, new_last_fsb, XFS_DATA_FORK, &eof); |
115 | if (error) | 126 | if (error) |
116 | return error; | 127 | return error; |
@@ -180,7 +191,7 @@ xfs_iomap_write_direct( | |||
180 | */ | 191 | */ |
181 | ASSERT(XFS_IFORK_PTR(ip, XFS_DATA_FORK)->if_flags & | 192 | ASSERT(XFS_IFORK_PTR(ip, XFS_DATA_FORK)->if_flags & |
182 | XFS_IFEXTENTS); | 193 | XFS_IFEXTENTS); |
183 | error = xfs_iomap_eof_align_last_fsb(mp, ip, extsz, &last_fsb); | 194 | error = xfs_iomap_eof_align_last_fsb(ip, extsz, &last_fsb); |
184 | if (error) | 195 | if (error) |
185 | goto out_unlock; | 196 | goto out_unlock; |
186 | } else { | 197 | } else { |
@@ -638,7 +649,7 @@ retry: | |||
638 | } | 649 | } |
639 | 650 | ||
640 | if (prealloc || extsz) { | 651 | if (prealloc || extsz) { |
641 | error = xfs_iomap_eof_align_last_fsb(mp, ip, extsz, &last_fsb); | 652 | error = xfs_iomap_eof_align_last_fsb(ip, extsz, &last_fsb); |
642 | if (error) | 653 | if (error) |
643 | return error; | 654 | return error; |
644 | } | 655 | } |