diff options
Diffstat (limited to 'sys/nfs/nfs_bio.c')
-rw-r--r-- | sys/nfs/nfs_bio.c | 79 |
1 files changed, 16 insertions, 63 deletions
diff --git a/sys/nfs/nfs_bio.c b/sys/nfs/nfs_bio.c index 45e827946f1..f670a997e02 100644 --- a/sys/nfs/nfs_bio.c +++ b/sys/nfs/nfs_bio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_bio.c,v 1.66 2009/08/27 23:39:46 thib Exp $ */ +/* $OpenBSD: nfs_bio.c,v 1.67 2009/09/02 18:20:54 thib Exp $ */ /* $NetBSD: nfs_bio.c,v 1.25.4.2 1996/07/08 20:47:04 jtc Exp $ */ /* @@ -57,7 +57,10 @@ #include <nfs/nfsnode.h> #include <nfs/nfs_var.h> +extern int nfs_numasync; extern struct nfsstats nfsstats; +struct nfs_bufqhead nfs_bufq; +uint32_t nfs_bufqmax, nfs_bufqlen; /* * Vnode op for read using bio @@ -147,7 +150,7 @@ nfs_bioread(vp, uio, ioflag, cred) /* * Start the read ahead(s), as required. */ - if (nfs_numaiods > 0 && nmp->nm_readahead > 0) { + if (nfs_numasync > 0 && nmp->nm_readahead > 0) { for (nra = 0; nra < nmp->nm_readahead && (lbn + 1 + nra) * biosize < np->n_size; nra++) { rabn = (lbn + 1 + nra) * (biosize / DEV_BSIZE); @@ -503,75 +506,25 @@ nfs_vinvalbuf(struct vnode *vp, int flags, struct ucred *cred, struct proc *p) * are all hung on a dead server. */ int -nfs_asyncio(struct buf *bp) +nfs_asyncio(bp) + struct buf *bp; { - struct nfs_aiod *aiod; - struct nfsmount *nmp; - int gotone, error; - - aiod = NULL; - nmp = VFSTONFS(bp->b_vp->v_mount); - gotone = error = 0; - - mtx_enter(&nfs_aiodl_mtx); - aiod = LIST_FIRST(&nfs_aiods_idle); - if (aiod) { - /* - * Found an available aiod, wake it up and send - * it to work on this mount. - */ - LIST_REMOVE(aiod, nad_idle); - mtx_leave(&nfs_aiodl_mtx); - - aiod->nad_flags |= NFSAIOD_WAKEUP; - gotone = 1; - KASSERT(aiod->nad_mnt == NULL); - aiod->nad_mnt = nmp; - nmp->nm_naiods++; - wakeup_one(aiod); - } else { - mtx_leave(&nfs_aiodl_mtx); - } - - /* - * If no aiod's are available, check if theres already an - * aiod assoicated with this mount, if so it will process - * this buf. - */ - if (!gotone && nmp->nm_naiods > 0) - gotone = 1; - - /* - * If we still don't have an aiod to process this buffer, - * force it sync. - */ - if (!gotone) + if (nfs_numasync == 0) goto out; + if (nfs_bufqlen > nfs_bufqmax) + goto out; /* too many bufs in use, force sync */ - /* - * Make sure we don't queue up too much. - * TODO: Look into implementing migration for aiods. - */ - if (nmp->nm_bufqlen >= nfs_aiodbufqmax) { - if (aiod != NULL) { - aiod->nad_flags &= ~NFSAIOD_WAKEUP; - aiod->nad_mnt = NULL; - mtx_enter(&nfs_aiodl_mtx); - LIST_INSERT_HEAD(&nfs_aiods_idle, aiod, nad_idle); - mtx_leave(&nfs_aiodl_mtx); - } - goto out; + if ((bp->b_flags & B_READ) == 0) { + bp->b_flags |= B_WRITEINPROG; } - /* Finally, queue the buffer and return. */ + TAILQ_INSERT_TAIL(&nfs_bufq, bp, b_freelist); + nfs_bufqlen++; - if ((bp->b_flags & B_READ) == 0) - bp->b_flags |= B_WRITEINPROG; - - TAILQ_INSERT_TAIL(&nmp->nm_bufq, bp, b_freelist); - nmp->nm_bufqlen++; + wakeup_one(&nfs_bufq); return (0); + out: nfsstats.forcedsync++; return (EIO); |