svn commit: r333977 - in projects/pnfs-planb-server/sys/fs: nfs nfsserver

Rick Macklem rmacklem at FreeBSD.org
Mon May 21 13:08:20 UTC 2018


Author: rmacklem
Date: Mon May 21 13:08:18 2018
New Revision: 333977
URL: https://svnweb.freebsd.org/changeset/base/333977

Log:
  Only allocate the nfslayouthash table when a pNFS service is started the
  first time. This allows the allocation to be quite large, since pNFS
  MDS servers will normally be dedicated fairly large servers.
  Replace vfs.nfsd.layouthashsize with vfs.nfsd.layouthighwater, so that
  both the maximum # of layouts in the server and the size of the hash table
  can both be tuned with this.

Modified:
  projects/pnfs-planb-server/sys/fs/nfs/nfs.h
  projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdport.c
  projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdstate.c
  projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdsubs.c

Modified: projects/pnfs-planb-server/sys/fs/nfs/nfs.h
==============================================================================
--- projects/pnfs-planb-server/sys/fs/nfs/nfs.h	Mon May 21 11:58:02 2018	(r333976)
+++ projects/pnfs-planb-server/sys/fs/nfs/nfs.h	Mon May 21 13:08:18 2018	(r333977)
@@ -98,7 +98,7 @@
 #define	NFSSESSIONHASHSIZE	20	/* Size of server session hash table */
 #endif
 #define	NFSSTATEHASHSIZE	10	/* Size of server stateid hash table */
-#define	NFSLAYOUTHASHSIZE	100	/* Size of server layout hash table */
+#define	NFSLAYOUTHIGHWATER	1000000	/* Upper limit for # of layouts */
 #ifndef	NFSCLDELEGHIGHWATER
 #define	NFSCLDELEGHIGHWATER	10000	/* limit for client delegations */
 #endif

Modified: projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdport.c
==============================================================================
--- projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdport.c	Mon May 21 11:58:02 2018	(r333976)
+++ projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdport.c	Mon May 21 13:08:18 2018	(r333977)
@@ -5496,13 +5496,15 @@ nfsd_modevent(module_t mod, int type, void *data)
 		mtx_destroy(&nfsrv_recalllock_mtx);
 		for (i = 0; i < nfsrv_sessionhashsize; i++)
 			mtx_destroy(&nfssessionhash[i].mtx);
-		for (i = 0; i < nfsrv_layouthashsize; i++)
-			mtx_destroy(&nfslayouthash[i].mtx);
+		if (nfslayouthash != NULL) {
+			for (i = 0; i < nfsrv_layouthashsize; i++)
+				mtx_destroy(&nfslayouthash[i].mtx);
+			free(nfslayouthash, M_NFSDSESSION);
+		}
 		lockdestroy(&nfsv4root_mnt.mnt_explock);
 		free(nfsclienthash, M_NFSDCLIENT);
 		free(nfslockhash, M_NFSDLOCKFILE);
 		free(nfssessionhash, M_NFSDSESSION);
-		free(nfslayouthash, M_NFSDSESSION);
 		loaded = 0;
 		break;
 	default:

Modified: projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdstate.c
==============================================================================
--- projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdstate.c	Mon May 21 11:58:02 2018	(r333976)
+++ projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdstate.c	Mon May 21 13:08:18 2018	(r333977)
@@ -39,6 +39,7 @@ int nfsrv_issuedelegs = 0;
 int nfsrv_dolocallocks = 0;
 struct nfsv4lock nfsv4rootfs_lock;
 time_t nfsdev_time = 0;
+int nfsrv_layouthashsize;
 
 extern int newnfs_numnfsd;
 extern struct nfsstatsv1 nfsstatsv1;
@@ -80,10 +81,10 @@ SYSCTL_INT(_vfs_nfsd, OID_AUTO, sessionhashsize, CTLFL
     &nfsrv_sessionhashsize, 0,
     "Size of session hash table set via loader.conf");
 
