Module Name:    src
Committed By:   mlelstv
Date:           Thu Sep 20 07:18:38 UTC 2018

Modified Files:
        src/sys/dev: vnd.c vndvar.h

Log Message:
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.264 -r1.265 src/sys/dev/vnd.c
cvs rdiff -u -r1.36 -r1.37 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.264 src/sys/dev/vnd.c:1.265
--- src/sys/dev/vnd.c:1.264	Mon Sep  3 16:29:30 2018
+++ src/sys/dev/vnd.c	Thu Sep 20 07:18:38 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: vnd.c,v 1.264 2018/09/03 16:29:30 riastradh Exp $	*/
+/*	$NetBSD: vnd.c,v 1.265 2018/09/20 07:18:38 mlelstv 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.264 2018/09/03 16:29:30 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.265 2018/09/20 07:18:38 mlelstv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_vnd.h"
@@ -573,20 +573,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
@@ -1401,6 +1399,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.36 src/sys/dev/vndvar.h:1.37
--- src/sys/dev/vndvar.h:1.36	Fri Jul 28 15:52:53 2017
+++ src/sys/dev/vndvar.h	Thu Sep 20 07:18:38 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: vndvar.h,v 1.36 2017/07/28 15:52:53 riastradh Exp $	*/
+/*	$NetBSD: vndvar.h,v 1.37 2018/09/20 07:18:38 mlelstv 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 */

Reply via email to