aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_iget.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/xfs_iget.c')
-rw-r--r--fs/xfs/xfs_iget.c127
1 files changed, 24 insertions, 103 deletions
diff --git a/fs/xfs/xfs_iget.c b/fs/xfs/xfs_iget.c
index 073bb4a26b19..fa402a6bbbcf 100644
--- a/fs/xfs/xfs_iget.c
+++ b/fs/xfs/xfs_iget.c
@@ -43,7 +43,7 @@
43#include "xfs_inode_item.h" 43#include "xfs_inode_item.h"
44#include "xfs_bmap.h" 44#include "xfs_bmap.h"
45#include "xfs_btree_trace.h" 45#include "xfs_btree_trace.h"
46#include "xfs_dir2_trace.h" 46#include "xfs_trace.h"
47 47
48 48
49/* 49/*
@@ -90,30 +90,8 @@ xfs_inode_alloc(
90 ip->i_size = 0; 90 ip->i_size = 0;
91 ip->i_new_size = 0; 91 ip->i_new_size = 0;
92 92
93 /*
94 * Initialize inode's trace buffers.
95 */
96#ifdef XFS_INODE_TRACE
97 ip->i_trace = ktrace_alloc(INODE_TRACE_SIZE, KM_NOFS);
98#endif
99#ifdef XFS_BMAP_TRACE
100 ip->i_xtrace = ktrace_alloc(XFS_BMAP_KTRACE_SIZE, KM_NOFS);
101#endif
102#ifdef XFS_BTREE_TRACE
103 ip->i_btrace = ktrace_alloc(XFS_BMBT_KTRACE_SIZE, KM_NOFS);
104#endif
105#ifdef XFS_RW_TRACE
106 ip->i_rwtrace = ktrace_alloc(XFS_RW_KTRACE_SIZE, KM_NOFS);
107#endif
108#ifdef XFS_ILOCK_TRACE
109 ip->i_lock_trace = ktrace_alloc(XFS_ILOCK_KTRACE_SIZE, KM_NOFS);
110#endif
111#ifdef XFS_DIR2_TRACE
112 ip->i_dir_trace = ktrace_alloc(XFS_DIR2_KTRACE_SIZE, KM_NOFS);
113#endif
114
115 /* prevent anyone from using this yet */ 93 /* prevent anyone from using this yet */
116 VFS_I(ip)->i_state = I_NEW|I_LOCK; 94 VFS_I(ip)->i_state = I_NEW;
117 95
118 return ip; 96 return ip;
119} 97}
@@ -133,25 +111,6 @@ xfs_inode_free(
133 if (ip->i_afp) 111 if (ip->i_afp)
134 xfs_idestroy_fork(ip, XFS_ATTR_FORK); 112 xfs_idestroy_fork(ip, XFS_ATTR_FORK);
135 113
136#ifdef XFS_INODE_TRACE
137 ktrace_free(ip->i_trace);
138#endif
139#ifdef XFS_BMAP_TRACE
140 ktrace_free(ip->i_xtrace);
141#endif
142#ifdef XFS_BTREE_TRACE
143 ktrace_free(ip->i_btrace);
144#endif
145#ifdef XFS_RW_TRACE
146 ktrace_free(ip->i_rwtrace);
147#endif
148#ifdef XFS_ILOCK_TRACE
149 ktrace_free(ip->i_lock_trace);
150#endif
151#ifdef XFS_DIR2_TRACE
152 ktrace_free(ip->i_dir_trace);
153#endif
154
155 if (ip->i_itemp) { 114 if (ip->i_itemp) {
156 /* 115 /*
157 * Only if we are shutting down the fs will we see an 116 * Only if we are shutting down the fs will we see an
@@ -210,6 +169,7 @@ xfs_iget_cache_hit(
210 * instead of polling for it. 169 * instead of polling for it.
211 */ 170 */
212 if (ip->i_flags & (XFS_INEW|XFS_IRECLAIM)) { 171 if (ip->i_flags & (XFS_INEW|XFS_IRECLAIM)) {
172 trace_xfs_iget_skip(ip);
213 XFS_STATS_INC(xs_ig_frecycle); 173 XFS_STATS_INC(xs_ig_frecycle);
214 error = EAGAIN; 174 error = EAGAIN;
215 goto out_error; 175 goto out_error;
@@ -228,7 +188,7 @@ xfs_iget_cache_hit(
228 * Need to carefully get it back into useable state. 188 * Need to carefully get it back into useable state.
229 */ 189 */
230 if (ip->i_flags & XFS_IRECLAIMABLE) { 190 if (ip->i_flags & XFS_IRECLAIMABLE) {
231 xfs_itrace_exit_tag(ip, "xfs_iget.alloc"); 191 trace_xfs_iget_reclaim(ip);
232 192
233 /* 193 /*
234 * We need to set XFS_INEW atomically with clearing the 194 * We need to set XFS_INEW atomically with clearing the
@@ -254,9 +214,10 @@ xfs_iget_cache_hit(
254 ip->i_flags &= ~XFS_INEW; 214 ip->i_flags &= ~XFS_INEW;
255 ip->i_flags |= XFS_IRECLAIMABLE; 215 ip->i_flags |= XFS_IRECLAIMABLE;
256 __xfs_inode_set_reclaim_tag(pag, ip); 216 __xfs_inode_set_reclaim_tag(pag, ip);
217 trace_xfs_iget_reclaim(ip);
257 goto out_error; 218 goto out_error;
258 } 219 }
259 inode->i_state = I_LOCK|I_NEW; 220 inode->i_state = I_NEW;
260 } else { 221 } else {
261 /* If the VFS inode is being torn down, pause and try again. */ 222 /* If the VFS inode is being torn down, pause and try again. */
262 if (!igrab(inode)) { 223 if (!igrab(inode)) {
@@ -273,8 +234,9 @@ xfs_iget_cache_hit(
273 xfs_ilock(ip, lock_flags); 234 xfs_ilock(ip, lock_flags);
274 235
275 xfs_iflags_clear(ip, XFS_ISTALE); 236 xfs_iflags_clear(ip, XFS_ISTALE);
276 xfs_itrace_exit_tag(ip, "xfs_iget.found");
277 XFS_STATS_INC(xs_ig_found); 237 XFS_STATS_INC(xs_ig_found);
238
239 trace_xfs_iget_found(ip);
278 return 0; 240 return 0;
279 241
280out_error: 242out_error:
@@ -308,7 +270,7 @@ xfs_iget_cache_miss(
308 if (error) 270 if (error)
309 goto out_destroy; 271 goto out_destroy;
310 272
311 xfs_itrace_exit_tag(ip, "xfs_iget.alloc"); 273 xfs_itrace_entry(ip);
312 274
313 if ((ip->i_d.di_mode == 0) && !(flags & XFS_IGET_CREATE)) { 275 if ((ip->i_d.di_mode == 0) && !(flags & XFS_IGET_CREATE)) {
314 error = ENOENT; 276 error = ENOENT;
@@ -353,6 +315,8 @@ xfs_iget_cache_miss(
353 315
354 write_unlock(&pag->pag_ici_lock); 316 write_unlock(&pag->pag_ici_lock);
355 radix_tree_preload_end(); 317 radix_tree_preload_end();
318
319 trace_xfs_iget_alloc(ip);
356 *ipp = ip; 320 *ipp = ip;
357 return 0; 321 return 0;
358 322
@@ -514,17 +478,21 @@ xfs_ireclaim(
514{ 478{
515 struct xfs_mount *mp = ip->i_mount; 479 struct xfs_mount *mp = ip->i_mount;
516 struct xfs_perag *pag; 480 struct xfs_perag *pag;
481 xfs_agino_t agino = XFS_INO_TO_AGINO(mp, ip->i_ino);
517 482
518 XFS_STATS_INC(xs_ig_reclaims); 483 XFS_STATS_INC(xs_ig_reclaims);
519 484
520 /* 485 /*
521 * Remove the inode from the per-AG radix tree. It doesn't matter 486 * Remove the inode from the per-AG radix tree.
522 * if it was never added to it because radix_tree_delete can deal 487 *
523 * with that case just fine. 488 * Because radix_tree_delete won't complain even if the item was never
489 * added to the tree assert that it's been there before to catch
490 * problems with the inode life time early on.
524 */ 491 */
525 pag = xfs_get_perag(mp, ip->i_ino); 492 pag = xfs_get_perag(mp, ip->i_ino);
526 write_lock(&pag->pag_ici_lock); 493 write_lock(&pag->pag_ici_lock);
527 radix_tree_delete(&pag->pag_ici_root, XFS_INO_TO_AGINO(mp, ip->i_ino)); 494 if (!radix_tree_delete(&pag->pag_ici_root, agino))
495 ASSERT(0);
528 write_unlock(&pag->pag_ici_lock); 496 write_unlock(&pag->pag_ici_lock);
529 xfs_put_perag(mp, pag); 497 xfs_put_perag(mp, pag);
530 498
@@ -639,7 +607,7 @@ xfs_ilock(
639 else if (lock_flags & XFS_ILOCK_SHARED) 607 else if (lock_flags & XFS_ILOCK_SHARED)
640 mraccess_nested(&ip->i_lock, XFS_ILOCK_DEP(lock_flags)); 608 mraccess_nested(&ip->i_lock, XFS_ILOCK_DEP(lock_flags));
641 609
642 xfs_ilock_trace(ip, 1, lock_flags, (inst_t *)__return_address); 610 trace_xfs_ilock(ip, lock_flags, _RET_IP_);
643} 611}
644 612
645/* 613/*
@@ -684,7 +652,7 @@ xfs_ilock_nowait(
684 if (!mrtryaccess(&ip->i_lock)) 652 if (!mrtryaccess(&ip->i_lock))
685 goto out_undo_iolock; 653 goto out_undo_iolock;
686 } 654 }
687 xfs_ilock_trace(ip, 2, lock_flags, (inst_t *)__return_address); 655 trace_xfs_ilock_nowait(ip, lock_flags, _RET_IP_);
688 return 1; 656 return 1;
689 657
690 out_undo_iolock: 658 out_undo_iolock:
@@ -746,7 +714,7 @@ xfs_iunlock(
746 xfs_trans_unlocked_item(ip->i_itemp->ili_item.li_ailp, 714 xfs_trans_unlocked_item(ip->i_itemp->ili_item.li_ailp,
747 (xfs_log_item_t*)(ip->i_itemp)); 715 (xfs_log_item_t*)(ip->i_itemp));
748 } 716 }
749 xfs_ilock_trace(ip, 3, lock_flags, (inst_t *)__return_address); 717 trace_xfs_iunlock(ip, lock_flags, _RET_IP_);
750} 718}
751 719
752/* 720/*
@@ -765,6 +733,8 @@ xfs_ilock_demote(
765 mrdemote(&ip->i_lock); 733 mrdemote(&ip->i_lock);
766 if (lock_flags & XFS_IOLOCK_EXCL) 734 if (lock_flags & XFS_IOLOCK_EXCL)
767 mrdemote(&ip->i_iolock); 735 mrdemote(&ip->i_iolock);
736
737 trace_xfs_ilock_demote(ip, lock_flags, _RET_IP_);
768} 738}
769 739
770#ifdef DEBUG 740#ifdef DEBUG
@@ -795,52 +765,3 @@ xfs_isilocked(
795 return 1; 765 return 1;
796} 766}
797#endif 767#endif
798
799#ifdef XFS_INODE_TRACE
800
801#define KTRACE_ENTER(ip, vk, s, line, ra) \
802 ktrace_enter((ip)->i_trace, \
803/* 0 */ (void *)(__psint_t)(vk), \
804/* 1 */ (void *)(s), \
805/* 2 */ (void *)(__psint_t) line, \
806/* 3 */ (void *)(__psint_t)atomic_read(&VFS_I(ip)->i_count), \
807/* 4 */ (void *)(ra), \
808/* 5 */ NULL, \
809/* 6 */ (void *)(__psint_t)current_cpu(), \
810/* 7 */ (void *)(__psint_t)current_pid(), \
811/* 8 */ (void *)__return_address, \
812/* 9 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL)
813
814/*
815 * Vnode tracing code.
816 */
817void
818_xfs_itrace_entry(xfs_inode_t *ip, const char *func, inst_t *ra)
819{
820 KTRACE_ENTER(ip, INODE_KTRACE_ENTRY, func, 0, ra);
821}
822
823void
824_xfs_itrace_exit(xfs_inode_t *ip, const char *func, inst_t *ra)
825{
826 KTRACE_ENTER(ip, INODE_KTRACE_EXIT, func, 0, ra);
827}
828
829void
830xfs_itrace_hold(xfs_inode_t *ip, char *file, int line, inst_t *ra)
831{
832 KTRACE_ENTER(ip, INODE_KTRACE_HOLD, file, line, ra);
833}
834
835void
836_xfs_itrace_ref(xfs_inode_t *ip, char *file, int line, inst_t *ra)
837{
838 KTRACE_ENTER(ip, INODE_KTRACE_REF, file, line, ra);
839}
840
841void
842xfs_itrace_rele(xfs_inode_t *ip, char *file, int line, inst_t *ra)
843{
844 KTRACE_ENTER(ip, INODE_KTRACE_RELE, file, line, ra);
845}
846#endif /* XFS_INODE_TRACE */