From 5a9972aa3f94b865d56adac10840dae461d4b4c4 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Tue, 16 Mar 2010 12:15:54 -0700 Subject: [PATCH] kernel - rework struct nchstats for systat * Remove ncs_long, ncs_pass2 and ncs_2passes and replace with ncs_longhits, ncs_longmiss, and ncs_unused (so the structure size does not change). The new longhits/longmiss statistics are for whole path lookups. --- sys/kern/vfs_nlookup.c | 10 ++++++++++ sys/sys/nchstats.h | 6 +++--- sys/vfs/gnu/ext2fs/ext2_lookup.c | 4 ---- sys/vfs/isofs/cd9660/cd9660_lookup.c | 5 ----- sys/vfs/udf/udf_vnops.c | 3 --- sys/vfs/ufs/ufs_lookup.c | 4 ---- 6 files changed, 13 insertions(+), 19 deletions(-) diff --git a/sys/kern/vfs_nlookup.c b/sys/kern/vfs_nlookup.c index 9d9f22eafd..ab7df3912d 100644 --- a/sys/kern/vfs_nlookup.c +++ b/sys/kern/vfs_nlookup.c @@ -408,6 +408,7 @@ nlookup_simple(const char *str, enum uio_seg seg, int nlookup(struct nlookupdata *nd) { + globaldata_t gd = mycpu; struct nlcomponent nlc; struct nchandle nch; struct nchandle par; @@ -419,6 +420,7 @@ nlookup(struct nlookupdata *nd) int error; int len; int dflags; + int hit = 1; #ifdef KTRACE if (KTRPOINT(nd->nl_td, KTR_NAMEI)) @@ -559,6 +561,8 @@ nlookup(struct nlookupdata *nd) cache_unlock(&nd->nl_nch); nd->nl_flags &= ~NLC_NCPISLOCKED; nch = cache_nlookup(&nd->nl_nch, &nlc); + if (nch.ncp->nc_flag & NCF_UNRESOLVED) + hit = 0; while ((error = cache_resolve(&nch, nd->nl_cred)) == EAGAIN) { kprintf("[diagnostic] nlookup: relookup %*.*s\n", nch.ncp->nc_nlen, nch.ncp->nc_nlen, nch.ncp->nc_name); @@ -608,6 +612,7 @@ nlookup(struct nlookupdata *nd) * previously resolved and thus cannot be newly created ncp's. */ if (nch.ncp->nc_flag & NCF_UNRESOLVED) { + hit = 0; error = cache_resolve(&nch, nd->nl_cred); KKASSERT(error != EAGAIN); } else { @@ -814,6 +819,11 @@ nlookup(struct nlookupdata *nd) break; } + if (hit) + ++gd->gd_nchstats->ncs_longhits; + else + ++gd->gd_nchstats->ncs_longmiss; + /* * NOTE: If NLC_CREATE was set the ncp may represent a negative hit * (ncp->nc_error will be ENOENT), but we will still return an error diff --git a/sys/sys/nchstats.h b/sys/sys/nchstats.h index 45770bd26e..d77d34aa50 100644 --- a/sys/sys/nchstats.h +++ b/sys/sys/nchstats.h @@ -46,9 +46,9 @@ struct nchstats { unsigned long ncs_badhits; /* hits we must drop */ unsigned long ncs_falsehits; /* hits with id mismatch */ unsigned long ncs_miss; /* misses */ - unsigned long ncs_long; /* long names that ignore cache */ - unsigned long ncs_pass2; /* names found with passes == 2 */ - unsigned long ncs_2passes; /* number of times we attempt it */ + unsigned long ncs_longhits; /* path lookup hits */ + unsigned long ncs_longmiss; /* path lookup misses */ + unsigned long ncs_unused; /* number of times we attempt it */ }; #endif /* _SYS_NCHSTATS_H_ */ diff --git a/sys/vfs/gnu/ext2fs/ext2_lookup.c b/sys/vfs/gnu/ext2fs/ext2_lookup.c index 48fa130960..ee2df364c0 100644 --- a/sys/vfs/gnu/ext2fs/ext2_lookup.c +++ b/sys/vfs/gnu/ext2fs/ext2_lookup.c @@ -311,7 +311,6 @@ ext2_lookup(struct vop_old_lookup_args *ap) struct ucred *cred = cnp->cn_cred; int flags = cnp->cn_flags; int nameiop = cnp->cn_nameiop; - globaldata_t gd = mycpu; int DIRBLKSIZ = VTOI(ap->a_dvp)->i_e2fs->s_blocksize; @@ -366,7 +365,6 @@ ext2_lookup(struct vop_old_lookup_args *ap) (error = EXT2_BLKATOFF(vdp, (off_t)dp->i_offset, NULL, &bp))) return (error); numdirpasses = 2; - gd->gd_nchstats->ncs_2passes++; } prevoff = dp->i_offset; endsearch = roundup(dp->i_size, DIRBLKSIZ); @@ -533,8 +531,6 @@ searchloop: return (ENOENT); found: - if (numdirpasses == 2) - gd->gd_nchstats->ncs_pass2++; /* * Check that directory length properly reflects presence * of this entry. diff --git a/sys/vfs/isofs/cd9660/cd9660_lookup.c b/sys/vfs/isofs/cd9660/cd9660_lookup.c index e3c5553e5d..d758658ac2 100644 --- a/sys/vfs/isofs/cd9660/cd9660_lookup.c +++ b/sys/vfs/isofs/cd9660/cd9660_lookup.c @@ -93,7 +93,6 @@ int cd9660_lookup(struct vop_old_lookup_args *ap) { struct vnode *vdp; /* vnode for directory being searched */ - globaldata_t gd = mycpu; struct iso_node *dp; /* inode for directory being searched */ struct iso_mnt *imp; /* file system that directory is in */ struct buf *bp; /* a buffer of directory entries */ @@ -168,7 +167,6 @@ cd9660_lookup(struct vop_old_lookup_args *ap) (error = cd9660_devblkatoff(vdp, (off_t)dp->i_offset, NULL, &bp))) return (error); numdirpasses = 2; - gd->gd_nchstats->ncs_2passes++; } endsearch = dp->i_size; @@ -315,9 +313,6 @@ notfound: return (ENOENT); found: - if (numdirpasses == 2) - gd->gd_nchstats->ncs_pass2++; - /* * Found component in pathname. * If the final component of path name, save information diff --git a/sys/vfs/udf/udf_vnops.c b/sys/vfs/udf/udf_vnops.c index 79696cc2e9..57c6ec4f38 100644 --- a/sys/vfs/udf/udf_vnops.c +++ b/sys/vfs/udf/udf_vnops.c @@ -908,7 +908,6 @@ udf_lookup(struct vop_old_lookup_args *a) } else { offset = node->diroff; numdirpasses = 2; - gd->gd_nchstats->ncs_2passes++; } lookloop: @@ -959,8 +958,6 @@ lookloop: */ if (nameiop == NAMEI_LOOKUP) node->diroff = ds->offset + ds->off; - if (numdirpasses == 2) - gd->gd_nchstats->ncs_pass2++; if ((flags & CNP_LOCKPARENT) == 0) { a->a_cnp->cn_flags |= CNP_PDIRUNLOCK; vn_unlock(dvp); diff --git a/sys/vfs/ufs/ufs_lookup.c b/sys/vfs/ufs/ufs_lookup.c index 22fc72a81a..9f1c571588 100644 --- a/sys/vfs/ufs/ufs_lookup.c +++ b/sys/vfs/ufs/ufs_lookup.c @@ -138,7 +138,6 @@ ufs_lookup(struct vop_old_lookup_args *ap) struct ucred *cred = cnp->cn_cred; int flags = cnp->cn_flags; int nameiop = cnp->cn_nameiop; - globaldata_t gd = mycpu; bp = NULL; slotoffset = -1; @@ -230,7 +229,6 @@ ufs_lookup(struct vop_old_lookup_args *ap) (error = ffs_blkatoff(vdp, (off_t)dp->i_offset, NULL, &bp))) return (error); numdirpasses = 2; - gd->gd_nchstats->ncs_2passes++; } prevoff = dp->i_offset; endsearch = roundup2(dp->i_size, DIRBLKSIZ); @@ -433,8 +431,6 @@ notfound: return (ENOENT); found: - if (numdirpasses == 2) - gd->gd_nchstats->ncs_pass2++; /* * Check that directory length properly reflects presence * of this entry. -- 2.41.0