aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Chinner <david@fromorbit.com>2009-06-08 09:35:07 -0400
committerChristoph Hellwig <hch@brick.lst.de>2009-06-08 09:35:07 -0400
commit1da8eecab5f866b4f5be43adbaadf18e259a8cc5 (patch)
tree0edb76f83331e1844e01e451afe5eb67774bf6d4
parent845b6d0cbbc2304e8a54ed4038272c55f85b2269 (diff)
xfs: factor out inode validation for sync
Separate the validation of inodes found by the radix tree walk from the radix tree lookup. Signed-off-by: Dave Chinner <david@fromorbit.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Eric Sandeen <sandeen@sandeen.net>
-rw-r--r--fs/xfs/linux-2.6/xfs_sync.c59
1 files changed, 37 insertions, 22 deletions
diff --git a/fs/xfs/linux-2.6/xfs_sync.c b/fs/xfs/linux-2.6/xfs_sync.c
index 1712caa12017..c91d5b2a568e 100644
--- a/fs/xfs/linux-2.6/xfs_sync.c
+++ b/fs/xfs/linux-2.6/xfs_sync.c
@@ -49,6 +49,39 @@
49#include <linux/freezer.h> 49#include <linux/freezer.h>
50 50
51 51
52/* must be called with pag_ici_lock held and releases it */
53STATIC int
54xfs_sync_inode_valid(
55 struct xfs_inode *ip,
56 struct xfs_perag *pag)
57{
58 struct inode *inode = VFS_I(ip);
59
60 /* nothing to sync during shutdown */
61 if (XFS_FORCED_SHUTDOWN(ip->i_mount)) {
62 read_unlock(&pag->pag_ici_lock);
63 return EFSCORRUPTED;
64 }
65
66 /*
67 * If we can't get a reference on the inode, it must be in reclaim.
68 * Leave it for the reclaim code to flush. Also avoid inodes that
69 * haven't been fully initialised.
70 */
71 if (!igrab(inode)) {
72 read_unlock(&pag->pag_ici_lock);
73 return ENOENT;
74 }
75 read_unlock(&pag->pag_ici_lock);
76
77 if (is_bad_inode(inode) || xfs_iflags_test(ip, XFS_INEW)) {
78 IRELE(ip);
79 return ENOENT;
80 }
81
82 return 0;
83}
84
52STATIC int 85STATIC int
53xfs_sync_inode_data( 86xfs_sync_inode_data(
54 struct xfs_inode *ip, 87 struct xfs_inode *ip,
@@ -123,7 +156,6 @@ xfs_sync_inodes_ag(
123 int last_error = 0; 156 int last_error = 0;
124 157
125 do { 158 do {
126 struct inode *inode;
127 xfs_inode_t *ip = NULL; 159 xfs_inode_t *ip = NULL;
128 160
129 /* 161 /*
@@ -152,27 +184,10 @@ xfs_sync_inodes_ag(
152 break; 184 break;
153 } 185 }
154 186
155 /* nothing to sync during shutdown */ 187 error = xfs_sync_inode_valid(ip, pag);
156 if (XFS_FORCED_SHUTDOWN(mp)) { 188 if (error) {
157 read_unlock(&pag->pag_ici_lock); 189 if (error == EFSCORRUPTED)
158 return 0; 190 return 0;
159 }
160
161 /*
162 * If we can't get a reference on the inode, it must be
163 * in reclaim. Leave it for the reclaim code to flush.
164 */
165 inode = VFS_I(ip);
166 if (!igrab(inode)) {
167 read_unlock(&pag->pag_ici_lock);
168 continue;
169 }
170 read_unlock(&pag->pag_ici_lock);
171
172 /* avoid new or bad inodes */
173 if (is_bad_inode(inode) ||
174 xfs_iflags_test(ip, XFS_INEW)) {
175 IRELE(ip);
176 continue; 191 continue;
177 } 192 }
178 193