Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 29 Nov 2015 21:01:02 +0000 (UTC)
From:      Kirk McKusick <mckusick@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r291459 - in head/sys: fs/nfs fs/nfsclient ufs/ffs
Message-ID:  <201511292101.tATL12sd028077@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mckusick
Date: Sun Nov 29 21:01:02 2015
New Revision: 291459
URL: https://svnweb.freebsd.org/changeset/base/291459

Log:
  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

Modified:
  head/sys/fs/nfs/nfsport.h
  head/sys/fs/nfsclient/nfs_clnode.c
  head/sys/fs/nfsclient/nfs_clport.c
  head/sys/ufs/ffs/ffs_vfsops.c

Modified: head/sys/fs/nfs/nfsport.h
==============================================================================
--- head/sys/fs/nfs/nfsport.h	Sun Nov 29 18:14:18 2015	(r291458)
+++ head/sys/fs/nfs/nfsport.h	Sun Nov 29 21:01:02 2015	(r291459)
@@ -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 */

Modified: head/sys/fs/nfsclient/nfs_clnode.c
==============================================================================
--- head/sys/fs/nfsclient/nfs_clnode.c	Sun Nov 29 18:14:18 2015	(r291458)
+++ head/sys/fs/nfsclient/nfs_clnode.c	Sun Nov 29 21:01:02 2015	(r291459)
@@ -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 *f
 	}
 	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);
 }
-

Modified: head/sys/fs/nfsclient/nfs_clport.c
==============================================================================
--- head/sys/fs/nfsclient/nfs_clport.c	Sun Nov 29 18:14:18 2015	(r291458)
+++ head/sys/fs/nfsclient/nfs_clport.c	Sun Nov 29 21:01:02 2015	(r291459)
@@ -210,7 +210,7 @@ nfscl_nget(struct mount *mntp, struct vn
 	}
 	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);

Modified: head/sys/ufs/ffs/ffs_vfsops.c
==============================================================================
--- head/sys/ufs/ffs/ffs_vfsops.c	Sun Nov 29 18:14:18 2015	(r291458)
+++ head/sys/ufs/ffs/ffs_vfsops.c	Sun Nov 29 21:01:02 2015	(r291459)
@@ -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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201511292101.tATL12sd028077>