From 43ccc52f24eb43960280df1c6802ed25600aa0c9 Mon Sep 17 00:00:00 2001 From: pooka Date: Mon, 3 Aug 2009 16:22:00 +0000 Subject: [PATCH] Support read/write in rumpblk via physio() --- sys/rump/librump/rumpvfs/Makefile.rumpvfs | 5 ++++- sys/rump/librump/rumpvfs/rumpblk.c | 26 +++++++++++++++++------ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/sys/rump/librump/rumpvfs/Makefile.rumpvfs b/sys/rump/librump/rumpvfs/Makefile.rumpvfs index 853500382a9a..c2a6795c88fd 100644 --- a/sys/rump/librump/rumpvfs/Makefile.rumpvfs +++ b/sys/rump/librump/rumpvfs/Makefile.rumpvfs @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.rumpvfs,v 1.9 2009/06/10 20:50:51 pooka Exp $ +# $NetBSD: Makefile.rumpvfs,v 1.10 2009/08/03 16:22:00 pooka Exp $ # .include "${RUMPTOP}/Makefile.rump" @@ -18,6 +18,9 @@ SRCS= genfs_io.c rump_vfs.c rumpblk.c rumpfs.c vm_vfs.c SRCS+= fstrans_stub.c vfsops_stub.c +# sys/kern I/O +SRCS+= kern_physio.c + # sys/kern vfs SRCS+= vfs_bio.c vfs_cache.c vfs_cwd.c vfs_dirhash.c vfs_getcwd.c \ vfs_hooks.c vfs_init.c vfs_lockf.c vfs_lookup.c vfs_subr.c \ diff --git a/sys/rump/librump/rumpvfs/rumpblk.c b/sys/rump/librump/rumpvfs/rumpblk.c index 1b8b4c848f26..f1dd6d5b9744 100644 --- a/sys/rump/librump/rumpvfs/rumpblk.c +++ b/sys/rump/librump/rumpvfs/rumpblk.c @@ -1,4 +1,4 @@ -/* $NetBSD: rumpblk.c,v 1.24 2009/08/03 14:23:30 pooka Exp $ */ +/* $NetBSD: rumpblk.c,v 1.25 2009/08/03 16:22:00 pooka Exp $ */ /* * Copyright (c) 2009 Antti Kantee. All Rights Reserved. @@ -43,7 +43,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: rumpblk.c,v 1.24 2009/08/03 14:23:30 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rumpblk.c,v 1.25 2009/08/03 16:22:00 pooka Exp $"); #include #include @@ -89,7 +89,7 @@ struct blkwin { static struct rblkdev { char *rblk_path; int rblk_fd; - int rblk_refcnt; + int rblk_opencnt; #ifdef HAS_ODIRECT int rblk_dfd; #endif @@ -376,7 +376,8 @@ rumpblk_open(dev_t dev, int flag, int fmt, struct lwp *l) int ft, dummy; int error, fd; - KASSERT(rblk->rblk_fd == -1); /* XXX */ + if (rblk->rblk_fd != -1) + return 0; /* XXX: refcount, open mode */ fd = rumpuser_open(rblk->rblk_path, OFLAGS(flag), &error); if (error) return error; @@ -492,18 +493,31 @@ rumpblk_ioctl(dev_t dev, u_long xfer, void *addr, int flag, struct lwp *l) return 0; } +static int +do_physio(dev_t dev, struct uio *uio, int which) +{ + void (*strat)(struct buf *); + + if (blkfail) + strat = rumpblk_strategy_fail; + else + strat = rumpblk_strategy; + + return physio(strat, NULL, dev, which, minphys, uio); +} + int rumpblk_read(dev_t dev, struct uio *uio, int flags) { - panic("%s: unimplemented", __func__); + return do_physio(dev, uio, B_READ); } int rumpblk_write(dev_t dev, struct uio *uio, int flags) { - panic("%s: unimplemented", __func__); + return do_physio(dev, uio, B_WRITE); } static void