Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/rump/librump/rumpvfs * fix blkno->offset calculation for...



details:   https://anonhg.NetBSD.org/src/rev/89ce6a5d918b
branches:  trunk
changeset: 761626:89ce6a5d918b
user:      pooka <pooka%NetBSD.org@localhost>
date:      Thu Feb 03 10:06:06 2011 +0000

description:
* fix blkno->offset calculation for simulated non-512 devices
* allows transfers only in multiples of block size
* g/c unused struct member

diffstat:

 sys/rump/librump/rumpvfs/rumpblk.c |  19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)

diffs (61 lines):

diff -r cd93069d8809 -r 89ce6a5d918b sys/rump/librump/rumpvfs/rumpblk.c
--- a/sys/rump/librump/rumpvfs/rumpblk.c        Thu Feb 03 04:24:23 2011 +0000
+++ b/sys/rump/librump/rumpvfs/rumpblk.c        Thu Feb 03 10:06:06 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rumpblk.c,v 1.43 2011/02/02 15:55:22 pooka Exp $       */
+/*     $NetBSD: rumpblk.c,v 1.44 2011/02/03 10:06:06 pooka Exp $       */
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -52,7 +52,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rumpblk.c,v 1.43 2011/02/02 15:55:22 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rumpblk.c,v 1.44 2011/02/03 10:06:06 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/buf.h>
@@ -99,7 +99,6 @@
 static struct rblkdev {
        char *rblk_path;
        int rblk_fd;
-       int rblk_opencnt;
 #ifdef HAS_ODIRECT
        int rblk_dfd;
 #endif
@@ -467,7 +466,6 @@
 
        rblk = &minors[i];
        KASSERT(rblk->rblk_fd == -1);
-       KASSERT(rblk->rblk_opencnt == 0);
 
        wincleanup(rblk);
        free(rblk->rblk_path, M_TEMP);
@@ -632,6 +630,11 @@
        int async = bp->b_flags & B_ASYNC;
        int error;
 
+       if (bp->b_bcount % (1<<sectshift) != 0) {
+               rump_biodone(bp, 0, EINVAL);
+               return;
+       }
+
        /* collect statistics */
        ev_io_total.ev_count++;
        if (async)
@@ -644,7 +647,13 @@
                ev_bread_total.ev_count++;
        }
 
-       off = bp->b_blkno << sectshift;
+       /*
+        * b_blkno is always in terms of DEV_BSIZE, and since we need
+        * to translate to a byte offset for the host read, this
+        * calculation does not need sectshift.
+        */
+       off = bp->b_blkno << DEV_BSHIFT;
+
        /*
         * Do bounds checking if we're working on a file.  Otherwise
         * invalid file systems might attempt to read beyond EOF.  This



Home | Main Index | Thread Index | Old Index