[XFS] Clean up i_flags and i_flags_lock handling.

SGI-PV: 956832
SGI-Modid: xfs-linux-melb:xfs-kern:27358a

Signed-off-by: David Chinner <dgc@sgi.com>
Signed-off-by: Nathan Scott <nscott@aconex.com>
Signed-off-by: Tim Shimmin <tes@sgi.com>

authored by David Chinner and committed by Tim Shimmin 7a18c386 2e2e7bb1

+57 -35
+1 -3
fs/xfs/linux-2.6/xfs_super.c
··· 227 xfs_revalidate_inode(XFS_BHVTOM(bdp), vp, ip); 228 xfs_set_inodeops(inode); 229 230 - spin_lock(&ip->i_flags_lock); 231 - ip->i_flags &= ~XFS_INEW; 232 - spin_unlock(&ip->i_flags_lock); 233 barrier(); 234 235 unlock_new_inode(inode);
··· 227 xfs_revalidate_inode(XFS_BHVTOM(bdp), vp, ip); 228 xfs_set_inodeops(inode); 229 230 + xfs_iflags_clear(ip, XFS_INEW); 231 barrier(); 232 233 unlock_new_inode(inode);
+6 -14
fs/xfs/xfs_iget.c
··· 215 * If INEW is set this inode is being set up 216 * we need to pause and try again. 217 */ 218 - if (ip->i_flags & XFS_INEW) { 219 read_unlock(&ih->ih_lock); 220 delay(1); 221 XFS_STATS_INC(xs_ig_frecycle); ··· 230 * on its way out of the system, 231 * we need to pause and try again. 232 */ 233 - if (ip->i_flags & XFS_IRECLAIM) { 234 read_unlock(&ih->ih_lock); 235 delay(1); 236 XFS_STATS_INC(xs_ig_frecycle); ··· 243 244 XFS_STATS_INC(xs_ig_found); 245 246 - spin_lock(&ip->i_flags_lock); 247 - ip->i_flags &= ~XFS_IRECLAIMABLE; 248 - spin_unlock(&ip->i_flags_lock); 249 version = ih->ih_version; 250 read_unlock(&ih->ih_lock); 251 xfs_ihash_promote(ih, ip, version); ··· 297 if (lock_flags != 0) 298 xfs_ilock(ip, lock_flags); 299 300 - spin_lock(&ip->i_flags_lock); 301 - ip->i_flags &= ~XFS_ISTALE; 302 - spin_unlock(&ip->i_flags_lock); 303 - 304 vn_trace_exit(vp, "xfs_iget.found", 305 (inst_t *)__return_address); 306 goto return_ip; ··· 366 ih->ih_next = ip; 367 ip->i_udquot = ip->i_gdquot = NULL; 368 ih->ih_version++; 369 - spin_lock(&ip->i_flags_lock); 370 - ip->i_flags |= XFS_INEW; 371 - spin_unlock(&ip->i_flags_lock); 372 - 373 write_unlock(&ih->ih_lock); 374 375 /* ··· 617 vn_trace_entry(vp, "xfs_iput_new", (inst_t *)__return_address); 618 619 if ((ip->i_d.di_mode == 0)) { 620 - ASSERT(!(ip->i_flags & XFS_IRECLAIMABLE)); 621 vn_mark_bad(vp); 622 } 623 if (inode->i_state & I_NEW)
··· 215 * If INEW is set this inode is being set up 216 * we need to pause and try again. 217 */ 218 + if (xfs_iflags_test(ip, XFS_INEW)) { 219 read_unlock(&ih->ih_lock); 220 delay(1); 221 XFS_STATS_INC(xs_ig_frecycle); ··· 230 * on its way out of the system, 231 * we need to pause and try again. 232 */ 233 + if (xfs_iflags_test(ip, XFS_IRECLAIM)) { 234 read_unlock(&ih->ih_lock); 235 delay(1); 236 XFS_STATS_INC(xs_ig_frecycle); ··· 243 244 XFS_STATS_INC(xs_ig_found); 245 246 + xfs_iflags_clear(ip, XFS_IRECLAIMABLE); 247 version = ih->ih_version; 248 read_unlock(&ih->ih_lock); 249 xfs_ihash_promote(ih, ip, version); ··· 299 if (lock_flags != 0) 300 xfs_ilock(ip, lock_flags); 301 302 + xfs_iflags_clear(ip, XFS_ISTALE); 303 vn_trace_exit(vp, "xfs_iget.found", 304 (inst_t *)__return_address); 305 goto return_ip; ··· 371 ih->ih_next = ip; 372 ip->i_udquot = ip->i_gdquot = NULL; 373 ih->ih_version++; 374 + xfs_iflags_set(ip, XFS_INEW); 375 write_unlock(&ih->ih_lock); 376 377 /* ··· 625 vn_trace_entry(vp, "xfs_iput_new", (inst_t *)__return_address); 626 627 if ((ip->i_d.di_mode == 0)) { 628 + ASSERT(!xfs_iflags_test(ip, XFS_IRECLAIMABLE)); 629 vn_mark_bad(vp); 630 } 631 if (inode->i_state & I_NEW)
+5 -12
fs/xfs/xfs_inode.c
··· 2193 /* Inode not in memory or we found it already, 2194 * nothing to do 2195 */ 2196 - if (!ip || (ip->i_flags & XFS_ISTALE)) { 2197 read_unlock(&ih->ih_lock); 2198 continue; 2199 } ··· 2215 2216 if (ip == free_ip) { 2217 if (xfs_iflock_nowait(ip)) { 2218 - spin_lock(&ip->i_flags_lock); 2219 - ip->i_flags |= XFS_ISTALE; 2220 - spin_unlock(&ip->i_flags_lock); 2221 - 2222 if (xfs_inode_clean(ip)) { 2223 xfs_ifunlock(ip); 2224 } else { ··· 2228 2229 if (xfs_ilock_nowait(ip, XFS_ILOCK_EXCL)) { 2230 if (xfs_iflock_nowait(ip)) { 2231 - spin_lock(&ip->i_flags_lock); 2232 - ip->i_flags |= XFS_ISTALE; 2233 - spin_unlock(&ip->i_flags_lock); 2234 2235 if (xfs_inode_clean(ip)) { 2236 xfs_ifunlock(ip); ··· 2258 AIL_LOCK(mp,s); 2259 iip->ili_flush_lsn = iip->ili_item.li_lsn; 2260 AIL_UNLOCK(mp, s); 2261 - spin_lock(&iip->ili_inode->i_flags_lock); 2262 - iip->ili_inode->i_flags |= XFS_ISTALE; 2263 - spin_unlock(&iip->ili_inode->i_flags_lock); 2264 pre_flushed++; 2265 } 2266 lip = lip->li_bio_list; ··· 2757 struct inode *inode = NULL; 2758 2759 spin_lock(&ip->i_flags_lock); 2760 - if (!(ip->i_flags & (XFS_IRECLAIM|XFS_IRECLAIMABLE))) { 2761 bhv_vnode_t *vp = XFS_ITOV_NULL(ip); 2762 2763 /* make sync come back and flush this inode */
··· 2193 /* Inode not in memory or we found it already, 2194 * nothing to do 2195 */ 2196 + if (!ip || xfs_iflags_test(ip, XFS_ISTALE)) { 2197 read_unlock(&ih->ih_lock); 2198 continue; 2199 } ··· 2215 2216 if (ip == free_ip) { 2217 if (xfs_iflock_nowait(ip)) { 2218 + xfs_iflags_set(ip, XFS_ISTALE); 2219 if (xfs_inode_clean(ip)) { 2220 xfs_ifunlock(ip); 2221 } else { ··· 2231 2232 if (xfs_ilock_nowait(ip, XFS_ILOCK_EXCL)) { 2233 if (xfs_iflock_nowait(ip)) { 2234 + xfs_iflags_set(ip, XFS_ISTALE); 2235 2236 if (xfs_inode_clean(ip)) { 2237 xfs_ifunlock(ip); ··· 2263 AIL_LOCK(mp,s); 2264 iip->ili_flush_lsn = iip->ili_item.li_lsn; 2265 AIL_UNLOCK(mp, s); 2266 + xfs_iflags_set(ip, XFS_ISTALE); 2267 pre_flushed++; 2268 } 2269 lip = lip->li_bio_list; ··· 2764 struct inode *inode = NULL; 2765 2766 spin_lock(&ip->i_flags_lock); 2767 + if (!__xfs_iflags_test(ip, XFS_IRECLAIM|XFS_IRECLAIMABLE)) { 2768 bhv_vnode_t *vp = XFS_ITOV_NULL(ip); 2769 2770 /* make sync come back and flush this inode */
+41
fs/xfs/xfs_inode.h
··· 305 #endif 306 } xfs_inode_t; 307 308 #endif /* __KERNEL__ */ 309 310
··· 305 #endif 306 } xfs_inode_t; 307 308 + 309 + /* 310 + * i_flags helper functions 311 + */ 312 + static inline void 313 + __xfs_iflags_set(xfs_inode_t *ip, unsigned short flags) 314 + { 315 + ip->i_flags |= flags; 316 + } 317 + 318 + static inline void 319 + xfs_iflags_set(xfs_inode_t *ip, unsigned short flags) 320 + { 321 + spin_lock(&ip->i_flags_lock); 322 + __xfs_iflags_set(ip, flags); 323 + spin_unlock(&ip->i_flags_lock); 324 + } 325 + 326 + static inline void 327 + xfs_iflags_clear(xfs_inode_t *ip, unsigned short flags) 328 + { 329 + spin_lock(&ip->i_flags_lock); 330 + ip->i_flags &= ~flags; 331 + spin_unlock(&ip->i_flags_lock); 332 + } 333 + 334 + static inline int 335 + __xfs_iflags_test(xfs_inode_t *ip, unsigned short flags) 336 + { 337 + return (ip->i_flags & flags); 338 + } 339 + 340 + static inline int 341 + xfs_iflags_test(xfs_inode_t *ip, unsigned short flags) 342 + { 343 + int ret; 344 + spin_lock(&ip->i_flags_lock); 345 + ret = __xfs_iflags_test(ip, flags); 346 + spin_unlock(&ip->i_flags_lock); 347 + return ret; 348 + } 349 #endif /* __KERNEL__ */ 350 351
+4 -6
fs/xfs/xfs_vnodeops.c
··· 3844 XFS_MOUNT_ILOCK(mp); 3845 vn_bhv_remove(VN_BHV_HEAD(vp), XFS_ITOBHV(ip)); 3846 list_add_tail(&ip->i_reclaim, &mp->m_del_inodes); 3847 - spin_lock(&ip->i_flags_lock); 3848 - ip->i_flags |= XFS_IRECLAIMABLE; 3849 - spin_unlock(&ip->i_flags_lock); 3850 XFS_MOUNT_IUNLOCK(mp); 3851 } 3852 return 0; ··· 3870 */ 3871 write_lock(&ih->ih_lock); 3872 spin_lock(&ip->i_flags_lock); 3873 - if ((ip->i_flags & XFS_IRECLAIM) || 3874 - (!(ip->i_flags & XFS_IRECLAIMABLE) && vp == NULL)) { 3875 spin_unlock(&ip->i_flags_lock); 3876 write_unlock(&ih->ih_lock); 3877 if (locked) { ··· 3880 } 3881 return 1; 3882 } 3883 - ip->i_flags |= XFS_IRECLAIM; 3884 spin_unlock(&ip->i_flags_lock); 3885 write_unlock(&ih->ih_lock); 3886
··· 3844 XFS_MOUNT_ILOCK(mp); 3845 vn_bhv_remove(VN_BHV_HEAD(vp), XFS_ITOBHV(ip)); 3846 list_add_tail(&ip->i_reclaim, &mp->m_del_inodes); 3847 + xfs_iflags_set(ip, XFS_IRECLAIMABLE); 3848 XFS_MOUNT_IUNLOCK(mp); 3849 } 3850 return 0; ··· 3872 */ 3873 write_lock(&ih->ih_lock); 3874 spin_lock(&ip->i_flags_lock); 3875 + if (__xfs_iflags_test(ip, XFS_IRECLAIM) || 3876 + (!__xfs_iflags_test(ip, XFS_IRECLAIMABLE) && vp == NULL)) { 3877 spin_unlock(&ip->i_flags_lock); 3878 write_unlock(&ih->ih_lock); 3879 if (locked) { ··· 3882 } 3883 return 1; 3884 } 3885 + __xfs_iflags_set(ip, XFS_IRECLAIM); 3886 spin_unlock(&ip->i_flags_lock); 3887 write_unlock(&ih->ih_lock); 3888