-int	nfsrv_layouthashsize = NFSLAYOUTHASHSIZE;
-SYSCTL_INT(_vfs_nfsd, OID_AUTO, layouthashsize, CTLFLAG_RDTUN,
-    &nfsrv_layouthashsize, 0,
-    "Size of layout hash table set via loader.conf");
+int	nfsrv_layouthighwater = NFSLAYOUTHIGHWATER;
+SYSCTL_INT(_vfs_nfsd, OID_AUTO, layouthighwater, CTLFLAG_RDTUN,
+    &nfsrv_layouthighwater, 0,
+    "High water mark for number of layouts set via loader.conf");
 
 static int	nfsrv_v4statelimit = NFSRV_V4STATELIMIT;
 SYSCTL_INT(_vfs_nfsd, OID_AUTO, v4statelimit, CTLFLAG_RWTUN,
@@ -7476,7 +7477,7 @@ nfsrv_createdevids(struct nfsd_nfsd_args *args, NFSPRO
 {
 	struct nfsdevice *ds;
 	char *addrp, *dnshostp, *dspathp, *mirrorp;
-	int error;
+	int error, i;
 
 	addrp = args->addr;
 	dnshostp = args->dnshost;
@@ -7511,6 +7512,23 @@ nfsrv_createdevids(struct nfsd_nfsd_args *args, NFSPRO
 		dnshostp += (strlen(dnshostp) + 1);
 		dspathp += (strlen(dspathp) + 1);
 		mirrorp += (strlen(mirrorp) + 1);
+	}
+
+	/*
+	 * Allocate the nfslayout hash table now, since this is a pNFS server.
+	 * Make it 1% of the high water mark and at least 100.
+	 */
+	if (nfslayouthash == NULL) {
+		nfsrv_layouthashsize = nfsrv_layouthighwater / 100;
+		if (nfsrv_layouthashsize < 100)
+			nfsrv_layouthashsize = 100;
+		nfslayouthash = mallocarray(nfsrv_layouthashsize,
+		    sizeof(struct nfslayouthash), M_NFSDSESSION, M_WAITOK |
+		    M_ZERO);
+		for (i = 0; i < nfsrv_layouthashsize; i++) {
+			mtx_init(&nfslayouthash[i].mtx, "nfslm", NULL, MTX_DEF);
+			TAILQ_INIT(&nfslayouthash[i].list);
+		}
 	}
 	return (0);
 }

Modified: projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdsubs.c
==============================================================================
--- projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdsubs.c	Mon May 21 11:58:02 2018	(r333976)
+++ projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdsubs.c	Mon May 21 13:08:18 2018	(r333977)
@@ -52,8 +52,6 @@ extern struct nfslockhashhead *nfslockhash;
 extern int nfsrv_lockhashsize;
 extern struct nfssessionhash *nfssessionhash;
 extern int nfsrv_sessionhashsize;
-extern struct nfslayouthash *nfslayouthash;
-extern int nfsrv_layouthashsize;
 extern int nfsrv_useacl;
 extern uid_t nfsrv_defaultuid;
 extern gid_t nfsrv_defaultgid;
@@ -2063,12 +2061,6 @@ nfsd_init(void)
 	for (i = 0; i < nfsrv_sessionhashsize; i++) {
 		mtx_init(&nfssessionhash[i].mtx, "nfssm", NULL, MTX_DEF);
 		LIST_INIT(&nfssessionhash[i].list);
-	}
-	nfslayouthash = malloc(sizeof(struct nfslayouthash) *
-	    nfsrv_layouthashsize, M_NFSDSESSION, M_WAITOK | M_ZERO);
-	for (i = 0; i < nfsrv_layouthashsize; i++) {
-		mtx_init(&nfslayouthash[i].mtx, "nfslm", NULL, MTX_DEF);
-		TAILQ_INIT(&nfslayouthash[i].list);
 	}
 	LIST_INIT(&nfsrv_dontlisthead);
 	TAILQ_INIT(&nfsrv_recalllisthead);


More information about the svn-src-projects mailing list