From 365e894b0f63e67763498fc8f9ebd33fa3cfa8bf Mon Sep 17 00:00:00 2001 From: mohans Date: Wed, 24 May 2006 23:06:50 +0000 Subject: Since NFSv4 is not SMP safe, nfsiod needs to acquire Giant for NFSv4 mounts before doing the read/write. Reported by: Chuck Lever. --- sys/nfsclient/nfs.h | 1 + sys/nfsclient/nfs_nfsiod.c | 8 ++++++++ 2 files changed, 9 insertions(+) (limited to 'sys/nfsclient') diff --git a/sys/nfsclient/nfs.h b/sys/nfsclient/nfs.h index a87966d..c0a649f 100644 --- a/sys/nfsclient/nfs.h +++ b/sys/nfsclient/nfs.h @@ -86,6 +86,7 @@ #define NFS_CMPFH(n, f, s) \ ((n)->n_fhsize == (s) && !bcmp((caddr_t)(n)->n_fhp, (caddr_t)(f), (s))) #define NFS_ISV3(v) (VFSTONFS((v)->v_mount)->nm_flag & NFSMNT_NFSV3) +#define NFS_ISV4(v) (VFSTONFS((v)->v_mount)->nm_flag & NFSMNT_NFSV4) #define NFSSTA_HASWRITEVERF 0x00040000 /* Has write verifier for V3 */ #define NFSSTA_GOTFSINFO 0x00100000 /* Got the V3 fsinfo */ diff --git a/sys/nfsclient/nfs_nfsiod.c b/sys/nfsclient/nfs_nfsiod.c index 4851824..e219c71 100644 --- a/sys/nfsclient/nfs_nfsiod.c +++ b/sys/nfsclient/nfs_nfsiod.c @@ -248,6 +248,8 @@ nfssvc_iod(void *instance) if (error) break; while ((bp = TAILQ_FIRST(&nmp->nm_bufq)) != NULL) { + int giant_locked = 0; + /* Take one off the front of the list */ TAILQ_REMOVE(&nmp->nm_bufq, bp, b_freelist); nmp->nm_bufqlen--; @@ -256,6 +258,10 @@ nfssvc_iod(void *instance) wakeup(&nmp->nm_bufq); } mtx_unlock(&nfs_iod_mtx); + if (NFS_ISV4(bp->b_vp)) { + giant_locked = 1; + mtx_lock(&Giant); + } if (bp->b_flags & B_DIRECT) { KASSERT((bp->b_iocmd == BIO_WRITE), ("nfscvs_iod: BIO_WRITE not set")); (void)nfs_doio_directwrite(bp); @@ -265,6 +271,8 @@ nfssvc_iod(void *instance) else (void) nfs_doio(bp->b_vp, bp, bp->b_wcred, NULL); } + if (giant_locked) + mtx_unlock(&Giant); mtx_lock(&nfs_iod_mtx); /* * If there are more than one iod on this mount, then defect -- cgit v1.1