Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/miscfs/genfs make genfs get/put work for block devices a...
details: https://anonhg.NetBSD.org/src/rev/c1a9d11d6325
branches: trunk
changeset: 513899:c1a9d11d6325
user: chs <chs%NetBSD.org@localhost>
date: Fri Aug 17 05:51:29 2001 +0000
description:
make genfs get/put work for block devices as well:
- the "fs bshift" for block devices is always DEV_BSHIFT.
- retrieve the device vnode from VOP_BMAP() and use that to set b_dev
in page i/o buffers.
diffstat:
sys/miscfs/genfs/genfs_vnops.c | 28 +++++++++++++++++++++-------
1 files changed, 21 insertions(+), 7 deletions(-)
diffs (92 lines):
diff -r 3e9dfb40b0c9 -r c1a9d11d6325 sys/miscfs/genfs/genfs_vnops.c
--- a/sys/miscfs/genfs/genfs_vnops.c Fri Aug 17 05:49:43 2001 +0000
+++ b/sys/miscfs/genfs/genfs_vnops.c Fri Aug 17 05:51:29 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: genfs_vnops.c,v 1.35 2001/06/14 08:22:14 chs Exp $ */
+/* $NetBSD: genfs_vnops.c,v 1.36 2001/08/17 05:51:29 chs Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@@ -456,6 +456,7 @@
vaddr_t kva;
struct buf *bp, *mbp;
struct vnode *vp = ap->a_vp;
+ struct vnode *devvp;
struct uvm_object *uobj = &vp->v_uvm.u_obj;
struct vm_page *pgs[16]; /* XXXUBC 16 */
struct ucred *cred = curproc->p_ucred; /* XXXUBC curproc */
@@ -528,9 +529,14 @@
* leave space in the page array for a whole block.
*/
- fs_bshift = vp->v_mount->mnt_fs_bshift;
+ if (vp->v_type == VREG) {
+ fs_bshift = vp->v_mount->mnt_fs_bshift;
+ dev_bshift = vp->v_mount->mnt_dev_bshift;
+ } else {
+ fs_bshift = DEV_BSHIFT;
+ dev_bshift = DEV_BSHIFT;
+ }
fs_bsize = 1 << fs_bshift;
- dev_bshift = vp->v_mount->mnt_dev_bshift;
dev_bsize = 1 << dev_bshift;
KASSERT((diskeof & (dev_bsize - 1)) == 0);
KASSERT((memeof & (dev_bsize - 1)) == 0);
@@ -695,7 +701,7 @@
*/
lbn = offset >> fs_bshift;
- error = VOP_BMAP(vp, lbn, NULL, &blkno, &run);
+ error = VOP_BMAP(vp, lbn, &devvp, &blkno, &run);
if (error) {
UVMHIST_LOG(ubchist, "VOP_BMAP lbn 0x%x -> %d\n",
lbn, error,0,0);
@@ -767,6 +773,7 @@
}
bp->b_lblkno = 0;
bp->b_private = mbp;
+ bp->b_dev = devvp->v_rdev;
/* adjust physical blkno for partial blocks */
bp->b_blkno = blkno + ((offset - ((off_t)lbn << fs_bshift)) >>
@@ -960,6 +967,7 @@
struct vm_page *pg;
struct buf *mbp, *bp;
struct vnode *vp = ap->a_vp;
+ struct vnode *devvp;
boolean_t async = (ap->a_flags & PGO_SYNCIO) == 0;
UVMHIST_FUNC("genfs_putpages"); UVMHIST_CALLED(ubchist);
UVMHIST_LOG(ubchist, "vp %p offset 0x%x count %d",
@@ -974,8 +982,13 @@
error = 0;
npages = ap->a_count;
- fs_bshift = vp->v_mount->mnt_fs_bshift;
- dev_bshift = vp->v_mount->mnt_dev_bshift;
+ if (vp->v_type == VREG) {
+ fs_bshift = vp->v_mount->mnt_fs_bshift;
+ dev_bshift = vp->v_mount->mnt_dev_bshift;
+ } else {
+ fs_bshift = DEV_BSHIFT;
+ dev_bshift = DEV_BSHIFT;
+ }
dev_bsize = 1 << dev_bshift;
KASSERT((eof & (dev_bsize - 1)) == 0);
@@ -1008,7 +1021,7 @@
bytes > 0;
offset += iobytes, bytes -= iobytes) {
lbn = offset >> fs_bshift;
- error = VOP_BMAP(vp, lbn, NULL, &blkno, &run);
+ error = VOP_BMAP(vp, lbn, &devvp, &blkno, &run);
if (error) {
UVMHIST_LOG(ubchist, "VOP_BMAP() -> %d", error,0,0,0);
skipbytes += bytes;
@@ -1043,6 +1056,7 @@
}
bp->b_lblkno = 0;
bp->b_private = mbp;
+ bp->b_dev = devvp->v_rdev;
/* adjust physical blkno for partial blocks */
bp->b_blkno = blkno + ((offset - ((off_t)lbn << fs_bshift)) >>
Home |
Main Index |
Thread Index |
Old Index