nfscl: Add a check for VREG for delegations

Since delegations are only issued for regular files, check
v_type to see if the query is for a regular file.  This is
a simple optimization for the non-VREG case.
While here, fix a couple of global variable declarations.

This patch should only affect the NFSv4.1/4.2 behaviour
when delegations are enabled, which is not the default.

MFC after:	1 month
This commit is contained in:
Rick Macklem 2024-06-12 16:17:23 -07:00
parent ec1f285f2e
commit 4308d6e0fc

View File

@ -93,9 +93,8 @@ NFSREQSPINLOCK;
NFSCLSTATEMUTEX;
int nfscl_inited = 0;
struct nfsclhead nfsclhead; /* Head of clientid list */
int nfscl_deleghighwater = NFSCLDELEGHIGHWATER;
int nfscl_layouthighwater = NFSCLLAYOUTHIGHWATER;
static int nfscl_deleghighwater = NFSCLDELEGHIGHWATER;
static int nfscl_delegcnt = 0;
static int nfscl_layoutcnt = 0;
static int nfscl_getopen(struct nfsclownerhead *, struct nfsclopenhash *,
@ -4647,7 +4646,7 @@ nfscl_mustflush(vnode_t vp)
np = VTONFS(vp);
nmp = VFSTONFS(vp->v_mount);
if (!NFSHASNFSV4(nmp))
if (!NFSHASNFSV4(nmp) || vp->v_type != VREG)
return (1);
NFSLOCKMNT(nmp);
if ((nmp->nm_privflag & NFSMNTP_DELEGISSUED) == 0) {
@ -4687,7 +4686,7 @@ nfscl_nodeleg(vnode_t vp, int writedeleg)
np = VTONFS(vp);
nmp = VFSTONFS(vp->v_mount);
if (!NFSHASNFSV4(nmp))
if (!NFSHASNFSV4(nmp) || vp->v_type != VREG)
return (1);
NFSLOCKMNT(nmp);
if ((nmp->nm_privflag & NFSMNTP_DELEGISSUED) == 0) {