aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Chinner <dgc@sgi.com>2006-11-11 02:04:54 -0500
committerTim Shimmin <tes@sgi.com>2006-11-11 02:04:54 -0500
commit7a18c386078eaf17ae54595f66c0d64d9c1cb29c (patch)
treed3194ced5802969f78cbd21c9d99dc01c622bb51
parent2e2e7bb1fd857b9fc83b0cd77b6b647ebb423301 (diff)
[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>
-rw-r--r--fs/xfs/linux-2.6/xfs_super.c4
-rw-r--r--fs/xfs/xfs_iget.c20
-rw-r--r--fs/xfs/xfs_inode.c17
-rw-r--r--fs/xfs/xfs_inode.h41
-rw-r--r--fs/xfs/xfs_vnodeops.c10
5 files changed, 57 insertions, 35 deletions
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c
index 38c4d128a8c0..de05abbbe7fd 100644
--- a/fs/xfs/linux-2.6/xfs_super.c
+++ b/fs/xfs/linux-2.6/xfs_super.c
@@ -227,9 +227,7 @@ xfs_initialize_vnode(
227 xfs_revalidate_inode(XFS_BHVTOM(bdp), vp, ip); 227 xfs_revalidate_inode(XFS_BHVTOM(bdp), vp, ip);
228 xfs_set_inodeops(inode); 228 xfs_set_inodeops(inode);
229 229
230 spin_lock(&ip->i_flags_lock); 230 xfs_iflags_clear(ip, XFS_INEW);
231 ip->i_flags &= ~XFS_INEW;
232 spin_unlock(&ip->i_flags_lock);
233 barrier(); 231 barrier();
234 232
235 unlock_new_inode(inode); 233 unlock_new_inode(inode);
diff --git a/fs/xfs/xfs_iget.c b/fs/xfs/xfs_iget.c
index 1562ac2dd67c..4b0c1881d6d5 100644
--- a/fs/xfs/xfs_iget.c
+++ b/fs/xfs/xfs_iget.c
@@ -215,7 +215,7 @@ again:
215 * If INEW is set this inode is being set up 215 * If INEW is set this inode is being set up
216 * we need to pause and try again. 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 read_unlock(&ih->ih_lock); 219 read_unlock(&ih->ih_lock);
220 delay(1); 220 delay(1);
221 XFS_STATS_INC(xs_ig_frecycle); 221 XFS_STATS_INC(xs_ig_frecycle);
@@ -230,7 +230,7 @@ again:
230 * on its way out of the system, 230 * on its way out of the system,
231 * we need to pause and try again. 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 read_unlock(&ih->ih_lock); 234 read_unlock(&ih->ih_lock);
235 delay(1); 235 delay(1);
236 XFS_STATS_INC(xs_ig_frecycle); 236 XFS_STATS_INC(xs_ig_frecycle);
@@ -243,9 +243,7 @@ again:
243 243
244 XFS_STATS_INC(xs_ig_found); 244 XFS_STATS_INC(xs_ig_found);
245 245
246 spin_lock(&ip->i_flags_lock); 246 xfs_iflags_clear(ip, XFS_IRECLAIMABLE);
247 ip->i_flags &= ~XFS_IRECLAIMABLE;
248 spin_unlock(&ip->i_flags_lock);
249 version = ih->ih_version; 247 version = ih->ih_version;
250 read_unlock(&ih->ih_lock); 248 read_unlock(&ih->ih_lock);
251 xfs_ihash_promote(ih, ip, version); 249 xfs_ihash_promote(ih, ip, version);
@@ -299,10 +297,7 @@ finish_inode:
299 if (lock_flags != 0) 297 if (lock_flags != 0)
300 xfs_ilock(ip, lock_flags); 298 xfs_ilock(ip, lock_flags);
301 299
302 spin_lock(&ip->i_flags_lock); 300 xfs_iflags_clear(ip, XFS_ISTALE);
303 ip->i_flags &= ~XFS_ISTALE;
304 spin_unlock(&ip->i_flags_lock);
305
306 vn_trace_exit(vp, "xfs_iget.found", 301 vn_trace_exit(vp, "xfs_iget.found",
307 (inst_t *)__return_address); 302 (inst_t *)__return_address);
308 goto return_ip; 303 goto return_ip;
@@ -371,10 +366,7 @@ finish_inode:
371 ih->ih_next = ip; 366 ih->ih_next = ip;
372 ip->i_udquot = ip->i_gdquot = NULL; 367 ip->i_udquot = ip->i_gdquot = NULL;
373 ih->ih_version++; 368 ih->ih_version++;
374 spin_lock(&ip->i_flags_lock); 369 xfs_iflags_set(ip, XFS_INEW);
375 ip->i_flags |= XFS_INEW;
376 spin_unlock(&ip->i_flags_lock);
377
378 write_unlock(&ih->ih_lock); 370 write_unlock(&ih->ih_lock);
379 371
380 /* 372 /*
@@ -625,7 +617,7 @@ xfs_iput_new(xfs_inode_t *ip,
625 vn_trace_entry(vp, "xfs_iput_new", (inst_t *)__return_address); 617 vn_trace_entry(vp, "xfs_iput_new", (inst_t *)__return_address);
626 618
627 if ((ip->i_d.di_mode == 0)) { 619 if ((ip->i_d.di_mode == 0)) {
628 ASSERT(!(ip->i_flags & XFS_IRECLAIMABLE)); 620 ASSERT(!xfs_iflags_test(ip, XFS_IRECLAIMABLE));
629 vn_mark_bad(vp); 621 vn_mark_bad(vp);
630 } 622 }
631 if (inode->i_state & I_NEW) 623 if (inode->i_state & I_NEW)
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index c27d7d495aa0..17d2a471751e 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -2193,7 +2193,7 @@ xfs_ifree_cluster(
2193 /* Inode not in memory or we found it already, 2193 /* Inode not in memory or we found it already,
2194 * nothing to do 2194 * nothing to do
2195 */ 2195 */
2196 if (!ip || (ip->i_flags & XFS_ISTALE)) { 2196 if (!ip || xfs_iflags_test(ip, XFS_ISTALE)) {
2197 read_unlock(&ih->ih_lock); 2197 read_unlock(&ih->ih_lock);
2198 continue; 2198 continue;
2199 } 2199 }
@@ -2215,10 +2215,7 @@ xfs_ifree_cluster(
2215 2215
2216 if (ip == free_ip) { 2216 if (ip == free_ip) {
2217 if (xfs_iflock_nowait(ip)) { 2217 if (xfs_iflock_nowait(ip)) {
2218 spin_lock(&ip->i_flags_lock); 2218 xfs_iflags_set(ip, XFS_ISTALE);
2219 ip->i_flags |= XFS_ISTALE;
2220 spin_unlock(&ip->i_flags_lock);
2221
2222 if (xfs_inode_clean(ip)) { 2219 if (xfs_inode_clean(ip)) {
2223 xfs_ifunlock(ip); 2220 xfs_ifunlock(ip);
2224 } else { 2221 } else {
@@ -2231,9 +2228,7 @@ xfs_ifree_cluster(
2231 2228
2232 if (xfs_ilock_nowait(ip, XFS_ILOCK_EXCL)) { 2229 if (xfs_ilock_nowait(ip, XFS_ILOCK_EXCL)) {
2233 if (xfs_iflock_nowait(ip)) { 2230 if (xfs_iflock_nowait(ip)) {
2234 spin_lock(&ip->i_flags_lock); 2231 xfs_iflags_set(ip, XFS_ISTALE);
2235 ip->i_flags |= XFS_ISTALE;
2236 spin_unlock(&ip->i_flags_lock);
2237 2232
2238 if (xfs_inode_clean(ip)) { 2233 if (xfs_inode_clean(ip)) {
2239 xfs_ifunlock(ip); 2234 xfs_ifunlock(ip);
@@ -2263,9 +2258,7 @@ xfs_ifree_cluster(
2263 AIL_LOCK(mp,s); 2258 AIL_LOCK(mp,s);
2264 iip->ili_flush_lsn = iip->ili_item.li_lsn; 2259 iip->ili_flush_lsn = iip->ili_item.li_lsn;
2265 AIL_UNLOCK(mp, s); 2260 AIL_UNLOCK(mp, s);
2266 spin_lock(&iip->ili_inode->i_flags_lock); 2261 xfs_iflags_set(ip, XFS_ISTALE);
2267 iip->ili_inode->i_flags |= XFS_ISTALE;
2268 spin_unlock(&iip->ili_inode->i_flags_lock);
2269 pre_flushed++; 2262 pre_flushed++;
2270 } 2263 }
2271 lip = lip->li_bio_list; 2264 lip = lip->li_bio_list;
@@ -2764,7 +2757,7 @@ xfs_iunpin(
2764 struct inode *inode = NULL; 2757 struct inode *inode = NULL;
2765 2758
2766 spin_lock(&ip->i_flags_lock); 2759 spin_lock(&ip->i_flags_lock);
2767 if (!(ip->i_flags & (XFS_IRECLAIM|XFS_IRECLAIMABLE))) { 2760 if (!__xfs_iflags_test(ip, XFS_IRECLAIM|XFS_IRECLAIMABLE)) {
2768 bhv_vnode_t *vp = XFS_ITOV_NULL(ip); 2761 bhv_vnode_t *vp = XFS_ITOV_NULL(ip);
2769 2762
2770 /* make sync come back and flush this inode */ 2763 /* make sync come back and flush this inode */
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index e96eb0835fe6..bc823720d88f 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -305,6 +305,47 @@ typedef struct xfs_inode {
305#endif 305#endif
306} xfs_inode_t; 306} xfs_inode_t;
307 307
308
309/*
310 * i_flags helper functions
311 */
312static inline void
313__xfs_iflags_set(xfs_inode_t *ip, unsigned short flags)
314{
315 ip->i_flags |= flags;
316}
317
318static inline void
319xfs_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
326static inline void
327xfs_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
334static inline int
335__xfs_iflags_test(xfs_inode_t *ip, unsigned short flags)
336{
337 return (ip->i_flags & flags);
338}
339
340static inline int
341xfs_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#endif /* __KERNEL__ */ 349#endif /* __KERNEL__ */
309 350
310 351
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
index 2c79c3670589..4c5d73cbb901 100644
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -3844,9 +3844,7 @@ xfs_reclaim(
3844 XFS_MOUNT_ILOCK(mp); 3844 XFS_MOUNT_ILOCK(mp);
3845 vn_bhv_remove(VN_BHV_HEAD(vp), XFS_ITOBHV(ip)); 3845 vn_bhv_remove(VN_BHV_HEAD(vp), XFS_ITOBHV(ip));
3846 list_add_tail(&ip->i_reclaim, &mp->m_del_inodes); 3846 list_add_tail(&ip->i_reclaim, &mp->m_del_inodes);
3847 spin_lock(&ip->i_flags_lock); 3847 xfs_iflags_set(ip, XFS_IRECLAIMABLE);
3848 ip->i_flags |= XFS_IRECLAIMABLE;
3849 spin_unlock(&ip->i_flags_lock);
3850 XFS_MOUNT_IUNLOCK(mp); 3848 XFS_MOUNT_IUNLOCK(mp);
3851 } 3849 }
3852 return 0; 3850 return 0;
@@ -3872,8 +3870,8 @@ xfs_finish_reclaim(
3872 */ 3870 */
3873 write_lock(&ih->ih_lock); 3871 write_lock(&ih->ih_lock);
3874 spin_lock(&ip->i_flags_lock); 3872 spin_lock(&ip->i_flags_lock);
3875 if ((ip->i_flags & XFS_IRECLAIM) || 3873 if (__xfs_iflags_test(ip, XFS_IRECLAIM) ||
3876 (!(ip->i_flags & XFS_IRECLAIMABLE) && vp == NULL)) { 3874 (!__xfs_iflags_test(ip, XFS_IRECLAIMABLE) && vp == NULL)) {
3877 spin_unlock(&ip->i_flags_lock); 3875 spin_unlock(&ip->i_flags_lock);
3878 write_unlock(&ih->ih_lock); 3876 write_unlock(&ih->ih_lock);
3879 if (locked) { 3877 if (locked) {
@@ -3882,7 +3880,7 @@ xfs_finish_reclaim(
3882 } 3880 }
3883 return 1; 3881 return 1;
3884 } 3882 }
3885 ip->i_flags |= XFS_IRECLAIM; 3883 __xfs_iflags_set(ip, XFS_IRECLAIM);
3886 spin_unlock(&ip->i_flags_lock); 3884 spin_unlock(&ip->i_flags_lock);
3887 write_unlock(&ih->ih_lock); 3885 write_unlock(&ih->ih_lock);
3888 3886