Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev getdisksize only operates on device vnodes. Use the ...
details: https://anonhg.NetBSD.org/src/rev/674e3b9a8a75
branches: trunk
changeset: 433550:674e3b9a8a75
user: mlelstv <mlelstv%NetBSD.org@localhost>
date: Thu Sep 20 07:18:38 2018 +0000
description:
getdisksize only operates on device vnodes. Use the ioctl on the underlying
device instead.
diffstat:
sys/dev/vnd.c | 25 +++++++++++++++----------
sys/dev/vndvar.h | 3 ++-
2 files changed, 17 insertions(+), 11 deletions(-)
diffs (76 lines):
diff -r d208516d8774 -r 674e3b9a8a75 sys/dev/vnd.c
--- a/sys/dev/vnd.c Thu Sep 20 07:08:00 2018 +0000
+++ b/sys/dev/vnd.c Thu Sep 20 07:18:38 2018 +0000
@@ -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_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;
+ u_int32_t vnd_secsize, iosize;
- if (getdisksize(vnd->sc_vp, &numsec, &secsize))
- return true;
-
+ 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 @@
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.
diff -r d208516d8774 -r 674e3b9a8a75 sys/dev/vndvar.h
--- a/sys/dev/vndvar.h Thu Sep 20 07:08:00 2018 +0000
+++ b/sys/dev/vndvar.h Thu Sep 20 07:18:38 2018 +0000
@@ -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 @@
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 */
Home |
Main Index |
Thread Index |
Old Index