From ad9789f6db8d77fd5ab6f8e63003c7cae46fd9ca Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Sun, 23 Dec 2012 22:43:27 +0000 Subject: [PATCH] Do not force a writer to the devfs file to drain the buffer writes. Requested and tested by: Ian Lepore MFC after: 2 weeks --- sys/fs/devfs/devfs_vnops.c | 11 +++++++++++ sys/kern/sys_generic.c | 3 ++- sys/sys/file.h | 3 ++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c index 97a1bcfc72ee..9851229d5c69 100644 --- a/sys/fs/devfs/devfs_vnops.c +++ b/sys/fs/devfs/devfs_vnops.c @@ -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); } diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c index f47cb0332e72..b97ff7f5ea2a 100644 --- a/sys/kern/sys_generic.c +++ b/sys/kern/sys_generic.c @@ -536,7 +536,8 @@ dofilewrite(td, fd, fp, auio, offset, flags) 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 || diff --git a/sys/sys/file.h b/sys/sys/file.h index dc49895fa089..cf5f1ea4965b 100644 --- a/sys/sys/file.h +++ b/sys/sys/file.h @@ -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 */