diff options
-rw-r--r-- | fs/xfs/linux-2.6/xfs_sync.c | 52 |
1 files changed, 32 insertions, 20 deletions
diff --git a/fs/xfs/linux-2.6/xfs_sync.c b/fs/xfs/linux-2.6/xfs_sync.c index b06b95c154cc..7adc62dd14bb 100644 --- a/fs/xfs/linux-2.6/xfs_sync.c +++ b/fs/xfs/linux-2.6/xfs_sync.c | |||
@@ -48,6 +48,35 @@ | |||
48 | #include <linux/kthread.h> | 48 | #include <linux/kthread.h> |
49 | #include <linux/freezer.h> | 49 | #include <linux/freezer.h> |
50 | 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 | |||
51 | /* | 80 | /* |
52 | * Sync all the inodes in the given AG according to the | 81 | * Sync all the inodes in the given AG according to the |
53 | * direction given by the flags. | 82 | * direction given by the flags. |
@@ -123,27 +152,10 @@ xfs_sync_inodes_ag( | |||
123 | * If we have to flush data or wait for I/O completion | 152 | * If we have to flush data or wait for I/O completion |
124 | * we need to hold the iolock. | 153 | * we need to hold the iolock. |
125 | */ | 154 | */ |
126 | if (flags & SYNC_DELWRI) { | 155 | if (flags & SYNC_DELWRI) |
127 | if (VN_DIRTY(inode)) { | 156 | error = xfs_sync_inode_data(ip, flags); |
128 | if (flags & SYNC_TRYLOCK) { | ||
129 | if (xfs_ilock_nowait(ip, XFS_IOLOCK_SHARED)) | ||
130 | lock_flags |= XFS_IOLOCK_SHARED; | ||
131 | } else { | ||
132 | xfs_ilock(ip, XFS_IOLOCK_SHARED); | ||
133 | lock_flags |= XFS_IOLOCK_SHARED; | ||
134 | } | ||
135 | if (lock_flags & XFS_IOLOCK_SHARED) { | ||
136 | error = xfs_flush_pages(ip, 0, -1, | ||
137 | (flags & SYNC_WAIT) ? 0 | ||
138 | : XFS_B_ASYNC, | ||
139 | FI_NONE); | ||
140 | } | ||
141 | } | ||
142 | if (VN_CACHED(inode) && (flags & SYNC_IOWAIT)) | ||
143 | xfs_ioend_wait(ip); | ||
144 | } | ||
145 | xfs_ilock(ip, XFS_ILOCK_SHARED); | ||
146 | 157 | ||
158 | xfs_ilock(ip, XFS_ILOCK_SHARED); | ||
147 | if ((flags & SYNC_ATTR) && !xfs_inode_clean(ip)) { | 159 | if ((flags & SYNC_ATTR) && !xfs_inode_clean(ip)) { |
148 | if (flags & SYNC_WAIT) { | 160 | if (flags & SYNC_WAIT) { |
149 | xfs_iflock(ip); | 161 | xfs_iflock(ip); |