NetBSD-Bugs archive

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

kern/47879: vnd cannot handle disk image larger than 2TiB



>Number:         47879
>Category:       kern
>Synopsis:       vnd cannot handle disk image larger than 2TiB
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jun 03 00:25:00 +0000 2013
>Originator:     Takahiro HAYASHI
>Release:        NetBSD 6.99.21 (around 2013.05.30.07.53.38)
>Organization:
>Environment:
System: NetBSD halt 6.99.21 NetBSD 6.99.21 (UNION) #0: Thu May 30 19:10:33 JST 
2013 root@halt:/usr/build2/obj.i386/sys/arch/i386/compile/UNION i386
Architecture: i386
Machine: i386
>Description:
        vnd(4) can't handle disk image larger than 2TiB on i386.
        There are two problems:
        1) sectors-per-unit is calculated in integer.
        2) number of disk blocks is stored in size_t variable,
           which is unsigned int on i386.

>How-To-Repeat:
        dd if=/dev/zero bs=512 count=1 seek=`expr 3000000000000 / 512 - 1` 
of=dkimg
        vnconfig -c -v vnd0 dkimg
        drvctl -p vnd0
>Fix:
        Following patch may suggest solution.

Index: src/sys/dev/vnd.c
===================================================================
RCS file: /cvsroot/src/sys/dev/vnd.c,v
retrieving revision 1.222
diff -u -p -r1.222 vnd.c
--- src/sys/dev/vnd.c   29 May 2013 00:47:48 -0000      1.222
+++ src/sys/dev/vnd.c   2 Jun 2013 21:29:39 -0000
@@ -1021,7 +1021,7 @@ vndioctl(dev_t dev, u_long cmd, void *da
        struct pathbuf *pb;
        struct nameidata nd;
        int error, part, pmask;
-       size_t geomsize;
+       uint64_t geomsize;
        int fflags;
 #ifdef __HAVE_OLD_DISKLABEL
        struct disklabel newlabel;
@@ -2002,7 +2002,7 @@ vnd_set_geometry(struct vnd_softc *vnd)
 
        memset(dg, 0, sizeof(*dg));
 
-       dg->dg_secperunit = vnd->sc_geom.vng_nsectors *
+       dg->dg_secperunit = (int64_t)vnd->sc_geom.vng_nsectors *
            vnd->sc_geom.vng_ntracks * vnd->sc_geom.vng_ncylinders;
        dg->dg_secsize = vnd->sc_geom.vng_secsize;
        dg->dg_nsectors = vnd->sc_geom.vng_nsectors;
Index: src/sys/dev/vndvar.h
===================================================================
RCS file: /cvsroot/src/sys/dev/vndvar.h,v
retrieving revision 1.32
diff -u -p -r1.32 vndvar.h
--- src/sys/dev/vndvar.h        26 Mar 2012 16:28:08 -0000      1.32
+++ src/sys/dev/vndvar.h        2 Jun 2013 21:29:39 -0000
@@ -108,7 +108,7 @@ struct vnode;
 struct vnd_softc {
        device_t         sc_dev;
        int              sc_flags;      /* flags */
-       size_t           sc_size;       /* size of vnd */
+       uint64_t         sc_size;       /* disk blocks of vnd */
        struct vnode    *sc_vp;         /* vnode */
        kauth_cred_t     sc_cred;       /* credentials */
        int              sc_maxactive;  /* max # of active requests */

--
t-hash



Home | Main Index | Thread Index | Old Index