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);
_______________________________________________
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"

Reply via email to