Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 23 Dec 2012 22:43:27 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r244643 - in head/sys: fs/devfs kern sys
Message-ID:  <201212232243.qBNMhRFt081673@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Sun Dec 23 22:43:27 2012
New Revision: 244643
URL: http://svnweb.freebsd.org/changeset/base/244643

Log:
  Do not force a writer to the devfs file to drain the buffer writes.
  
  Requested and tested by:	Ian Lepore <freebsd@damnhippie.dyndns.org>
  MFC after:	2 weeks

Modified:
  head/sys/fs/devfs/devfs_vnops.c
  head/sys/kern/sys_generic.c
  head/sys/sys/file.h

Modified: head/sys/fs/devfs/devfs_vnops.c
==============================================================================
--- head/sys/fs/devfs/devfs_vnops.c	Sun Dec 23 22:41:54 2012	(r244642)
+++ head/sys/fs/devfs/devfs_vnops.c	Sun Dec 23 22:43:27 2012	(r244643)
@@ -1049,6 +1049,7 @@ devfs_open(struct vop_open_args *ap)
 	int error, ref, vlocked;
 	struct cdevsw *dsw;
 	struct file *fpop;
+	struct mtx *mtxp;
 
 	if (vp->v_type == VBLK)
 		return (ENXIO);
@@ -1099,6 +1100,16 @@ devfs_open(struct vop_open_args *ap)
 #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: head/sys/kern/sys_generic.c
==============================================================================
--- head/sys/kern/sys_generic.c	Sun Dec 23 22:41:54 2012	(r244642)
+++ head/sys/kern/sys_generic.c	Sun Dec 23 22:43:27 2012	(r244643)
@@ -536,7 +536,8 @@ dofilewrite(td, fd, fp, auio, offset, fl
 		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: head/sys/sys/file.h
==============================================================================
--- head/sys/sys/file.h	Sun Dec 23 22:41:54 2012	(r244642)
+++ head/sys/sys/file.h	Sun Dec 23 22:43:27 2012	(r244643)
@@ -178,7 +178,8 @@ struct file {
 #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 */
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201212232243.qBNMhRFt081673>