tech-kern archive

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

bmap/strategy for vnd backing file



Hello

The code in sys/dev/vnd.c is abls to handle I/O either using
bmap/strategy, or using read/write. The later is more efficient,
the later is supported on any filesystem.

There are a few tests to decide which method to use, but in 
the case where the backing store is a plain file on a filesystem,
we have a test for bmap/strategy that always fail: the
call to getdisksize() produces an ioctl DIOCGPARTINFO  which is
unsupported on regular files.

We use getdisksize() to read block size. I added an alternative 
using mount->mnt_dev_bshift when the backing store is of type VREG.
Anyone sees a reason to not commit that?

--- sys/dev/vnd.c.orig
+++ sys/dev/vnd.c
@@ -111,8 +111,9 @@
 #include <sys/disklabel.h>
 #include <sys/device.h>
 #include <sys/disk.h>
 #include <sys/stat.h>
+#include <sys/statvfs.h>
 #include <sys/mount.h>
 #include <sys/vnode.h>
 #include <sys/file.h>
 #include <sys/uio.h>
@@ -580,10 +581,15 @@
        u_int32_t vnd_secsize, mnt_secsize;
        uint64_t numsec;
        unsigned secsize;
 
-       if (getdisksize(vnd->sc_vp, &numsec, &secsize))
-               return true;
+       if (vnd->sc_vp->v_type == VREG) {
+               secsize = 1 << vnd->sc_vp->v_mount->mnt_dev_bshift;
+               numsec = vnd->sc_vp->v_size / secsize;
+       } else {
+               if (getdisksize(vnd->sc_vp, &numsec, &secsize))
+                       return true;
+       }
 
        vnd_secsize = vnd->sc_geom.vng_secsize;
        mnt_secsize = secsize;



-- 
Emmanuel Dreyfus
manu%netbsd.org@localhost


Home | Main Index | Thread Index | Old Index