xfs: split inode data writeback from xfs_sync_inodes_ag

In many cases we only want to sync inode data. Start spliting the inode sync
into data sync and inode sync by factoring out the inode data flush.

[hch: minor cleanups]

Signed-off-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Eric Sandeen <sandeen@sandeen.net>

authored by

Dave Chinner and committed by
Christoph Hellwig
5a34d5cd 7d095257

+32 -20
+32 -20
fs/xfs/linux-2.6/xfs_sync.c
··· 48 #include <linux/kthread.h> 49 #include <linux/freezer.h> 50 51 /* 52 * Sync all the inodes in the given AG according to the 53 * direction given by the flags. ··· 152 * If we have to flush data or wait for I/O completion 153 * we need to hold the iolock. 154 */ 155 - if (flags & SYNC_DELWRI) { 156 - if (VN_DIRTY(inode)) { 157 - if (flags & SYNC_TRYLOCK) { 158 - if (xfs_ilock_nowait(ip, XFS_IOLOCK_SHARED)) 159 - lock_flags |= XFS_IOLOCK_SHARED; 160 - } else { 161 - xfs_ilock(ip, XFS_IOLOCK_SHARED); 162 - lock_flags |= XFS_IOLOCK_SHARED; 163 - } 164 - if (lock_flags & XFS_IOLOCK_SHARED) { 165 - error = xfs_flush_pages(ip, 0, -1, 166 - (flags & SYNC_WAIT) ? 0 167 - : XFS_B_ASYNC, 168 - FI_NONE); 169 - } 170 - } 171 - if (VN_CACHED(inode) && (flags & SYNC_IOWAIT)) 172 - xfs_ioend_wait(ip); 173 - } 174 - xfs_ilock(ip, XFS_ILOCK_SHARED); 175 176 if ((flags & SYNC_ATTR) && !xfs_inode_clean(ip)) { 177 if (flags & SYNC_WAIT) { 178 xfs_iflock(ip);
··· 48 #include <linux/kthread.h> 49 #include <linux/freezer.h> 50 51 + 52 + STATIC int 53 + xfs_sync_inode_data( 54 + struct xfs_inode *ip, 55 + int flags) 56 + { 57 + struct inode *inode = VFS_I(ip); 58 + struct address_space *mapping = inode->i_mapping; 59 + int error = 0; 60 + 61 + if (!mapping_tagged(mapping, PAGECACHE_TAG_DIRTY)) 62 + goto out_wait; 63 + 64 + if (!xfs_ilock_nowait(ip, XFS_IOLOCK_SHARED)) { 65 + if (flags & SYNC_TRYLOCK) 66 + goto out_wait; 67 + xfs_ilock(ip, XFS_IOLOCK_SHARED); 68 + } 69 + 70 + error = xfs_flush_pages(ip, 0, -1, (flags & SYNC_WAIT) ? 71 + 0 : XFS_B_ASYNC, FI_NONE); 72 + xfs_iunlock(ip, XFS_IOLOCK_SHARED); 73 + 74 + out_wait: 75 + if (flags & SYNC_IOWAIT) 76 + xfs_ioend_wait(ip); 77 + return error; 78 + } 79 + 80 /* 81 * Sync all the inodes in the given AG according to the 82 * direction given by the flags. ··· 123 * If we have to flush data or wait for I/O completion 124 * we need to hold the iolock. 125 */ 126 + if (flags & SYNC_DELWRI) 127 + error = xfs_sync_inode_data(ip, flags); 128 129 + xfs_ilock(ip, XFS_ILOCK_SHARED); 130 if ((flags & SYNC_ATTR) && !xfs_inode_clean(ip)) { 131 if (flags & SYNC_WAIT) { 132 xfs_iflock(ip);