Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev Fall back to VOP_READ/VOP_WRITE if the simulated dis...
details: https://anonhg.NetBSD.org/src/rev/ecab369d3c10
branches: trunk
changeset: 341936:ecab369d3c10
user: mlelstv <mlelstv%NetBSD.org@localhost>
date: Mon Nov 30 06:04:47 2015 +0000
description:
Fall back to VOP_READ/VOP_WRITE if the simulated disk has smaller
sectors than the underlying filesystem and VOP_STRATEGY would fail.
diffstat:
sys/dev/vnd.c | 30 ++++++++++++++++++++++++++++--
1 files changed, 28 insertions(+), 2 deletions(-)
diffs (65 lines):
diff -r f9a8898ae870 -r ecab369d3c10 sys/dev/vnd.c
--- a/sys/dev/vnd.c Mon Nov 30 01:31:02 2015 +0000
+++ b/sys/dev/vnd.c Mon Nov 30 06:04:47 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vnd.c,v 1.254 2015/11/12 15:28:07 christos Exp $ */
+/* $NetBSD: vnd.c,v 1.255 2015/11/30 06:04:47 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.254 2015/11/12 15:28:07 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.255 2015/11/30 06:04:47 mlelstv Exp $");
#if defined(_KERNEL_OPT)
#include "opt_vnd.h"
@@ -573,6 +573,22 @@
vnode_has_op(vnd->sc_vp, VOFFSET(vop_strategy));
}
+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;
+
+ vnd_secsize = vnd->sc_geom.vng_secsize;
+ mnt_secsize = secsize;
+
+ return vnd_secsize % mnt_secsize != 0;
+}
+
/* XXX this function needs a reliable check to detect
* sparse files. Otherwise, bmap/strategy may be used
* and fail on non-allocated blocks. VOP_READ/VOP_WRITE
@@ -588,6 +604,9 @@
if (!vnode_has_strategy(vnd))
return false;
+ if (vnode_has_large_blocks(vnd))
+ return false;
+
/* Convert the first logical block number to its
* physical block number.
*/
@@ -619,6 +638,13 @@
! vnode_has_strategy(vnd))
vnd->sc_flags |= VNF_USE_VN_RDWR;
+ /* VOP_STRATEGY can only be used if the backing vnode allows
+ * to access blocks as small as defined by the vnd geometry.
+ */
+ if ((vnd->sc_flags & VNF_USE_VN_RDWR) == 0 &&
+ vnode_has_large_blocks(vnd))
+ vnd->sc_flags |= VNF_USE_VN_RDWR;
+
#ifdef DEBUG
if (vnddebug & VDB_INIT)
printf("vndthread: vp %p, %s\n", vnd->sc_vp,
Home |
Main Index |
Thread Index |
Old Index