From 0c419e226cb80c91f7971efdeb6f5e8355828d28 Mon Sep 17 00:00:00 2001 From: Rick Macklem Date: Fri, 29 May 2015 20:22:53 +0000 Subject: [PATCH] Make the NFS server use shared vnode locks for a few cases that are allowed by the VFS/VOP interface instead of using exclusive locks. MFC after: 2 weeks --- sys/fs/nfsserver/nfs_nfsdsocket.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/sys/fs/nfsserver/nfs_nfsdsocket.c b/sys/fs/nfsserver/nfs_nfsdsocket.c index 9c00a0c09b3..4497161f6dd 100644 --- a/sys/fs/nfsserver/nfs_nfsdsocket.c +++ b/sys/fs/nfsserver/nfs_nfsdsocket.c @@ -440,9 +440,12 @@ nfsrvd_dorpc(struct nfsrv_descript *nd, int isdgram, u_char *tag, int taglen, if (nd->nd_procnum == NFSPROC_READ || nd->nd_procnum == NFSPROC_WRITE || nd->nd_procnum == NFSPROC_READDIR || + nd->nd_procnum == NFSPROC_READDIRPLUS || nd->nd_procnum == NFSPROC_READLINK || nd->nd_procnum == NFSPROC_GETATTR || - nd->nd_procnum == NFSPROC_ACCESS) + nd->nd_procnum == NFSPROC_ACCESS || + nd->nd_procnum == NFSPROC_FSSTAT || + nd->nd_procnum == NFSPROC_FSINFO) lktype = LK_SHARED; else lktype = LK_EXCLUSIVE; @@ -544,7 +547,7 @@ static void nfsrvd_compound(struct nfsrv_descript *nd, int isdgram, u_char *tag, int taglen, u_int32_t minorvers, NFSPROC_T *p) { - int i, op, op0 = 0; + int i, lktype, op, op0 = 0; u_int32_t *tl; struct nfsclient *clp, *nclp; int numops, error = 0, igotlock; @@ -953,11 +956,15 @@ nfsrvd_compound(struct nfsrv_descript *nd, int isdgram, u_char *tag, panic("nfsrvd_compound"); if (nfsv4_opflag[op].needscfh) { if (vp != NULL) { - if (nfsv4_opflag[op].modifyfs) + lktype = nfsv4_opflag[op].lktype; + if (nfsv4_opflag[op].modifyfs) { vn_start_write(vp, &temp_mp, V_WAIT); - if (NFSVOPLOCK(vp, nfsv4_opflag[op].lktype) - == 0) + if (op == NFSV4OP_WRITE && + MNT_SHARED_WRITES(temp_mp)) + lktype = LK_SHARED; + } + if (NFSVOPLOCK(vp, lktype) == 0) VREF(vp); else nd->nd_repstat = NFSERR_PERM;