summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormlelstv <mlelstv@NetBSD.org>2018-10-07 11:51:26 +0000
committermlelstv <mlelstv@NetBSD.org>2018-10-07 11:51:26 +0000
commitc26b4e856f1783260f529fefba4f49a3efbef89d (patch)
tree50efbe97a1f3b7be75df7fc7ab8ffc87bd038be0
parent62b963d55ef3bd7892ead30c798ac89bb12fb838 (diff)
Add flag to enforce file I/O even when bmap/strategy would be possible.
This makes it easier to compare both modes, it also allows coherent operation between vnd device and image file.
-rw-r--r--sys/dev/vnd.c8
-rw-r--r--sys/dev/vndvar.h4
-rw-r--r--usr.sbin/vnconfig/vnconfig.87
-rw-r--r--usr.sbin/vnconfig/vnconfig.c13
4 files changed, 23 insertions, 9 deletions
diff --git a/sys/dev/vnd.c b/sys/dev/vnd.c
index 38439695cf3..327dc2213ec 100644
--- a/sys/dev/vnd.c
+++ b/sys/dev/vnd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: vnd.c,v 1.266 2018/10/05 09:51:55 hannken Exp $ */
+/* $NetBSD: vnd.c,v 1.267 2018/10/07 11:51:26 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.266 2018/10/05 09:51:55 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.267 2018/10/07 11:51:26 mlelstv Exp $");
#if defined(_KERNEL_OPT)
#include "opt_vnd.h"
@@ -1243,6 +1243,8 @@ vndioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
fflags = FREAD;
if ((vio->vnd_flags & VNDIOF_READONLY) == 0)
fflags |= FWRITE;
+ if ((vio->vnd_flags & VNDIOF_FILEIO) != 0)
+ vnd->sc_flags |= VNF_USE_VN_RDWR;
error = pathbuf_copyin(vio->vnd_file, &pb);
if (error) {
goto unlock_and_exit;
@@ -1266,7 +1268,7 @@ vndioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
/* If using a compressed file, initialize its info */
/* (or abort with an error if kernel has no compression) */
- if (vio->vnd_flags & VNF_COMP) {
+ if (vio->vnd_flags & VNDIOF_COMP) {
#ifdef VND_COMPRESSION
struct vnd_comp_header *ch;
int i;
diff --git a/sys/dev/vndvar.h b/sys/dev/vndvar.h
index 52ef1d48623..59f916af027 100644
--- a/sys/dev/vndvar.h
+++ b/sys/dev/vndvar.h
@@ -1,4 +1,4 @@
-/* $NetBSD: vndvar.h,v 1.37 2018/09/20 07:18:38 mlelstv Exp $ */
+/* $NetBSD: vndvar.h,v 1.38 2018/10/07 11:51:26 mlelstv Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -98,6 +98,8 @@ struct vnd_ioctl {
#define VNDIOF_HASGEOM 0x01 /* use specified geometry */
#define VNDIOF_READONLY 0x02 /* as read-only device */
#define VNDIOF_FORCE 0x04 /* force close */
+#define VNDIOF_FILEIO 0x08 /* have to use read/write */
+#define VNDIOF_COMP 0x0400 /* must stay the same as VNF_COMP */
#ifdef _KERNEL
diff --git a/usr.sbin/vnconfig/vnconfig.8 b/usr.sbin/vnconfig/vnconfig.8
index fcaff93ad13..cccc4ab387d 100644
--- a/usr.sbin/vnconfig/vnconfig.8
+++ b/usr.sbin/vnconfig/vnconfig.8
@@ -1,4 +1,4 @@
-.\" $NetBSD: vnconfig.8,v 1.43 2018/05/01 09:03:49 uwe Exp $
+.\" $NetBSD: vnconfig.8,v 1.44 2018/10/07 11:51:26 mlelstv Exp $
.\"
.\" Copyright (c) 1997 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -70,7 +70,7 @@
.Sh SYNOPSIS
.Nm
.\" Fcf:lm:rt:uvz
-.Op Fl crvz
+.Op Fl crivz
.Op Fl f Ar disktab
.Op Fl t Ar typename
.Ar vnode_disk
@@ -168,6 +168,9 @@ is set to 0,
then only vnd devices currently in use will be shown.
.It Fl r
Configure the device as read-only.
+.It Fl i
+Configure the device to use regular file I/O even when direct I/O using
+bmap/strategy would be possible.
.It Fl t Ar typename
If configuring the device, look up
.Ar typename
diff --git a/usr.sbin/vnconfig/vnconfig.c b/usr.sbin/vnconfig/vnconfig.c
index 97fba5114b6..18eac51f8a6 100644
--- a/usr.sbin/vnconfig/vnconfig.c
+++ b/usr.sbin/vnconfig/vnconfig.c
@@ -1,4 +1,4 @@
-/* $NetBSD: vnconfig.c,v 1.46 2018/03/12 01:15:00 christos Exp $ */
+/* $NetBSD: vnconfig.c,v 1.47 2018/10/07 11:51:26 mlelstv Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -98,6 +98,7 @@
static int verbose = 0;
static int readonly = 0;
+static int fileio = 0;
static int force = 0;
static int compressed = 0;
static int minimum = DUMMY_FREE;
@@ -116,7 +117,7 @@ main(int argc, char *argv[])
char *end;
unsigned long cnt;
- while ((ch = getopt(argc, argv, "Fcf:lm:rt:uvz")) != -1) {
+ while ((ch = getopt(argc, argv, "Fcf:lm:rit:uvz")) != -1) {
switch (ch) {
case 'F':
force = 1;
@@ -140,6 +141,9 @@ main(int argc, char *argv[])
case 'r':
readonly = 1;
break;
+ case 'i':
+ fileio = 1;
+ break;
case 't':
tabname = optarg;
break;
@@ -321,6 +325,9 @@ config(char *dev, char *file, char *geom, int action)
if (compressed)
vndio.vnd_flags |= VNF_COMP;
+ if (fileio)
+ vndio.vnd_flags |= VNDIOF_FILEIO;
+
/*
* Clear (un-configure) the device
*/
@@ -425,7 +432,7 @@ usage(void)
{
const char *p = getprogname();
(void)fprintf(stderr,
- "Usage: %s [-crvz] [-f dsktab] [-t type] vnode_disk"
+ "Usage: %s [-crivz] [-f dsktab] [-t type] vnode_disk"
" reg-file [geomspec]\n"
" %s -u [-Fv] vnode_disk\n"
" %s -l [-m num | vnode_disk...]\n", p, p, p);