[Midnightbsd-cvs] src [8579] trunk/sys: do not force a writer to the devfs file to drain buffer writes.

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Mon Sep 19 12:15:38 EDT 2016


Revision: 8579
          http://svnweb.midnightbsd.org/src/?rev=8579
Author:   laffer1
Date:     2016-09-19 12:15:37 -0400 (Mon, 19 Sep 2016)
Log Message:
-----------
do not force a writer to the devfs file to drain buffer writes.

Modified Paths:
--------------
    trunk/sys/fs/devfs/devfs_vnops.c
    trunk/sys/kern/sys_generic.c
    trunk/sys/sys/file.h

Modified: trunk/sys/fs/devfs/devfs_vnops.c
===================================================================
--- trunk/sys/fs/devfs/devfs_vnops.c	2016-09-19 16:15:02 UTC (rev 8578)
+++ trunk/sys/fs/devfs/devfs_vnops.c	2016-09-19 16:15:37 UTC (rev 8579)
@@ -1049,6 +1049,7 @@
 	int error, ref, vlocked;
 	struct cdevsw *dsw;
 	struct file *fpop;
+	struct mtx *mtxp;
 
 	if (vp->v_type == VBLK)
 		return (ENXIO);
@@ -1099,6 +1100,16 @@
 #endif
 	if (fp->f_ops == &badfileops)
 		finit(fp, fp->f_flag, DTYPE_VNODE, dev, &devfs_ops_f);
+	mtxp = mtx_pool_find(mtxpool_sleep, fp);
+
+	/*
+	 * Hint to the dofilewrite() to not force the buffer draining
+	 * on the writer to the file.  Most likely, the write would
+	 * not need normal buffers.
+	 */
+	mtx_lock(mtxp);
+	fp->f_vnread_flags |= FDEVFS_VNODE;
+	mtx_unlock(mtxp);
 	return (error);
 }
 

Modified: trunk/sys/kern/sys_generic.c
===================================================================
--- trunk/sys/kern/sys_generic.c	2016-09-19 16:15:02 UTC (rev 8578)
+++ trunk/sys/kern/sys_generic.c	2016-09-19 16:15:37 UTC (rev 8579)
@@ -536,7 +536,8 @@
 		ktruio = cloneuio(auio);
 #endif
 	cnt = auio->uio_resid;
-	if (fp->f_type == DTYPE_VNODE)
+	if (fp->f_type == DTYPE_VNODE &&
+	    (fp->f_vnread_flags & FDEVFS_VNODE) == 0)
 		bwillwrite();
 	if ((error = fo_write(fp, auio, td->td_ucred, flags, td))) {
 		if (auio->uio_resid != cnt && (error == ERESTART ||

Modified: trunk/sys/sys/file.h
===================================================================
--- trunk/sys/sys/file.h	2016-09-19 16:15:02 UTC (rev 8578)
+++ trunk/sys/sys/file.h	2016-09-19 16:15:37 UTC (rev 8579)
@@ -178,7 +178,8 @@
 #define	f_advice	f_vnun.fvn_advice
 
 #define	FOFFSET_LOCKED       0x1
-#define	FOFFSET_LOCK_WAITING 0x2		 
+#define	FOFFSET_LOCK_WAITING 0x2
+#define	FDEVFS_VNODE	     0x4
 
 #endif /* _KERNEL || _WANT_FILE */
 



More information about the Midnightbsd-cvs mailing list