CVS commit: [netbsd-7] src/sys/fs/puffs
Module Name:src Committed By: snj Date: Sun Mar 15 22:43:02 UTC 2015 Modified Files: src/sys/fs/puffs [netbsd-7]: puffs_vfsops.c Log Message: Pull up following revision(s) (requested by tron in ticket #587): sys/fs/puffs/puffs_vfsops.c: revision 1.117 Remove debug printf To generate a diff of this commit: cvs rdiff -u -r1.113.2.3 -r1.113.2.4 src/sys/fs/puffs/puffs_vfsops.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/fs/puffs/puffs_vfsops.c diff -u src/sys/fs/puffs/puffs_vfsops.c:1.113.2.3 src/sys/fs/puffs/puffs_vfsops.c:1.113.2.4 --- src/sys/fs/puffs/puffs_vfsops.c:1.113.2.3 Fri Feb 27 19:39:56 2015 +++ src/sys/fs/puffs/puffs_vfsops.c Sun Mar 15 22:43:02 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_vfsops.c,v 1.113.2.3 2015/02/27 19:39:56 martin Exp $ */ +/* $NetBSD: puffs_vfsops.c,v 1.113.2.4 2015/03/15 22:43:02 snj Exp $ */ /* * Copyright (c) 2005, 2006 Antti Kantee. All Rights Reserved. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: puffs_vfsops.c,v 1.113.2.3 2015/02/27 19:39:56 martin Exp $); +__KERNEL_RCSID(0, $NetBSD: puffs_vfsops.c,v 1.113.2.4 2015/03/15 22:43:02 snj Exp $); #include sys/param.h #include sys/kernel.h @@ -124,7 +124,6 @@ puffs_vfsop_mount(struct mount *mp, cons goto out; } -printf(args-pa_flags = 0x%x\n, args-pa_flags); if ((args-pa_flags ~PUFFS_KFLAG_MASK) != 0) { printf(puffs_mount: invalid KFLAGs 0x%x\n, args-pa_flags); error = EINVAL;
CVS commit: [netbsd-7] src/sys/fs/puffs
Module Name:src Committed By: martin Date: Sat Jan 17 11:49:09 UTC 2015 Modified Files: src/sys/fs/puffs [netbsd-7]: puffs_vnops.c Log Message: Pull up following revision(s) (requested by manu in ticket #423): sys/fs/puffs/puffs_vnops.c: revision 1.199 Make sure reads on empty files reach PUFFS filesystems Sending a read through the page cache will get the operation short-circuited. This is a problem with some filesystems that expect to receive the read operation in order to update atime. We fix that by bypassing the page cache when reading a file wich a size known to be zero. To generate a diff of this commit: cvs rdiff -u -r1.182.2.11 -r1.182.2.12 src/sys/fs/puffs/puffs_vnops.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/fs/puffs/puffs_vnops.c diff -u src/sys/fs/puffs/puffs_vnops.c:1.182.2.11 src/sys/fs/puffs/puffs_vnops.c:1.182.2.12 --- src/sys/fs/puffs/puffs_vnops.c:1.182.2.11 Sun Nov 9 10:09:32 2014 +++ src/sys/fs/puffs/puffs_vnops.c Sat Jan 17 11:49:09 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_vnops.c,v 1.182.2.11 2014/11/09 10:09:32 msaitoh Exp $ */ +/* $NetBSD: puffs_vnops.c,v 1.182.2.12 2015/01/17 11:49:09 martin Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: puffs_vnops.c,v 1.182.2.11 2014/11/09 10:09:32 msaitoh Exp $); +__KERNEL_RCSID(0, $NetBSD: puffs_vnops.c,v 1.182.2.12 2015/01/17 11:49:09 martin Exp $); #include sys/param.h #include sys/buf.h @@ -2279,9 +2279,17 @@ puffs_vnop_read(void *v) if (uio-uio_offset 0) return EFBIG; + /* + * On the case of reading empty files and (vp-v_size != 0) below: + * some filesystems (hint: FUSE and distributed filesystems) still + * expect to get the READ in order to update atime. Reading through + * the case filters empty files, therefore we prefer to bypass the + * cache here. + */ if (vp-v_type == VREG PUFFS_USE_PAGECACHE(pmp) - !(pn-pn_stat PNODE_RDIRECT)) { + !(pn-pn_stat PNODE_RDIRECT) + (vp-v_size != 0)) { const int advice = IO_ADV_DECODE(ap-a_ioflag); while (uio-uio_resid 0) {
CVS commit: [netbsd-7] src/sys/fs/puffs
Module Name:src Committed By: msaitoh Date: Sun Nov 9 10:07:31 UTC 2014 Modified Files: src/sys/fs/puffs [netbsd-7]: puffs_vnops.c Log Message: Pull up following revision(s) (requested by manu in ticket #193): sys/fs/puffs/puffs_vnops.c: revision 1.198 PUFFS direct I/O cache fix There are a few situations where we must take care of the cache if direct I/O was enabled: - if we do direct I/O for write but not for read, then any write must invalidate the cache so that a reader gets the written data and not the not-updated cache. - if we used a vnode without direct I/O and it is enabled for writing, we must flush the cache before compeling the open operation, so that the cachec write are not lost. And at inactive time, we wipe direct I/O flags so that a new open without direct I/O does not inherit direct I/O. To generate a diff of this commit: cvs rdiff -u -r1.182.2.9 -r1.182.2.10 src/sys/fs/puffs/puffs_vnops.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/fs/puffs/puffs_vnops.c diff -u src/sys/fs/puffs/puffs_vnops.c:1.182.2.9 src/sys/fs/puffs/puffs_vnops.c:1.182.2.10 --- src/sys/fs/puffs/puffs_vnops.c:1.182.2.9 Wed Nov 5 18:16:17 2014 +++ src/sys/fs/puffs/puffs_vnops.c Sun Nov 9 10:07:31 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_vnops.c,v 1.182.2.9 2014/11/05 18:16:17 snj Exp $ */ +/* $NetBSD: puffs_vnops.c,v 1.182.2.10 2014/11/09 10:07:31 msaitoh Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: puffs_vnops.c,v 1.182.2.9 2014/11/05 18:16:17 snj Exp $); +__KERNEL_RCSID(0, $NetBSD: puffs_vnops.c,v 1.182.2.10 2014/11/09 10:07:31 msaitoh Exp $); #include sys/param.h #include sys/buf.h @@ -908,6 +908,12 @@ puffs_vnop_open(void *v) error = checkerr(pmp, error, __func__); if (open_msg-pvnr_oflags PUFFS_OPEN_IO_DIRECT) { + /* + * Flush cache: + * - we do not want to discard cached write by direct write + * - read cache is now useless and should be freed + */ + flushvncache(vp, 0, 0, true); if (mode FREAD) pn-pn_stat |= PNODE_RDIRECT; if (mode FWRITE) @@ -1404,6 +1410,11 @@ puffs_vnop_inactive(void *v) } } + /* + * Wipe direct I/O flags + */ + pnode-pn_stat = ~(PNODE_RDIRECT|PNODE_WDIRECT); + *ap-a_recycle = recycle; mutex_exit(pnode-pn_sizemtx); @@ -2369,19 +2380,20 @@ puffs_vnop_write(void *v) mutex_enter(pn-pn_sizemtx); + /* + * userspace *should* be allowed to control this, + * but with UBC it's a bit unclear how to handle it + */ + if (ap-a_ioflag IO_APPEND) + uio-uio_offset = vp-v_size; + + origoff = uio-uio_offset; + if (vp-v_type == VREG PUFFS_USE_PAGECACHE(pmp) !(pn-pn_stat PNODE_WDIRECT)) { ubcflags = UBC_WRITE | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp); - /* - * userspace *should* be allowed to control this, - * but with UBC it's a bit unclear how to handle it - */ - if (ap-a_ioflag IO_APPEND) - uio-uio_offset = vp-v_size; - - origoff = uio-uio_offset; while (uio-uio_resid 0) { oldoff = uio-uio_offset; bytelen = uio-uio_resid; @@ -2488,6 +2500,22 @@ puffs_vnop_write(void *v) } } puffs_msgmem_release(park_write); + + /* + * Direct I/O on write but not on read: we must + * invlidate the written pages so that we read + * the written data and not the stalled cache. + */ + if ((error == 0) + (vp-v_type == VREG) PUFFS_USE_PAGECACHE(pmp) + (pn-pn_stat PNODE_WDIRECT) + !(pn-pn_stat PNODE_RDIRECT)) { + voff_t off_lo = trunc_page(origoff); + voff_t off_hi = round_page(uio-uio_offset); + + mutex_enter(vp-v_uobj.vmobjlock); + error = VOP_PUTPAGES(vp, off_lo, off_hi, PGO_FREE); + } } if (vp-v_mount-mnt_flag MNT_RELATIME)
CVS commit: [netbsd-7] src/sys/fs/puffs
Module Name:src Committed By: snj Date: Wed Nov 5 18:16:17 UTC 2014 Modified Files: src/sys/fs/puffs [netbsd-7]: puffs_vnops.c Log Message: Pull up following revision(s) (requested by manu in ticket #182): sys/fs/puffs/puffs_vnops.c: revision 1.195 According to pooka@'s comment, a long time ago, VOP_STRATEGY could not fail without taking down the kernel. It seems this is not the case anymore, hence we can stop dropping errors in puffs_vnop_strategy() Approved by pooka@ To generate a diff of this commit: cvs rdiff -u -r1.182.2.8 -r1.182.2.9 src/sys/fs/puffs/puffs_vnops.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/fs/puffs/puffs_vnops.c diff -u src/sys/fs/puffs/puffs_vnops.c:1.182.2.8 src/sys/fs/puffs/puffs_vnops.c:1.182.2.9 --- src/sys/fs/puffs/puffs_vnops.c:1.182.2.8 Wed Nov 5 18:11:31 2014 +++ src/sys/fs/puffs/puffs_vnops.c Wed Nov 5 18:16:17 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_vnops.c,v 1.182.2.8 2014/11/05 18:11:31 snj Exp $ */ +/* $NetBSD: puffs_vnops.c,v 1.182.2.9 2014/11/05 18:16:17 snj Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: puffs_vnops.c,v 1.182.2.8 2014/11/05 18:11:31 snj Exp $); +__KERNEL_RCSID(0, $NetBSD: puffs_vnops.c,v 1.182.2.9 2014/11/05 18:16:17 snj Exp $); #include sys/param.h #include sys/buf.h @@ -2841,13 +2841,6 @@ puffs_vnop_strategy(void *v) if (dobiodone == 0) goto out; - /* - * : wrong, but kernel can't survive strategy - * failure currently. Here, have one more X: X. - */ - if (error != ENOMEM) - error = 0; - error = checkerr(pmp, error, __func__); if (error) goto out;
CVS commit: [netbsd-7] src/sys/fs/puffs
Module Name:src Committed By: martin Date: Tue Oct 14 08:16:03 UTC 2014 Modified Files: src/sys/fs/puffs [netbsd-7]: puffs_vnops.c Log Message: Pull up revisions 1.192-1.194: fix debug printf formatting and make it compile without debugging enabled. To generate a diff of this commit: cvs rdiff -u -r1.182.2.6 -r1.182.2.7 src/sys/fs/puffs/puffs_vnops.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/fs/puffs/puffs_vnops.c diff -u src/sys/fs/puffs/puffs_vnops.c:1.182.2.6 src/sys/fs/puffs/puffs_vnops.c:1.182.2.7 --- src/sys/fs/puffs/puffs_vnops.c:1.182.2.6 Mon Oct 13 18:57:46 2014 +++ src/sys/fs/puffs/puffs_vnops.c Tue Oct 14 08:16:03 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_vnops.c,v 1.182.2.6 2014/10/13 18:57:46 martin Exp $ */ +/* $NetBSD: puffs_vnops.c,v 1.182.2.7 2014/10/14 08:16:03 martin Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: puffs_vnops.c,v 1.182.2.6 2014/10/13 18:57:46 martin Exp $); +__KERNEL_RCSID(0, $NetBSD: puffs_vnops.c,v 1.182.2.7 2014/10/14 08:16:03 martin Exp $); #include sys/param.h #include sys/buf.h @@ -1159,9 +1159,10 @@ zerofill_lastpage(struct vnode *vp, voff error = ubc_uiomove(vp-v_uobj, uio, len, UVM_ADV_SEQUENTIAL, UBC_WRITE|UBC_UNMAP_FLAG(vp)); - if (error) - DPRINTF((zero-fill 0x%lx@0x% PRIx64 failed: error = %d\n, - len, off, error)); + if (error) { + DPRINTF((zero-fill 0x% PRIxVSIZE @0x% PRIx64 + failed: error = %d\n, len, off, error)); + } return; }
CVS commit: [netbsd-7] src/sys/fs/puffs
Module Name:src Committed By: martin Date: Mon Oct 13 18:57:46 UTC 2014 Modified Files: src/sys/fs/puffs [netbsd-7]: puffs_vnops.c Log Message: Pull up following revision(s) (requested by manu in ticket #136): sys/fs/puffs/puffs_vnops.c: revision 1.189-1.191 If we truncate a file open for writing, make sure we zero-fill the end of the last page, otherwise if the file is later truncated to a larger size (creating a hole), that area will not return zeroes as it should. To generate a diff of this commit: cvs rdiff -u -r1.182.2.5 -r1.182.2.6 src/sys/fs/puffs/puffs_vnops.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/fs/puffs/puffs_vnops.c diff -u src/sys/fs/puffs/puffs_vnops.c:1.182.2.5 src/sys/fs/puffs/puffs_vnops.c:1.182.2.6 --- src/sys/fs/puffs/puffs_vnops.c:1.182.2.5 Tue Sep 30 18:14:22 2014 +++ src/sys/fs/puffs/puffs_vnops.c Mon Oct 13 18:57:46 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_vnops.c,v 1.182.2.5 2014/09/30 18:14:22 martin Exp $ */ +/* $NetBSD: puffs_vnops.c,v 1.182.2.6 2014/10/13 18:57:46 martin Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: puffs_vnops.c,v 1.182.2.5 2014/09/30 18:14:22 martin Exp $); +__KERNEL_RCSID(0, $NetBSD: puffs_vnops.c,v 1.182.2.6 2014/10/13 18:57:46 martin Exp $); #include sys/param.h #include sys/buf.h @@ -1130,12 +1130,49 @@ puffs_vnop_getattr(void *v) return error; } +static void +zerofill_lastpage(struct vnode *vp, voff_t off) +{ + char zbuf[PAGE_SIZE]; + struct iovec iov; + struct uio uio; + vsize_t len; + int error; + + if (trunc_page(off) == off) + return; + + if (vp-v_writecount == 0) + return; + + len = round_page(off) - off; + memset(zbuf, 0, len); + + iov.iov_base = zbuf; + iov.iov_len = len; + UIO_SETUP_SYSSPACE(uio); + uio.uio_iov = iov; + uio.uio_iovcnt = 1; + uio.uio_offset = off; + uio.uio_resid = len; + uio.uio_rw = UIO_WRITE; + + error = ubc_uiomove(vp-v_uobj, uio, len, + UVM_ADV_SEQUENTIAL, UBC_WRITE|UBC_UNMAP_FLAG(vp)); + if (error) + DPRINTF((zero-fill 0x%lx@0x% PRIx64 failed: error = %d\n, + len, off, error)); + + return; +} + static int dosetattr(struct vnode *vp, struct vattr *vap, kauth_cred_t cred, int flags) { PUFFS_MSG_VARS(vn, setattr); struct puffs_mount *pmp = MPTOPUFFSMP(vp-v_mount); struct puffs_node *pn = vp-v_data; + vsize_t oldsize = vp-v_size; int error = 0; KASSERT(!(flags SETATTR_CHSIZE) || mutex_owned(pn-pn_sizemtx)); @@ -1208,6 +1245,17 @@ dosetattr(struct vnode *vp, struct vattr } if (vap-va_size != VNOVAL) { + /* + * If we truncated the file, make sure the data beyond + * EOF in last page does not remain in cache, otherwise + * if the file is later truncated to a larger size (creating + * a hole), that area will not return zeroes as it + * should. + */ + if ((flags SETATTR_CHSIZE) PUFFS_USE_PAGECACHE(pmp) + (vap-va_size oldsize)) + zerofill_lastpage(vp, vap-va_size); + pn-pn_serversize = vap-va_size; if (flags SETATTR_CHSIZE) uvm_vnp_setsize(vp, vap-va_size);
CVS commit: [netbsd-7] src/sys/fs/puffs
Module Name:src Committed By: martin Date: Tue Sep 30 18:14:22 UTC 2014 Modified Files: src/sys/fs/puffs [netbsd-7]: puffs_node.c puffs_vnops.c Log Message: Pull up following revision(s) (requested by hannken in ticket #67): sys/fs/puffs/puffs_node.c: revision 1.34 sys/fs/puffs/puffs_vnops.c: revision 1.187 Fix the puffs_sop_thread - puffs_cookie2vnode path: - pass the cookie by reference - add missing mutex_exit() - update assertion for VNON typed vnodes To generate a diff of this commit: cvs rdiff -u -r1.31.4.2 -r1.31.4.3 src/sys/fs/puffs/puffs_node.c cvs rdiff -u -r1.182.2.4 -r1.182.2.5 src/sys/fs/puffs/puffs_vnops.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/fs/puffs/puffs_node.c diff -u src/sys/fs/puffs/puffs_node.c:1.31.4.2 src/sys/fs/puffs/puffs_node.c:1.31.4.3 --- src/sys/fs/puffs/puffs_node.c:1.31.4.2 Wed Sep 10 08:42:28 2014 +++ src/sys/fs/puffs/puffs_node.c Tue Sep 30 18:14:22 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_node.c,v 1.31.4.2 2014/09/10 08:42:28 martin Exp $ */ +/* $NetBSD: puffs_node.c,v 1.31.4.3 2014/09/30 18:14:22 martin Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: puffs_node.c,v 1.31.4.2 2014/09/10 08:42:28 martin Exp $); +__KERNEL_RCSID(0, $NetBSD: puffs_node.c,v 1.31.4.3 2014/09/30 18:14:22 martin Exp $); #include sys/param.h #include sys/hash.h @@ -260,7 +260,7 @@ puffs_cookie2vnode(struct puffs_mount *p return 0; } - rv = vcache_get(PMPTOMP(pmp), ck, sizeof(ck), vpp); + rv = vcache_get(PMPTOMP(pmp), ck, sizeof(ck), vpp); if (rv != 0) return rv; mutex_enter((*vpp)-v_interlock); @@ -270,6 +270,7 @@ puffs_cookie2vnode(struct puffs_mount *p *vpp = NULL; return PUFFS_NOSUCHCOOKIE; } + mutex_exit((*vpp)-v_interlock); return 0; } Index: src/sys/fs/puffs/puffs_vnops.c diff -u src/sys/fs/puffs/puffs_vnops.c:1.182.2.4 src/sys/fs/puffs/puffs_vnops.c:1.182.2.5 --- src/sys/fs/puffs/puffs_vnops.c:1.182.2.4 Thu Sep 11 14:00:54 2014 +++ src/sys/fs/puffs/puffs_vnops.c Tue Sep 30 18:14:22 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_vnops.c,v 1.182.2.4 2014/09/11 14:00:54 martin Exp $ */ +/* $NetBSD: puffs_vnops.c,v 1.182.2.5 2014/09/30 18:14:22 martin Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: puffs_vnops.c,v 1.182.2.4 2014/09/11 14:00:54 martin Exp $); +__KERNEL_RCSID(0, $NetBSD: puffs_vnops.c,v 1.182.2.5 2014/09/30 18:14:22 martin Exp $); #include sys/param.h #include sys/buf.h @@ -1428,7 +1428,7 @@ puffs_vnop_reclaim(void *v) if (__predict_true(VPTOPP(vp)-pn_parent != NULL)) vrele(VPTOPP(vp)-pn_parent); else - KASSERT(vp-v_vflag VV_ROOT); + KASSERT(vp-v_type == VNON || (vp-v_vflag VV_ROOT)); } puffs_putvnode(vp);
CVS commit: [netbsd-7] src/sys/fs/puffs
Module Name:src Committed By: martin Date: Thu Sep 11 14:00:54 UTC 2014 Modified Files: src/sys/fs/puffs [netbsd-7]: puffs_vnops.c Log Message: Pull up following revision(s) (requested by manu in ticket #93): sys/fs/puffs/puffs_vnops.c: revision 1.186 PUFFS fixes for size update ater write plus read/write sanity checks - Always update kernel metadata cache for size when writing This fixes situation where size update after appending to a file lagged - Make read/write nilpotent when called with null size, as FFS does - Return EFBIG instead of EINVAL for negative offsets, as FFS does To generate a diff of this commit: cvs rdiff -u -r1.182.2.3 -r1.182.2.4 src/sys/fs/puffs/puffs_vnops.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/fs/puffs/puffs_vnops.c diff -u src/sys/fs/puffs/puffs_vnops.c:1.182.2.3 src/sys/fs/puffs/puffs_vnops.c:1.182.2.4 --- src/sys/fs/puffs/puffs_vnops.c:1.182.2.3 Wed Sep 10 08:42:28 2014 +++ src/sys/fs/puffs/puffs_vnops.c Thu Sep 11 14:00:54 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_vnops.c,v 1.182.2.3 2014/09/10 08:42:28 martin Exp $ */ +/* $NetBSD: puffs_vnops.c,v 1.182.2.4 2014/09/11 14:00:54 martin Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: puffs_vnops.c,v 1.182.2.3 2014/09/10 08:42:28 martin Exp $); +__KERNEL_RCSID(0, $NetBSD: puffs_vnops.c,v 1.182.2.4 2014/09/11 14:00:54 martin Exp $); #include sys/param.h #include sys/buf.h @@ -2203,7 +2203,7 @@ puffs_vnop_read(void *v) if (uio-uio_resid == 0) return 0; if (uio-uio_offset 0) - return EINVAL; + return EFBIG; if (vp-v_type == VREG PUFFS_USE_PAGECACHE(pmp) @@ -2310,6 +2310,12 @@ puffs_vnop_write(void *v) error = uflags = 0; write_msg = NULL; + /* std sanity */ + if (uio-uio_resid == 0) + return 0; + if (uio-uio_offset 0) + return EFBIG; + mutex_enter(pn-pn_sizemtx); if (vp-v_type == VREG @@ -2326,10 +2332,6 @@ puffs_vnop_write(void *v) origoff = uio-uio_offset; while (uio-uio_resid 0) { - if (vp-v_mount-mnt_flag MNT_RELATIME) -uflags |= PUFFS_UPDATEATIME; - uflags |= PUFFS_UPDATECTIME; - uflags |= PUFFS_UPDATEMTIME; oldoff = uio-uio_offset; bytelen = uio-uio_resid; @@ -2390,8 +2392,6 @@ puffs_vnop_write(void *v) error = VOP_PUTPAGES(vp, trunc_page(origoff), round_page(uio-uio_offset), PGO_CLEANIT); } - - puffs_updatenode(VPTOPP(vp), uflags, vp-v_size); } else { /* tomove is non-increasing */ tomove = PUFFS_TOMOVE(uio-uio_resid, pmp); @@ -2425,8 +2425,10 @@ puffs_vnop_write(void *v) } /* adjust file size */ - if (vp-v_size uio-uio_offset) + if (vp-v_size uio-uio_offset) { +uflags |= PUFFS_UPDATESIZE; uvm_vnp_setsize(vp, uio-uio_offset); + } /* didn't move everything? bad userspace. bail */ if (write_msg-pvnr_resid != 0) { @@ -2437,6 +2439,12 @@ puffs_vnop_write(void *v) puffs_msgmem_release(park_write); } + if (vp-v_mount-mnt_flag MNT_RELATIME) + uflags |= PUFFS_UPDATEATIME; + uflags |= PUFFS_UPDATECTIME; + uflags |= PUFFS_UPDATEMTIME; + puffs_updatenode(VPTOPP(vp), uflags, vp-v_size); + mutex_exit(pn-pn_sizemtx); return error; }
CVS commit: [netbsd-7] src/sys/fs/puffs
Module Name:src Committed By: martin Date: Wed Sep 10 08:42:28 UTC 2014 Modified Files: src/sys/fs/puffs [netbsd-7]: puffs_node.c puffs_vnops.c Log Message: Pull up following revision(s) (requested by manu in ticket #79): sys/fs/puffs/puffs_node.c: revision 1.33 sys/fs/puffs/puffs_vnops.c: revision 1.185 When changing a directory content, update the ctime/mtime in kernel cache, otherwise the updated ctime/mtime appears after the cached entry expire. To generate a diff of this commit: cvs rdiff -u -r1.31.4.1 -r1.31.4.2 src/sys/fs/puffs/puffs_node.c cvs rdiff -u -r1.182.2.2 -r1.182.2.3 src/sys/fs/puffs/puffs_vnops.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/fs/puffs/puffs_node.c diff -u src/sys/fs/puffs/puffs_node.c:1.31.4.1 src/sys/fs/puffs/puffs_node.c:1.31.4.2 --- src/sys/fs/puffs/puffs_node.c:1.31.4.1 Fri Aug 29 11:55:34 2014 +++ src/sys/fs/puffs/puffs_node.c Wed Sep 10 08:42:28 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_node.c,v 1.31.4.1 2014/08/29 11:55:34 martin Exp $ */ +/* $NetBSD: puffs_node.c,v 1.31.4.2 2014/09/10 08:42:28 martin Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: puffs_node.c,v 1.31.4.1 2014/08/29 11:55:34 martin Exp $); +__KERNEL_RCSID(0, $NetBSD: puffs_node.c,v 1.31.4.2 2014/09/10 08:42:28 martin Exp $); #include sys/param.h #include sys/hash.h @@ -180,6 +180,8 @@ puffs_newnode(struct mount *mp, struct v cache_enter(dvp, *vpp, cnp-cn_nameptr, cnp-cn_namelen, cnp-cn_flags); + puffs_updatenode(VPTOPP(dvp), PUFFS_UPDATECTIME|PUFFS_UPDATEMTIME, 0); + return 0; } Index: src/sys/fs/puffs/puffs_vnops.c diff -u src/sys/fs/puffs/puffs_vnops.c:1.182.2.2 src/sys/fs/puffs/puffs_vnops.c:1.182.2.3 --- src/sys/fs/puffs/puffs_vnops.c:1.182.2.2 Fri Aug 29 11:55:34 2014 +++ src/sys/fs/puffs/puffs_vnops.c Wed Sep 10 08:42:28 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_vnops.c,v 1.182.2.2 2014/08/29 11:55:34 martin Exp $ */ +/* $NetBSD: puffs_vnops.c,v 1.182.2.3 2014/09/10 08:42:28 martin Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: puffs_vnops.c,v 1.182.2.2 2014/08/29 11:55:34 martin Exp $); +__KERNEL_RCSID(0, $NetBSD: puffs_vnops.c,v 1.182.2.3 2014/09/10 08:42:28 martin Exp $); #include sys/param.h #include sys/buf.h @@ -1805,6 +1805,8 @@ puffs_vnop_remove(void *v) PUFFS_MSG_RELEASE(remove); + puffs_updatenode(VPTOPP(dvp), PUFFS_UPDATECTIME|PUFFS_UPDATEMTIME, 0); + RELEPN_AND_VP(dvp, dpn); RELEPN_AND_VP(vp, pn); @@ -1922,6 +1924,8 @@ puffs_vnop_rmdir(void *v) PUFFS_MSG_RELEASE(rmdir); + puffs_updatenode(VPTOPP(dvp), PUFFS_UPDATECTIME|PUFFS_UPDATEMTIME, 0); + /* XXX: some call cache_purge() *for both vnodes* here, investigate */ RELEPN_AND_VP(dvp, dpn); RELEPN_AND_VP(vp, pn); @@ -1967,8 +1971,11 @@ puffs_vnop_link(void *v) * XXX: stay in touch with the cache. I don't like this, but * don't have a better solution either. See also puffs_rename(). */ - if (error == 0) + if (error == 0) { puffs_updatenode(pn, PUFFS_UPDATECTIME, 0); + puffs_updatenode(VPTOPP(dvp), + PUFFS_UPDATECTIME|PUFFS_UPDATEMTIME, 0); + } RELEPN_AND_VP(dvp, dpn); puffs_releasenode(pn); @@ -2133,6 +2140,12 @@ puffs_vnop_rename(void *v) */ if (error == 0) { puffs_updatenode(fpn, PUFFS_UPDATECTIME, 0); + puffs_updatenode(VPTOPP(fdvp), + PUFFS_UPDATECTIME|PUFFS_UPDATEMTIME, 0); + if (fdvp != tdvp) + puffs_updatenode(VPTOPP(tdvp), + PUFFS_UPDATECTIME|PUFFS_UPDATEMTIME, + 0); if (PUFFS_USE_DOTDOTCACHE(pmp) (VPTOPP(fvp)-pn_parent != tdvp))
CVS commit: [netbsd-7] src/sys/fs/puffs
Module Name:src Committed By: martin Date: Fri Aug 29 11:55:34 UTC 2014 Modified Files: src/sys/fs/puffs [netbsd-7]: puffs_msgif.c puffs_node.c puffs_sys.h puffs_vfsops.c puffs_vnops.c Log Message: Pull up following revision(s) (requested by hannken in ticket #67): sys/fs/puffs/puffs_sys.h: revision 1.86 sys/fs/puffs/puffs_vfsops.c: revision 1.114 sys/fs/puffs/puffs_msgif.c: revision 1.95 sys/fs/puffs/puffs_node.c: revision 1.32 sys/fs/puffs/puffs_vnops.c: revision 1.184 Change puffs from hashlist to vcache. - field pa_nhashbuckets of struct puffs_kargs becomes a no-op. and should be removed on the next protocol version bump. To generate a diff of this commit: cvs rdiff -u -r1.94 -r1.94.4.1 src/sys/fs/puffs/puffs_msgif.c cvs rdiff -u -r1.31 -r1.31.4.1 src/sys/fs/puffs/puffs_node.c cvs rdiff -u -r1.84.4.1 -r1.84.4.2 src/sys/fs/puffs/puffs_sys.h cvs rdiff -u -r1.113 -r1.113.2.1 src/sys/fs/puffs/puffs_vfsops.c cvs rdiff -u -r1.182.2.1 -r1.182.2.2 src/sys/fs/puffs/puffs_vnops.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/fs/puffs/puffs_msgif.c diff -u src/sys/fs/puffs/puffs_msgif.c:1.94 src/sys/fs/puffs/puffs_msgif.c:1.94.4.1 --- src/sys/fs/puffs/puffs_msgif.c:1.94 Thu Oct 17 21:03:27 2013 +++ src/sys/fs/puffs/puffs_msgif.c Fri Aug 29 11:55:34 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_msgif.c,v 1.94 2013/10/17 21:03:27 christos Exp $ */ +/* $NetBSD: puffs_msgif.c,v 1.94.4.1 2014/08/29 11:55:34 martin Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: puffs_msgif.c,v 1.94 2013/10/17 21:03:27 christos Exp $); +__KERNEL_RCSID(0, $NetBSD: puffs_msgif.c,v 1.94.4.1 2014/08/29 11:55:34 martin Exp $); #include sys/param.h #include sys/kernel.h @@ -856,7 +856,7 @@ puffsop_expire(struct puffs_mount *pmp, * vrele should cause it to be reclaimed. * Otherwise, we have nothing to do. */ - if (puffs_cookie2vnode(pmp, cookie, 0, 0, vp) == 0) { + if (puffs_cookie2vnode(pmp, cookie, vp) == 0) { VPTOPP(vp)-pn_stat = ~PNODE_SOPEXP; vrele(vp); } @@ -889,7 +889,7 @@ puffsop_flush(struct puffs_mount *pmp, s * reason we need to eventually bump locking to userspace, as we * will need to lock the node if we wish to do flushes. */ - rv = puffs_cookie2vnode(pmp, pf-pf_cookie, 0, 0, vp); + rv = puffs_cookie2vnode(pmp, pf-pf_cookie, vp); if (rv) { if (rv == PUFFS_NOSUCHCOOKIE) rv = ENOENT; Index: src/sys/fs/puffs/puffs_node.c diff -u src/sys/fs/puffs/puffs_node.c:1.31 src/sys/fs/puffs/puffs_node.c:1.31.4.1 --- src/sys/fs/puffs/puffs_node.c:1.31 Thu Jan 23 10:13:56 2014 +++ src/sys/fs/puffs/puffs_node.c Fri Aug 29 11:55:34 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_node.c,v 1.31 2014/01/23 10:13:56 hannken Exp $ */ +/* $NetBSD: puffs_node.c,v 1.31.4.1 2014/08/29 11:55:34 martin Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: puffs_node.c,v 1.31 2014/01/23 10:13:56 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: puffs_node.c,v 1.31.4.1 2014/08/29 11:55:34 martin Exp $); #include sys/param.h #include sys/hash.h @@ -48,148 +48,96 @@ __KERNEL_RCSID(0, $NetBSD: puffs_node.c #include miscfs/genfs/genfs_node.h #include miscfs/specfs/specdev.h -static const struct genfs_ops puffs_genfsops = { - .gop_size = puffs_gop_size, - .gop_write = genfs_gop_write, - .gop_markupdate = puffs_gop_markupdate, -#if 0 - .gop_alloc, should ask userspace -#endif -}; - -static __inline struct puffs_node_hashlist - *puffs_cookie2hashlist(struct puffs_mount *, puffs_cookie_t); -static struct puffs_node *puffs_cookie2pnode(struct puffs_mount *, - puffs_cookie_t); - struct pool puffs_pnpool; struct pool puffs_vapool; /* * Grab a vnode, intialize all the puffs-dependent stuff. */ -int -puffs_getvnode(struct mount *mp, puffs_cookie_t ck, enum vtype type, - voff_t vsize, dev_t rdev, struct vnode **vpp) +static int +puffs_getvnode1(struct mount *mp, puffs_cookie_t ck, enum vtype type, + voff_t vsize, dev_t rdev, bool may_exist, struct vnode **vpp) { struct puffs_mount *pmp; - struct puffs_newcookie *pnc; struct vnode *vp; struct puffs_node *pnode; - struct puffs_node_hashlist *plist; int error; pmp = MPTOPUFFSMP(mp); - error = EPROTO; if (type = VNON || type = VBAD) { puffs_senderr(pmp, PUFFS_ERR_MAKENODE, EINVAL, bad node type, ck); - goto bad; + return EPROTO; } if (vsize == VSIZENOTSET) { puffs_senderr(pmp, PUFFS_ERR_MAKENODE, EINVAL, VSIZENOTSET is not a valid size, ck); - goto bad; + return EPROTO; } - error = getnewvnode(VT_PUFFS, mp, puffs_vnodeop_p, NULL, vp); - if (error) { - goto bad; + for (;;) { + error = vcache_get(mp, ck, sizeof(ck), vp); + if (error) +
CVS commit: [netbsd-7] src/sys/fs/puffs
Module Name:src Committed By: riz Date: Tue Aug 26 23:15:13 UTC 2014 Modified Files: src/sys/fs/puffs [netbsd-7]: puffs_msgif.h puffs_sys.h puffs_vnops.c Log Message: Pull up following revision(s) (requested by manu in ticket #52): sys/fs/puffs/puffs_msgif.h: revision 1.81 sys/fs/puffs/puffs_sys.h: revision 1.85 sys/fs/puffs/puffs_vnops.c: revision 1.183 Add a oflags input field to open requests so that the filesystem can pass back information about the file. Implement PUFFS_OPEN_IO_DIRECT, which will force direct IO (bypassing page cache) for the file. To generate a diff of this commit: cvs rdiff -u -r1.80 -r1.80.14.1 src/sys/fs/puffs/puffs_msgif.h cvs rdiff -u -r1.84 -r1.84.4.1 src/sys/fs/puffs/puffs_sys.h cvs rdiff -u -r1.182 -r1.182.2.1 src/sys/fs/puffs/puffs_vnops.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/fs/puffs/puffs_msgif.h diff -u src/sys/fs/puffs/puffs_msgif.h:1.80 src/sys/fs/puffs/puffs_msgif.h:1.80.14.1 --- src/sys/fs/puffs/puffs_msgif.h:1.80 Fri Aug 10 16:49:35 2012 +++ src/sys/fs/puffs/puffs_msgif.h Tue Aug 26 23:15:12 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_msgif.h,v 1.80 2012/08/10 16:49:35 manu Exp $ */ +/* $NetBSD: puffs_msgif.h,v 1.80.14.1 2014/08/26 23:15:12 riz Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -339,6 +339,9 @@ struct puffs_vfsmsg_suspend { #define PUFFS_EXTATTRCTL_HASNODE 0x01 #define PUFFS_EXTATTRCTL_HASATTRNAME 0x02 + +#define PUFFS_OPEN_IO_DIRECT 0x01 + struct puffs_vfsmsg_extattrctl { struct puffs_req pvfsr_pr; @@ -399,6 +402,7 @@ struct puffs_vnmsg_open { struct puffs_kcred pvnr_cred; /* OUT */ int pvnr_mode; /* OUT */ + int pvnr_oflags; /* IN */ }; struct puffs_vnmsg_close { Index: src/sys/fs/puffs/puffs_sys.h diff -u src/sys/fs/puffs/puffs_sys.h:1.84 src/sys/fs/puffs/puffs_sys.h:1.84.4.1 --- src/sys/fs/puffs/puffs_sys.h:1.84 Thu Oct 17 21:03:27 2013 +++ src/sys/fs/puffs/puffs_sys.h Tue Aug 26 23:15:12 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_sys.h,v 1.84 2013/10/17 21:03:27 christos Exp $ */ +/* $NetBSD: puffs_sys.h,v 1.84.4.1 2014/08/26 23:15:12 riz Exp $ */ /* * Copyright (c) 2005, 2006 Antti Kantee. All Rights Reserved. @@ -197,6 +197,8 @@ struct puffs_mount { #define PNODE_FAF 0x004 /* issue all operations as FAF */ #define PNODE_DOINACT 0x008 /* if inactive-on-demand, call inactive */ #define PNODE_SOPEXP 0x100 /* Node reclaim postponed in sop thread */ +#define PNODE_RDIRECT 0x200 /* bypass page cache on read */ +#define PNODE_WDIRECT 0x400 /* bypass page cache on write */ #define PNODE_METACACHE_ATIME 0x10 /* cache atime metadata */ #define PNODE_METACACHE_CTIME 0x20 /* cache atime metadata */ Index: src/sys/fs/puffs/puffs_vnops.c diff -u src/sys/fs/puffs/puffs_vnops.c:1.182 src/sys/fs/puffs/puffs_vnops.c:1.182.2.1 --- src/sys/fs/puffs/puffs_vnops.c:1.182 Fri Jul 25 08:20:52 2014 +++ src/sys/fs/puffs/puffs_vnops.c Tue Aug 26 23:15:12 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_vnops.c,v 1.182 2014/07/25 08:20:52 dholland Exp $ */ +/* $NetBSD: puffs_vnops.c,v 1.182.2.1 2014/08/26 23:15:12 riz Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: puffs_vnops.c,v 1.182 2014/07/25 08:20:52 dholland Exp $); +__KERNEL_RCSID(0, $NetBSD: puffs_vnops.c,v 1.182.2.1 2014/08/26 23:15:12 riz Exp $); #include sys/param.h #include sys/buf.h @@ -893,6 +893,7 @@ puffs_vnop_open(void *v) PUFFS_MSG_VARS(vn, open); struct vnode *vp = ap-a_vp; struct puffs_mount *pmp = MPTOPUFFSMP(vp-v_mount); + struct puffs_node *pn = VPTOPP(vp); int mode = ap-a_mode; int error; @@ -913,6 +914,12 @@ puffs_vnop_open(void *v) PUFFS_MSG_ENQUEUEWAIT2(pmp, park_open, vp-v_data, NULL, error); error = checkerr(pmp, error, __func__); + if (open_msg-pvnr_oflags PUFFS_OPEN_IO_DIRECT) { + if (mode FREAD) + pn-pn_stat |= PNODE_RDIRECT; + if (mode FWRITE) + pn-pn_stat |= PNODE_WDIRECT; + } out: DPRINTF((puffs_open: returning %d\n, error)); PUFFS_MSG_RELEASE(open); @@ -2181,6 +2188,7 @@ puffs_vnop_read(void *v) } */ *ap = v; PUFFS_MSG_VARS(vn, read); struct vnode *vp = ap-a_vp; + struct puffs_node *pn = VPTOPP(vp); struct puffs_mount *pmp = MPTOPUFFSMP(vp-v_mount); struct uio *uio = ap-a_uio; size_t tomove, argsize; @@ -2196,7 +2204,9 @@ puffs_vnop_read(void *v) if (uio-uio_offset 0) return EINVAL; - if (vp-v_type == VREG PUFFS_USE_PAGECACHE(pmp)) { + if (vp-v_type == VREG + PUFFS_USE_PAGECACHE(pmp) + !(pn-pn_stat PNODE_RDIRECT)) { const int advice = IO_ADV_DECODE(ap-a_ioflag); while (uio-uio_resid 0) { @@ -2301,7 +2311,9 @@ puffs_vnop_write(void *v) mutex_enter(pn-pn_sizemtx); - if (vp-v_type == VREG PUFFS_USE_PAGECACHE(pmp)) { + if (vp-v_type == VREG +