1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-17 10:26:15 +00:00

For performance reasons, it is useful to have a single string used as

the name of a filesystem when setting it as the first parameter to the
getnewvnode() function. Most filesystems call getnewvnode from just one
place so can use a literal string as the first parameter. However, NFS
calls getnewvnode from two places, so we create a global constant string
that can be used by the two instances. This change also collapses two
instances of getnewvnode() in the UFS filesystem to a single call.

Reviewed by: kib
Tested by:   Peter Holm
This commit is contained in:
Kirk McKusick 2015-11-29 21:01:02 +00:00
parent 0bc93f5ad7
commit 43a993bb7d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=291459
4 changed files with 13 additions and 7 deletions

View File

@ -964,6 +964,13 @@ struct nfsreq {
#define NFSVNO_DELEGOK(v) (1)
#endif
/*
* Name used by getnewvnode() to describe filesystem, "nfs".
* For perfomance reasons it is useful to have the same string
* used in both places that call getnewvnode().
*/
extern const char nfs_vnode_tag[];
#endif /* _KERNEL */
#endif /* _NFS_NFSPORT_H */

View File

@ -64,6 +64,8 @@ MALLOC_DECLARE(M_NEWNFSREQ);
uma_zone_t newnfsnode_zone;
const char nfs_vnode_tag[] = "nfs";
static void nfs_freesillyrename(void *arg, __unused int pending);
void
@ -122,7 +124,7 @@ ncl_nget(struct mount *mntp, u_int8_t *fhp, int fhsize, struct nfsnode **npp,
}
np = uma_zalloc(newnfsnode_zone, M_WAITOK | M_ZERO);
error = getnewvnode("nfs", mntp, &newnfs_vnodeops, &nvp);
error = getnewvnode(nfs_vnode_tag, mntp, &newnfs_vnodeops, &nvp);
if (error) {
uma_zfree(newnfsnode_zone, np);
return (error);
@ -330,4 +332,3 @@ ncl_invalcaches(struct vnode *vp)
KDTRACE_NFS_ATTRCACHE_FLUSH_DONE(vp);
mtx_unlock(&np->n_mtx);
}

View File

@ -210,7 +210,7 @@ nfscl_nget(struct mount *mntp, struct vnode *dvp, struct nfsfh *nfhp,
}
np = uma_zalloc(newnfsnode_zone, M_WAITOK | M_ZERO);
error = getnewvnode("nfs", mntp, &newnfs_vnodeops, &nvp);
error = getnewvnode(nfs_vnode_tag, mntp, &newnfs_vnodeops, &nvp);
if (error) {
uma_zfree(newnfsnode_zone, np);
FREE((caddr_t)nfhp, M_NFSFH);

View File

@ -1670,10 +1670,8 @@ ffs_vgetf(mp, ino, flags, vpp, ffs_flags)
ip = uma_zalloc(uma_inode, M_WAITOK | M_ZERO);
/* Allocate a new vnode/inode. */
if (fs->fs_magic == FS_UFS1_MAGIC)
error = getnewvnode("ufs", mp, &ffs_vnodeops1, &vp);
else
error = getnewvnode("ufs", mp, &ffs_vnodeops2, &vp);
error = getnewvnode("ufs", mp, fs->fs_magic == FS_UFS1_MAGIC ?
&ffs_vnodeops1 : &ffs_vnodeops2, &vp);
if (error) {
*vpp = NULL;
uma_zfree(uma_inode, ip);