Module Name:    src
Committed By:   mlelstv
Date:           Sun Oct  7 11:51:26 UTC 2018

Modified Files:
        src/sys/dev: vnd.c vndvar.h
        src/usr.sbin/vnconfig: vnconfig.8 vnconfig.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.266 -r1.267 src/sys/dev/vnd.c
cvs rdiff -u -r1.37 -r1.38 src/sys/dev/vndvar.h
cvs rdiff -u -r1.43 -r1.44 src/usr.sbin/vnconfig/vnconfig.8
cvs rdiff -u -r1.46 -r1.47 src/usr.sbin/vnconfig/vnconfig.c

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.266 src/sys/dev/vnd.c:1.267
--- src/sys/dev/vnd.c:1.266	Fri Oct  5 09:51:55 2018
+++ src/sys/dev/vnd.c	Sun Oct  7 11:51:26 2018
@@ -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 *da
 		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 *da
 
 		/* 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;

Index: src/sys/dev/vndvar.h
diff -u src/sys/dev/vndvar.h:1.37 src/sys/dev/vndvar.h:1.38
--- src/sys/dev/vndvar.h:1.37	Thu Sep 20 07:18:38 2018
+++ src/sys/dev/vndvar.h	Sun Oct  7 11:51:26 2018
@@ -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
 

Index: src/usr.sbin/vnconfig/vnconfig.8
diff -u src/usr.sbin/vnconfig/vnconfig.8:1.43 src/usr.sbin/vnconfig/vnconfig.8:1.44
--- src/usr.sbin/vnconfig/vnconfig.8:1.43	Tue May  1 09:03:49 2018
+++ src/usr.sbin/vnconfig/vnconfig.8	Sun Oct  7 11:51:26 2018
@@ -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

Index: src/usr.sbin/vnconfig/vnconfig.c
diff -u src/usr.sbin/vnconfig/vnconfig.c:1.46 src/usr.sbin/vnconfig/vnconfig.c:1.47
--- src/usr.sbin/vnconfig/vnconfig.c:1.46	Mon Mar 12 01:15:00 2018
+++ src/usr.sbin/vnconfig/vnconfig.c	Sun Oct  7 11:51:26 2018
@@ -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
 	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);

Reply via email to