CVS commit: [netbsd-6] src/sys/fs/puffs
Module Name:src Committed By: martin Date: Fri Jan 16 19:44:53 UTC 2015 Modified Files: src/sys/fs/puffs [netbsd-6]: puffs_vnops.c Log Message: Pull up following revision(s) (requested by manu in ticket #1236): 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.163.2.10 -r1.163.2.11 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.163.2.10 src/sys/fs/puffs/puffs_vnops.c:1.163.2.11 --- src/sys/fs/puffs/puffs_vnops.c:1.163.2.10 Sun Nov 9 11:05:15 2014 +++ src/sys/fs/puffs/puffs_vnops.c Fri Jan 16 19:44:53 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_vnops.c,v 1.163.2.10 2014/11/09 11:05:15 msaitoh Exp $ */ +/* $NetBSD: puffs_vnops.c,v 1.163.2.11 2015/01/16 19:44:53 martin Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.163.2.10 2014/11/09 11:05:15 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.163.2.11 2015/01/16 19:44:53 martin Exp $"); #include #include @@ -2261,9 +2261,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-6] src/sys/fs/puffs
Module Name:src Committed By: msaitoh Date: Sun Nov 9 11:05:15 UTC 2014 Modified Files: src/sys/fs/puffs [netbsd-6]: puffs_vnops.c Log Message: Pull up following revision(s) (requested by manu in ticket #1187): 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.163.2.9 -r1.163.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.163.2.9 src/sys/fs/puffs/puffs_vnops.c:1.163.2.10 --- src/sys/fs/puffs/puffs_vnops.c:1.163.2.9 Sun Nov 9 07:50:12 2014 +++ src/sys/fs/puffs/puffs_vnops.c Sun Nov 9 11:05:15 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_vnops.c,v 1.163.2.9 2014/11/09 07:50:12 msaitoh Exp $ */ +/* $NetBSD: puffs_vnops.c,v 1.163.2.10 2014/11/09 11:05:15 msaitoh Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.163.2.9 2014/11/09 07:50:12 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.163.2.10 2014/11/09 11:05:15 msaitoh Exp $"); #include #include @@ -893,6 +893,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) @@ -1393,6 +1399,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); @@ -2363,19 +2374,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; @@ -2482,6 +2494,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-6] src/sys/fs/puffs
Module Name:src Committed By: msaitoh Date: Sun Nov 9 07:50:12 UTC 2014 Modified Files: src/sys/fs/puffs [netbsd-6]: puffs_vnops.c Log Message: Pull up following revision(s) (requested by manu in ticket #1184): 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.163.2.8 -r1.163.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.163.2.8 src/sys/fs/puffs/puffs_vnops.c:1.163.2.9 --- src/sys/fs/puffs/puffs_vnops.c:1.163.2.8 Sun Nov 9 06:28:03 2014 +++ src/sys/fs/puffs/puffs_vnops.c Sun Nov 9 07:50:12 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_vnops.c,v 1.163.2.8 2014/11/09 06:28:03 msaitoh Exp $ */ +/* $NetBSD: puffs_vnops.c,v 1.163.2.9 2014/11/09 07:50:12 msaitoh Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.163.2.8 2014/11/09 06:28:03 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.163.2.9 2014/11/09 07:50:12 msaitoh Exp $"); #include #include @@ -2762,13 +2762,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-6] src/sys/fs/puffs
Module Name:src Committed By: msaitoh Date: Sun Nov 9 06:28:03 UTC 2014 Modified Files: src/sys/fs/puffs [netbsd-6]: puffs_vnops.c Log Message: Pull up following revision(s) (requested by manu in ticket #1166): sys/fs/puffs/puffs_vnops.c: revision 1.188-1.194 - If we truncate the file, 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. - Use PRIx64 for printing offsets - Improve zero-fill of last page after shrink fix: 1) do it only if the file is open for writing, otherwise we send write requests to the FS on a file that has never been open. 2) do it inside existing if (vap->va_size != VNOVAL) block - Retore LP64 fix that was removed by mistake - Make this build again without debugging enabled; DPRINTF() can end up as empty, and in an if conditional, you then need braces if that's the only potential body. - As is evidenced by several of our 32-bit MIPS ports, it's wrong to print vsize_t with PRIx64 -- instead use our own PRIxVSIZE macro. - Do the previous correctly... To generate a diff of this commit: cvs rdiff -u -r1.163.2.7 -r1.163.2.8 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.163.2.7 src/sys/fs/puffs/puffs_vnops.c:1.163.2.8 --- src/sys/fs/puffs/puffs_vnops.c:1.163.2.7 Mon Nov 3 19:51:36 2014 +++ src/sys/fs/puffs/puffs_vnops.c Sun Nov 9 06:28:03 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_vnops.c,v 1.163.2.7 2014/11/03 19:51:36 msaitoh Exp $ */ +/* $NetBSD: puffs_vnops.c,v 1.163.2.8 2014/11/09 06:28:03 msaitoh Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.163.2.7 2014/11/03 19:51:36 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.163.2.8 2014/11/09 06:28:03 msaitoh Exp $"); #include #include @@ -1117,12 +1117,50 @@ 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%" PRIxVSIZE "@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)); @@ -1195,6 +1233,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-6] src/sys/fs/puffs
Module Name:src Committed By: msaitoh Date: Mon Nov 3 19:51:37 UTC 2014 Modified Files: src/sys/fs/puffs [netbsd-6]: puffs_vnops.c Log Message: Pull up following revision(s) (requested by manu in ticket #1152): 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.163.2.6 -r1.163.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.163.2.6 src/sys/fs/puffs/puffs_vnops.c:1.163.2.7 --- src/sys/fs/puffs/puffs_vnops.c:1.163.2.6 Mon Nov 3 19:42:33 2014 +++ src/sys/fs/puffs/puffs_vnops.c Mon Nov 3 19:51:36 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_vnops.c,v 1.163.2.6 2014/11/03 19:42:33 msaitoh Exp $ */ +/* $NetBSD: puffs_vnops.c,v 1.163.2.7 2014/11/03 19:51:36 msaitoh Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.163.2.6 2014/11/03 19:42:33 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.163.2.7 2014/11/03 19:51:36 msaitoh Exp $"); #include #include @@ -2199,7 +2199,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) && @@ -2306,6 +2306,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 && @@ -2322,10 +2328,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; @@ -2386,8 +2388,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); @@ -2421,8 +2421,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) { @@ -2433,6 +2435,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-6] src/sys/fs/puffs
Module Name:src Committed By: msaitoh Date: Mon Nov 3 19:42:34 UTC 2014 Modified Files: src/sys/fs/puffs [netbsd-6]: puffs_node.c puffs_vnops.c Log Message: Pull up following revision(s) (requested by manu in ticket #1149): 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.23.2.2 -r1.23.2.3 src/sys/fs/puffs/puffs_node.c cvs rdiff -u -r1.163.2.5 -r1.163.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_node.c diff -u src/sys/fs/puffs/puffs_node.c:1.23.2.2 src/sys/fs/puffs/puffs_node.c:1.23.2.3 --- src/sys/fs/puffs/puffs_node.c:1.23.2.2 Sun Aug 12 12:59:50 2012 +++ src/sys/fs/puffs/puffs_node.c Mon Nov 3 19:42:33 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_node.c,v 1.23.2.2 2012/08/12 12:59:50 martin Exp $ */ +/* $NetBSD: puffs_node.c,v 1.23.2.3 2014/11/03 19:42:33 msaitoh Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: puffs_node.c,v 1.23.2.2 2012/08/12 12:59:50 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: puffs_node.c,v 1.23.2.3 2014/11/03 19:42:33 msaitoh Exp $"); #include #include @@ -249,6 +249,8 @@ puffs_newnode(struct mount *mp, struct v if (PUFFS_USE_NAMECACHE(pmp)) cache_enter(dvp, vp, cnp); + 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.163.2.5 src/sys/fs/puffs/puffs_vnops.c:1.163.2.6 --- src/sys/fs/puffs/puffs_vnops.c:1.163.2.5 Mon Nov 3 19:18:09 2014 +++ src/sys/fs/puffs/puffs_vnops.c Mon Nov 3 19:42:33 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_vnops.c,v 1.163.2.5 2014/11/03 19:18:09 msaitoh Exp $ */ +/* $NetBSD: puffs_vnops.c,v 1.163.2.6 2014/11/03 19:42:33 msaitoh Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.163.2.5 2014/11/03 19:18:09 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.163.2.6 2014/11/03 19:42:33 msaitoh Exp $"); #include #include @@ -1799,6 +1799,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); @@ -1917,6 +1919,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); @@ -1962,8 +1966,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); @@ -2129,6 +2136,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-6] src/sys/fs/puffs
Module Name:src Committed By: riz Date: Tue Apr 3 15:57:50 UTC 2012 Modified Files: src/sys/fs/puffs [netbsd-6]: puffs_vnops.c Log Message: Pull up following revision(s) (requested by jakllsch in ticket #154): sys/fs/puffs/puffs_vnops.c: revision 1.164 Prevent access beyond end of PUFFS file on read, similar to as is done for NFS. To generate a diff of this commit: cvs rdiff -u -r1.163 -r1.163.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_vnops.c diff -u src/sys/fs/puffs/puffs_vnops.c:1.163 src/sys/fs/puffs/puffs_vnops.c:1.163.2.1 --- src/sys/fs/puffs/puffs_vnops.c:1.163 Tue Jan 17 09:30:16 2012 +++ src/sys/fs/puffs/puffs_vnops.c Tue Apr 3 15:57:50 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_vnops.c,v 1.163 2012/01/17 09:30:16 martin Exp $ */ +/* $NetBSD: puffs_vnops.c,v 1.163.2.1 2012/04/03 15:57:50 riz Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.163 2012/01/17 09:30:16 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.163.2.1 2012/04/03 15:57:50 riz Exp $"); #include #include @@ -1862,6 +1862,9 @@ puffs_vnop_read(void *v) const int advice = IO_ADV_DECODE(ap->a_ioflag); while (uio->uio_resid > 0) { + if (vp->v_size <= uio->uio_offset) { +break; + } bytelen = MIN(uio->uio_resid, vp->v_size - uio->uio_offset); if (bytelen == 0)