Skip to content

Commit

Permalink
[XFS] move v_trace from bhv_vnode to xfs_inode
Browse files Browse the repository at this point in the history
struct bhv_vnode is on it's way out, so move the trace buffer to the XFS
inode. Note that this makes the tracing macros rather misnamed, but this
kind of fallout will be fixed up incrementally later on.

SGI-PV: 969608
SGI-Modid: xfs-linux-melb:xfs-kern:29498a

Signed-off-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: David Chinner <dgc@sgi.com>
Signed-off-by: Tim Shimmin <tes@sgi.com>
  • Loading branch information
Christoph Hellwig authored and Tim Shimmin committed Oct 16, 2007
1 parent b677c21 commit 1543d79
Show file tree
Hide file tree
Showing 13 changed files with 94 additions and 89 deletions.
2 changes: 1 addition & 1 deletion fs/xfs/linux-2.6/xfs_aops.c
Original file line number Diff line number Diff line change
Expand Up @@ -1526,7 +1526,7 @@ xfs_vm_bmap(
struct inode *inode = (struct inode *)mapping->host;
struct xfs_inode *ip = XFS_I(inode);

vn_trace_entry(vn_from_inode(inode), __FUNCTION__,
vn_trace_entry(XFS_I(inode), __FUNCTION__,
(inst_t *)__return_address);
xfs_rwlock(ip, VRWLOCK_READ);
xfs_flush_pages(ip, (xfs_off_t)0, -1, 0, FI_REMAPF);
Expand Down
2 changes: 1 addition & 1 deletion fs/xfs/linux-2.6/xfs_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ xfs_ioctl(
xfs_mount_t *mp = ip->i_mount;
int error;

vn_trace_entry(vp, "xfs_ioctl", (inst_t *)__return_address);
vn_trace_entry(XFS_I(inode), "xfs_ioctl", (inst_t *)__return_address);

switch (cmd) {

Expand Down
40 changes: 17 additions & 23 deletions fs/xfs/linux-2.6/xfs_super.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ xfs_fs_write_inode(
{
int error = 0, flags = FLUSH_INODE;

vn_trace_entry(vn_from_inode(inode), __FUNCTION__,
vn_trace_entry(XFS_I(inode), __FUNCTION__,
(inst_t *)__return_address);
if (sync) {
filemap_fdatawait(inode->i_mapping);
Expand All @@ -425,34 +425,27 @@ STATIC void
xfs_fs_clear_inode(
struct inode *inode)
{
bhv_vnode_t *vp = vn_from_inode(inode);

vn_trace_entry(vp, __FUNCTION__, (inst_t *)__return_address);

XFS_STATS_INC(vn_rele);
XFS_STATS_INC(vn_remove);
XFS_STATS_INC(vn_reclaim);
XFS_STATS_DEC(vn_active);
xfs_inode_t *ip = XFS_I(inode);

/*
* This can happen because xfs_iget_core calls xfs_idestroy if we
* ip can be null when xfs_iget_core calls xfs_idestroy if we
* find an inode with di_mode == 0 but without IGET_CREATE set.
*/
if (XFS_I(inode))
xfs_inactive(XFS_I(inode));


if (XFS_I(inode)) {
xfs_iflags_clear(XFS_I(inode), XFS_IMODIFIED);
if (xfs_reclaim(XFS_I(inode)))
panic("%s: cannot reclaim 0x%p\n", __FUNCTION__, vp);
if (ip) {
vn_trace_entry(ip, __FUNCTION__, (inst_t *)__return_address);

XFS_STATS_INC(vn_rele);
XFS_STATS_INC(vn_remove);
XFS_STATS_INC(vn_reclaim);
XFS_STATS_DEC(vn_active);

xfs_inactive(ip);
xfs_iflags_clear(ip, XFS_IMODIFIED);
if (xfs_reclaim(ip))
panic("%s: cannot reclaim 0x%p\n", __FUNCTION__, inode);
}

ASSERT(XFS_I(inode) == NULL);

#ifdef XFS_VNODE_TRACE
ktrace_free(vp->v_trace);
#endif
}

/*
Expand Down Expand Up @@ -840,7 +833,8 @@ xfs_fs_fill_super(
}
if ((error = xfs_fs_start_syncd(vfsp)))
goto fail_vnrele;
vn_trace_exit(rootvp, __FUNCTION__, (inst_t *)__return_address);
vn_trace_exit(XFS_I(sb->s_root->d_inode), __FUNCTION__,
(inst_t *)__return_address);

kmem_free(args, sizeof(*args));
return 0;
Expand Down
46 changes: 27 additions & 19 deletions fs/xfs/linux-2.6/xfs_vnode.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,6 @@ vn_initialize(

ASSERT(VN_CACHED(vp) == 0);

#ifdef XFS_VNODE_TRACE
vp->v_trace = ktrace_alloc(VNODE_TRACE_SIZE, KM_SLEEP);
#endif /* XFS_VNODE_TRACE */

vn_trace_exit(vp, __FUNCTION__, (inst_t *)__return_address);
return vp;
}

Expand Down Expand Up @@ -158,7 +153,7 @@ __vn_revalidate(
{
int error;

vn_trace_entry(vp, __FUNCTION__, (inst_t *)__return_address);
vn_trace_entry(xfs_vtoi(vp), __FUNCTION__, (inst_t *)__return_address);
vattr->va_mask = XFS_AT_STAT | XFS_AT_XFLAGS;
error = xfs_getattr(xfs_vtoi(vp), vattr, 0);
if (likely(!error)) {
Expand Down Expand Up @@ -196,12 +191,25 @@ vn_hold(

#ifdef XFS_VNODE_TRACE

#define KTRACE_ENTER(vp, vk, s, line, ra) \
ktrace_enter( (vp)->v_trace, \
/*
* Reference count of Linux inode if present, -1 if the xfs_inode
* has no associated Linux inode.
*/
static inline int xfs_icount(struct xfs_inode *ip)
{
bhv_vnode_t *vp = XFS_ITOV_NULL(ip);

if (vp)
return vn_count(vp);
return -1;
}

#define KTRACE_ENTER(ip, vk, s, line, ra) \
ktrace_enter( (ip)->i_trace, \
/* 0 */ (void *)(__psint_t)(vk), \
/* 1 */ (void *)(s), \
/* 2 */ (void *)(__psint_t) line, \
/* 3 */ (void *)(__psint_t)(vn_count(vp)), \
/* 3 */ (void *)(__psint_t)xfs_icount(ip), \
/* 4 */ (void *)(ra), \
/* 5 */ NULL, \
/* 6 */ (void *)(__psint_t)current_cpu(), \
Expand All @@ -213,32 +221,32 @@ vn_hold(
* Vnode tracing code.
*/
void
vn_trace_entry(bhv_vnode_t *vp, const char *func, inst_t *ra)
vn_trace_entry(xfs_inode_t *ip, const char *func, inst_t *ra)
{
KTRACE_ENTER(vp, VNODE_KTRACE_ENTRY, func, 0, ra);
KTRACE_ENTER(ip, VNODE_KTRACE_ENTRY, func, 0, ra);
}

void
vn_trace_exit(bhv_vnode_t *vp, const char *func, inst_t *ra)
vn_trace_exit(xfs_inode_t *ip, const char *func, inst_t *ra)
{
KTRACE_ENTER(vp, VNODE_KTRACE_EXIT, func, 0, ra);
KTRACE_ENTER(ip, VNODE_KTRACE_EXIT, func, 0, ra);
}

void
vn_trace_hold(bhv_vnode_t *vp, char *file, int line, inst_t *ra)
vn_trace_hold(xfs_inode_t *ip, char *file, int line, inst_t *ra)
{
KTRACE_ENTER(vp, VNODE_KTRACE_HOLD, file, line, ra);
KTRACE_ENTER(ip, VNODE_KTRACE_HOLD, file, line, ra);
}

void
vn_trace_ref(bhv_vnode_t *vp, char *file, int line, inst_t *ra)
vn_trace_ref(xfs_inode_t *ip, char *file, int line, inst_t *ra)
{
KTRACE_ENTER(vp, VNODE_KTRACE_REF, file, line, ra);
KTRACE_ENTER(ip, VNODE_KTRACE_REF, file, line, ra);
}

void
vn_trace_rele(bhv_vnode_t *vp, char *file, int line, inst_t *ra)
vn_trace_rele(xfs_inode_t *ip, char *file, int line, inst_t *ra)
{
KTRACE_ENTER(vp, VNODE_KTRACE_RELE, file, line, ra);
KTRACE_ENTER(ip, VNODE_KTRACE_RELE, file, line, ra);
}
#endif /* XFS_VNODE_TRACE */
21 changes: 7 additions & 14 deletions fs/xfs/linux-2.6/xfs_vnode.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ typedef __u64 bhv_vnumber_t;

typedef struct bhv_vnode {
bhv_vnumber_t v_number; /* in-core vnode number */
#ifdef XFS_VNODE_TRACE
struct ktrace *v_trace; /* trace header structure */
#endif
struct inode v_inode; /* Linux inode */
/* inode MUST be last */
} bhv_vnode_t;
Expand Down Expand Up @@ -222,9 +219,9 @@ extern bhv_vnode_t *vn_hold(struct bhv_vnode *);
#if defined(XFS_VNODE_TRACE)
#define VN_HOLD(vp) \
((void)vn_hold(vp), \
vn_trace_hold(vp, __FILE__, __LINE__, (inst_t *)__return_address))
vn_trace_hold(xfs_vtoi(vp), __FILE__, __LINE__, (inst_t *)__return_address))
#define VN_RELE(vp) \
(vn_trace_rele(vp, __FILE__, __LINE__, (inst_t *)__return_address), \
(vn_trace_rele(xfs_vtoi(vp), __FILE__, __LINE__, (inst_t *)__return_address), \
iput(vn_to_inode(vp)))
#else
#define VN_HOLD(vp) ((void)vn_hold(vp))
Expand Down Expand Up @@ -314,21 +311,17 @@ static inline void vn_atime_to_time_t(bhv_vnode_t *vp, time_t *tt)
#define VNODE_KTRACE_REF 4
#define VNODE_KTRACE_RELE 5

extern void vn_trace_entry(struct bhv_vnode *, const char *, inst_t *);
extern void vn_trace_exit(struct bhv_vnode *, const char *, inst_t *);
extern void vn_trace_hold(struct bhv_vnode *, char *, int, inst_t *);
extern void vn_trace_ref(struct bhv_vnode *, char *, int, inst_t *);
extern void vn_trace_rele(struct bhv_vnode *, char *, int, inst_t *);

#define VN_TRACE(vp) \
vn_trace_ref(vp, __FILE__, __LINE__, (inst_t *)__return_address)
extern void vn_trace_entry(struct xfs_inode *, const char *, inst_t *);
extern void vn_trace_exit(struct xfs_inode *, const char *, inst_t *);
extern void vn_trace_hold(struct xfs_inode *, char *, int, inst_t *);
extern void vn_trace_ref(struct xfs_inode *, char *, int, inst_t *);
extern void vn_trace_rele(struct xfs_inode *, char *, int, inst_t *);
#else
#define vn_trace_entry(a,b,c)
#define vn_trace_exit(a,b,c)
#define vn_trace_hold(a,b,c,d)
#define vn_trace_ref(a,b,c,d)
#define vn_trace_rele(a,b,c,d)
#define VN_TRACE(vp)
#endif

#endif /* __XFS_VNODE_H__ */
2 changes: 1 addition & 1 deletion fs/xfs/xfs_dir2.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ xfs_readdir(
int rval; /* return value */
int v; /* type-checking value */

vn_trace_entry(XFS_ITOV(dp), __FUNCTION__, (inst_t *)__return_address);
vn_trace_entry(dp, __FUNCTION__, (inst_t *)__return_address);

if (XFS_FORCED_SHUTDOWN(dp->i_mount))
return XFS_ERROR(EIO);
Expand Down
10 changes: 5 additions & 5 deletions fs/xfs/xfs_iget.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ xfs_iget_core(
goto again;
}

vn_trace_exit(vp, "xfs_iget.alloc",
vn_trace_exit(ip, "xfs_iget.alloc",
(inst_t *)__return_address);

XFS_STATS_INC(xs_ig_found);
Expand Down Expand Up @@ -212,7 +212,7 @@ xfs_iget_core(
xfs_ilock(ip, lock_flags);

xfs_iflags_clear(ip, XFS_ISTALE);
vn_trace_exit(vp, "xfs_iget.found",
vn_trace_exit(ip, "xfs_iget.found",
(inst_t *)__return_address);
goto return_ip;
}
Expand All @@ -234,7 +234,7 @@ xfs_iget_core(
return error;
}

vn_trace_exit(vp, "xfs_iget.alloc", (inst_t *)__return_address);
vn_trace_exit(ip, "xfs_iget.alloc", (inst_t *)__return_address);

xfs_inode_lock_init(ip, vp);
xfs_iocore_inode_init(ip);
Expand Down Expand Up @@ -467,7 +467,7 @@ xfs_iput(xfs_inode_t *ip,
{
bhv_vnode_t *vp = XFS_ITOV(ip);

vn_trace_entry(vp, "xfs_iput", (inst_t *)__return_address);
vn_trace_entry(ip, "xfs_iput", (inst_t *)__return_address);
xfs_iunlock(ip, lock_flags);
VN_RELE(vp);
}
Expand All @@ -482,7 +482,7 @@ xfs_iput_new(xfs_inode_t *ip,
bhv_vnode_t *vp = XFS_ITOV(ip);
struct inode *inode = vn_to_inode(vp);

vn_trace_entry(vp, "xfs_iput_new", (inst_t *)__return_address);
vn_trace_entry(ip, "xfs_iput_new", (inst_t *)__return_address);

if ((ip->i_d.di_mode == 0)) {
ASSERT(!xfs_iflags_test(ip, XFS_IRECLAIMABLE));
Expand Down
7 changes: 7 additions & 0 deletions fs/xfs/xfs_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,9 @@ xfs_iread(
* Initialize inode's trace buffers.
* Do this before xfs_iformat in case it adds entries.
*/
#ifdef XFS_VNODE_TRACE
ip->i_trace = ktrace_alloc(VNODE_TRACE_SIZE, KM_SLEEP);
#endif
#ifdef XFS_BMAP_TRACE
ip->i_xtrace = ktrace_alloc(XFS_BMAP_KTRACE_SIZE, KM_SLEEP);
#endif
Expand Down Expand Up @@ -2729,6 +2732,10 @@ xfs_idestroy(
mrfree(&ip->i_lock);
mrfree(&ip->i_iolock);
freesema(&ip->i_flock);

#ifdef XFS_VNODE_TRACE
ktrace_free(ip->i_trace);
#endif
#ifdef XFS_BMAP_TRACE
ktrace_free(ip->i_xtrace);
#endif
Expand Down
3 changes: 3 additions & 0 deletions fs/xfs/xfs_inode.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,9 @@ typedef struct xfs_inode {
xfs_fsize_t i_size; /* in-memory size */
atomic_t i_iocount; /* outstanding I/O count */
/* Trace buffers per inode. */
#ifdef XFS_VNODE_TRACE
struct ktrace *i_trace; /* general inode trace */
#endif
#ifdef XFS_BMAP_TRACE
struct ktrace *i_xtrace; /* inode extent list trace */
#endif
Expand Down
4 changes: 2 additions & 2 deletions fs/xfs/xfs_rename.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ xfs_rename(
int src_namelen = VNAMELEN(src_vname);
int target_namelen = VNAMELEN(target_vname);

vn_trace_entry(src_dir_vp, "xfs_rename", (inst_t *)__return_address);
vn_trace_entry(target_dir_vp, "xfs_rename", (inst_t *)__return_address);
vn_trace_entry(src_dp, "xfs_rename", (inst_t *)__return_address);
vn_trace_entry(xfs_vtoi(target_dir_vp), "xfs_rename", (inst_t *)__return_address);

/*
* Find the XFS behavior descriptor for the target directory
Expand Down
2 changes: 1 addition & 1 deletion fs/xfs/xfs_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ xfs_dir_lookup_int(
{
int error;

vn_trace_entry(XFS_ITOV(dp), __FUNCTION__, (inst_t *)__return_address);
vn_trace_entry(dp, __FUNCTION__, (inst_t *)__return_address);

error = xfs_dir_lookup(NULL, dp, VNAME(dentry), VNAMELEN(dentry), inum);
if (!error) {
Expand Down
2 changes: 1 addition & 1 deletion fs/xfs/xfs_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#define IRELE(ip) VN_RELE(XFS_ITOV(ip))
#define IHOLD(ip) VN_HOLD(XFS_ITOV(ip))
#define ITRACE(ip) vn_trace_ref(XFS_ITOV(ip), __FILE__, __LINE__, \
#define ITRACE(ip) vn_trace_ref(ip, __FILE__, __LINE__, \
(inst_t *)__return_address)

extern int xfs_get_dir_entry (bhv_vname_t *, xfs_inode_t **);
Expand Down
Loading

0 comments on commit 1543d79

Please sign in to comment.