use nestiobuf api for genfs.
This commit is contained in:
parent
db2c8f4e34
commit
58d3c6b6cd
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: genfs_vnops.c,v 1.119 2006/01/04 10:13:06 yamt Exp $ */
|
||||
/* $NetBSD: genfs_vnops.c,v 1.120 2006/01/11 00:46:54 yamt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1989, 1993
|
||||
@ -31,7 +31,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.119 2006/01/04 10:13:06 yamt Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.120 2006/01/11 00:46:54 yamt Exp $");
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_nfsserver.h"
|
||||
@ -441,7 +441,7 @@ genfs_getpages(void *v)
|
||||
off_t newsize, diskeof, memeof;
|
||||
off_t offset, origoffset, startoffset, endoffset, raoffset;
|
||||
daddr_t lbn, blkno;
|
||||
int s, i, error, npages, orignpages, npgs, run, ridx, pidx, pcount;
|
||||
int i, error, npages, orignpages, npgs, run, ridx, pidx, pcount;
|
||||
int fs_bshift, fs_bsize, dev_bshift;
|
||||
int flags = ap->a_flags;
|
||||
size_t bytes, iobytes, tailbytes, totalbytes, skipbytes;
|
||||
@ -672,6 +672,10 @@ genfs_getpages(void *v)
|
||||
mbp->b_flags = B_BUSY|B_READ| (async ? B_CALL|B_ASYNC : 0);
|
||||
mbp->b_iodone = (async ? uvm_aio_biodone : 0);
|
||||
mbp->b_vp = vp;
|
||||
if (async)
|
||||
BIO_SETPRIO(mbp, BPRIO_TIMELIMITED);
|
||||
else
|
||||
BIO_SETPRIO(mbp, BPRIO_TIMECRITICAL);
|
||||
|
||||
/*
|
||||
* if EOF is in the middle of the range, zero the part past EOF.
|
||||
@ -800,15 +804,9 @@ genfs_getpages(void *v)
|
||||
bp = mbp;
|
||||
} else {
|
||||
bp = getiobuf();
|
||||
bp->b_data = (char *)kva + offset - startoffset;
|
||||
bp->b_resid = bp->b_bcount = iobytes;
|
||||
bp->b_flags = B_BUSY|B_READ|B_CALL|B_ASYNC;
|
||||
bp->b_iodone = uvm_aio_biodone1;
|
||||
bp->b_vp = vp;
|
||||
bp->b_proc = NULL;
|
||||
nestiobuf_setup(mbp, bp, offset - startoffset, iobytes);
|
||||
}
|
||||
bp->b_lblkno = 0;
|
||||
bp->b_private = mbp;
|
||||
|
||||
/* adjust physical blkno for partial blocks */
|
||||
bp->b_blkno = blkno + ((offset - ((off_t)lbn << fs_bshift)) >>
|
||||
@ -818,28 +816,11 @@ genfs_getpages(void *v)
|
||||
"bp %p offset 0x%x bcount 0x%x blkno 0x%x",
|
||||
bp, offset, iobytes, bp->b_blkno);
|
||||
|
||||
if (async)
|
||||
BIO_SETPRIO(bp, BPRIO_TIMELIMITED);
|
||||
else
|
||||
BIO_SETPRIO(bp, BPRIO_TIMECRITICAL);
|
||||
|
||||
VOP_STRATEGY(devvp, bp);
|
||||
}
|
||||
|
||||
loopdone:
|
||||
if (skipbytes) {
|
||||
s = splbio();
|
||||
if (error) {
|
||||
mbp->b_flags |= B_ERROR;
|
||||
mbp->b_error = error;
|
||||
}
|
||||
mbp->b_resid -= skipbytes;
|
||||
if (mbp->b_resid == 0) {
|
||||
biodone(mbp);
|
||||
}
|
||||
splx(s);
|
||||
}
|
||||
|
||||
nestiobuf_done(mbp, skipbytes, error);
|
||||
if (async) {
|
||||
UVMHIST_LOG(ubchist, "returning 0 (async)",0,0,0,0);
|
||||
lockmgr(&gp->g_glock, LK_RELEASE, NULL);
|
||||
@ -1476,6 +1457,12 @@ genfs_gop_write(struct vnode *vp, struct vm_page **pgs, int npages, int flags)
|
||||
mbp->b_flags = B_BUSY|B_WRITE|B_AGE| (async ? (B_CALL|B_ASYNC) : 0);
|
||||
mbp->b_iodone = uvm_aio_biodone;
|
||||
mbp->b_vp = vp;
|
||||
if (curproc == uvm.pagedaemon_proc)
|
||||
BIO_SETPRIO(mbp, BPRIO_TIMELIMITED);
|
||||
else if (async)
|
||||
BIO_SETPRIO(mbp, BPRIO_TIMENONCRITICAL);
|
||||
else
|
||||
BIO_SETPRIO(mbp, BPRIO_TIMECRITICAL);
|
||||
|
||||
bp = NULL;
|
||||
for (offset = startoffset;
|
||||
@ -1501,21 +1488,12 @@ genfs_gop_write(struct vnode *vp, struct vm_page **pgs, int npages, int flags)
|
||||
if (offset == startoffset && iobytes == bytes) {
|
||||
bp = mbp;
|
||||
} else {
|
||||
s = splbio();
|
||||
V_INCR_NUMOUTPUT(vp);
|
||||
splx(s);
|
||||
bp = getiobuf();
|
||||
UVMHIST_LOG(ubchist, "vp %p bp %p num now %d",
|
||||
vp, bp, vp->v_numoutput, 0);
|
||||
bp->b_data = (char *)kva +
|
||||
(vaddr_t)(offset - pg->offset);
|
||||
bp->b_resid = bp->b_bcount = iobytes;
|
||||
bp->b_flags = B_BUSY|B_WRITE|B_CALL|B_ASYNC;
|
||||
bp->b_iodone = uvm_aio_biodone1;
|
||||
bp->b_vp = vp;
|
||||
bp = getiobuf();
|
||||
nestiobuf_setup(mbp, bp, offset - pg->offset, iobytes);
|
||||
}
|
||||
bp->b_lblkno = 0;
|
||||
bp->b_private = mbp;
|
||||
|
||||
/* adjust physical blkno for partial blocks */
|
||||
bp->b_blkno = blkno + ((offset - ((off_t)lbn << fs_bshift)) >>
|
||||
@ -1523,28 +1501,13 @@ genfs_gop_write(struct vnode *vp, struct vm_page **pgs, int npages, int flags)
|
||||
UVMHIST_LOG(ubchist,
|
||||
"vp %p offset 0x%x bcount 0x%x blkno 0x%x",
|
||||
vp, offset, bp->b_bcount, bp->b_blkno);
|
||||
if (curproc == uvm.pagedaemon_proc)
|
||||
BIO_SETPRIO(bp, BPRIO_TIMELIMITED);
|
||||
else if (async)
|
||||
BIO_SETPRIO(bp, BPRIO_TIMENONCRITICAL);
|
||||
else
|
||||
BIO_SETPRIO(bp, BPRIO_TIMECRITICAL);
|
||||
|
||||
VOP_STRATEGY(devvp, bp);
|
||||
}
|
||||
if (skipbytes) {
|
||||
UVMHIST_LOG(ubchist, "skipbytes %d", skipbytes, 0,0,0);
|
||||
s = splbio();
|
||||
if (error) {
|
||||
mbp->b_flags |= B_ERROR;
|
||||
mbp->b_error = error;
|
||||
}
|
||||
mbp->b_resid -= skipbytes;
|
||||
if (mbp->b_resid == 0) {
|
||||
biodone(mbp);
|
||||
}
|
||||
splx(s);
|
||||
}
|
||||
nestiobuf_done(mbp, skipbytes, error);
|
||||
if (async) {
|
||||
UVMHIST_LOG(ubchist, "returning 0 (async)", 0,0,0,0);
|
||||
return (0);
|
||||
|
Loading…
Reference in New Issue
Block a user