Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 25 Apr 2017 20:24:00 +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-11@freebsd.org
Subject:   svn commit: r317422 - stable/11/sys/fs/nfsclient
Message-ID:  <201704252024.v3PKO0rf064276@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rmacklem
Date: Tue Apr 25 20:24:00 2017
New Revision: 317422
URL: https://svnweb.freebsd.org/changeset/base/317422

Log:
  MFC: r316669
  Avoid starvation of the server crash recovery thread for the NFSv4 client.
  
  This patch gives a requestor of the exclusive lock on the client state
  in the NFSv4 client priority over shared lock requestors. This avoids
  the server crash recovery thread being starved out by other threads doing
  RPCs.

Modified:
  stable/11/sys/fs/nfsclient/nfs_clstate.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/fs/nfsclient/nfs_clstate.c
==============================================================================
--- stable/11/sys/fs/nfsclient/nfs_clstate.c	Tue Apr 25 19:54:34 2017	(r317421)
+++ stable/11/sys/fs/nfsclient/nfs_clstate.c	Tue Apr 25 20:24:00 2017	(r317422)
@@ -797,8 +797,18 @@ nfscl_getcl(struct mount *mp, struct ucr
 	    (mp->mnt_kern_flag & MNTK_UNMOUNTF) == 0)
 		igotlock = nfsv4_lock(&clp->nfsc_lock, 1, NULL,
 		    NFSCLSTATEMUTEXPTR, mp);
-	if (!igotlock)
+	if (igotlock == 0) {
+		/*
+		 * Call nfsv4_lock() with "iwantlock == 0" so that it will
+		 * wait for a pending exclusive lock request.  This gives the
+		 * exclusive lock request priority over this shared lock
+		 * request.
+		 * An exclusive lock on nfsc_lock is used mainly for server
+		 * crash recoveries.
+		 */
+		nfsv4_lock(&clp->nfsc_lock, 0, NULL, NFSCLSTATEMUTEXPTR, mp);
 		nfsv4_getref(&clp->nfsc_lock, NULL, NFSCLSTATEMUTEXPTR, mp);
+	}
 	if (igotlock == 0 && (mp->mnt_kern_flag & MNTK_UNMOUNTF) != 0) {
 		/*
 		 * Both nfsv4_lock() and nfsv4_getref() know to check



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