Module Name: src Committed By: manu Date: Thu Sep 11 07:59:14 UTC 2014
Modified Files: src/sys/fs/puffs: puffs_vnops.c Log Message: 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.185 -r1.186 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.185 src/sys/fs/puffs/puffs_vnops.c:1.186 --- src/sys/fs/puffs/puffs_vnops.c:1.185 Fri Sep 5 15:39:18 2014 +++ src/sys/fs/puffs/puffs_vnops.c Thu Sep 11 07:59:14 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_vnops.c,v 1.185 2014/09/05 15:39:18 manu Exp $ */ +/* $NetBSD: puffs_vnops.c,v 1.186 2014/09/11 07:59:14 manu 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.185 2014/09/05 15:39:18 manu Exp $"); +__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.186 2014/09/11 07:59:14 manu 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; }