From f4e141a98936a15883841b776de7393b90aeaa5f Mon Sep 17 00:00:00 2001 From: rmacklem Date: Tue, 25 Apr 2017 20:34:56 +0000 Subject: [PATCH] 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. git-svn-id: svn://svn.freebsd.org/base/stable/10@317423 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/fs/nfsclient/nfs_clstate.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/sys/fs/nfsclient/nfs_clstate.c b/sys/fs/nfsclient/nfs_clstate.c index 8c28fff09..ac4452f0b 100644 --- a/sys/fs/nfsclient/nfs_clstate.c +++ b/sys/fs/nfsclient/nfs_clstate.c @@ -797,8 +797,18 @@ nfscl_getcl(struct mount *mp, struct ucred *cred, NFSPROC_T *p, (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 -- 2.45.0