NetBSD Problem Report #47879
From t-hash@abox3.so-net.ne.jp Mon Jun 3 00:20:30 2013
Return-Path: <t-hash@abox3.so-net.ne.jp>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
(Client CN "mail.NetBSD.org", Issuer "Postmaster NetBSD.org" (verified OK))
by mollari.NetBSD.org (Postfix) with ESMTPS id 2799671AC4
for <gnats-bugs@gnats.NetBSD.org>; Mon, 3 Jun 2013 00:20:30 +0000 (UTC)
Message-Id: <201306022214.r52ME5AO008254@ms-omx13.plus.so-net.ne.jp>
Date: Mon, 03 Jun 2013 07:14:06 +0900
From: Takahiro HAYASHI <t-hash@abox3.so-net.ne.jp>
To: gnats-bugs@gnats.NetBSD.org
Subject: 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: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Jun 03 00:25:00 +0000 2013
>Closed-Date: Sun Apr 18 20:16:14 +0000 2021
>Last-Modified: Sun Apr 18 20:16:14 +0000 2021
>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
>Release-Note:
>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/47879 CVS commit: src/sys/dev
Date: Mon, 3 Jun 2013 12:42:32 -0400
Module Name: src
Committed By: christos
Date: Mon Jun 3 16:42:32 UTC 2013
Modified Files:
src/sys/dev: vnd.c vndvar.h
Log Message:
PR/47879: Takahiro HAYASHI: vnd cannot handle disk image larger than 2TiB
change size_t to uint64_t where needed.
To generate a diff of this commit:
cvs rdiff -u -r1.222 -r1.223 src/sys/dev/vnd.c
cvs rdiff -u -r1.32 -r1.33 src/sys/dev/vndvar.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: Takahiro HAYASHI <t-hash@abox3.so-net.ne.jp>
To: gnats-bugs@NetBSD.org
Cc: kern-bug-people@NetBSD.org, gnats-admin@NetBSD.org, netbsd-bugs@NetBSD.org
Subject: Re: PR/47879 CVS commit: src/sys/dev
Date: Tue, 04 Jun 2013 05:28:55 +0900
On Mon, 3 Jun 2013 16:45:01 +0000 (UTC)
"Christos Zoulas" <christos@netbsd.org> wrote:
> The following reply was made to PR kern/47879; it has been noted by GNATS.
>
> From: "Christos Zoulas" <christos@netbsd.org>
> To: gnats-bugs@gnats.NetBSD.org
> Cc:
> Subject: PR/47879 CVS commit: src/sys/dev
> Date: Mon, 3 Jun 2013 12:42:32 -0400
>
> Module Name: src
> Committed By: christos
> Date: Mon Jun 3 16:42:32 UTC 2013
>
> Modified Files:
> src/sys/dev: vnd.c vndvar.h
>
> Log Message:
> PR/47879: Takahiro HAYASHI: vnd cannot handle disk image larger than 2TiB
> change size_t to uint64_t where needed.
Thanks for commit but the fix is insufficient.
In function vnd_set_geometry() of src/sys/dev/vnd.c, sectors per unit
is the product of num of sectors, tracks and cylinders.
This may cause interger overflow.
dg->dg_secperunit = vnd->sc_geom.vng_nsectors *
vnd->sc_geom.vng_ntracks * vnd->sc_geom.vng_ncylinders;
The typeof right side variables are all uint32_t, so the result is
calculated in interger.
One of solutions to avoid overflow is to start right side
with "1LL *".
dg->dg_secperunit = 1LL * vnd->sc_geom.vng_nsectors *
vnd->sc_geom.vng_ntracks * vnd->sc_geom.vng_ncylinders;
Or cast first variable to int64_t.
dg->dg_secperunit = (int64_t)vnd->sc_geom.vng_nsectors *
vnd->sc_geom.vng_ntracks * vnd->sc_geom.vng_ncylinders;
--
t-hash
From: Takahiro HAYASHI <t-hash@abox3.so-net.ne.jp>
To: gnats-bugs@netbsd.org
Cc: kern-bug-people@netbsd.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: PR/47879 CVS commit: src/sys/dev
Date: Sun, 30 Jun 2013 16:44:22 +0900
Hello, sorry for late response.
I have confirmed it works fine by doing drvctl -p.
Thank you for fixing this prob.
On Mon, 3 Jun 2013 20:30:01 +0000 (UTC)
Takahiro HAYASHI <t-hash@abox3.so-net.ne.jp> wrote:
> The following reply was made to PR kern/47879; it has been noted by GNATS.
>
> From: Takahiro HAYASHI <t-hash@abox3.so-net.ne.jp>
> To: gnats-bugs@NetBSD.org
> Cc: kern-bug-people@NetBSD.org, gnats-admin@NetBSD.org, netbsd-bugs@NetBSD.org
> Subject: Re: PR/47879 CVS commit: src/sys/dev
> Date: Tue, 04 Jun 2013 05:28:55 +0900
>
> On Mon, 3 Jun 2013 16:45:01 +0000 (UTC)
> "Christos Zoulas" <christos@netbsd.org> wrote:
>
> > The following reply was made to PR kern/47879; it has been noted by GNATS.
> >
> > From: "Christos Zoulas" <christos@netbsd.org>
> > To: gnats-bugs@gnats.NetBSD.org
> > Cc:
> > Subject: PR/47879 CVS commit: src/sys/dev
> > Date: Mon, 3 Jun 2013 12:42:32 -0400
> >
> > Module Name: src
> > Committed By: christos
> > Date: Mon Jun 3 16:42:32 UTC 2013
> >
> > Modified Files:
> > src/sys/dev: vnd.c vndvar.h
> >
> > Log Message:
> > PR/47879: Takahiro HAYASHI: vnd cannot handle disk image larger than 2TiB
> > change size_t to uint64_t where needed.
>
> Thanks for commit but the fix is insufficient.
>
> In function vnd_set_geometry() of src/sys/dev/vnd.c, sectors per unit
> is the product of num of sectors, tracks and cylinders.
> This may cause interger overflow.
>
> dg->dg_secperunit = vnd->sc_geom.vng_nsectors *
> vnd->sc_geom.vng_ntracks * vnd->sc_geom.vng_ncylinders;
>
> The typeof right side variables are all uint32_t, so the result is
> calculated in interger.
>
> One of solutions to avoid overflow is to start right side
> with "1LL *".
>
> dg->dg_secperunit = 1LL * vnd->sc_geom.vng_nsectors *
> vnd->sc_geom.vng_ntracks * vnd->sc_geom.vng_ncylinders;
>
> Or cast first variable to int64_t.
>
> dg->dg_secperunit = (int64_t)vnd->sc_geom.vng_nsectors *
> vnd->sc_geom.vng_ntracks * vnd->sc_geom.vng_ncylinders;
>
> --
> t-hash
>
--
t-hash
From: Takahiro HAYASHI <t-hash@abox3.so-net.ne.jp>
To: gnats-bugs@NetBSD.org
Cc: kern-bug-people@NetBSD.org, gnats-admin@NetBSD.org, netbsd-bugs@NetBSD.org
Subject: Re: kern/47879: vnd cannot handle disk image larger than 2TiB
Date: Thu, 04 Jul 2013 00:55:33 +0900
netbsd-6 has same problem.
Following patch should fix this problem on netbsd-6.
Index: src/sys/dev/vnd.c
===================================================================
RCS file: /cvsroot/src/sys/dev/vnd.c,v
retrieving revision 1.219.8.2
diff -u -p -r1.219.8.2 vnd.c
--- src/sys/dev/vnd.c 5 Jul 2012 18:12:46 -0000 1.219.8.2
+++ src/sys/dev/vnd.c 24 Jun 2013 11:37:56 -0000
@@ -1023,7 +1023,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;
@@ -2007,7 +2007,7 @@ vnd_set_properties(struct vnd_softc *vnd
geom = prop_dictionary_create();
prop_dictionary_set_uint64(geom, "sectors-per-unit",
- vnd->sc_geom.vng_nsectors * vnd->sc_geom.vng_ntracks *
+ (uint64_t)vnd->sc_geom.vng_nsectors * vnd->sc_geom.vng_ntracks *
vnd->sc_geom.vng_ncylinders);
prop_dictionary_set_uint32(geom, "sector-size",
Index: src/sys/dev/vndvar.h
===================================================================
RCS file: /cvsroot/src/sys/dev/vndvar.h,v
retrieving revision 1.31.8.1
diff -u -p -r1.31.8.1 vndvar.h
--- src/sys/dev/vndvar.h 6 Apr 2012 17:44:21 -0000 1.31.8.1
+++ src/sys/dev/vndvar.h 24 Jun 2013 11:37:56 -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; /* size of vnd */
struct vnode *sc_vp; /* vnode */
kauth_cred_t sc_cred; /* credentials */
int sc_maxactive; /* max # of active requests */
--
t-hash
From: christos@zoulas.com (Christos Zoulas)
To: Takahiro HAYASHI <t-hash@abox3.so-net.ne.jp>, gnats-bugs@NetBSD.org
Cc: kern-bug-people@NetBSD.org, gnats-admin@NetBSD.org,
netbsd-bugs@NetBSD.org, pullup-6@netbsd.org
Subject: Re: kern/47879: vnd cannot handle disk image larger than 2TiB
Date: Wed, 3 Jul 2013 13:02:33 -0400
This would be good to pullup.
christos
On Jul 4, 12:55am, t-hash@abox3.so-net.ne.jp (Takahiro HAYASHI) wrote:
-- Subject: Re: kern/47879: vnd cannot handle disk image larger than 2TiB
| netbsd-6 has same problem.
| Following patch should fix this problem on netbsd-6.
|
|
| Index: src/sys/dev/vnd.c
| ===================================================================
| RCS file: /cvsroot/src/sys/dev/vnd.c,v
| retrieving revision 1.219.8.2
| diff -u -p -r1.219.8.2 vnd.c
| --- src/sys/dev/vnd.c 5 Jul 2012 18:12:46 -0000 1.219.8.2
| +++ src/sys/dev/vnd.c 24 Jun 2013 11:37:56 -0000
| @@ -1023,7 +1023,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;
| @@ -2007,7 +2007,7 @@ vnd_set_properties(struct vnd_softc *vnd
| geom = prop_dictionary_create();
|
| prop_dictionary_set_uint64(geom, "sectors-per-unit",
| - vnd->sc_geom.vng_nsectors * vnd->sc_geom.vng_ntracks *
| + (uint64_t)vnd->sc_geom.vng_nsectors * vnd->sc_geom.vng_ntracks *
| vnd->sc_geom.vng_ncylinders);
|
| prop_dictionary_set_uint32(geom, "sector-size",
| Index: src/sys/dev/vndvar.h
| ===================================================================
| RCS file: /cvsroot/src/sys/dev/vndvar.h,v
| retrieving revision 1.31.8.1
| diff -u -p -r1.31.8.1 vndvar.h
| --- src/sys/dev/vndvar.h 6 Apr 2012 17:44:21 -0000 1.31.8.1
| +++ src/sys/dev/vndvar.h 24 Jun 2013 11:37:56 -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; /* size of vnd */
| struct vnode *sc_vp; /* vnode */
| kauth_cred_t sc_cred; /* credentials */
| int sc_maxactive; /* max # of active requests */
|
| --
| t-hash
-- End of excerpt from Takahiro HAYASHI
From: Takahiro HAYASHI <t-hash@abox3.so-net.ne.jp>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@NetBSD.org, kern-bug-people@NetBSD.org, netbsd-bugs@NetBSD.org
Subject: Re: kern/47879: vnd cannot handle disk image larger than 2TiB
Date: Sun, 15 Sep 2013 20:48:47 +0900
About this problem on netbsd-5.
netbsd-5 has same problem and the patch for netbsd-6 can be applied
to netbsd-5 to fix kernel.
But vnconfig(8) shows incorrent value (realsize % 2^32) even on
patched kernel if configured vnd size > 2GiB because typeof vnd_size
in struct vnd_ioctl is signed int.
To fix this, rename old structure, add 64bit version of vnd_size
to new struct vnd_ioctl and modify sys/dev/vnd.c and usr.sbin/vnconfig
to use new structure like netbsd-6 or later do.
However it includes COMPAT_50 part.
Folowing patch works, but i'm not sure this is acceptable.
Index: src/sys/dev/vnd.c
===================================================================
RCS file: /cvsroot/src/sys/dev/vnd.c,v
retrieving revision 1.187.4.6
diff -u -p -r1.187.4.6 vnd.c
--- src/sys/dev/vnd.c 22 Aug 2012 20:29:20 -0000 1.187.4.6
+++ src/sys/dev/vnd.c 15 Sep 2013 10:59:04 -0000
@@ -128,6 +128,9 @@
*
* NOTE 3: Doesn't interact with leases, should it?
*/
+#ifndef COMPAT_50
+#define COMPAT_50 /* XXX */
+#endif
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.187.4.6 2012/08/22 20:29:20 bouyer Exp $");
@@ -1000,7 +1002,10 @@ vndioctl(dev_t dev, u_long cmd, void *da
vnd = device_lookup_private(&vnd_cd, unit);
if (vnd == NULL &&
#ifdef COMPAT_30
- cmd != VNDIOOCGET &&
+ cmd != VNDIOCGET30 &&
+#endif
+#ifdef COMPAT_50
+ cmd != VNDIOCGET50 &&
#endif
cmd != VNDIOCGET)
return ENXIO;
@@ -1010,6 +1015,10 @@ vndioctl(dev_t dev, u_long cmd, void *da
switch (cmd) {
case VNDIOCSET:
case VNDIOCCLR:
+#ifdef COMPAT_50
+ case VNDIOCSET50:
+ case VNDIOCCLR50:
+#endif
case DIOCSDINFO:
case DIOCWDINFO:
#ifdef __HAVE_OLD_DISKLABEL
@@ -1025,6 +1034,9 @@ vndioctl(dev_t dev, u_long cmd, void *da
/* Must be initialized for these... */
switch (cmd) {
case VNDIOCCLR:
+#ifdef VNDIOCCLR50
+ case VNDIOCCLR50:
+#endif
case DIOCGDINFO:
case DIOCSDINFO:
case DIOCWDINFO:
@@ -1044,6 +1056,9 @@ vndioctl(dev_t dev, u_long cmd, void *da
}
switch (cmd) {
+#ifdef VNDIOCSET50
+ case VNDIOCSET50:
+#endif
case VNDIOCSET:
if (vnd->sc_flags & VNF_INITED)
return (EBUSY);
@@ -1248,7 +1264,11 @@ vndioctl(dev_t dev, u_long cmd, void *da
goto close_and_exit;
vndthrottle(vnd, vnd->sc_vp);
- vio->vnd_size = dbtob(vnd->sc_size);
+ vio->vnd_osize = dbtob(vnd->sc_size);
+#ifdef VNDIOCSET50
+ if (cmd != VNDIOCSET50)
+#endif
+ vio->vnd_size = dbtob(vnd->sc_size);
vnd->sc_flags |= VNF_INITED;
/* create the kernel thread, wait for it to be up */
@@ -1312,6 +1332,9 @@ unlock_and_exit:
vndunlock(vnd);
return (error);
+#ifdef VNDIOCCLR50
+ case VNDIOCCLR50:
+#endif
case VNDIOCCLR:
if ((error = vndlock(vnd)) != 0)
return (error);
@@ -1351,10 +1374,10 @@ unlock_and_exit:
break;
#ifdef COMPAT_30
- case VNDIOOCGET: {
- struct vnd_ouser *vnu;
+ case VNDIOCGET30: {
+ struct vnd_user30 *vnu;
struct vattr va;
- vnu = (struct vnd_ouser *)data;
+ vnu = (struct vnd_user30 *)data;
KASSERT(l);
switch (error = vnd_cget(l, unit, &vnu->vnu_unit, &va)) {
case 0:
@@ -1372,6 +1395,16 @@ unlock_and_exit:
break;
}
#endif
+
+#if 0
+#ifdef COMPAT_50
+ /*
+ * on netbsd-5 vnd_user50 is actually vnd_user because
+ * dev_t is still uint32_t, so VNDIOCGET50 is VNDIOCGET.
+ */
+ case VNDIOCGET50:
+#endif
+#endif
case VNDIOCGET: {
struct vnd_user *vnu;
struct vattr va;
@@ -1956,7 +1989,7 @@ vnd_set_properties(struct vnd_softc *vnd
geom = prop_dictionary_create();
prop_dictionary_set_uint64(geom, "sectors-per-unit",
- vnd->sc_geom.vng_nsectors * vnd->sc_geom.vng_ntracks *
+ (uint64_t)vnd->sc_geom.vng_nsectors * vnd->sc_geom.vng_ntracks *
vnd->sc_geom.vng_ncylinders);
prop_dictionary_set_uint32(geom, "sector-size",
Index: src/sys/dev/vndvar.h
===================================================================
RCS file: /cvsroot/src/sys/dev/vndvar.h,v
retrieving revision 1.23.10.1
diff -u -p -r1.23.10.1 vndvar.h
--- src/sys/dev/vndvar.h 31 Dec 2011 22:11:12 -0000 1.23.10.1
+++ src/sys/dev/vndvar.h 15 Sep 2013 10:59:04 -0000
@@ -105,6 +105,8 @@
*
* @(#)vnioctl.h 8.1 (Berkeley) 6/10/93
*/
+#ifndef _SYS_DEV_VNDVAR_H_
+#define _SYS_DEV_VNDVAR_H_
#include <sys/pool.h>
@@ -125,7 +127,8 @@ struct vnd_ioctl {
char *vnd_file; /* pathname of file to mount */
int vnd_flags; /* flags; see below */
struct vndgeom vnd_geom; /* geometry to emulate */
- int vnd_size; /* (returned) size of disk */
+ unsigned int vnd_osize; /* (returned) size of disk */
+ uint64_t vnd_size; /* (returned) size of disk */
};
/* vnd_flags */
@@ -143,7 +146,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; /* size of vnd */
struct vnode *sc_vp; /* vnode */
kauth_cred_t sc_cred; /* credentials */
int sc_maxactive; /* max # of active requests */
@@ -189,14 +192,6 @@ struct vnd_comp_header
/*
* A simple structure for describing which vnd units are in use.
*/
-#ifdef COMPAT_30
-struct vnd_ouser {
- int vnu_unit; /* which vnd unit */
- dev_t vnu_dev; /* file is on this device... */
- uint32_t vnu_ino; /* ...at this inode */
-};
-#define VNDIOOCGET _IOWR('F', 2, struct vnd_ouser) /* get list */
-#endif
struct vnd_user {
int vnu_unit; /* which vnd unit */
@@ -213,3 +208,38 @@ struct vnd_user {
#define VNDIOCSET _IOWR('F', 0, struct vnd_ioctl) /* enable disk */
#define VNDIOCCLR _IOW('F', 1, struct vnd_ioctl) /* disable disk */
#define VNDIOCGET _IOWR('F', 3, struct vnd_user) /* get list */
+
+#ifdef _KERNEL
+/*
+ * Everything else is kernel-private, mostly exported for compat/netbsd32.
+ *
+ * NetBSD 3.0 had a 32-bit value for vnu_ino.
+ *
+ * NetBSD 5.0 had a 32-bit value for vnu_dev, and vnd_size.
+ */
+struct vnd_user30 {
+ int vnu_unit; /* which vnd unit */
+ uint32_t vnu_dev; /* file is on this device... */
+ uint32_t vnu_ino; /* ...at this inode */
+};
+#define VNDIOCGET30 _IOWR('F', 2, struct vnd_user30) /* get list */
+
+struct vnd_user50 {
+ int vnu_unit; /* which vnd unit */
+ uint32_t vnu_dev; /* file is on this device... */
+ ino_t vnu_ino; /* ...at this inode */
+};
+#define VNDIOCGET50 _IOWR('F', 3, struct vnd_user50) /* get list */
+
+struct vnd_ioctl50 {
+ char *vnd_file; /* pathname of file to mount */
+ int vnd_flags; /* flags; see below */
+ struct vndgeom vnd_geom; /* geometry to emulate */
+ unsigned int vnd_size; /* (returned) size of disk */
+};
+#define VNDIOCSET50 _IOWR('F', 0, struct vnd_ioctl50)
+#define VNDIOCCLR50 _IOW('F', 1, struct vnd_ioctl50)
+
+#endif /* _KERNEL */
+
+#endif /* _SYS_DEV_VNDVAR_H_ */
Index: src/usr.sbin/vnconfig/vnconfig.c
===================================================================
RCS file: /cvsroot/src/usr.sbin/vnconfig/vnconfig.c,v
retrieving revision 1.35
diff -u -p -r1.35 vnconfig.c
--- src/usr.sbin/vnconfig/vnconfig.c 28 Apr 2008 20:24:17 -0000 1.35
+++ src/usr.sbin/vnconfig/vnconfig.c 15 Sep 2013 11:02:20 -0000
@@ -325,6 +325,10 @@ config(dev, file, geom, action)
if (force)
vndio.vnd_flags |= VNDIOF_FORCE;
rv = ioctl(fd, VNDIOCCLR, &vndio);
+#ifdef VNDIOOCCLR
+ if (rv && errno == ENOTTY)
+ rv = ioctl(fd, VNDIOOCCLR, &vndio);
+#endif
if (rv)
warn("%s: VNDIOCCLR", rdev);
else if (verbose)
@@ -343,10 +347,16 @@ config(dev, file, geom, action)
(void) close(ffd);
rv = ioctl(fd, VNDIOCSET, &vndio);
+#ifdef VNDIOOCSET
+ if (rv && errno == ENOTTY) {
+ rv = ioctl(fd, VNDIOOCSET, &vndio);
+ vndio.vnd_size = vndio.vnd_osize;
+ }
+#endif
if (rv)
warn("%s: VNDIOCSET", rdev);
else if (verbose) {
- printf("%s: %d bytes on %s", rdev,
+ printf("%s: %" PRIu64 " bytes on %s", rdev,
vndio.vnd_size, file);
if (vndio.vnd_flags & VNDIOF_HASGEOM)
printf(" using geometry %d/%d/%d/%d",
--
t-hash
From: Takahiro HAYASHI <t.hash425@gmail.com>
To: gnats-bugs@NetBSD.org, kern-bug-people@netbsd.org,
Christos Zoulas <christos@zoulas.com>
Cc:
Subject: Re: kern/47879: vnd cannot handle disk image larger than 2TiB
Date: Fri, 08 Aug 2014 01:49:26 +0900
Hello,
(07/04/13 02:05), Christos Zoulas wrote:
> The following reply was made to PR kern/47879; it has been noted by GNATS.
>
> From: christos@zoulas.com (Christos Zoulas)
> To: Takahiro HAYASHI <t-hash@abox3.so-net.ne.jp>, gnats-bugs@NetBSD.org
> Cc: kern-bug-people@NetBSD.org, gnats-admin@NetBSD.org,
> netbsd-bugs@NetBSD.org, pullup-6@netbsd.org
> Subject: Re: kern/47879: vnd cannot handle disk image larger than 2TiB
> Date: Wed, 3 Jul 2013 13:02:33 -0400
>
> This would be good to pullup.
Do you have plan to pullup this to netbsd-6?
Thanks,
> christos
>
> On Jul 4, 12:55am, t-hash@abox3.so-net.ne.jp (Takahiro HAYASHI) wrote:
> -- Subject: Re: kern/47879: vnd cannot handle disk image larger than 2TiB
>
> | netbsd-6 has same problem.
> | Following patch should fix this problem on netbsd-6.
> |
> |
> | Index: src/sys/dev/vnd.c
> | ===================================================================
> | RCS file: /cvsroot/src/sys/dev/vnd.c,v
> | retrieving revision 1.219.8.2
> | diff -u -p -r1.219.8.2 vnd.c
> | --- src/sys/dev/vnd.c 5 Jul 2012 18:12:46 -0000 1.219.8.2
> | +++ src/sys/dev/vnd.c 24 Jun 2013 11:37:56 -0000
> | @@ -1023,7 +1023,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;
> | @@ -2007,7 +2007,7 @@ vnd_set_properties(struct vnd_softc *vnd
> | geom = prop_dictionary_create();
> |
> | prop_dictionary_set_uint64(geom, "sectors-per-unit",
> | - vnd->sc_geom.vng_nsectors * vnd->sc_geom.vng_ntracks *
> | + (uint64_t)vnd->sc_geom.vng_nsectors * vnd->sc_geom.vng_ntracks *
> | vnd->sc_geom.vng_ncylinders);
> |
> | prop_dictionary_set_uint32(geom, "sector-size",
> | Index: src/sys/dev/vndvar.h
> | ===================================================================
> | RCS file: /cvsroot/src/sys/dev/vndvar.h,v
> | retrieving revision 1.31.8.1
> | diff -u -p -r1.31.8.1 vndvar.h
> | --- src/sys/dev/vndvar.h 6 Apr 2012 17:44:21 -0000 1.31.8.1
> | +++ src/sys/dev/vndvar.h 24 Jun 2013 11:37:56 -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; /* size of vnd */
> | struct vnode *sc_vp; /* vnode */
> | kauth_cred_t sc_cred; /* credentials */
> | int sc_maxactive; /* max # of active requests */
> |
> | --
> | t-hash
> -- End of excerpt from Takahiro HAYASHI
--
t-hash
From: christos@zoulas.com (Christos Zoulas)
To: gnats-bugs@NetBSD.org, kern-bug-people@netbsd.org,
gnats-admin@netbsd.org, netbsd-bugs@netbsd.org,
Takahiro HAYASHI <t-hash@abox3.so-net.ne.jp>
Cc: pullup-6@netbsd.org
Subject: Re: kern/47879: vnd cannot handle disk image larger than 2TiB
Date: Fri, 8 Aug 2014 03:27:41 -0400
On Aug 7, 4:50pm, t.hash425@gmail.com (Takahiro HAYASHI) wrote:
-- Subject: Re: kern/47879: vnd cannot handle disk image larger than 2TiB
| Do you have plan to pullup this to netbsd-6?
It is complicated I think because there are various commits involved.
Let's ask what releng thinks.
christos
From: Masanobu SAITOH <msaitoh@execsw.org>
To: Christos Zoulas <christos@zoulas.com>, gnats-bugs@NetBSD.org,
kern-bug-people@netbsd.org, gnats-admin@netbsd.org,
netbsd-bugs@netbsd.org, Takahiro HAYASHI <t-hash@abox3.so-net.ne.jp>
Cc: msaitoh@execsw.org, releng-6@netbsd.org
Subject: Re: kern/47879: vnd cannot handle disk image larger than 2TiB
Date: Fri, 08 Aug 2014 18:12:22 +0900
Hi, christos.
On 2014/08/08 16:27, Christos Zoulas wrote:
> On Aug 7, 4:50pm, t.hash425@gmail.com (Takahiro HAYASHI) wrote:
> -- Subject: Re: kern/47879: vnd cannot handle disk image larger than 2TiB
>
> | Do you have plan to pullup this to netbsd-6?
>
> It is complicated I think because there are various commits involved.
> Let's ask what releng thinks.
>
> christos
pullup-6@ is not for discussion. It's only for managing pullup
request. Use releng-6@ if discussion is needed.
BTW, this topic (kern/47879) was happended before (I remembered)
http://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=47879
See Wed, 3 Jul 2013's mail in avove page.
At that time, the mail was Cc:ed to pullup-6@ but the ticket system
silently discard. I don't know why.
I think it's ok to pullup this fix.
--
-----------------------------------------------
SAITOH Masanobu (msaitoh@execsw.org
msaitoh@netbsd.org)
State-Changed-From-To: open->closed
State-Changed-By: maya@NetBSD.org
State-Changed-When: Sun, 18 Apr 2021 20:16:14 +0000
State-Changed-Why:
it looks like the problem is fixed in -current, but a pullup was requested to netbsd-5 and netbsd-6 and never done- that is no longer applicable as they are EOL. So it seems like the problem is fixed.
Thanks for the report! sorry the pullup did not happen.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.