svn commit: r321394 - projects/pnfs-planb-server/sys/fs/nfsserver

Rick Macklem rmacklem at FreeBSD.org
Sun Jul 23 19:50:28 UTC 2017


Author: rmacklem
Date: Sun Jul 23 19:50:27 2017
New Revision: 321394
URL: https://svnweb.freebsd.org/changeset/base/321394

Log:
  Since "struct nfsrv_descript" has grown to about 200bytes, malloc it to
  avoid excessive kernel stack usage.

Modified:
  projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdport.c

Modified: projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdport.c
==============================================================================
--- projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdport.c	Sun Jul 23 19:35:14 2017	(r321393)
+++ projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdport.c	Sun Jul 23 19:50:27 2017	(r321394)
@@ -4087,13 +4087,13 @@ nfsrv_readdsrpc(fhandle_t *fhp, off_t off, int len, st
     NFSPROC_T *p, struct nfsmount *nmp, struct mbuf **mpp, struct mbuf **mpendp)
 {
 	uint32_t *tl;
-	struct nfsrv_descript nfsd, *nd = &nfsd;
+	struct nfsrv_descript *nd;
 	nfsv4stateid_t st;
 	struct mbuf *m, *m2;
 	int error = 0, retlen, tlen, trimlen;
 
 	NFSD_DEBUG(4, "in nfsrv_readdsrpc\n");
-	nd->nd_mrep = NULL;
+	nd = malloc(sizeof(*nd), M_TEMP, M_WAITOK | M_ZERO);
 	*mpp = NULL;
 	/*
 	 * Use a stateid where other is an alternating 01010 pattern and
@@ -4113,8 +4113,10 @@ nfsrv_readdsrpc(fhandle_t *fhp, off_t off, int len, st
 	*(tl + 2) = txdr_unsigned(len);
 	error = newnfs_request(nd, nmp, NULL, &nmp->nm_sockreq, NULL, p, cred,
 	    NFS_PROG, NFS_VER4, NULL, 1, NULL, NULL);
-	if (error != 0)
+	if (error != 0) {
+		free(nd, M_TEMP);
 		return (error);
+	}
 	if (nd->nd_repstat == 0) {
 		NFSM_DISSECT(tl, u_int32_t *, NFSX_UNSIGNED);
 		NFSM_STRSIZ(retlen, len);
@@ -4177,6 +4179,7 @@ nfsrv_readdsrpc(fhandle_t *fhp, off_t off, int len, st
 nfsmout:
 	/* If nd->nd_mrep is already NULL, this is a no-op. */
 	m_freem(nd->nd_mrep);
+	free(nd, M_TEMP);
 	NFSD_DEBUG(4, "nfsrv_readdsrpc error=%d\n", error);
 	return (error);
 }
