[XFS] move v_trace from bhv_vnode to xfs_inode

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>
This commit is contained in:
Christoph Hellwig 2007-08-29 11:46:47 +10:00 committed by Tim Shimmin
parent b677c210ce
commit 1543d79c45
13 changed files with 92 additions and 87 deletions

View File

@ -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);

View File

@ -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) {

View File

@ -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);
@ -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 (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);
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);
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
}
/*
@ -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;

View File

@ -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;
}
@ -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)) {
@ -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(), \
@ -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 */

View File

@ -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;
@ -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))
@ -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__ */

View File

@ -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);

View File

@ -157,7 +157,7 @@ again:
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);
@ -212,7 +212,7 @@ finish_inode:
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;
}
@ -234,7 +234,7 @@ finish_inode:
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);
@ -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);
}
@ -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));

View File

@ -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
@ -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

View File

@ -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

View File

@ -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

View File

@ -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) {

View File

@ -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 **);

View File

@ -88,7 +88,7 @@ xfs_getattr(
bhv_vnode_t *vp = XFS_ITOV(ip);
xfs_mount_t *mp = ip->i_mount;
vn_trace_entry(vp, __FUNCTION__, (inst_t *)__return_address);
vn_trace_entry(ip, __FUNCTION__, (inst_t *)__return_address);
if (XFS_FORCED_SHUTDOWN(mp))
return XFS_ERROR(EIO);
@ -228,7 +228,7 @@ xfs_setattr(
int file_owner;
int need_iolock = 1;
vn_trace_entry(vp, __FUNCTION__, (inst_t *)__return_address);
vn_trace_entry(ip, __FUNCTION__, (inst_t *)__return_address);
if (XFS_MTOVFS(mp)->vfs_flag & VFS_RDONLY)
return XFS_ERROR(EROFS);
@ -915,7 +915,7 @@ xfs_access(
{
int error;
vn_trace_entry(XFS_ITOV(ip), __FUNCTION__, (inst_t *)__return_address);
vn_trace_entry(ip, __FUNCTION__, (inst_t *)__return_address);
xfs_ilock(ip, XFS_ILOCK_SHARED);
error = xfs_iaccess(ip, mode, credp);
@ -987,7 +987,7 @@ xfs_readlink(
int pathlen;
int error = 0;
vn_trace_entry(XFS_ITOV(ip), __FUNCTION__, (inst_t *)__return_address);
vn_trace_entry(ip, __FUNCTION__, (inst_t *)__return_address);
if (XFS_FORCED_SHUTDOWN(mp))
return XFS_ERROR(EIO);
@ -1033,7 +1033,7 @@ xfs_fsync(
int error;
int log_flushed = 0, changed = 1;
vn_trace_entry(XFS_ITOV(ip), __FUNCTION__, (inst_t *)__return_address);
vn_trace_entry(ip, __FUNCTION__, (inst_t *)__return_address);
ASSERT(start >= 0 && stop >= -1);
@ -1592,7 +1592,7 @@ xfs_inactive(
int error;
int truncate;
vn_trace_entry(vp, __FUNCTION__, (inst_t *)__return_address);
vn_trace_entry(ip, __FUNCTION__, (inst_t *)__return_address);
/*
* If the inode is already free, then there can be nothing
@ -1805,7 +1805,7 @@ xfs_lookup(
int error;
uint lock_mode;
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);
@ -1849,7 +1849,7 @@ xfs_create(
int namelen;
ASSERT(!*vpp);
vn_trace_entry(dir_vp, __FUNCTION__, (inst_t *)__return_address);
vn_trace_entry(dp, __FUNCTION__, (inst_t *)__return_address);
dm_di_mode = vap->va_mode;
namelen = VNAMELEN(dentry);
@ -2326,7 +2326,7 @@ xfs_remove(
uint resblks;
int namelen;
vn_trace_entry(dir_vp, __FUNCTION__, (inst_t *)__return_address);
vn_trace_entry(dp, __FUNCTION__, (inst_t *)__return_address);
if (XFS_FORCED_SHUTDOWN(mp))
return XFS_ERROR(EIO);
@ -2369,7 +2369,7 @@ xfs_remove(
dm_di_mode = ip->i_d.di_mode;
vn_trace_entry(XFS_ITOV(ip), __FUNCTION__, (inst_t *)__return_address);
vn_trace_entry(ip, __FUNCTION__, (inst_t *)__return_address);
ITRACE(ip);
@ -2503,7 +2503,7 @@ xfs_remove(
if (link_zero && xfs_inode_is_filestream(ip))
xfs_filestream_deassociate(ip);
vn_trace_exit(XFS_ITOV(ip), __FUNCTION__, (inst_t *)__return_address);
vn_trace_exit(ip, __FUNCTION__, (inst_t *)__return_address);
IRELE(ip);
@ -2567,8 +2567,8 @@ xfs_link(
char *target_name = VNAME(dentry);
int target_namelen;
vn_trace_entry(target_dir_vp, __FUNCTION__, (inst_t *)__return_address);
vn_trace_entry(src_vp, __FUNCTION__, (inst_t *)__return_address);
vn_trace_entry(tdp, __FUNCTION__, (inst_t *)__return_address);
vn_trace_entry(xfs_vtoi(src_vp), __FUNCTION__, (inst_t *)__return_address);
target_namelen = VNAMELEN(dentry);
ASSERT(!VN_ISDIR(src_vp));
@ -2751,7 +2751,7 @@ xfs_mkdir(
/* Return through std_return after this point. */
vn_trace_entry(dir_vp, __FUNCTION__, (inst_t *)__return_address);
vn_trace_entry(dp, __FUNCTION__, (inst_t *)__return_address);
mp = dp->i_mount;
udqp = gdqp = NULL;
@ -2945,7 +2945,7 @@ xfs_rmdir(
int last_cdp_link;
uint resblks;
vn_trace_entry(dir_vp, __FUNCTION__, (inst_t *)__return_address);
vn_trace_entry(dp, __FUNCTION__, (inst_t *)__return_address);
if (XFS_FORCED_SHUTDOWN(mp))
return XFS_ERROR(EIO);
@ -3198,7 +3198,7 @@ xfs_symlink(
ip = NULL;
tp = NULL;
vn_trace_entry(dir_vp, __FUNCTION__, (inst_t *)__return_address);
vn_trace_entry(dp, __FUNCTION__, (inst_t *)__return_address);
if (XFS_FORCED_SHUTDOWN(mp))
@ -3490,7 +3490,7 @@ xfs_fid2(
{
xfs_fid2_t *xfid = (xfs_fid2_t *)fidp;
vn_trace_entry(XFS_ITOV(ip), __FUNCTION__, (inst_t *)__return_address);
vn_trace_entry(ip, __FUNCTION__, (inst_t *)__return_address);
ASSERT(sizeof(fid_t) >= sizeof(xfs_fid2_t));
xfid->fid_len = sizeof(xfs_fid2_t) - sizeof(xfid->fid_len);
@ -3673,7 +3673,7 @@ xfs_reclaim(
{
bhv_vnode_t *vp = XFS_ITOV(ip);
vn_trace_entry(vp, __FUNCTION__, (inst_t *)__return_address);
vn_trace_entry(ip, __FUNCTION__, (inst_t *)__return_address);
ASSERT(!VN_MAPPED(vp));
@ -3891,7 +3891,7 @@ xfs_alloc_file_space(
int committed;
int error;
vn_trace_entry(XFS_ITOV(ip), __FUNCTION__, (inst_t *)__return_address);
vn_trace_entry(ip, __FUNCTION__, (inst_t *)__return_address);
if (XFS_FORCED_SHUTDOWN(mp))
return XFS_ERROR(EIO);
@ -4161,7 +4161,7 @@ xfs_free_file_space(
vp = XFS_ITOV(ip);
mp = ip->i_mount;
vn_trace_entry(vp, __FUNCTION__, (inst_t *)__return_address);
vn_trace_entry(ip, __FUNCTION__, (inst_t *)__return_address);
if ((error = XFS_QM_DQATTACH(mp, ip, 0)))
return error;
@ -4367,7 +4367,7 @@ xfs_change_file_space(
xfs_trans_t *tp;
bhv_vattr_t va;
vn_trace_entry(XFS_ITOV(ip), __FUNCTION__, (inst_t *)__return_address);
vn_trace_entry(ip, __FUNCTION__, (inst_t *)__return_address);
/*
* must be a regular file and have write permission