aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/linux-2.6/xfs_sync.c
diff options
context:
space:
mode:
authorDavid Chinner <david@fromorbit.com>2008-10-30 02:15:03 -0400
committerLachlan McIlroy <lachlan@sgi.com>2008-10-30 02:15:03 -0400
commitbc60a99323b3ec628273b5fa998285c87d464ca6 (patch)
tree5084bb53b48d1b9ba3ceed8a3995296cc21840c5 /fs/xfs/linux-2.6/xfs_sync.c
parent2af75df7be7ca86965bf73766f827575d1c26fbd (diff)
[XFS] Use struct inodes instead of vnodes to kill vn_grab
With the sync code relocated to the linux-2.6 directory we can use struct inodes directly. If we do the same thing for the quota release code, we can remove vn_grab altogether. While here, convert the VN_BAD() checks to is_bad_inode() so we can remove vnodes entirely from this code. SGI-PV: 988140 SGI-Modid: xfs-linux-melb:xfs-kern:32304a Signed-off-by: David Chinner <david@fromorbit.com> Signed-off-by: Lachlan McIlroy <lachlan@sgi.com> Signed-off-by: Christoph Hellwig <hch@infradead.org>
Diffstat (limited to 'fs/xfs/linux-2.6/xfs_sync.c')
-rw-r--r--fs/xfs/linux-2.6/xfs_sync.c53
1 files changed, 26 insertions, 27 deletions
diff --git a/fs/xfs/linux-2.6/xfs_sync.c b/fs/xfs/linux-2.6/xfs_sync.c
index 59da3327a6b5..461c1dc35d37 100644
--- a/fs/xfs/linux-2.6/xfs_sync.c
+++ b/fs/xfs/linux-2.6/xfs_sync.c
@@ -131,10 +131,7 @@ xfs_sync_inodes_ag(
131 int flags, 131 int flags,
132 int *bypassed) 132 int *bypassed)
133{ 133{
134 xfs_inode_t *ip = NULL;
135 struct inode *vp = NULL;
136 xfs_perag_t *pag = &mp->m_perag[ag]; 134 xfs_perag_t *pag = &mp->m_perag[ag];
137 boolean_t vnode_refed = B_FALSE;
138 int nr_found; 135 int nr_found;
139 int first_index = 0; 136 int first_index = 0;
140 int error = 0; 137 int error = 0;
@@ -156,6 +153,10 @@ xfs_sync_inodes_ag(
156 } 153 }
157 154
158 do { 155 do {
156 struct inode *inode;
157 boolean_t inode_refed;
158 xfs_inode_t *ip = NULL;
159
159 /* 160 /*
160 * use a gang lookup to find the next inode in the tree 161 * use a gang lookup to find the next inode in the tree
161 * as the tree is sparse and a gang lookup walks to find 162 * as the tree is sparse and a gang lookup walks to find
@@ -177,14 +178,14 @@ xfs_sync_inodes_ag(
177 * skip inodes in reclaim. Let xfs_syncsub do that for 178 * skip inodes in reclaim. Let xfs_syncsub do that for
178 * us so we don't need to worry. 179 * us so we don't need to worry.
179 */ 180 */
180 vp = VFS_I(ip); 181 if (xfs_iflags_test(ip, (XFS_IRECLAIM|XFS_IRECLAIMABLE))) {
181 if (!vp) {
182 read_unlock(&pag->pag_ici_lock); 182 read_unlock(&pag->pag_ici_lock);
183 continue; 183 continue;
184 } 184 }
185 185
186 /* bad inodes are dealt with elsewhere */ 186 /* bad inodes are dealt with elsewhere */
187 if (VN_BAD(vp)) { 187 inode = VFS_I(ip);
188 if (is_bad_inode(inode)) {
188 read_unlock(&pag->pag_ici_lock); 189 read_unlock(&pag->pag_ici_lock);
189 continue; 190 continue;
190 } 191 }
@@ -196,30 +197,29 @@ xfs_sync_inodes_ag(
196 } 197 }
197 198
198 /* 199 /*
199 * The inode lock here actually coordinates with the almost 200 * If we can't get a reference on the VFS_I, the inode must be
200 * spurious inode lock in xfs_ireclaim() to prevent the vnode 201 * in reclaim. If we can get the inode lock without blocking,
201 * we handle here without a reference from being freed while we 202 * it is safe to flush the inode because we hold the tree lock
202 * reference it. If we lock the inode while it's on the mount 203 * and xfs_iextract will block right now. Hence if we lock the
203 * list here, then the spurious inode lock in xfs_ireclaim() 204 * inode while holding the tree lock, xfs_ireclaim() is
204 * after the inode is pulled from the mount list will sleep 205 * guaranteed to block on the inode lock we now hold and hence
205 * until we release it here. This keeps the vnode from being 206 * it is safe to reference the inode until we drop the inode
206 * freed while we reference it. 207 * locks completely.
207 */ 208 */
208 if (xfs_ilock_nowait(ip, lock_flags) == 0) { 209 inode_refed = B_FALSE;
209 vp = vn_grab(vp); 210 if (igrab(inode)) {
210 read_unlock(&pag->pag_ici_lock); 211 read_unlock(&pag->pag_ici_lock);
211 if (!vp)
212 continue;
213 xfs_ilock(ip, lock_flags); 212 xfs_ilock(ip, lock_flags);
214 213 inode_refed = B_TRUE;
215 ASSERT(vp == VFS_I(ip));
216 ASSERT(ip->i_mount == mp);
217
218 vnode_refed = B_TRUE;
219 } else { 214 } else {
220 /* safe to unlock here as we have a reference */ 215 if (!xfs_ilock_nowait(ip, lock_flags)) {
216 /* leave it to reclaim */
217 read_unlock(&pag->pag_ici_lock);
218 continue;
219 }
221 read_unlock(&pag->pag_ici_lock); 220 read_unlock(&pag->pag_ici_lock);
222 } 221 }
222
223 /* 223 /*
224 * If we have to flush data or wait for I/O completion 224 * If we have to flush data or wait for I/O completion
225 * we need to drop the ilock that we currently hold. 225 * we need to drop the ilock that we currently hold.
@@ -240,7 +240,7 @@ xfs_sync_inodes_ag(
240 xfs_ilock(ip, XFS_ILOCK_SHARED); 240 xfs_ilock(ip, XFS_ILOCK_SHARED);
241 } 241 }
242 242
243 if ((flags & SYNC_DELWRI) && VN_DIRTY(vp)) { 243 if ((flags & SYNC_DELWRI) && VN_DIRTY(inode)) {
244 xfs_iunlock(ip, XFS_ILOCK_SHARED); 244 xfs_iunlock(ip, XFS_ILOCK_SHARED);
245 error = xfs_flush_pages(ip, 0, -1, fflag, FI_NONE); 245 error = xfs_flush_pages(ip, 0, -1, fflag, FI_NONE);
246 if (flags & SYNC_IOWAIT) 246 if (flags & SYNC_IOWAIT)
@@ -268,9 +268,8 @@ xfs_sync_inodes_ag(
268 if (lock_flags) 268 if (lock_flags)
269 xfs_iunlock(ip, lock_flags); 269 xfs_iunlock(ip, lock_flags);
270 270
271 if (vnode_refed) { 271 if (inode_refed) {
272 IRELE(ip); 272 IRELE(ip);
273 vnode_refed = B_FALSE;
274 } 273 }
275 274
276 if (error) 275 if (error)