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>

authored by

Dave Chinner and committed by
Christoph Hellwig
1da8eeca 845b6d0c

+37 -22
+37 -22
fs/xfs/linux-2.6/xfs_sync.c
··· 49 49 #include <linux/freezer.h> 50 50 51 51 52 + /* must be called with pag_ici_lock held and releases it */ 53 + STATIC int 54 + xfs_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 + 52 85 STATIC int 53 86 xfs_sync_inode_data( 54 87 struct xfs_inode *ip, ··· 156 123 int last_error = 0; 157 124 158 125 do { 159 - struct inode *inode; 160 126 xfs_inode_t *ip = NULL; 161 127 162 128 /* ··· 184 152 break; 185 153 } 186 154 187 - /* nothing to sync during shutdown */ 188 - if (XFS_FORCED_SHUTDOWN(mp)) { 189 - read_unlock(&pag->pag_ici_lock); 190 - return 0; 191 - } 192 - 193 - /* 194 - * If we can't get a reference on the inode, it must be 195 - * in reclaim. Leave it for the reclaim code to flush. 196 - */ 197 - inode = VFS_I(ip); 198 - if (!igrab(inode)) { 199 - read_unlock(&pag->pag_ici_lock); 200 - continue; 201 - } 202 - read_unlock(&pag->pag_ici_lock); 203 - 204 - /* avoid new or bad inodes */ 205 - if (is_bad_inode(inode) || 206 - xfs_iflags_test(ip, XFS_INEW)) { 207 - IRELE(ip); 155 + error = xfs_sync_inode_valid(ip, pag); 156 + if (error) { 157 + if (error == EFSCORRUPTED) 158 + return 0; 208 159 continue; 209 160 } 210 161