Module Name: src Committed By: martin Date: Sat Oct 13 17:21:51 UTC 2018
Modified Files: src/sys/dev [netbsd-8]: vnd.c vndvar.h Log Message: Pull up following revision(s) (requested by mlelstv in ticket #1059): sys/dev/vnd.c: revision 1.265 sys/dev/vndvar.h: revision 1.37 getdisksize only operates on device vnodes. Use the ioctl on the underlying device instead. To generate a diff of this commit: cvs rdiff -u -r1.259.6.3 -r1.259.6.4 src/sys/dev/vnd.c cvs rdiff -u -r1.35 -r1.35.10.1 src/sys/dev/vndvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/vnd.c diff -u src/sys/dev/vnd.c:1.259.6.3 src/sys/dev/vnd.c:1.259.6.4 --- src/sys/dev/vnd.c:1.259.6.3 Sat Oct 13 17:19:05 2018 +++ src/sys/dev/vnd.c Sat Oct 13 17:21:51 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: vnd.c,v 1.259.6.3 2018/10/13 17:19:05 martin Exp $ */ +/* $NetBSD: vnd.c,v 1.259.6.4 2018/10/13 17:21:51 martin Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc. @@ -91,7 +91,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.259.6.3 2018/10/13 17:19:05 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.259.6.4 2018/10/13 17:21:51 martin Exp $"); #if defined(_KERNEL_OPT) #include "opt_vnd.h" @@ -575,20 +575,18 @@ vnode_has_strategy(struct vnd_softc *vnd vnode_has_op(vnd->sc_vp, VOFFSET(vop_strategy)); } +/* Verify that I/O requests cannot be smaller than the + * smallest I/O size supported by the backend. + */ static bool vnode_has_large_blocks(struct vnd_softc *vnd) { - u_int32_t vnd_secsize, mnt_secsize; - uint64_t numsec; - unsigned secsize; - - if (getdisksize(vnd->sc_vp, &numsec, &secsize)) - return true; + u_int32_t vnd_secsize, iosize; + iosize = vnd->sc_iosize; vnd_secsize = vnd->sc_geom.vng_secsize; - mnt_secsize = secsize; - return vnd_secsize % mnt_secsize != 0; + return vnd_secsize % iosize != 0; } /* XXX this function needs a reliable check to detect @@ -1406,6 +1404,13 @@ vndioctl(dev_t dev, u_long cmd, void *da vnd->sc_vp = nd.ni_vp; vnd->sc_size = btodb(vattr.va_size); /* note truncation */ + /* get smallest I/O size for underlying device, fall back to + * fundamental I/O size of underlying filesystem + */ + error = bdev_ioctl(vattr.va_fsid, DIOCGSECTORSIZE, &vnd->sc_iosize, FKIOCTL, l); + if (error) + vnd->sc_iosize = vnd->sc_vp->v_mount->mnt_stat.f_frsize; + /* * Use pseudo-geometry specified. If none was provided, * use "standard" Adaptec fictitious geometry. Index: src/sys/dev/vndvar.h diff -u src/sys/dev/vndvar.h:1.35 src/sys/dev/vndvar.h:1.35.10.1 --- src/sys/dev/vndvar.h:1.35 Sun Sep 6 06:00:59 2015 +++ src/sys/dev/vndvar.h Sat Oct 13 17:21:51 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: vndvar.h,v 1.35 2015/09/06 06:00:59 dholland Exp $ */ +/* $NetBSD: vndvar.h,v 1.35.10.1 2018/10/13 17:21:51 martin Exp $ */ /*- * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. @@ -111,6 +111,7 @@ struct vnd_softc { int sc_flags; /* flags */ uint64_t sc_size; /* size of vnd */ struct vnode *sc_vp; /* vnode */ + u_int sc_iosize; /* smallest I/O size for backend */ kauth_cred_t sc_cred; /* credentials */ int sc_maxactive; /* max # of active requests */ struct bufq_state *sc_tab; /* transfer queue */