From b78c698115dc8f09b8ebecdeda95af99f095a753 Mon Sep 17 00:00:00 2001 From: millert Date: Mon, 8 Jan 2018 16:15:34 +0000 Subject: [PATCH] Add kqueue support for ext2fs based on ffs. OK deraadt@ --- sys/ufs/ext2fs/ext2fs_readwrite.c | 11 ++++++++--- sys/ufs/ext2fs/ext2fs_vnops.c | 4 ++-- sys/ufs/ufs/ufs_vnops.c | 9 +++++++-- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/sys/ufs/ext2fs/ext2fs_readwrite.c b/sys/ufs/ext2fs/ext2fs_readwrite.c index d3497747dfd..2f7715739d3 100644 --- a/sys/ufs/ext2fs/ext2fs_readwrite.c +++ b/sys/ufs/ext2fs/ext2fs_readwrite.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ext2fs_readwrite.c,v 1.41 2017/12/30 20:47:00 guenther Exp $ */ +/* $OpenBSD: ext2fs_readwrite.c,v 1.42 2018/01/08 16:15:34 millert Exp $ */ /* $NetBSD: ext2fs_readwrite.c,v 1.16 2001/02/27 04:37:47 chs Exp $ */ /*- @@ -44,6 +44,7 @@ #include #include #include +#include #include #include @@ -241,10 +242,11 @@ ext2fs_write(void *v) struct buf *bp; int32_t lbn; off_t osize; - int blkoffset, error, flags, ioflag, size, xfersize; + int blkoffset, error, extended, flags, ioflag, size, xfersize; size_t resid; ssize_t overrun; + extended = 0; ioflag = ap->a_ioflag; uio = ap->a_uio; vp = ap->a_vp; @@ -312,6 +314,7 @@ ext2fs_write(void *v) if (error) break; uvm_vnp_setsize(vp, ip->i_e2fs_size); + extended = 1; } uvm_vnp_uncache(vp); @@ -319,7 +322,7 @@ ext2fs_write(void *v) if (size < xfersize) xfersize = size; - error = uiomove((char *)bp->b_data + blkoffset, xfersize, uio); + error = uiomove(bp->b_data + blkoffset, xfersize, uio); #if 0 if (ioflag & IO_NOCACHE) bp->b_flags |= B_NOCACHE; @@ -341,6 +344,8 @@ ext2fs_write(void *v) */ if (resid > uio->uio_resid && ap->a_cred && ap->a_cred->cr_uid != 0) ip->i_e2fs_mode &= ~(ISUID | ISGID); + if (resid > uio->uio_resid) + VN_KNOTE(vp, NOTE_WRITE | (extended ? NOTE_EXTEND : 0)); if (error) { if (ioflag & IO_UNIT) { (void)ext2fs_truncate(ip, osize, diff --git a/sys/ufs/ext2fs/ext2fs_vnops.c b/sys/ufs/ext2fs/ext2fs_vnops.c index 7ea282af241..9a795ff81b4 100644 --- a/sys/ufs/ext2fs/ext2fs_vnops.c +++ b/sys/ufs/ext2fs/ext2fs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ext2fs_vnops.c,v 1.78 2017/12/30 23:08:29 guenther Exp $ */ +/* $OpenBSD: ext2fs_vnops.c,v 1.79 2018/01/08 16:15:34 millert Exp $ */ /* $NetBSD: ext2fs_vnops.c,v 1.1 1997/06/11 09:34:09 bouyer Exp $ */ /* @@ -1292,7 +1292,7 @@ struct vops ext2fs_vops = { .vop_write = ext2fs_write, .vop_ioctl = ufs_ioctl, .vop_poll = ufs_poll, - .vop_kqfilter = vop_generic_kqfilter, + .vop_kqfilter = ufs_kqfilter, .vop_fsync = ext2fs_fsync, .vop_remove = ext2fs_remove, .vop_link = ext2fs_link, diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index 00f2551ae50..ad25d038876 100644 --- a/sys/ufs/ufs/ufs_vnops.c +++ b/sys/ufs/ufs/ufs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ufs_vnops.c,v 1.135 2018/01/02 06:38:45 guenther Exp $ */ +/* $OpenBSD: ufs_vnops.c,v 1.136 2018/01/08 16:15:34 millert Exp $ */ /* $NetBSD: ufs_vnops.c,v 1.18 1996/05/11 18:28:04 mycroft Exp $ */ /* @@ -1962,7 +1962,12 @@ filt_ufsread(struct knote *kn, long hint) return (1); } - kn->kn_data = DIP(ip, size) - kn->kn_fp->f_offset; +#ifdef EXT2FS + if (IS_EXT2_VNODE(ip->i_vnode)) + kn->kn_data = ext2fs_size(ip) - kn->kn_fp->f_offset; + else +#endif + kn->kn_data = DIP(ip, size) - kn->kn_fp->f_offset; if (kn->kn_data == 0 && kn->kn_sfflags & NOTE_EOF) { kn->kn_fflags |= NOTE_EOF; return (1); -- 2.20.1