aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2012-02-29 04:53:49 -0500
committerBen Myers <bpm@sgi.com>2012-03-05 12:19:26 -0500
commit6923e686f19cb7017fc9777a10e06c2e2b2a2936 (patch)
tree14398306804485fd7c0f04538d76f042f5cec6d9 /fs
parentaa6bf01d391935a8929333bc2e243084ea0c58db (diff)
xfs: do not require an ioend for new EOF calculation
Replace xfs_ioend_new_eof with a new inline xfs_new_eof helper that doesn't require and ioend, and is available also outside of xfs_aops.c. Also make the code a bit more clear by using a normal if statement instead of a slightly misleading MIN(). Reviewed-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Mark Tinguely <tinguely@sgi.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/xfs_aops.c24
-rw-r--r--fs/xfs/xfs_inode.h14
2 files changed, 18 insertions, 20 deletions
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index 540a01742c6d..745492b6c666 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -99,23 +99,6 @@ xfs_destroy_ioend(
99} 99}
100 100
101/* 101/*
102 * If the end of the current ioend is beyond the current EOF,
103 * return the new EOF value, otherwise zero.
104 */
105STATIC xfs_fsize_t
106xfs_ioend_new_eof(
107 xfs_ioend_t *ioend)
108{
109 xfs_inode_t *ip = XFS_I(ioend->io_inode);
110 xfs_fsize_t isize;
111 xfs_fsize_t bsize;
112
113 bsize = ioend->io_offset + ioend->io_size;
114 isize = MIN(i_size_read(VFS_I(ip)), bsize);
115 return isize > ip->i_d.di_size ? isize : 0;
116}
117
118/*
119 * Fast and loose check if this write could update the on-disk inode size. 102 * Fast and loose check if this write could update the on-disk inode size.
120 */ 103 */
121static inline bool xfs_ioend_is_append(struct xfs_ioend *ioend) 104static inline bool xfs_ioend_is_append(struct xfs_ioend *ioend)
@@ -135,7 +118,7 @@ xfs_setfilesize(
135 xfs_fsize_t isize; 118 xfs_fsize_t isize;
136 119
137 xfs_ilock(ip, XFS_ILOCK_EXCL); 120 xfs_ilock(ip, XFS_ILOCK_EXCL);
138 isize = xfs_ioend_new_eof(ioend); 121 isize = xfs_new_eof(ip, ioend->io_offset + ioend->io_size);
139 if (isize) { 122 if (isize) {
140 trace_xfs_setfilesize(ip, ioend->io_offset, ioend->io_size); 123 trace_xfs_setfilesize(ip, ioend->io_offset, ioend->io_size);
141 ip->i_d.di_size = isize; 124 ip->i_d.di_size = isize;
@@ -357,6 +340,7 @@ xfs_submit_ioend_bio(
357 xfs_ioend_t *ioend, 340 xfs_ioend_t *ioend,
358 struct bio *bio) 341 struct bio *bio)
359{ 342{
343 struct xfs_inode *ip = XFS_I(ioend->io_inode);
360 atomic_inc(&ioend->io_remaining); 344 atomic_inc(&ioend->io_remaining);
361 bio->bi_private = ioend; 345 bio->bi_private = ioend;
362 bio->bi_end_io = xfs_end_bio; 346 bio->bi_end_io = xfs_end_bio;
@@ -365,8 +349,8 @@ xfs_submit_ioend_bio(
365 * If the I/O is beyond EOF we mark the inode dirty immediately 349 * If the I/O is beyond EOF we mark the inode dirty immediately
366 * but don't update the inode size until I/O completion. 350 * but don't update the inode size until I/O completion.
367 */ 351 */
368 if (xfs_ioend_new_eof(ioend)) 352 if (xfs_new_eof(ip, ioend->io_offset + ioend->io_size))
369 xfs_mark_inode_dirty(XFS_I(ioend->io_inode)); 353 xfs_mark_inode_dirty(ip);
370 354
371 submit_bio(wbc->sync_mode == WB_SYNC_ALL ? WRITE_SYNC : WRITE, bio); 355 submit_bio(wbc->sync_mode == WB_SYNC_ALL ? WRITE_SYNC : WRITE, bio);
372} 356}
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index eda493780395..7f90469141d7 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -275,6 +275,20 @@ static inline xfs_fsize_t XFS_ISIZE(struct xfs_inode *ip)
275} 275}
276 276
277/* 277/*
278 * If this I/O goes past the on-disk inode size update it unless it would
279 * be past the current in-core inode size.
280 */
281static inline xfs_fsize_t
282xfs_new_eof(struct xfs_inode *ip, xfs_fsize_t new_size)
283{
284 xfs_fsize_t i_size = i_size_read(VFS_I(ip));
285
286 if (new_size > i_size)
287 new_size = i_size;
288 return new_size > ip->i_d.di_size ? new_size : 0;
289}
290
291/*
278 * i_flags helper functions 292 * i_flags helper functions
279 */ 293 */
280static inline void 294static inline void