Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 8 May 2017 19:57:43 +0000 (UTC)
From:      Rick Macklem <rmacklem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r317975 - stable/10/sys/fs/nfsclient
Message-ID:  <201705081957.v48JvhNc013383@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rmacklem
Date: Mon May  8 19:57:43 2017
New Revision: 317975
URL: https://svnweb.freebsd.org/changeset/base/317975

Log:
  MFC: r317296
  Fix some krpc leaks for the NFSv4.1/pNFS client.
  
  The NFSv4.1/pNFS client wasn't doing a newnfs_disconnect() call for the
  connection to the Data Server (DS) under some circumstances. The main
  effect of this was a leak of malloc'd structures in the krpc. This patch
  adds the newnfs_disconnect() calls to fix this.
  Detected during recent testing against the pNFS server under development.

Modified:
  stable/10/sys/fs/nfsclient/nfs_clrpcops.c
  stable/10/sys/fs/nfsclient/nfs_clvfsops.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/fs/nfsclient/nfs_clrpcops.c
==============================================================================
--- stable/10/sys/fs/nfsclient/nfs_clrpcops.c	Mon May  8 19:57:15 2017	(r317974)
+++ stable/10/sys/fs/nfsclient/nfs_clrpcops.c	Mon May  8 19:57:43 2017	(r317975)
@@ -5396,10 +5396,13 @@ nfsrpc_fillsa(struct nfsmount *nmp, stru
 	NFSCL_DEBUG(3, "DS connect=%d\n", error);
 
 	/* Now, do the exchangeid and create session. */
-	if (error == 0)
+	if (error == 0) {
 		error = nfsrpc_exchangeid(nmp, clp, nrp, NFSV4EXCH_USEPNFSDS,
 		    &dsp, nrp->nr_cred, p);
-	NFSCL_DEBUG(3, "DS exchangeid=%d\n", error);
+		NFSCL_DEBUG(3, "DS exchangeid=%d\n", error);
+		if (error != 0)
+			newnfs_disconnect(nrp);
+	}
 	if (error == 0) {
 		dsp->nfsclds_sockp = nrp;
 		NFSLOCKMNT(nmp);
@@ -5442,8 +5445,10 @@ nfsrpc_fillsa(struct nfsmount *nmp, stru
 		TAILQ_INSERT_TAIL(&nmp->nm_sess, dsp, nfsclds_list);
 		NFSUNLOCKMNT(nmp);
 		*dspp = dsp;
-	} else if (dsp != NULL)
+	} else if (dsp != NULL) {
+		newnfs_disconnect(nrp);
 		nfscl_freenfsclds(dsp);
+	}
 	return (error);
 }
 

Modified: stable/10/sys/fs/nfsclient/nfs_clvfsops.c
==============================================================================
--- stable/10/sys/fs/nfsclient/nfs_clvfsops.c	Mon May  8 19:57:15 2017	(r317974)
+++ stable/10/sys/fs/nfsclient/nfs_clvfsops.c	Mon May  8 19:57:43 2017	(r317975)
@@ -1527,8 +1527,12 @@ bad:
 		NFSUNLOCKCLSTATE();
 		free(nmp->nm_clp, M_NFSCLCLIENT);
 	}
-	TAILQ_FOREACH_SAFE(dsp, &nmp->nm_sess, nfsclds_list, tdsp)
+	TAILQ_FOREACH_SAFE(dsp, &nmp->nm_sess, nfsclds_list, tdsp) {
+		if (dsp != TAILQ_FIRST(&nmp->nm_sess) &&
+		    dsp->nfsclds_sockp != NULL)
+			newnfs_disconnect(dsp->nfsclds_sockp);
 		nfscl_freenfsclds(dsp);
+	}
 	FREE(nmp, M_NEWNFSMNT);
 	FREE(nam, M_SONAME);
 	return (error);
@@ -1593,8 +1597,12 @@ nfs_unmount(struct mount *mp, int mntfla
 		AUTH_DESTROY(nmp->nm_sockreq.nr_auth);
 	mtx_destroy(&nmp->nm_sockreq.nr_mtx);
 	mtx_destroy(&nmp->nm_mtx);
-	TAILQ_FOREACH_SAFE(dsp, &nmp->nm_sess, nfsclds_list, tdsp)
+	TAILQ_FOREACH_SAFE(dsp, &nmp->nm_sess, nfsclds_list, tdsp) {
+		if (dsp != TAILQ_FIRST(&nmp->nm_sess) &&
+		    dsp->nfsclds_sockp != NULL)
+			newnfs_disconnect(dsp->nfsclds_sockp);
 		nfscl_freenfsclds(dsp);
+	}
 	FREE(nmp, M_NEWNFSMNT);
 out:
 	return (error);



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