@@ -4187,7 +4190,7 @@ nfsrv_writedsrpc(fhandle_t *fhp, off_t off, int len, s
     char *cp)
 {
 	uint32_t *tl;
-	struct nfsrv_descript nfsd, *nd = &nfsd;
+	struct nfsrv_descript *nd;
 	nfsv4stateid_t st;
 	struct mbuf *m;
 	struct nfsvattr na;
@@ -4196,7 +4199,7 @@ nfsrv_writedsrpc(fhandle_t *fhp, off_t off, int len, s
 
 	NFSD_DEBUG(4, "in nfsrv_writedsrpc\n");
 	KASSERT(*mpp != NULL, ("nfsrv_writedsrpc: NULL mbuf chain"));
-	nd->nd_mrep = NULL;
+	nd = malloc(sizeof(*nd), M_TEMP, M_WAITOK | M_ZERO);
 	/*
 	 * Use a stateid where other is an alternating 01010 pattern and
 	 * seqid is 0xffffffff.  This value is not defined as special by
@@ -4249,8 +4252,10 @@ nfsrv_writedsrpc(fhandle_t *fhp, off_t off, int len, s
 	(void) nfsrv_putattrbit(nd, &attrbits);
 	error = newnfs_request(nd, nmp, NULL, &nmp->nm_sockreq, NULL, p, cred,
 	    NFS_PROG, NFS_VER4, NULL, 1, NULL, NULL);
-	if (error != 0)
+	if (error != 0) {
+		free(nd, M_TEMP);
 		return (error);
+	}
 	NFSD_DEBUG(4, "nfsrv_writedsrpc: aft writerpc=%d\n", nd->nd_repstat);
 	/* Get rid of weak cache consistency data for now. */
 	if ((nd->nd_flag & (ND_NOMOREDATA | ND_NFSV4 | ND_V4WCCATTR)) ==
@@ -4297,6 +4302,7 @@ nfsrv_writedsrpc(fhandle_t *fhp, off_t off, int len, s
 	NFSD_DEBUG(4, "nfsrv_writedsrpc: aft setextat=%d\n", error);
 nfsmout:
 	m_freem(nd->nd_mrep);
+	free(nd, M_TEMP);
 	NFSD_DEBUG(4, "nfsrv_writedsrpc error=%d\n", error);
 	return (error);
 }
@@ -4306,14 +4312,14 @@ nfsrv_setattrdsrpc(fhandle_t *fhp, struct ucred *cred,
     struct vnode *vp, struct nfsmount *nmp, struct nfsvattr *nap)
 {
 	uint32_t *tl;
-	struct nfsrv_descript nfsd, *nd = &nfsd;
+	struct nfsrv_descript *nd;
 	nfsv4stateid_t st;
 	nfsattrbit_t attrbits;
 	struct nfsvattr na;
 	int error;
 
 	NFSD_DEBUG(4, "in nfsrv_setattrdsrpc\n");
-	nd->nd_mrep = NULL;
+	nd = malloc(sizeof(*nd), M_TEMP, M_WAITOK | M_ZERO);
 	/*
 	 * Use a stateid where other is an alternating 01010 pattern and
 	 * seqid is 0xffffffff.  This value is not defined as special by
@@ -4340,8 +4346,10 @@ nfsrv_setattrdsrpc(fhandle_t *fhp, struct ucred *cred,
 	(void) nfsrv_putattrbit(nd, &attrbits);
 	error = newnfs_request(nd, nmp, NULL, &nmp->nm_sockreq, NULL, p, cred,
 	    NFS_PROG, NFS_VER4, NULL, 1, NULL, NULL);
-	if (error != 0)
+	if (error != 0) {
+		free(nd, M_TEMP);
 		return (error);
+	}
 	NFSD_DEBUG(4, "nfsrv_setattrdsrpc: aft setattrrpc=%d\n",
 	    nd->nd_repstat);
 	/* Get rid of weak cache consistency data for now. */
@@ -4382,6 +4390,7 @@ nfsrv_setattrdsrpc(fhandle_t *fhp, struct ucred *cred,
 	NFSD_DEBUG(4, "nfsrv_setattrdsrpc: aft setextat=%d\n", error);
 nfsmout:
 	m_freem(nd->nd_mrep);
+	free(nd, M_TEMP);
 	NFSD_DEBUG(4, "nfsrv_setattrdsrpc error=%d\n", error);
 	return (error);
 }
@@ -4393,13 +4402,13 @@ static int
 nfsrv_setacldsrpc(fhandle_t *fhp, struct ucred *cred, NFSPROC_T *p,
     struct vnode *vp, struct nfsmount *nmp, struct acl *aclp)
 {
-	struct nfsrv_descript nfsd, *nd = &nfsd;
+	struct nfsrv_descript *nd;
 	nfsv4stateid_t st;
 	nfsattrbit_t attrbits;
 	int error;
 
 	NFSD_DEBUG(4, "in nfsrv_setacldsrpc\n");
-	nd->nd_mrep = NULL;
+	nd = malloc(sizeof(*nd), M_TEMP, M_WAITOK | M_ZERO);
 	/*
 	 * Use a stateid where other is an alternating 01010 pattern and
 	 * seqid is 0xffffffff.  This value is not defined as special by
@@ -4424,12 +4433,15 @@ nfsrv_setacldsrpc(fhandle_t *fhp, struct ucred *cred, 
 	    NULL, 0, 0, 0, 0, 0);
 	error = newnfs_request(nd, nmp, NULL, &nmp->nm_sockreq, NULL, p, cred,
 	    NFS_PROG, NFS_VER4, NULL, 1, NULL, NULL);
-	if (error != 0)
+	if (error != 0) {
+		free(nd, M_TEMP);
 		return (error);
+	}
 	NFSD_DEBUG(4, "nfsrv_setacldsrpc: aft setaclrpc=%d\n",
 	    nd->nd_repstat);
 	error = nd->nd_repstat;
 	m_freem(nd->nd_mrep);
+	free(nd, M_TEMP);
 	return (error);
 }
 
@@ -4440,12 +4452,12 @@ static int
 nfsrv_getattrdsrpc(fhandle_t *fhp, struct ucred *cred, NFSPROC_T *p,
     struct vnode *vp, struct nfsmount *nmp, struct nfsvattr *nap)
 {
-	struct nfsrv_descript nfsd, *nd = &nfsd;
+	struct nfsrv_descript *nd;
 	int error;
 	nfsattrbit_t attrbits;
 	
 	NFSD_DEBUG(4, "in nfsrv_getattrdsrpc\n");
-	nd->nd_mrep = NULL;
+	nd = malloc(sizeof(*nd), M_TEMP, M_WAITOK | M_ZERO);
 	nfscl_reqstart(nd, NFSPROC_GETATTR, nmp, (u_int8_t *)fhp,
 	    sizeof(fhandle_t), NULL, NULL);
 	NFSZERO_ATTRBIT(&attrbits);
@@ -4456,8 +4468,10 @@ nfsrv_getattrdsrpc(fhandle_t *fhp, struct ucred *cred,
 	(void) nfsrv_putattrbit(nd, &attrbits);
 	error = newnfs_request(nd, nmp, NULL, &nmp->nm_sockreq, NULL, p, cred,
 	    NFS_PROG, NFS_VER4, NULL, 1, NULL, NULL);
-	if (error != 0)
+	if (error != 0) {
+		free(nd, M_TEMP);
 		return (error);
+	}
 	NFSD_DEBUG(4, "nfsrv_getattrdsrpc: aft getattrrpc=%d\n",
 	    nd->nd_repstat);
 	if (nd->nd_repstat == 0) {
@@ -4472,6 +4486,7 @@ nfsrv_getattrdsrpc(fhandle_t *fhp, struct ucred *cred,
 	} else
 		error = nd->nd_repstat;
 	m_freem(nd->nd_mrep);
+	free(nd, M_TEMP);
 	NFSD_DEBUG(4, "nfsrv_getattrdsrpc error=%d\n", error);
 	return (error);
 }


More information about the svn-src-projects mailing list