From 8bfa5617b62252ac6a5a5194052bfc13782dff76 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Fri, 17 Jul 2009 22:31:28 -0700 Subject: [PATCH] NFS - Stability pass / recent work. * Fix numerous bugs introduced in the conversion, on both the server side and the client side. --- sys/vfs/nfs/nfs_bio.c | 2 ++ sys/vfs/nfs/nfs_serv.c | 6 +++++- sys/vfs/nfs/nfs_vnops.c | 6 ++++++ sys/vfs/nfs/nfsm_subs.c | 27 ++++++++++++--------------- sys/vfs/nfs/nfsm_subs.h | 6 +++--- 5 files changed, 28 insertions(+), 19 deletions(-) diff --git a/sys/vfs/nfs/nfs_bio.c b/sys/vfs/nfs/nfs_bio.c index d5acf9370a..5b4897446a 100644 --- a/sys/vfs/nfs/nfs_bio.c +++ b/sys/vfs/nfs/nfs_bio.c @@ -1376,6 +1376,7 @@ nfs_startio(struct vnode *vp, struct bio *bio, struct thread *td) bp->b_flags &= ~(B_NEEDCOMMIT | B_CLUSTEROK); bp->b_resid = 0; biodone(bio); + return; } if (retv == NFSERR_STALEWRITEVERF) { nfs_clearcommit(vp->v_mount); @@ -1464,6 +1465,7 @@ nfs_startio(struct vnode *vp, struct bio *bio, struct thread *td) } else { bp->b_resid = 0; biodone(bio); + return; } } bp->b_resid = uiop->uio_resid; diff --git a/sys/vfs/nfs/nfs_serv.c b/sys/vfs/nfs/nfs_serv.c index 6f37d667d5..ecccf7ee3b 100644 --- a/sys/vfs/nfs/nfs_serv.c +++ b/sys/vfs/nfs/nfs_serv.c @@ -1219,6 +1219,8 @@ nfsrv_writegather(struct nfsrv_descript **ndp, struct nfssvc_sock *slp, u_quad_t cur_usec; struct nfsm_info info; + info.mreq = NULL; + nfsdbprintf(("%s %d\n", __FILE__, __LINE__)); #ifndef nolint i = 0; @@ -1517,6 +1519,7 @@ loop1: break; } crit_exit(); + *mrq = info.mreq; return (0); } @@ -1848,7 +1851,7 @@ nfsmreply0: /* fall through */ nfsmout: - info.mreq = NULL; + *mrq = info.mreq; if (dirp) vrele(dirp); nlookup_done(&nd); @@ -1996,6 +1999,7 @@ out: } nfsm_srvwcc_data(&info, nfsd, dirfor_ret, &dirfor, diraft_ret, &diraft); + *mrq = info.mreq; return (0); nfsmout: *mrq = info.mreq; diff --git a/sys/vfs/nfs/nfs_vnops.c b/sys/vfs/nfs/nfs_vnops.c index 98724124f5..3f7152608e 100644 --- a/sys/vfs/nfs/nfs_vnops.c +++ b/sys/vfs/nfs/nfs_vnops.c @@ -2934,9 +2934,15 @@ nfs_strategy(struct vop_strategy_args *ap) * We probably don't need to push an nbio any more since no * block conversion is required due to the use of 64 bit byte * offsets, but do it anyway. + * + * NOTE: When NFS callers itself via this strategy routines and + * sets up a synchronous I/O, it expects the I/O to run + * synchronously (its bio_done routine just assumes it), + * so for now we have to honor the bit. */ nbio = push_bio(bio); nbio->bio_offset = bio->bio_offset; + nbio->bio_flags = bio->bio_flags & BIO_SYNC; /* * If the op is asynchronous and an i/o daemon is waiting diff --git a/sys/vfs/nfs/nfsm_subs.c b/sys/vfs/nfs/nfsm_subs.c index ee7c13cc68..13dd892de2 100644 --- a/sys/vfs/nfs/nfsm_subs.c +++ b/sys/vfs/nfs/nfsm_subs.c @@ -939,23 +939,20 @@ nfsm_srvmtofh(nfsm_info_t info, struct nfsrv_descript *nfsd, } void * -_nfsm_clget(nfsm_info_t info, struct mbuf *mp1, struct mbuf *mp2, - char *bp, char *be) +_nfsm_clget(nfsm_info_t info, struct mbuf **mp1, struct mbuf **mp2, + char **bp, char **be) { - u_int32_t *tl; - - if (bp >= be) { - if (mp1 == info->mb) - mp1->m_len += bp - info->bpos; - mp1 = m_getcl(MB_WAIT, MT_DATA, 0); - mp1->m_len = MCLBYTES; - mp2->m_next = mp1; - mp2 = mp1; - bp = mtod(mp1, caddr_t); - be = bp + mp1->m_len; + if (*bp >= *be) { + if (*mp1 == info->mb) + (*mp1)->m_len += *bp - info->bpos; + *mp1 = m_getcl(MB_WAIT, MT_DATA, 0); + (*mp1)->m_len = MCLBYTES; + (*mp2)->m_next = *mp1; + *mp2 = *mp1; + *bp = mtod(*mp1, caddr_t); + *be = *bp + (*mp1)->m_len; } - tl = (u_int32_t *)bp; - return (tl); + return(*bp); } int diff --git a/sys/vfs/nfs/nfsm_subs.h b/sys/vfs/nfs/nfsm_subs.h index 4af48642ec..b10c763653 100644 --- a/sys/vfs/nfs/nfsm_subs.h +++ b/sys/vfs/nfs/nfsm_subs.h @@ -169,8 +169,8 @@ void nfsm_writereply(nfsm_info_t info, struct nfsrv_descript *nfsd, int nfsm_adv(nfsm_info_t info, int len); int nfsm_srvmtofh(nfsm_info_t info, struct nfsrv_descript *nfsd, fhandle_t *fhp, int *errorp); -void *_nfsm_clget(nfsm_info_t info, struct mbuf *mp1, struct mbuf *mp2, - char *bp, char *be); +void *_nfsm_clget(nfsm_info_t info, struct mbuf **mp1, struct mbuf **mp2, + char **bp, char **be); int nfsm_srvsattr(nfsm_info_t info, struct vattr *vap); int nfsm_mbuftouio(struct mbuf **mrep, struct uio *uiop, int siz, caddr_t *dpos); @@ -195,7 +195,7 @@ void nfsm_srvfattr(struct nfsrv_descript *nfsd, struct vattr *vap, int nfs_request (struct nfsm_info *, nfsm_state_t, nfsm_state_t); #define nfsm_clget(info, mp1, mp2, bp, be) \ - ((bp >= be) ? _nfsm_clget(info, mp1, mp2, bp, be) : (void *)bp) + ((bp >= be) ? _nfsm_clget(info, &mp1, &mp2, &bp, &be) : (void *)bp) #define nfsm_rndup(a) (((a) + 3) & (~0x3)) -- 2.41.0