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