xfs: remove xfs_flush_pages
authorDave Chinner <dchinner@redhat.com>
Mon, 12 Nov 2012 11:53:56 +0000 (22:53 +1100)
committerBen Myers <bpm@sgi.com>
Wed, 14 Nov 2012 21:12:45 +0000 (15:12 -0600)
It is a complex wrapper around VFS functions, but there are VFS
functions that provide exactly the same functionality. Call the VFS
functions directly and remove the unnecessary indirection and
complexity.

We don't need to care about clearing the XFS_ITRUNCATED flag, as
that is done during .writepages. Hence is cleared by the VFS
writeback path if there is anything to write back during the flush.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Andrew Dahl <adahl@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
fs/xfs/xfs_aops.c
fs/xfs/xfs_bmap.c
fs/xfs/xfs_fs_subr.c
fs/xfs/xfs_iops.c
fs/xfs/xfs_vnodeops.c
fs/xfs/xfs_vnodeops.h

index e57e2daa357c34fc9634871a1d41dd76569cf871..71361da1f77c02b55e4e2647942ced86e0aec3a8 100644 (file)
@@ -1641,7 +1641,7 @@ xfs_vm_bmap(
 
        trace_xfs_vm_bmap(XFS_I(inode));
        xfs_ilock(ip, XFS_IOLOCK_SHARED);
-       xfs_flush_pages(ip, (xfs_off_t)0, -1, 0, FI_REMAPF);
+       filemap_write_and_wait(mapping);
        xfs_iunlock(ip, XFS_IOLOCK_SHARED);
        return generic_block_bmap(mapping, block, xfs_get_blocks);
 }
index 83d0cf3df930794c307c4adcb33dceb8a5415f7e..a60f3d1f151c3f58d0ad81ccc221900a71f0b5d0 100644 (file)
@@ -5599,7 +5599,7 @@ xfs_getbmap(
        xfs_ilock(ip, XFS_IOLOCK_SHARED);
        if (whichfork == XFS_DATA_FORK && !(iflags & BMV_IF_DELALLOC)) {
                if (ip->i_delayed_blks || XFS_ISIZE(ip) > ip->i_d.di_size) {
-                       error = xfs_flush_pages(ip, 0, -1, 0, FI_REMAPF);
+                       error = -filemap_write_and_wait(VFS_I(ip)->i_mapping);
                        if (error)
                                goto out_unlock_iolock;
                }
index 33658234dfc50aa217bda1cd55f2fe0d2c569d0b..b5380893728e67ddc915d7452b93d3d53f2d1aac 100644 (file)
@@ -44,27 +44,3 @@ xfs_flushinval_pages(
                truncate_inode_pages_range(mapping, first, last);
        return -ret;
 }
-
-int
-xfs_flush_pages(
-       xfs_inode_t     *ip,
-       xfs_off_t       first,
-       xfs_off_t       last,
-       uint64_t        flags,
-       int             fiopt)
-{
-       struct address_space *mapping = VFS_I(ip)->i_mapping;
-       int             ret = 0;
-       int             ret2;
-
-       xfs_iflags_clear(ip, XFS_ITRUNCATED);
-       ret = -filemap_fdatawrite_range(mapping, first,
-                               last == -1 ? LLONG_MAX : last);
-       if (flags & XBF_ASYNC)
-               return ret;
-       ret2 = -filemap_fdatawait_range(mapping, first,
-                               last == -1 ? XFS_ISIZE(ip) - 1 : last);
-       if (!ret)
-               ret = ret2;
-       return ret;
-}
index 81f5c495328758a70f58502065b5dc3d72c749ed..d82efaa2ac7350553c8804c014c5f299809af178 100644 (file)
@@ -780,8 +780,8 @@ xfs_setattr_size(
         * care about here.
         */
        if (oldsize != ip->i_d.di_size && newsize > ip->i_d.di_size) {
-               error = xfs_flush_pages(ip, ip->i_d.di_size, newsize, 0,
-                                       FI_NONE);
+               error = -filemap_write_and_wait_range(VFS_I(ip)->i_mapping,
+                                                     ip->i_d.di_size, newsize);
                if (error)
                        goto out_unlock;
        }
index 46a7a5de5d6d5f36a53fe36a7beac0680abd49ec..c00326afa7bf33fea6d178ed51e4c2dadf6c6c38 100644 (file)
@@ -428,8 +428,11 @@ xfs_release(
                truncated = xfs_iflags_test_and_clear(ip, XFS_ITRUNCATED);
                if (truncated) {
                        xfs_iflags_clear(ip, XFS_IDIRTY_RELEASE);
-                       if (VN_DIRTY(VFS_I(ip)) && ip->i_delayed_blks > 0)
-                               xfs_flush_pages(ip, 0, -1, XBF_ASYNC, FI_NONE);
+                       if (VN_DIRTY(VFS_I(ip)) && ip->i_delayed_blks > 0) {
+                               error = -filemap_flush(VFS_I(ip)->i_mapping);
+                               if (error)
+                                       return error;
+                       }
                }
        }
 
index c8ad48b61a25246b2aef4b109687dac2e2b6bef1..73cb3cb15f75b6aea9df9cfb3351dcd3945e6fae 100644 (file)
@@ -50,8 +50,6 @@ int xfs_attr_list(struct xfs_inode *dp, char *buffer, int bufsize,
                int flags, struct attrlist_cursor_kern *cursor);
 int xfs_flushinval_pages(struct xfs_inode *ip, xfs_off_t first,
                xfs_off_t last, int fiopt);
-int xfs_flush_pages(struct xfs_inode *ip, xfs_off_t first,
-               xfs_off_t last, uint64_t flags, int fiopt);
 
 int xfs_zero_eof(struct xfs_inode *, xfs_off_t, xfs_fsize_t);
 int xfs_free_eofblocks(struct xfs_mount *, struct xfs_inode *, bool);