CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: rin Date: Mon Aug 10 11:09:15 UTC 2020 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: Output offsets in hex for UVMHIST. To generate a diff of this commit: cvs rdiff -u -r1.98 -r1.99 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.98 src/sys/miscfs/genfs/genfs_io.c:1.99 --- src/sys/miscfs/genfs/genfs_io.c:1.98 Sun Jun 14 00:25:22 2020 +++ src/sys/miscfs/genfs/genfs_io.c Mon Aug 10 11:09:15 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.98 2020/06/14 00:25:22 ad Exp $ */ +/* $NetBSD: genfs_io.c,v 1.99 2020/08/10 11:09:15 rin Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.98 2020/06/14 00:25:22 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.99 2020/08/10 11:09:15 rin Exp $"); #include #include @@ -320,7 +320,7 @@ startover: (void)memset(pgs, 0, pgs_size); } - UVMHIST_LOG(ubchist, "ridx %jd npages %jd startoff %jd endoff %jd", + UVMHIST_LOG(ubchist, "ridx %jd npages %jd startoff %#jx endoff %#jx", ridx, npages, startoffset, endoffset); if (trans_mount == NULL) {
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: christos Date: Fri Aug 7 18:14:22 UTC 2020 Modified Files: src/sys/miscfs/genfs: genfs.h genfs_vnops.c Log Message: accmode should be accmode_t To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/sys/miscfs/genfs/genfs.h cvs rdiff -u -r1.208 -r1.209 src/sys/miscfs/genfs/genfs_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/miscfs/genfs/genfs.h diff -u src/sys/miscfs/genfs/genfs.h:1.35 src/sys/miscfs/genfs/genfs.h:1.36 --- src/sys/miscfs/genfs/genfs.h:1.35 Sat Jun 27 13:29:19 2020 +++ src/sys/miscfs/genfs/genfs.h Fri Aug 7 14:14:21 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs.h,v 1.35 2020/06/27 17:29:19 christos Exp $ */ +/* $NetBSD: genfs.h,v 1.36 2020/08/07 18:14:21 christos Exp $ */ #ifndef _MISCFS_GENFS_GENFS_H_ #define _MISCFS_GENFS_GENFS_H_ @@ -64,7 +64,7 @@ int genfs_can_chown(struct vnode *, kaut int genfs_can_chtimes(struct vnode *, kauth_cred_t, uid_t, u_int); int genfs_can_chflags(struct vnode *, kauth_cred_t, uid_t, bool); int genfs_can_sticky(struct vnode *, kauth_cred_t, uid_t, uid_t); -int genfs_can_extattr(struct vnode *, kauth_cred_t, int, int); +int genfs_can_extattr(struct vnode *, kauth_cred_t, accmode_t, int); /* * Rename is complicated. Sorry. Index: src/sys/miscfs/genfs/genfs_vnops.c diff -u src/sys/miscfs/genfs/genfs_vnops.c:1.208 src/sys/miscfs/genfs/genfs_vnops.c:1.209 --- src/sys/miscfs/genfs/genfs_vnops.c:1.208 Sat Jun 27 13:29:19 2020 +++ src/sys/miscfs/genfs/genfs_vnops.c Fri Aug 7 14:14:21 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_vnops.c,v 1.208 2020/06/27 17:29:19 christos Exp $ */ +/* $NetBSD: genfs_vnops.c,v 1.209 2020/08/07 18:14:21 christos Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.208 2020/06/27 17:29:19 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.209 2020/08/07 18:14:21 christos Exp $"); #include #include @@ -1397,7 +1397,7 @@ genfs_can_sticky(vnode_t *vp, kauth_cred } int -genfs_can_extattr(vnode_t *vp, kauth_cred_t cred, int accmode, +genfs_can_extattr(vnode_t *vp, kauth_cred_t cred, accmode_t accmode, int attrnamespace) { /*
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: ad Date: Sun Jun 14 00:25:22 UTC 2020 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: genfs_putpages(): when building a cluster make use of pages in the in the existing uvm_page_array. To generate a diff of this commit: cvs rdiff -u -r1.97 -r1.98 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.97 src/sys/miscfs/genfs/genfs_io.c:1.98 --- src/sys/miscfs/genfs/genfs_io.c:1.97 Mon May 25 21:15:10 2020 +++ src/sys/miscfs/genfs/genfs_io.c Sun Jun 14 00:25:22 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.97 2020/05/25 21:15:10 ad Exp $ */ +/* $NetBSD: genfs_io.c,v 1.98 2020/06/14 00:25:22 ad Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.97 2020/05/25 21:15:10 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.98 2020/06/14 00:25:22 ad Exp $"); #include #include @@ -1208,6 +1208,11 @@ retry: * 0 * UVM_PAGE_ARRAY_FILL_DIRTY * UVM_PAGE_ARRAY_FILL_DIRTY|WRITEBACK + * + * XXX this is fragile but it'll work: the array + * was earlier filled sparsely, but UFP_DIRTYONLY + * implies dense. see corresponding comment in + * uvn_findpages(). */ npages = MAXPAGES - nback - 1; @@ -1215,7 +1220,7 @@ retry: npages = MIN(npages, (fshi - off - 1) >> PAGE_SHIFT); uvn_findpages(uobj, off + PAGE_SIZE, , - [nback + 1], NULL, + [nback + 1], , UFP_NOWAIT|UFP_NOALLOC|UFP_DIRTYONLY); npages += nback + 1; } else {
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: christos Date: Wed May 20 17:06:15 UTC 2020 Modified Files: src/sys/miscfs/genfs: genfs_vnops.c Log Message: Fix EPERM vs EACCES on chtimes (thanks @hannken) To generate a diff of this commit: cvs rdiff -u -r1.206 -r1.207 src/sys/miscfs/genfs/genfs_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/miscfs/genfs/genfs_vnops.c diff -u src/sys/miscfs/genfs/genfs_vnops.c:1.206 src/sys/miscfs/genfs/genfs_vnops.c:1.207 --- src/sys/miscfs/genfs/genfs_vnops.c:1.206 Mon May 18 15:55:42 2020 +++ src/sys/miscfs/genfs/genfs_vnops.c Wed May 20 13:06:15 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_vnops.c,v 1.206 2020/05/18 19:55:42 christos Exp $ */ +/* $NetBSD: genfs_vnops.c,v 1.207 2020/05/20 17:06:15 christos Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.206 2020/05/18 19:55:42 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.207 2020/05/20 17:06:15 christos Exp $"); #include #include @@ -1320,7 +1320,7 @@ genfs_can_chtimes(vnode_t *vp, kauth_cre * server time. */ if ((error = VOP_ACCESSX(vp, VWRITE_ATTRIBUTES, cred)) != 0) - return (error); + return (vaflags & VA_UTIMES_NULL) == 0 ? EPERM : EACCES; /* Must be owner, or... */ if (kauth_cred_geteuid(cred) == owner_uid)
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: christos Date: Mon May 18 19:55:42 UTC 2020 Modified Files: src/sys/miscfs/genfs: genfs_vnops.c Log Message: remove debugging, it is just clutter. To generate a diff of this commit: cvs rdiff -u -r1.205 -r1.206 src/sys/miscfs/genfs/genfs_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/miscfs/genfs/genfs_vnops.c diff -u src/sys/miscfs/genfs/genfs_vnops.c:1.205 src/sys/miscfs/genfs/genfs_vnops.c:1.206 --- src/sys/miscfs/genfs/genfs_vnops.c:1.205 Mon May 18 15:42:16 2020 +++ src/sys/miscfs/genfs/genfs_vnops.c Mon May 18 15:55:42 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_vnops.c,v 1.205 2020/05/18 19:42:16 christos Exp $ */ +/* $NetBSD: genfs_vnops.c,v 1.206 2020/05/18 19:55:42 christos Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.205 2020/05/18 19:42:16 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.206 2020/05/18 19:55:42 christos Exp $"); #include #include @@ -695,13 +695,7 @@ genfs_can_access(vnode_t *vp, kauth_cred KASSERT((accmode & ~(VEXEC | VWRITE | VREAD | VADMIN | VAPPEND)) == 0); KASSERT((accmode & VAPPEND) == 0 || (accmode & VWRITE)); -#ifdef ACL_DEBUG - char buf[128]; - snprintb(buf, sizeof(buf), __VNODE_PERM_BITS, accmode); - printf("%s: %s cred_uid=%d cred_gid=%d file_uid=%d file_gid=%d\n", - __func__, buf, kauth_cred_geteuid(cred), kauth_cred_getegid(cred), - file_uid, file_gid); -#endif + /* * Look for a normal, non-privileged way to access the file/directory * as requested. If it exists, go with that. @@ -719,10 +713,6 @@ genfs_can_access(vnode_t *vp, kauth_cred if (file_mode & S_IWUSR) dac_granted |= (VWRITE | VAPPEND); -#ifdef ACL_DEBUG - printf("%s: owner %o %o\n", __func__, - accmode & dac_granted, accmode); -#endif goto privchk; } @@ -739,10 +729,6 @@ genfs_can_access(vnode_t *vp, kauth_cred if (file_mode & S_IWGRP) dac_granted |= (VWRITE | VAPPEND); -#ifdef ACL_DEBUG - printf("%s: group %o %o\n", __func__, - accmode & dac_granted, accmode); -#endif goto privchk; } @@ -754,10 +740,6 @@ genfs_can_access(vnode_t *vp, kauth_cred if (file_mode & S_IWOTH) dac_granted |= (VWRITE | VAPPEND); -#ifdef ACL_DEBUG - printf("%s: others %o %o\n", __func__, - accmode & dac_granted, accmode); -#endif privchk: if ((accmode & dac_granted) == accmode) return 0; @@ -1127,12 +1109,6 @@ genfs_can_access_acl_nfs4(vnode_t *vp, k VREAD_ACL | VWRITE_ACL | VWRITE_OWNER | VSYNCHRONIZE)) == 0); KASSERT((accmode & VAPPEND) == 0 || (accmode & VWRITE)); -#ifdef ACL_DEBUG - char buf[128]; - snprintb(buf, sizeof(buf), __VNODE_PERM_BITS, accmode); - printf("%s: %s file_uid=%d file_gid=%d\n", __func__, buf, file_uid, file_gid); -#endif - if (accmode & VADMIN) must_be_owner = 1;
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: christos Date: Mon May 18 19:42:16 UTC 2020 Modified Files: src/sys/miscfs/genfs: genfs_vnops.c Log Message: Fix EPERM vs EACCES return. To generate a diff of this commit: cvs rdiff -u -r1.204 -r1.205 src/sys/miscfs/genfs/genfs_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/miscfs/genfs/genfs_vnops.c diff -u src/sys/miscfs/genfs/genfs_vnops.c:1.204 src/sys/miscfs/genfs/genfs_vnops.c:1.205 --- src/sys/miscfs/genfs/genfs_vnops.c:1.204 Sat May 16 14:31:51 2020 +++ src/sys/miscfs/genfs/genfs_vnops.c Mon May 18 15:42:16 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_vnops.c,v 1.204 2020/05/16 18:31:51 christos Exp $ */ +/* $NetBSD: genfs_vnops.c,v 1.205 2020/05/18 19:42:16 christos Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.204 2020/05/16 18:31:51 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.205 2020/05/18 19:42:16 christos Exp $"); #include #include @@ -695,7 +695,13 @@ genfs_can_access(vnode_t *vp, kauth_cred KASSERT((accmode & ~(VEXEC | VWRITE | VREAD | VADMIN | VAPPEND)) == 0); KASSERT((accmode & VAPPEND) == 0 || (accmode & VWRITE)); - +#ifdef ACL_DEBUG + char buf[128]; + snprintb(buf, sizeof(buf), __VNODE_PERM_BITS, accmode); + printf("%s: %s cred_uid=%d cred_gid=%d file_uid=%d file_gid=%d\n", + __func__, buf, kauth_cred_geteuid(cred), kauth_cred_getegid(cred), + file_uid, file_gid); +#endif /* * Look for a normal, non-privileged way to access the file/directory * as requested. If it exists, go with that. @@ -713,7 +719,11 @@ genfs_can_access(vnode_t *vp, kauth_cred if (file_mode & S_IWUSR) dac_granted |= (VWRITE | VAPPEND); - return (accmode & dac_granted) == accmode ? 0 : EPERM; +#ifdef ACL_DEBUG + printf("%s: owner %o %o\n", __func__, + accmode & dac_granted, accmode); +#endif + goto privchk; } /* Otherwise, check the groups (first match) */ @@ -729,7 +739,11 @@ genfs_can_access(vnode_t *vp, kauth_cred if (file_mode & S_IWGRP) dac_granted |= (VWRITE | VAPPEND); - return (accmode & dac_granted) == accmode ? 0 : EACCES; +#ifdef ACL_DEBUG + printf("%s: group %o %o\n", __func__, + accmode & dac_granted, accmode); +#endif + goto privchk; } /* Otherwise, check everyone else. */ @@ -739,8 +753,16 @@ genfs_can_access(vnode_t *vp, kauth_cred dac_granted |= VREAD; if (file_mode & S_IWOTH) dac_granted |= (VWRITE | VAPPEND); - return (accmode & dac_granted) == accmode ? 0 : EACCES; - return (0); + +#ifdef ACL_DEBUG + printf("%s: others %o %o\n", __func__, + accmode & dac_granted, accmode); +#endif +privchk: + if ((accmode & dac_granted) == accmode) + return 0; + + return (accmode & VADMIN) ? EPERM : EACCES; } /* @@ -1108,7 +1130,7 @@ genfs_can_access_acl_nfs4(vnode_t *vp, k #ifdef ACL_DEBUG char buf[128]; snprintb(buf, sizeof(buf), __VNODE_PERM_BITS, accmode); - printf("%s: %s uid=%d gid=%d\n", __func__, buf, file_uid, file_gid); + printf("%s: %s file_uid=%d file_gid=%d\n", __func__, buf, file_uid, file_gid); #endif if (accmode & VADMIN)
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: christos Date: Sat Apr 25 22:28:47 UTC 2020 Modified Files: src/sys/miscfs/genfs: genfs_vnops.c Log Message: Allow root to access and modify system space extended attributes. XXX: this routine should not be using the string, but the attribute namespace. I have fixed this in the ACL code. To generate a diff of this commit: cvs rdiff -u -r1.202 -r1.203 src/sys/miscfs/genfs/genfs_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/miscfs/genfs/genfs_vnops.c diff -u src/sys/miscfs/genfs/genfs_vnops.c:1.202 src/sys/miscfs/genfs/genfs_vnops.c:1.203 --- src/sys/miscfs/genfs/genfs_vnops.c:1.202 Sun Feb 23 17:14:04 2020 +++ src/sys/miscfs/genfs/genfs_vnops.c Sat Apr 25 18:28:47 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_vnops.c,v 1.202 2020/02/23 22:14:04 ad Exp $ */ +/* $NetBSD: genfs_vnops.c,v 1.203 2020/04/25 22:28:47 christos Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.202 2020/02/23 22:14:04 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.203 2020/04/25 22:28:47 christos Exp $"); #include #include @@ -904,9 +904,13 @@ int genfs_can_extattr(kauth_cred_t cred, int access_mode, vnode_t *vp, const char *attr) { - /* We can't allow privileged namespaces. */ - if (strncasecmp(attr, "system", 6) == 0) - return EPERM; + /* + * This string comparison is bogus: see xattr_native in vfs_xattr.c; + * it is going to go away soon. + */ + if (strncasecmp(attr, "system.", 7) == 0) + return kauth_authorize_system(cred, KAUTH_SYSTEM_FS_EXTATTR, + 0, vp->v_mount, NULL, NULL); return VOP_ACCESS(vp, access_mode, cred); }
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: ad Date: Sat Mar 14 21:47:41 UTC 2020 Modified Files: src/sys/miscfs/genfs: genfs_node.h Log Message: Update a comment. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/miscfs/genfs/genfs_node.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/genfs/genfs_node.h diff -u src/sys/miscfs/genfs/genfs_node.h:1.23 src/sys/miscfs/genfs/genfs_node.h:1.24 --- src/sys/miscfs/genfs/genfs_node.h:1.23 Wed Jan 15 17:55:44 2020 +++ src/sys/miscfs/genfs/genfs_node.h Sat Mar 14 21:47:41 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_node.h,v 1.23 2020/01/15 17:55:44 ad Exp $ */ +/* $NetBSD: genfs_node.h,v 1.24 2020/03/14 21:47:41 ad Exp $ */ /* * Copyright (c) 2001 Chuck Silvers. @@ -61,7 +61,7 @@ struct genfs_ops { /* * GOP_MARKUPDATE: mark vnode's timestamps for update. * - * => called with v_interlock (and possibly other locks) held. + * => called with vmobjlock (and possibly other locks) held. * => used for accesses via mmap. */
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: ad Date: Sat Mar 14 19:07:22 UTC 2020 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: Unused variable. To generate a diff of this commit: cvs rdiff -u -r1.90 -r1.91 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.90 src/sys/miscfs/genfs/genfs_io.c:1.91 --- src/sys/miscfs/genfs/genfs_io.c:1.90 Sat Mar 14 18:08:39 2020 +++ src/sys/miscfs/genfs/genfs_io.c Sat Mar 14 19:07:22 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.90 2020/03/14 18:08:39 ad Exp $ */ +/* $NetBSD: genfs_io.c,v 1.91 2020/03/14 19:07:22 ad Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.90 2020/03/14 18:08:39 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.91 2020/03/14 19:07:22 ad Exp $"); #include #include @@ -884,7 +884,6 @@ genfs_do_putpages(struct vnode *vp, off_ bool wasclean, needs_clean; bool async = (origflags & PGO_SYNCIO) == 0; bool pagedaemon = curlwp == uvm.pagedaemon_lwp; - struct lwp * const l = curlwp ? curlwp : struct mount *trans_mp; int flags; bool modified; /* if we write out any pages */
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: ad Date: Sat Mar 14 15:34:24 UTC 2020 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: OR into bp->b_cflags; don't overwrite. To generate a diff of this commit: cvs rdiff -u -r1.88 -r1.89 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.88 src/sys/miscfs/genfs/genfs_io.c:1.89 --- src/sys/miscfs/genfs/genfs_io.c:1.88 Thu Feb 27 22:12:54 2020 +++ src/sys/miscfs/genfs/genfs_io.c Sat Mar 14 15:34:24 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.88 2020/02/27 22:12:54 ad Exp $ */ +/* $NetBSD: genfs_io.c,v 1.89 2020/03/14 15:34:24 ad Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.88 2020/02/27 22:12:54 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.89 2020/03/14 15:34:24 ad Exp $"); #include #include @@ -615,7 +615,7 @@ genfs_getpages_read(struct vnode *vp, st mbp->b_bufsize = totalbytes; mbp->b_data = (void *)kva; mbp->b_resid = mbp->b_bcount = bytes; - mbp->b_cflags = BC_BUSY; + mbp->b_cflags |= BC_BUSY; if (async) { mbp->b_flags = B_READ | B_ASYNC; mbp->b_iodone = uvm_aio_aiodone; @@ -1497,7 +1497,7 @@ genfs_do_io(struct vnode *vp, off_t off, mbp->b_bufsize = len; mbp->b_data = (void *)kva; mbp->b_resid = mbp->b_bcount = bytes; - mbp->b_cflags = BC_BUSY | BC_AGE; + mbp->b_cflags |= BC_BUSY | BC_AGE; if (async) { mbp->b_flags = brw | B_ASYNC; mbp->b_iodone = iodone; @@ -1735,7 +1735,7 @@ genfs_compat_gop_write(struct vnode *vp, mutex_exit(vp->v_interlock); bp = getiobuf(vp, true); - bp->b_cflags = BC_BUSY | BC_AGE; + bp->b_cflags |= BC_BUSY | BC_AGE; bp->b_lblkno = offset >> vp->v_mount->mnt_fs_bshift; bp->b_data = (char *)kva; bp->b_bcount = npages << PAGE_SHIFT;
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: ad Date: Mon Feb 24 20:49:51 UTC 2020 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: v_interlock -> vmobjlock To generate a diff of this commit: cvs rdiff -u -r1.86 -r1.87 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.86 src/sys/miscfs/genfs/genfs_io.c:1.87 --- src/sys/miscfs/genfs/genfs_io.c:1.86 Sun Feb 23 15:46:41 2020 +++ src/sys/miscfs/genfs/genfs_io.c Mon Feb 24 20:49:51 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.86 2020/02/23 15:46:41 ad Exp $ */ +/* $NetBSD: genfs_io.c,v 1.87 2020/02/24 20:49:51 ad Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.86 2020/02/23 15:46:41 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.87 2020/02/24 20:49:51 ad Exp $"); #include #include @@ -1916,7 +1916,7 @@ genfs_do_directio(struct vmspace *vs, va spoff = trunc_page(off); epoff = round_page(off + len); - mutex_enter(vp->v_interlock); + rw_enter(vp->v_uobj.vmobjlock, RW_WRITER); error = VOP_PUTPAGES(vp, spoff, epoff, pgoflags); if (error) { return error;
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: ad Date: Mon Dec 16 18:17:32 UTC 2019 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: genfs_do_putpages(): add a missing call to uvm_page_array_advance(). Spotted by the automated test runs and: Reported-by: syzbot+adc1f0ce21bcece53...@syzkaller.appspotmail.com To generate a diff of this commit: cvs rdiff -u -r1.80 -r1.81 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.80 src/sys/miscfs/genfs/genfs_io.c:1.81 --- src/sys/miscfs/genfs/genfs_io.c:1.80 Mon Dec 16 08:50:42 2019 +++ src/sys/miscfs/genfs/genfs_io.c Mon Dec 16 18:17:32 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.80 2019/12/16 08:50:42 ad Exp $ */ +/* $NetBSD: genfs_io.c,v 1.81 2019/12/16 18:17:32 ad Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.80 2019/12/16 08:50:42 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.81 2019/12/16 18:17:32 ad Exp $"); #include #include @@ -978,6 +978,7 @@ retry: if (pg->flags & (PG_RELEASED|PG_PAGEOUT)) { wasclean = false; nextoff = pg->offset + PAGE_SIZE; + uvm_page_array_advance(); continue; }
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: ad Date: Mon Dec 16 08:50:43 UTC 2019 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: Correction to previous for DEBUG case. To generate a diff of this commit: cvs rdiff -u -r1.79 -r1.80 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.79 src/sys/miscfs/genfs/genfs_io.c:1.80 --- src/sys/miscfs/genfs/genfs_io.c:1.79 Sun Dec 15 21:43:42 2019 +++ src/sys/miscfs/genfs/genfs_io.c Mon Dec 16 08:50:42 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.79 2019/12/15 21:43:42 ad Exp $ */ +/* $NetBSD: genfs_io.c,v 1.80 2019/12/16 08:50:42 ad Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.79 2019/12/15 21:43:42 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.80 2019/12/16 08:50:42 ad Exp $"); #include #include @@ -1239,6 +1239,7 @@ retry: if (pg == NULL) { break; } + uvm_page_array_advance(); if ((pg->flags & (PG_FAKE | PG_MARKER)) != 0) { continue; }
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: ad Date: Sun Dec 15 21:43:42 UTC 2019 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: Fix DEBUG build. To generate a diff of this commit: cvs rdiff -u -r1.78 -r1.79 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.78 src/sys/miscfs/genfs/genfs_io.c:1.79 --- src/sys/miscfs/genfs/genfs_io.c:1.78 Sun Dec 15 21:11:34 2019 +++ src/sys/miscfs/genfs/genfs_io.c Sun Dec 15 21:43:42 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.78 2019/12/15 21:11:34 ad Exp $ */ +/* $NetBSD: genfs_io.c,v 1.79 2019/12/15 21:43:42 ad Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.78 2019/12/15 21:11:34 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.79 2019/12/15 21:43:42 ad Exp $"); #include #include @@ -1232,7 +1232,13 @@ retry: if (cleanall && wasclean && gp->g_dirtygen == dirtygen && (vp->v_iflag & VI_ONWORKLST) != 0) { #if defined(DEBUG) - TAILQ_FOREACH(pg, >memq, listq.queue) { + uvm_page_array_init(); + for (nextoff = 0;; nextoff = pg->offset + PAGE_SIZE) { + pg = uvm_page_array_fill_and_peek(, uobj, nextoff, + 0, 0); + if (pg == NULL) { +break; + } if ((pg->flags & (PG_FAKE | PG_MARKER)) != 0) { continue; } @@ -1243,6 +1249,7 @@ retry: printf("%s: %p: modified\n", __func__, pg); } } + uvm_page_array_fini(); #endif /* defined(DEBUG) */ vp->v_iflag &= ~VI_WRMAPDIRTY; if (LIST_FIRST(>v_dirtyblkhd) == NULL)
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: jdolecek Date: Mon Dec 10 21:10:52 UTC 2018 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: assert that WAPBL journal write lock is actually held when called with PGO_JOURNALLOCKED or IO_JOURNALLOCKED suggested by mrg@, thanks To generate a diff of this commit: cvs rdiff -u -r1.73 -r1.74 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.73 src/sys/miscfs/genfs/genfs_io.c:1.74 --- src/sys/miscfs/genfs/genfs_io.c:1.73 Sun Dec 9 20:32:37 2018 +++ src/sys/miscfs/genfs/genfs_io.c Mon Dec 10 21:10:52 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.73 2018/12/09 20:32:37 jdolecek Exp $ */ +/* $NetBSD: genfs_io.c,v 1.74 2018/12/10 21:10:52 jdolecek Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.73 2018/12/09 20:32:37 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.74 2018/12/10 21:10:52 jdolecek Exp $"); #include #include @@ -141,6 +141,11 @@ genfs_getpages(void *v) KASSERT(vp->v_type == VREG || vp->v_type == VDIR || vp->v_type == VLNK || vp->v_type == VBLK); +#ifdef DIAGNOSTIC + if ((flags & PGO_JOURNALLOCKED) && vp->v_mount->mnt_wapbl) +WAPBL_JLOCK_ASSERT(vp->v_mount); +#endif + error = vdead_check(vp, VDEAD_NOWAIT); if (error) { if ((flags & PGO_LOCKED) == 0) @@ -869,6 +874,11 @@ genfs_do_putpages(struct vnode *vp, off_ UVMHIST_LOG(ubchist, "vp %#jx pages %jd off 0x%jx len 0x%jx", (uintptr_t)vp, uobj->uo_npages, startoff, endoff - startoff); +#ifdef DIAGNOSTIC + if ((origflags & PGO_JOURNALLOCKED) && vp->v_mount->mnt_wapbl) +WAPBL_JLOCK_ASSERT(vp->v_mount); +#endif + trans_mp = NULL; holds_wapbl = false; @@ -1714,6 +1724,11 @@ genfs_directio(struct vnode *vp, struct bool need_wapbl = (vp->v_mount && vp->v_mount->mnt_wapbl && (ioflag & IO_JOURNALLOCKED) == 0); +#ifdef DIAGNOSTIC + if ((ioflag & IO_JOURNALLOCKED) && vp->v_mount->mnt_wapbl) +WAPBL_JLOCK_ASSERT(vp->v_mount); +#endif + /* * We only support direct I/O to user space for now. */
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: jdolecek Date: Sun Dec 9 20:32:37 UTC 2018 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: support flag PGO_JOURNALLOCKED also for genfs_getpages() To generate a diff of this commit: cvs rdiff -u -r1.72 -r1.73 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.72 src/sys/miscfs/genfs/genfs_io.c:1.73 --- src/sys/miscfs/genfs/genfs_io.c:1.72 Mon May 28 21:04:38 2018 +++ src/sys/miscfs/genfs/genfs_io.c Sun Dec 9 20:32:37 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.72 2018/05/28 21:04:38 chs Exp $ */ +/* $NetBSD: genfs_io.c,v 1.73 2018/12/09 20:32:37 jdolecek Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.72 2018/05/28 21:04:38 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.73 2018/12/09 20:32:37 jdolecek Exp $"); #include #include @@ -128,6 +128,8 @@ genfs_getpages(void *v) const bool memwrite = (ap->a_access_type & VM_PROT_WRITE) != 0; const bool overwrite = (flags & PGO_OVERWRITE) != 0; const bool blockalloc = memwrite && (flags & PGO_NOBLOCKALLOC) == 0; + const bool need_wapbl = (vp->v_mount->mnt_wapbl && + (flags & PGO_JOURNALLOCKED) == 0); const bool glocked = (flags & PGO_GLOCKHELD) != 0; bool holds_wapbl = false; struct mount *trans_mount = NULL; @@ -313,7 +315,7 @@ startover: * XXX: This assumes that we come here only via * the mmio path */ - if (blockalloc && vp->v_mount->mnt_wapbl) { + if (blockalloc && need_wapbl) { error = WAPBL_BEGIN(trans_mount); if (error) goto out_err_free;
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: christos Date: Sat Jul 1 20:07:00 UTC 2017 Modified Files: src/sys/miscfs/genfs: genfs_vnops.c Log Message: Provide EVFILT_WRITE; this is what FreeBSD does and go wants it. Makes go unit tests pass. To generate a diff of this commit: cvs rdiff -u -r1.197 -r1.198 src/sys/miscfs/genfs/genfs_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/miscfs/genfs/genfs_vnops.c diff -u src/sys/miscfs/genfs/genfs_vnops.c:1.197 src/sys/miscfs/genfs/genfs_vnops.c:1.198 --- src/sys/miscfs/genfs/genfs_vnops.c:1.197 Sun Jun 4 04:02:26 2017 +++ src/sys/miscfs/genfs/genfs_vnops.c Sat Jul 1 16:07:00 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_vnops.c,v 1.197 2017/06/04 08:02:26 hannken Exp $ */ +/* $NetBSD: genfs_vnops.c,v 1.198 2017/07/01 20:07:00 christos Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.197 2017/06/04 08:02:26 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.198 2017/07/01 20:07:00 christos Exp $"); #include #include @@ -500,6 +500,32 @@ filt_genfsread(struct knote *kn, long hi } static int +filt_genfswrite(struct knote *kn, long hint) +{ + struct vnode *vp = (struct vnode *)kn->kn_hook; + + /* + * filesystem is gone, so set the EOF flag and schedule + * the knote for deletion. + */ + switch (hint) { + case NOTE_REVOKE: + KASSERT(mutex_owned(vp->v_interlock)); + kn->kn_flags |= (EV_EOF | EV_ONESHOT); + return (1); + case 0: + mutex_enter(vp->v_interlock); + kn->kn_data = 0; + mutex_exit(vp->v_interlock); + return 1; + default: + KASSERT(mutex_owned(vp->v_interlock)); + kn->kn_data = 0; + return 1; + } +} + +static int filt_genfsvnode(struct knote *kn, long hint) { struct vnode *vp = (struct vnode *)kn->kn_hook; @@ -530,6 +556,8 @@ filt_genfsvnode(struct knote *kn, long h static const struct filterops genfsread_filtops = { 1, NULL, filt_genfsdetach, filt_genfsread }; +static const struct filterops genfswrite_filtops = + { 1, NULL, filt_genfsdetach, filt_genfswrite }; static const struct filterops genfsvnode_filtops = { 1, NULL, filt_genfsdetach, filt_genfsvnode }; @@ -549,6 +577,9 @@ genfs_kqfilter(void *v) case EVFILT_READ: kn->kn_fop = _filtops; break; + case EVFILT_WRITE: + kn->kn_fop = _filtops; + break; case EVFILT_VNODE: kn->kn_fop = _filtops; break;
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: hannken Date: Tue Jun 27 08:40:53 UTC 2017 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: Add missing check for dead or dying vnode to the entry of genfs_getpages(). To generate a diff of this commit: cvs rdiff -u -r1.69 -r1.70 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.69 src/sys/miscfs/genfs/genfs_io.c:1.70 --- src/sys/miscfs/genfs/genfs_io.c:1.69 Sun Jun 4 08:05:42 2017 +++ src/sys/miscfs/genfs/genfs_io.c Tue Jun 27 08:40:53 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.69 2017/06/04 08:05:42 hannken Exp $ */ +/* $NetBSD: genfs_io.c,v 1.70 2017/06/27 08:40:53 hannken Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.69 2017/06/04 08:05:42 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.70 2017/06/27 08:40:53 hannken Exp $"); #include #include @@ -139,6 +139,13 @@ genfs_getpages(void *v) KASSERT(vp->v_type == VREG || vp->v_type == VDIR || vp->v_type == VLNK || vp->v_type == VBLK); + error = vdead_check(vp, VDEAD_NOWAIT); + if (error) { + if ((flags & PGO_LOCKED) == 0) + mutex_exit(uobj->vmobjlock); + return error; + } + startover: error = 0; const voff_t origvsize = vp->v_size;
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: hannken Date: Sun Jun 4 08:01:33 UTC 2017 Modified Files: src/sys/miscfs/genfs: genfs_vnops.c Log Message: Now that FSTRANS is part of VOP_*LOCK() remove FSTRANS and vdead_check() from genfs_.*lock() and assert the vnode state once the vnode is locked. To generate a diff of this commit: cvs rdiff -u -r1.195 -r1.196 src/sys/miscfs/genfs/genfs_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/miscfs/genfs/genfs_vnops.c diff -u src/sys/miscfs/genfs/genfs_vnops.c:1.195 src/sys/miscfs/genfs/genfs_vnops.c:1.196 --- src/sys/miscfs/genfs/genfs_vnops.c:1.195 Tue Apr 11 14:29:32 2017 +++ src/sys/miscfs/genfs/genfs_vnops.c Sun Jun 4 08:01:33 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_vnops.c,v 1.195 2017/04/11 14:29:32 riastradh Exp $ */ +/* $NetBSD: genfs_vnops.c,v 1.196 2017/06/04 08:01:33 hannken Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.195 2017/04/11 14:29:32 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.196 2017/06/04 08:01:33 hannken Exp $"); #include #include @@ -288,41 +288,18 @@ genfs_deadlock(void *v) vnode_impl_t *vip = VNODE_TO_VIMPL(vp); int flags = ap->a_flags; krw_t op; - int error; + + if (! ISSET(flags, LK_RETRY)) + return ENOENT; op = (ISSET(flags, LK_EXCLUSIVE) ? RW_WRITER : RW_READER); if (ISSET(flags, LK_NOWAIT)) { if (! rw_tryenter(vip->vi_lock, op)) return EBUSY; - if (mutex_tryenter(vp->v_interlock)) { - error = vdead_check(vp, VDEAD_NOWAIT); - if (error == ENOENT && ISSET(flags, LK_RETRY)) -error = 0; - mutex_exit(vp->v_interlock); - } else - error = EBUSY; - if (error) - rw_exit(vip->vi_lock); - return error; - } - - rw_enter(vip->vi_lock, op); - mutex_enter(vp->v_interlock); - error = vdead_check(vp, VDEAD_NOWAIT); - if (error == EBUSY) { - rw_exit(vip->vi_lock); - error = vdead_check(vp, 0); - KASSERT(error == ENOENT); - mutex_exit(vp->v_interlock); + } else { rw_enter(vip->vi_lock, op); - mutex_enter(vp->v_interlock); - } - KASSERT(error == ENOENT); - mutex_exit(vp->v_interlock); - if (! ISSET(flags, LK_RETRY)) { - rw_exit(vip->vi_lock); - return ENOENT; } + VSTATE_ASSERT_UNLOCKED(vp, VS_RECLAIMED); return 0; } @@ -355,43 +332,18 @@ genfs_lock(void *v) } */ *ap = v; vnode_t *vp = ap->a_vp; vnode_impl_t *vip = VNODE_TO_VIMPL(vp); - struct mount *mp = vp->v_mount; int flags = ap->a_flags; krw_t op; - int error; op = (ISSET(flags, LK_EXCLUSIVE) ? RW_WRITER : RW_READER); if (ISSET(flags, LK_NOWAIT)) { - if (fstrans_start_nowait(mp, FSTRANS_SHARED)) - return EBUSY; - if (! rw_tryenter(vip->vi_lock, op)) { - fstrans_done(mp); + if (! rw_tryenter(vip->vi_lock, op)) return EBUSY; - } - if (mutex_tryenter(vp->v_interlock)) { - error = vdead_check(vp, VDEAD_NOWAIT); - mutex_exit(vp->v_interlock); - } else - error = EBUSY; - if (error) { - rw_exit(vip->vi_lock); - fstrans_done(mp); - } - return error; - } - - fstrans_start(mp, FSTRANS_SHARED); - rw_enter(vip->vi_lock, op); - mutex_enter(vp->v_interlock); - error = vdead_check(vp, VDEAD_NOWAIT); - if (error) { - rw_exit(vip->vi_lock); - fstrans_done(mp); - error = vdead_check(vp, 0); - KASSERT(error == ENOENT); + } else { + rw_enter(vip->vi_lock, op); } - mutex_exit(vp->v_interlock); - return error; + VSTATE_ASSERT_UNLOCKED(vp, VS_ACTIVE); + return 0; } /* @@ -405,10 +357,8 @@ genfs_unlock(void *v) } */ *ap = v; vnode_t *vp = ap->a_vp; vnode_impl_t *vip = VNODE_TO_VIMPL(vp); - struct mount *mp = vp->v_mount; rw_exit(vip->vi_lock); - fstrans_done(mp); return 0; }
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: hannken Date: Wed May 24 09:54:40 UTC 2017 Modified Files: src/sys/miscfs/genfs: layer_vnops.c Log Message: Protect layer_getpages against vnodes disappearing during a forced unmount. To generate a diff of this commit: cvs rdiff -u -r1.64 -r1.65 src/sys/miscfs/genfs/layer_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/miscfs/genfs/layer_vnops.c diff -u src/sys/miscfs/genfs/layer_vnops.c:1.64 src/sys/miscfs/genfs/layer_vnops.c:1.65 --- src/sys/miscfs/genfs/layer_vnops.c:1.64 Sun May 7 08:21:57 2017 +++ src/sys/miscfs/genfs/layer_vnops.c Wed May 24 09:54:40 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: layer_vnops.c,v 1.64 2017/05/07 08:21:57 hannken Exp $ */ +/* $NetBSD: layer_vnops.c,v 1.65 2017/05/24 09:54:40 hannken Exp $ */ /* * Copyright (c) 1999 National Aeronautics & Space Administration @@ -170,7 +170,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: layer_vnops.c,v 1.64 2017/05/07 08:21:57 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: layer_vnops.c,v 1.65 2017/05/24 09:54:40 hannken Exp $"); #include #include @@ -183,6 +183,7 @@ __KERNEL_RCSID(0, "$NetBSD: layer_vnops. #include #include #include +#include #include #include @@ -790,6 +791,8 @@ layer_getpages(void *v) int a_flags; } */ *ap = v; struct vnode *vp = ap->a_vp; + struct mount *mp = vp->v_mount; + int error; KASSERT(mutex_owned(vp->v_interlock)); @@ -800,7 +803,19 @@ layer_getpages(void *v) KASSERT(vp->v_interlock == ap->a_vp->v_interlock); /* Just pass the request on to the underlying layer. */ - return VCALL(ap->a_vp, VOFFSET(vop_getpages), ap); + mutex_exit(vp->v_interlock); + fstrans_start(mp, FSTRANS_SHARED); + mutex_enter(vp->v_interlock); + if (mp == vp->v_mount) { + /* Will release the interlock. */ + error = VCALL(ap->a_vp, VOFFSET(vop_getpages), ap); + } else { + mutex_exit(vp->v_interlock); + error = ENOENT; + } + fstrans_done(mp); + + return error; } int
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: hannken Date: Sun May 7 08:21:57 UTC 2017 Modified Files: src/sys/miscfs/genfs: layer_vnops.c Log Message: Move v_writecount adjustment from revoke to reclaim. To generate a diff of this commit: cvs rdiff -u -r1.63 -r1.64 src/sys/miscfs/genfs/layer_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/miscfs/genfs/layer_vnops.c diff -u src/sys/miscfs/genfs/layer_vnops.c:1.63 src/sys/miscfs/genfs/layer_vnops.c:1.64 --- src/sys/miscfs/genfs/layer_vnops.c:1.63 Wed Apr 26 03:02:49 2017 +++ src/sys/miscfs/genfs/layer_vnops.c Sun May 7 08:21:57 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: layer_vnops.c,v 1.63 2017/04/26 03:02:49 riastradh Exp $ */ +/* $NetBSD: layer_vnops.c,v 1.64 2017/05/07 08:21:57 hannken Exp $ */ /* * Copyright (c) 1999 National Aeronautics & Space Administration @@ -170,7 +170,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: layer_vnops.c,v 1.63 2017/04/26 03:02:49 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: layer_vnops.c,v 1.64 2017/05/07 08:21:57 hannken Exp $"); #include #include @@ -693,15 +693,8 @@ layer_revoke(void *v) * We will most likely end up in vclean which uses the v_usecount * to determine if a vnode is active. Take an extra reference on * the lower vnode so it will always close and inactivate. - * Remove our writecount from the lower vnode. */ vref(lvp); - - mutex_enter(vp->v_interlock); - KASSERT(vp->v_interlock == lvp->v_interlock); - lvp->v_writecount -= vp->v_writecount; - mutex_exit(vp->v_interlock); - error = LAYERFS_DO_BYPASS(vp, ap); vrele(lvp); @@ -734,6 +727,12 @@ layer_reclaim(void *v) */ lmp->layerm_rootvp = NULL; } + + mutex_enter(vp->v_interlock); + KASSERT(vp->v_interlock == lowervp->v_interlock); + lowervp->v_writecount -= vp->v_writecount; + mutex_exit(vp->v_interlock); + /* After this assignment, this node will not be re-used. */ xp->layer_lowervp = NULL; kmem_free(vp->v_data, lmp->layerm_size);
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: dholland Date: Sat Apr 1 23:34:17 UTC 2017 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: Clarify meaning of "glocked" argument of genfs_putpages_read. To generate a diff of this commit: cvs rdiff -u -r1.67 -r1.68 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.67 src/sys/miscfs/genfs/genfs_io.c:1.68 --- src/sys/miscfs/genfs/genfs_io.c:1.67 Sat Apr 1 19:57:54 2017 +++ src/sys/miscfs/genfs/genfs_io.c Sat Apr 1 23:34:17 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.67 2017/04/01 19:57:54 riastradh Exp $ */ +/* $NetBSD: genfs_io.c,v 1.68 2017/04/01 23:34:17 dholland Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.67 2017/04/01 19:57:54 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.68 2017/04/01 23:34:17 dholland Exp $"); #include #include @@ -508,6 +508,10 @@ out_err: /* * genfs_getpages_read: Read the pages in with VOP_BMAP/VOP_STRATEGY. + * + * "glocked" (which is currently not actually used) tells us not whether + * the genfs_node is locked on entry (it always is) but whether it was + * locked on entry to genfs_getpages. */ static int genfs_getpages_read(struct vnode *vp, struct vm_page **pgs, int npages,
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: riastradh Date: Sat Apr 1 19:57:54 UTC 2017 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: Simplify genfs_getpages_read async/unlock protocol. Previously the caller unlocked for error or sync I/O, whereas genfs_getpages_read unlocked on successful async. Now caller unlocks in every case, and genfs_getpages_read doesn't touch the lock. To generate a diff of this commit: cvs rdiff -u -r1.66 -r1.67 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.66 src/sys/miscfs/genfs/genfs_io.c:1.67 --- src/sys/miscfs/genfs/genfs_io.c:1.66 Thu Mar 30 09:12:21 2017 +++ src/sys/miscfs/genfs/genfs_io.c Sat Apr 1 19:57:54 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.66 2017/03/30 09:12:21 hannken Exp $ */ +/* $NetBSD: genfs_io.c,v 1.67 2017/04/01 19:57:54 riastradh Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.66 2017/03/30 09:12:21 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.67 2017/04/01 19:57:54 riastradh Exp $"); #include #include @@ -428,11 +428,11 @@ startover: mutex_exit(uobj->vmobjlock); error = genfs_getpages_read(vp, pgs, npages, startoffset, diskeof, async, memwrite, blockalloc, glocked); - if (error == 0 && async) - goto out_err_free; if (!glocked) { genfs_node_unlock(vp); } + if (error == 0 && async) + goto out_err_free; mutex_enter(uobj->vmobjlock); /* @@ -714,9 +714,6 @@ loopdone: nestiobuf_done(mbp, skipbytes, error); if (async) { UVMHIST_LOG(ubchist, "returning 0 (async)",0,0,0,0); - if (!glocked) { - genfs_node_unlock(vp); - } return 0; } if (bp != NULL) {
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: hannken Date: Thu Mar 30 09:11:12 UTC 2017 Modified Files: src/sys/miscfs/genfs: genfs_rename.c Log Message: Remove now redundant calls to fstrans_start()/fstrans_done(). To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/miscfs/genfs/genfs_rename.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/miscfs/genfs/genfs_rename.c diff -u src/sys/miscfs/genfs/genfs_rename.c:1.2 src/sys/miscfs/genfs/genfs_rename.c:1.3 --- src/sys/miscfs/genfs/genfs_rename.c:1.2 Thu Feb 6 10:57:12 2014 +++ src/sys/miscfs/genfs/genfs_rename.c Thu Mar 30 09:11:12 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_rename.c,v 1.2 2014/02/06 10:57:12 hannken Exp $ */ +/* $NetBSD: genfs_rename.c,v 1.3 2017/03/30 09:11:12 hannken Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_rename.c,v 1.2 2014/02/06 10:57:12 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_rename.c,v 1.3 2017/03/30 09:11:12 hannken Exp $"); #include #include @@ -45,7 +45,6 @@ __KERNEL_RCSID(0, "$NetBSD: genfs_rename #include #include #include -#include #include #include @@ -177,7 +176,6 @@ genfs_insane_rename(void *v, struct componentname *fcnp = ap->a_fcnp; struct vnode *tdvp = ap->a_tdvp; struct vnode *tvp = ap->a_tvp; - struct mount *mp = fdvp->v_mount; struct componentname *tcnp = ap->a_tcnp; kauth_cred_t cred; int error; @@ -196,8 +194,6 @@ genfs_insane_rename(void *v, KASSERT(fdvp->v_type == VDIR); KASSERT(tdvp->v_type == VDIR); - fstrans_start(mp, FSTRANS_SHARED); - cred = fcnp->cn_cred; /* @@ -232,8 +228,6 @@ genfs_insane_rename(void *v, vrele(fdvp); vrele(tdvp); - fstrans_done(mp); - return error; }
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: hannken Date: Thu Mar 9 10:10:02 UTC 2017 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: Protect genfs_do_putpages() against vnodes disappearing during a forced mount update from read-write to read-only. To generate a diff of this commit: cvs rdiff -u -r1.64 -r1.65 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.64 src/sys/miscfs/genfs/genfs_io.c:1.65 --- src/sys/miscfs/genfs/genfs_io.c:1.64 Wed Mar 1 10:47:26 2017 +++ src/sys/miscfs/genfs/genfs_io.c Thu Mar 9 10:10:02 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.64 2017/03/01 10:47:26 hannken Exp $ */ +/* $NetBSD: genfs_io.c,v 1.65 2017/03/09 10:10:02 hannken Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.64 2017/03/01 10:47:26 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.65 2017/03/09 10:10:02 hannken Exp $"); #include #include @@ -842,11 +842,11 @@ genfs_do_putpages(struct vnode *vp, off_ bool pagedaemon = curlwp == uvm.pagedaemon_lwp; struct lwp * const l = curlwp ? curlwp : struct genfs_node * const gp = VTOG(vp); + struct mount *trans_mp; int flags; int dirtygen; bool modified; - bool need_wapbl; - bool has_trans; + bool holds_wapbl; bool cleanall; bool onworklst; @@ -859,9 +859,8 @@ genfs_do_putpages(struct vnode *vp, off_ UVMHIST_LOG(ubchist, "vp %p pages %d off 0x%x len 0x%x", vp, uobj->uo_npages, startoff, endoff - startoff); - has_trans = false; - need_wapbl = (!pagedaemon && vp->v_mount && vp->v_mount->mnt_wapbl && - (origflags & PGO_JOURNALLOCKED) == 0); + trans_mp = NULL; + holds_wapbl = false; retry: modified = false; @@ -874,10 +873,10 @@ retry: if (LIST_FIRST(>v_dirtyblkhd) == NULL) vn_syncer_remove_from_worklist(vp); } - if (has_trans) { - if (need_wapbl) -WAPBL_END(vp->v_mount); - fstrans_done(vp->v_mount); + if (trans_mp) { + if (holds_wapbl) +WAPBL_END(trans_mp); + fstrans_done(trans_mp); } mutex_exit(slock); return (0); @@ -887,24 +886,41 @@ retry: * the vnode has pages, set up to process the request. */ - if (!has_trans && (flags & PGO_CLEANIT) != 0) { - mutex_exit(slock); + if (trans_mp == NULL && (flags & PGO_CLEANIT) != 0) { if (pagedaemon) { - error = fstrans_start_nowait(vp->v_mount, FSTRANS_LAZY); - if (error) -return error; - } else - fstrans_start(vp->v_mount, FSTRANS_LAZY); - if (need_wapbl) { - error = WAPBL_BEGIN(vp->v_mount); + /* Pagedaemon must not sleep here. */ + trans_mp = vp->v_mount; + error = fstrans_start_nowait(trans_mp, FSTRANS_LAZY); if (error) { -fstrans_done(vp->v_mount); +mutex_exit(slock); return error; } + } else { + /* + * Cannot use vdeadcheck() here as this operation + * usually gets used from VOP_RECLAIM(). Test for + * change of v_mount instead and retry on change. + */ + mutex_exit(slock); + trans_mp = vp->v_mount; + fstrans_start(trans_mp, FSTRANS_LAZY); + if (vp->v_mount != trans_mp) { +fstrans_done(trans_mp); +trans_mp = NULL; + } else { +holds_wapbl = (trans_mp->mnt_wapbl && +(origflags & PGO_JOURNALLOCKED) == 0); +if (holds_wapbl) { + error = WAPBL_BEGIN(trans_mp); + if (error) { + fstrans_done(trans_mp); + return error; + } +} + } + mutex_enter(slock); + goto retry; } - has_trans = true; - mutex_enter(slock); - goto retry; } error = 0; @@ -1277,10 +1293,10 @@ skip_scan: goto retry; } - if (has_trans) { - if (need_wapbl) - WAPBL_END(vp->v_mount); - fstrans_done(vp->v_mount); + if (trans_mp) { + if (holds_wapbl) + WAPBL_END(trans_mp); + fstrans_done(trans_mp); } return (error);
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: hannken Date: Wed Mar 1 10:47:26 UTC 2017 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: Protect genfs_getpages() against vnodes disappearing during a forced mount update from read-write to read-only. To generate a diff of this commit: cvs rdiff -u -r1.63 -r1.64 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.63 src/sys/miscfs/genfs/genfs_io.c:1.64 --- src/sys/miscfs/genfs/genfs_io.c:1.63 Thu Sep 29 19:08:48 2016 +++ src/sys/miscfs/genfs/genfs_io.c Wed Mar 1 10:47:26 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.63 2016/09/29 19:08:48 christos Exp $ */ +/* $NetBSD: genfs_io.c,v 1.64 2017/03/01 10:47:26 hannken Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.63 2016/09/29 19:08:48 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.64 2017/03/01 10:47:26 hannken Exp $"); #include #include @@ -129,8 +129,8 @@ genfs_getpages(void *v) const bool overwrite = (flags & PGO_OVERWRITE) != 0; const bool blockalloc = memwrite && (flags & PGO_NOBLOCKALLOC) == 0; const bool glocked = (flags & PGO_GLOCKHELD) != 0; - const bool need_wapbl = blockalloc && vp->v_mount->mnt_wapbl; - bool has_trans_wapbl = false; + bool holds_wapbl = false; + struct mount *trans_mount = NULL; UVMHIST_FUNC("genfs_getpages"); UVMHIST_CALLED(ubchist); UVMHIST_LOG(ubchist, "vp %p off 0x%x/%x count %d", @@ -291,20 +291,27 @@ startover: UVMHIST_LOG(ubchist, "ridx %d npages %d startoff %ld endoff %ld", ridx, npages, startoffset, endoffset); - if (!has_trans_wapbl) { - fstrans_start(vp->v_mount, FSTRANS_SHARED); + if (trans_mount == NULL) { + trans_mount = vp->v_mount; + fstrans_start(trans_mount, FSTRANS_SHARED); + /* + * check if this vnode is still valid. + */ + mutex_enter(vp->v_interlock); + error = vdead_check(vp, 0); + mutex_exit(vp->v_interlock); + if (error) + goto out_err_free; /* * XXX: This assumes that we come here only via * the mmio path */ - if (need_wapbl) { - error = WAPBL_BEGIN(vp->v_mount); - if (error) { -fstrans_done(vp->v_mount); + if (blockalloc && vp->v_mount->mnt_wapbl) { + error = WAPBL_BEGIN(trans_mount); + if (error) goto out_err_free; - } + holds_wapbl = true; } - has_trans_wapbl = true; } /* @@ -491,10 +498,10 @@ out_err_free: if (pgs != NULL && pgs != pgs_onstack) kmem_free(pgs, pgs_size); out_err: - if (has_trans_wapbl) { - if (need_wapbl) - WAPBL_END(vp->v_mount); - fstrans_done(vp->v_mount); + if (trans_mount != NULL) { + if (holds_wapbl) + WAPBL_END(trans_mount); + fstrans_done(trans_mount); } return error; }
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: skrll Date: Sun Apr 12 14:44:06 UTC 2015 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: Fix UVMHIST build. To generate a diff of this commit: cvs rdiff -u -r1.59 -r1.60 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.59 src/sys/miscfs/genfs/genfs_io.c:1.60 --- src/sys/miscfs/genfs/genfs_io.c:1.59 Fri Apr 10 13:02:15 2015 +++ src/sys/miscfs/genfs/genfs_io.c Sun Apr 12 14:44:06 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.59 2015/04/10 13:02:15 riastradh Exp $ */ +/* $NetBSD: genfs_io.c,v 1.60 2015/04/12 14:44:06 skrll Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.59 2015/04/10 13:02:15 riastradh Exp $); +__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.60 2015/04/12 14:44:06 skrll Exp $); #include sys/param.h #include sys/systm.h @@ -521,6 +521,8 @@ genfs_getpages_read(struct vnode *vp, st int i; int error = 0; + UVMHIST_FUNC(__func__); UVMHIST_CALLED(ubchist); + /* * read the desired page(s). */
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: hannken Date: Wed May 28 10:51:20 UTC 2014 Modified Files: src/sys/miscfs/genfs: layer.h Log Message: Change field layerm_tag to correct type enum vtagtype. CID 1216449: Mixing enum types To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/miscfs/genfs/layer.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/genfs/layer.h diff -u src/sys/miscfs/genfs/layer.h:1.15 src/sys/miscfs/genfs/layer.h:1.16 --- src/sys/miscfs/genfs/layer.h:1.15 Sun May 25 13:51:25 2014 +++ src/sys/miscfs/genfs/layer.h Wed May 28 10:51:20 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: layer.h,v 1.15 2014/05/25 13:51:25 hannken Exp $ */ +/* $NetBSD: layer.h,v 1.16 2014/05/28 10:51:20 hannken Exp $ */ /* * Copyright (c) 1999 National Aeronautics Space Administration @@ -83,7 +83,7 @@ struct layer_mount { struct vnode *layerm_rootvp; /* Ref to root layer_node */ u_int layerm_flags; /* mount point layer flags */ u_int layerm_size; /* size of fs's struct node */ - enum vtype layerm_tag; /* vtag of our vnodes */ + enum vtagtype layerm_tag; /* vtag of our vnodes */ int/* bypass routine for this mount */ (*layerm_bypass)(void *); int (**layerm_vnodeop_p) /* ops for our nodes */
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: hannken Date: Wed Mar 12 09:38:51 UTC 2014 Modified Files: src/sys/miscfs/genfs: genfs_vnops.c Log Message: Restructure genfs_deadlock() and genfs_lock() to always lock before testing for dead node. Use ISSET() to test flags, add assertions. Save the mount for fstrans_done() before genfs_unlock() unlocks the node. To generate a diff of this commit: cvs rdiff -u -r1.190 -r1.191 src/sys/miscfs/genfs/genfs_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/miscfs/genfs/genfs_vnops.c diff -u src/sys/miscfs/genfs/genfs_vnops.c:1.190 src/sys/miscfs/genfs/genfs_vnops.c:1.191 --- src/sys/miscfs/genfs/genfs_vnops.c:1.190 Thu Feb 27 16:51:38 2014 +++ src/sys/miscfs/genfs/genfs_vnops.c Wed Mar 12 09:38:51 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_vnops.c,v 1.190 2014/02/27 16:51:38 hannken Exp $ */ +/* $NetBSD: genfs_vnops.c,v 1.191 2014/03/12 09:38:51 hannken Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: genfs_vnops.c,v 1.190 2014/02/27 16:51:38 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: genfs_vnops.c,v 1.191 2014/03/12 09:38:51 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -290,33 +290,42 @@ genfs_deadlock(void *v) struct vnode *vp = ap-a_vp; int flags = ap-a_flags; krw_t op; + int error; - if ((flags LK_NOWAIT) != 0) { - if (!mutex_tryenter(vp-v_interlock)) + op = (ISSET(flags, LK_EXCLUSIVE) ? RW_WRITER : RW_READER); + if (ISSET(flags, LK_NOWAIT)) { + if (! rw_tryenter(vp-v_lock, op)) return EBUSY; - if ((vp-v_iflag VI_XLOCK)) { + if (mutex_tryenter(vp-v_interlock)) { + if (ISSET(vp-v_iflag, VI_XLOCK)) +error = EBUSY; + else { +KASSERT(ISSET(vp-v_iflag, VI_CLEAN)); +error = (ISSET(flags, LK_RETRY) ? 0 : ENOENT); + } mutex_exit(vp-v_interlock); - return EBUSY; - } + } else + error = EBUSY; + if (error) + rw_exit(vp-v_lock); + return error; } + rw_enter(vp-v_lock, op); mutex_enter(vp-v_interlock); - if ((vp-v_iflag VI_XLOCK)) + if (ISSET(vp-v_iflag, VI_XLOCK)) { + rw_exit(vp-v_lock); vwait(vp, VI_XLOCK); + mutex_exit(vp-v_interlock); + rw_enter(vp-v_lock, op); + mutex_enter(vp-v_interlock); + } + KASSERT(ISSET(vp-v_iflag, VI_CLEAN)); mutex_exit(vp-v_interlock); - - if ((flags LK_RETRY) == 0) + if (! ISSET(flags, LK_RETRY)) { + rw_exit(vp-v_lock); return ENOENT; - - op = ((flags LK_EXCLUSIVE) != 0 ? RW_WRITER : RW_READER); - if ((flags LK_NOWAIT) != 0) { - if (! rw_tryenter(vp-v_lock, op)) - return EBUSY; - return 0; } - - rw_enter(vp-v_lock, op); - return 0; } @@ -350,39 +359,45 @@ genfs_lock(void *v) struct mount *mp = vp-v_mount; int flags = ap-a_flags; krw_t op; + int error; - op = ((flags LK_EXCLUSIVE) != 0 ? RW_WRITER : RW_READER); - if ((flags LK_NOWAIT) != 0) { - if (!mutex_tryenter(vp-v_interlock)) - return EBUSY; - if ((vp-v_iflag (VI_XLOCK | VI_CLEAN)) != 0) { - mutex_exit(vp-v_interlock); - return EBUSY; - } - mutex_exit(vp-v_interlock); + op = (ISSET(flags, LK_EXCLUSIVE) ? RW_WRITER : RW_READER); + if (ISSET(flags, LK_NOWAIT)) { if (fstrans_start_nowait(mp, FSTRANS_SHARED)) return EBUSY; if (! rw_tryenter(vp-v_lock, op)) { fstrans_done(mp); return EBUSY; } - return 0; + if (mutex_tryenter(vp-v_interlock)) { + if (ISSET(vp-v_iflag, VI_XLOCK)) +error = EBUSY; + else if (ISSET(vp-v_iflag, VI_CLEAN)) +error = ENOENT; + else +error = 0; + mutex_exit(vp-v_interlock); + } else + error = EBUSY; + if (error) { + rw_exit(vp-v_lock); + fstrans_done(mp); + } + return error; } fstrans_start(mp, FSTRANS_SHARED); rw_enter(vp-v_lock, op); - mutex_enter(vp-v_interlock); - if ((vp-v_iflag (VI_XLOCK | VI_CLEAN)) != 0) { + if (ISSET(vp-v_iflag, VI_XLOCK) || ISSET(vp-v_iflag, VI_CLEAN)) { rw_exit(vp-v_lock); fstrans_done(mp); - if ((vp-v_iflag VI_XLOCK)) - vwait(vp, VI_XLOCK); + vwait(vp, VI_XLOCK); + KASSERT(ISSET(vp-v_iflag, VI_CLEAN)); mutex_exit(vp-v_interlock); return ENOENT; } mutex_exit(vp-v_interlock); - return 0; } @@ -396,9 +411,10 @@ genfs_unlock(void *v) struct vnode *a_vp; } */ *ap = v; struct vnode *vp = ap-a_vp; + struct mount *mp = vp-v_mount; rw_exit(vp-v_lock); - fstrans_done(vp-v_mount); + fstrans_done(mp); return 0; }
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: hannken Date: Wed Mar 12 09:39:23 UTC 2014 Modified Files: src/sys/miscfs/genfs: layer_vnops.c Log Message: Restructure layer_lock() to always lock before testing for dead node. Use ISSET() to test flags, add assertions. To generate a diff of this commit: cvs rdiff -u -r1.55 -r1.56 src/sys/miscfs/genfs/layer_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/miscfs/genfs/layer_vnops.c diff -u src/sys/miscfs/genfs/layer_vnops.c:1.55 src/sys/miscfs/genfs/layer_vnops.c:1.56 --- src/sys/miscfs/genfs/layer_vnops.c:1.55 Thu Feb 27 16:51:38 2014 +++ src/sys/miscfs/genfs/layer_vnops.c Wed Mar 12 09:39:23 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: layer_vnops.c,v 1.55 2014/02/27 16:51:38 hannken Exp $ */ +/* $NetBSD: layer_vnops.c,v 1.56 2014/03/12 09:39:23 hannken Exp $ */ /* * Copyright (c) 1999 National Aeronautics Space Administration @@ -170,7 +170,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: layer_vnops.c,v 1.55 2014/02/27 16:51:38 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: layer_vnops.c,v 1.56 2014/03/12 09:39:23 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -718,15 +718,23 @@ layer_lock(void *v) int flags = ap-a_flags; int error; - if ((flags LK_NOWAIT) != 0) { - if (!mutex_tryenter(vp-v_interlock)) - return EBUSY; - if ((vp-v_iflag (VI_XLOCK | VI_CLEAN)) != 0) { + if (ISSET(flags, LK_NOWAIT)) { + error = VOP_LOCK(lowervp, flags); + if (error) + return error; + if (mutex_tryenter(vp-v_interlock)) { + if (ISSET(vp-v_iflag, VI_XLOCK)) +error = EBUSY; + else if (ISSET(vp-v_iflag, VI_CLEAN)) +error = ENOENT; + else +error = 0; mutex_exit(vp-v_interlock); - return EBUSY; - } - mutex_exit(vp-v_interlock); - return VOP_LOCK(lowervp, flags); + } else + error = EBUSY; + if (error) + VOP_UNLOCK(lowervp); + return error; } error = VOP_LOCK(lowervp, flags); @@ -734,10 +742,10 @@ layer_lock(void *v) return error; mutex_enter(vp-v_interlock); - if ((vp-v_iflag (VI_XLOCK | VI_CLEAN)) != 0) { + if (ISSET(vp-v_iflag, VI_XLOCK) || ISSET(vp-v_iflag, VI_CLEAN)) { VOP_UNLOCK(lowervp); - if ((vp-v_iflag VI_XLOCK)) - vwait(vp, VI_XLOCK); + vwait(vp, VI_XLOCK); + KASSERT(ISSET(vp-v_iflag, VI_CLEAN)); mutex_exit(vp-v_interlock); return ENOENT; }
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: hannken Date: Sun Feb 9 17:15:51 UTC 2014 Modified Files: src/sys/miscfs/genfs: layer_subr.c Log Message: When layer_node_alloc() finds another thread already inserted the node into the hashlist and discards the now unneeded node it will raise a panic dead but not clean. Reorder the initialization and use ungetnewvnode() to discard the node. To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/sys/miscfs/genfs/layer_subr.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/miscfs/genfs/layer_subr.c diff -u src/sys/miscfs/genfs/layer_subr.c:1.33 src/sys/miscfs/genfs/layer_subr.c:1.34 --- src/sys/miscfs/genfs/layer_subr.c:1.33 Wed Jan 29 08:27:04 2014 +++ src/sys/miscfs/genfs/layer_subr.c Sun Feb 9 17:15:51 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: layer_subr.c,v 1.33 2014/01/29 08:27:04 hannken Exp $ */ +/* $NetBSD: layer_subr.c,v 1.34 2014/02/09 17:15:51 hannken Exp $ */ /* * Copyright (c) 1999 National Aeronautics Space Administration @@ -69,7 +69,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: layer_subr.c,v 1.33 2014/01/29 08:27:04 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: layer_subr.c,v 1.34 2014/02/09 17:15:51 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -187,7 +187,6 @@ layer_node_alloc(struct mount *mp, struc struct layer_node *xp; struct vnode *vp, *nvp; int error; - extern int (**dead_vnodeop_p)(void *); /* Get a new vnode and share its interlock with underlying vnode. */ error = getnewvnode(lmp-layerm_tag, mp, lmp-layerm_vnodeop_p, @@ -209,31 +208,25 @@ layer_node_alloc(struct mount *mp, struc spec_node_init(vp, lowervp-v_rdev); } - vp-v_data = xp; - vp-v_vflag = (vp-v_vflag ~VV_MPSAFE) | - (lowervp-v_vflag VV_MPSAFE); - xp-layer_vnode = vp; - xp-layer_lowervp = lowervp; - xp-layer_flags = 0; - /* * Before inserting the node into the hash, check if other thread * did not race with us. If so - return that node, destroy ours. */ mutex_enter(lmp-layerm_hashlock); if ((nvp = layer_node_find(mp, lowervp)) != NULL) { - /* Free the structures we have created. */ - if (vp-v_type == VBLK || vp-v_type == VCHR) - spec_node_destroy(vp); - - vp-v_type = VBAD; /* node is discarded */ - vp-v_op = dead_vnodeop_p; /* so ops will still work */ - vrele(vp); /* get rid of it. */ + ungetnewvnode(vp); kmem_free(xp, lmp-layerm_size); *vpp = nvp; return 0; } + vp-v_data = xp; + vp-v_vflag = (vp-v_vflag ~VV_MPSAFE) | + (lowervp-v_vflag VV_MPSAFE); + xp-layer_vnode = vp; + xp-layer_lowervp = lowervp; + xp-layer_flags = 0; + /* * Insert the new node into the hash. * Add a reference to the lower node.
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: hannken Date: Wed Jan 29 08:27:04 UTC 2014 Modified Files: src/sys/miscfs/genfs: layer_subr.c layer_vnops.c Log Message: Allow layer_node_create() with unlocked lower node and change layer_bypass() to enter nodes from creation operations unlocked. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/sys/miscfs/genfs/layer_subr.c cvs rdiff -u -r1.52 -r1.53 src/sys/miscfs/genfs/layer_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/miscfs/genfs/layer_subr.c diff -u src/sys/miscfs/genfs/layer_subr.c:1.32 src/sys/miscfs/genfs/layer_subr.c:1.33 --- src/sys/miscfs/genfs/layer_subr.c:1.32 Sun Jun 12 03:35:58 2011 +++ src/sys/miscfs/genfs/layer_subr.c Wed Jan 29 08:27:04 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: layer_subr.c,v 1.32 2011/06/12 03:35:58 rmind Exp $ */ +/* $NetBSD: layer_subr.c,v 1.33 2014/01/29 08:27:04 hannken Exp $ */ /* * Copyright (c) 1999 National Aeronautics Space Administration @@ -69,7 +69,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: layer_subr.c,v 1.32 2011/06/12 03:35:58 rmind Exp $); +__KERNEL_RCSID(0, $NetBSD: layer_subr.c,v 1.33 2014/01/29 08:27:04 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -260,8 +260,6 @@ layer_node_create(struct mount *mp, stru struct vnode *aliasvp; struct layer_mount *lmp = MOUNTTOLAYERMOUNT(mp); - KASSERT(VOP_ISLOCKED(lowervp)); - mutex_enter(lmp-layerm_hashlock); aliasvp = layer_node_find(mp, lowervp); if (aliasvp != NULL) { Index: src/sys/miscfs/genfs/layer_vnops.c diff -u src/sys/miscfs/genfs/layer_vnops.c:1.52 src/sys/miscfs/genfs/layer_vnops.c:1.53 --- src/sys/miscfs/genfs/layer_vnops.c:1.52 Thu Jan 23 10:13:57 2014 +++ src/sys/miscfs/genfs/layer_vnops.c Wed Jan 29 08:27:04 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: layer_vnops.c,v 1.52 2014/01/23 10:13:57 hannken Exp $ */ +/* $NetBSD: layer_vnops.c,v 1.53 2014/01/29 08:27:04 hannken Exp $ */ /* * Copyright (c) 1999 National Aeronautics Space Administration @@ -170,7 +170,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: layer_vnops.c,v 1.52 2014/01/23 10:13:57 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: layer_vnops.c,v 1.53 2014/01/29 08:27:04 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -321,10 +321,7 @@ layer_bypass(void *v) * as a lookup on . would generate a locking error. * So all the calls which get us here have a unlocked vpp. :-) */ - /* XXX: lock node until lookup returns unlocked nodes. */ - vn_lock(**vppp, LK_EXCLUSIVE | LK_RETRY); error = layer_node_create(mp, **vppp, *vppp); - VOP_UNLOCK(**vppp); if (error) { vrele(**vppp); **vppp = NULL;
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: martin Date: Sat Oct 19 16:33:11 UTC 2013 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: Mark a potentially unused (if an arch implements pmap_update as empty macro) variable accordingly. To generate a diff of this commit: cvs rdiff -u -r1.55 -r1.56 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.55 src/sys/miscfs/genfs/genfs_io.c:1.56 --- src/sys/miscfs/genfs/genfs_io.c:1.55 Tue May 22 14:20:39 2012 +++ src/sys/miscfs/genfs/genfs_io.c Sat Oct 19 16:33:11 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.55 2012/05/22 14:20:39 yamt Exp $ */ +/* $NetBSD: genfs_io.c,v 1.56 2013/10/19 16:33:11 martin Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.55 2012/05/22 14:20:39 yamt Exp $); +__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.56 2013/10/19 16:33:11 martin Exp $); #include sys/param.h #include sys/systm.h @@ -1727,7 +1727,7 @@ genfs_do_directio(struct vmspace *vs, va off_t off, enum uio_rw rw) { struct vm_map *map; - struct pmap *upm, *kpm; + struct pmap *upm, *kpm __unused; size_t klen = round_page(uva + len) - trunc_page(uva); off_t spoff, epoff; vaddr_t kva, puva;
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: martin Date: Sat Oct 19 19:36:16 UTC 2013 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: Mark a potentially unused variable To generate a diff of this commit: cvs rdiff -u -r1.56 -r1.57 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.56 src/sys/miscfs/genfs/genfs_io.c:1.57 --- src/sys/miscfs/genfs/genfs_io.c:1.56 Sat Oct 19 16:33:11 2013 +++ src/sys/miscfs/genfs/genfs_io.c Sat Oct 19 19:36:16 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.56 2013/10/19 16:33:11 martin Exp $ */ +/* $NetBSD: genfs_io.c,v 1.57 2013/10/19 19:36:16 martin Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.56 2013/10/19 16:33:11 martin Exp $); +__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.57 2013/10/19 19:36:16 martin Exp $); #include sys/param.h #include sys/systm.h @@ -1733,7 +1733,7 @@ genfs_do_directio(struct vmspace *vs, va vaddr_t kva, puva; paddr_t pa; vm_prot_t prot; - int error, rv, poff, koff; + int error, rv __unused, poff, koff; const int pgoflags = PGO_CLEANIT | PGO_SYNCIO | PGO_JOURNALLOCKED | (rw == UIO_WRITE ? PGO_FREE : 0);
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: dholland Date: Thu Jun 6 02:00:59 UTC 2013 Modified Files: src/sys/miscfs/genfs: genfs_node.h Log Message: Add missing declaration of struct vnode. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/sys/miscfs/genfs/genfs_node.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/genfs/genfs_node.h diff -u src/sys/miscfs/genfs/genfs_node.h:1.20 src/sys/miscfs/genfs/genfs_node.h:1.21 --- src/sys/miscfs/genfs/genfs_node.h:1.20 Wed Sep 1 16:56:19 2010 +++ src/sys/miscfs/genfs/genfs_node.h Thu Jun 6 02:00:59 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_node.h,v 1.20 2010/09/01 16:56:19 chs Exp $ */ +/* $NetBSD: genfs_node.h,v 1.21 2013/06/06 02:00:59 dholland Exp $ */ /* * Copyright (c) 2001 Chuck Silvers. @@ -38,6 +38,7 @@ struct vm_page; struct kauth_cred; struct uio; +struct vnode; struct genfs_ops { void (*gop_size)(struct vnode *, off_t, off_t *, int);
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: riastradh Date: Thu May 2 14:49:51 UTC 2013 Modified Files: src/sys/miscfs/genfs: genfs.h Log Message: Fix (harmless) typo in struct genfs_rename_ops::gro_lookup prototype. To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/sys/miscfs/genfs/genfs.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/genfs/genfs.h diff -u src/sys/miscfs/genfs/genfs.h:1.30 src/sys/miscfs/genfs/genfs.h:1.31 --- src/sys/miscfs/genfs/genfs.h:1.30 Tue May 8 23:53:26 2012 +++ src/sys/miscfs/genfs/genfs.h Thu May 2 14:49:51 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs.h,v 1.30 2012/05/08 23:53:26 riastradh Exp $ */ +/* $NetBSD: genfs.h,v 1.31 2013/05/02 14:49:51 riastradh Exp $ */ #ifndef _MISCFS_GENFS_GENFS_H_ #define _MISCFS_GENFS_GENFS_H_ @@ -108,7 +108,7 @@ struct genfs_rename_ops { struct vnode *dvp, struct componentname *cnp, void *de, struct vnode *vp); int (*gro_lookup)(struct mount *mp, struct vnode *dvp, - struct componentname *cnp, void *fde_ret, struct vnode **vp_ret); + struct componentname *cnp, void *de_ret, struct vnode **vp_ret); int (*gro_genealogy)(struct mount *mp, kauth_cred_t cred, struct vnode *fdvp, struct vnode *tdvp, struct vnode **intermediate_node_ret);
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: pgoyette Date: Thu May 31 15:07:29 UTC 2012 Modified Files: src/sys/miscfs/genfs: layer_vfsops.c Log Message: When built as module, track sysctl node creations, and destroy them on module exit. To generate a diff of this commit: cvs rdiff -u -r1.39 -r1.40 src/sys/miscfs/genfs/layer_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/miscfs/genfs/layer_vfsops.c diff -u src/sys/miscfs/genfs/layer_vfsops.c:1.39 src/sys/miscfs/genfs/layer_vfsops.c:1.40 --- src/sys/miscfs/genfs/layer_vfsops.c:1.39 Wed Feb 1 05:34:42 2012 +++ src/sys/miscfs/genfs/layer_vfsops.c Thu May 31 15:07:29 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: layer_vfsops.c,v 1.39 2012/02/01 05:34:42 dholland Exp $ */ +/* $NetBSD: layer_vfsops.c,v 1.40 2012/05/31 15:07:29 pgoyette Exp $ */ /* * Copyright (c) 1999 National Aeronautics Space Administration @@ -74,7 +74,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: layer_vfsops.c,v 1.39 2012/02/01 05:34:42 dholland Exp $); +__KERNEL_RCSID(0, $NetBSD: layer_vfsops.c,v 1.40 2012/05/31 15:07:29 pgoyette Exp $); #include sys/param.h #include sys/sysctl.h @@ -89,16 +89,27 @@ __KERNEL_RCSID(0, $NetBSD: layer_vfsops #include miscfs/genfs/layer.h #include miscfs/genfs/layer_extern.h +SYSCTL_SETUP_PROTO(sysctl_vfs_layerfs_setup); + MODULE(MODULE_CLASS_MISC, layerfs, NULL); static int layerfs_modcmd(modcmd_t cmd, void *arg) { +#ifdef _MODULE + static struct sysctllog *layerfs_clog = NULL; +#endif switch (cmd) { case MODULE_CMD_INIT: +#ifdef _MODULE + sysctl_vfs_layerfs_setup(layerfs_clog); +#endif return 0; case MODULE_CMD_FINI: +#ifdef _MODULE + sysctl_teardown(layerfs_clog); +#endif return 0; default: return ENOTTY;
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: pgoyette Date: Thu May 31 16:08:14 UTC 2012 Modified Files: src/sys/miscfs/genfs: layer_vfsops.c Log Message: Ooopppsss! sysctl nodes created during module load time cannot be PERMANENT To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/sys/miscfs/genfs/layer_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/miscfs/genfs/layer_vfsops.c diff -u src/sys/miscfs/genfs/layer_vfsops.c:1.40 src/sys/miscfs/genfs/layer_vfsops.c:1.41 --- src/sys/miscfs/genfs/layer_vfsops.c:1.40 Thu May 31 15:07:29 2012 +++ src/sys/miscfs/genfs/layer_vfsops.c Thu May 31 16:08:14 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: layer_vfsops.c,v 1.40 2012/05/31 15:07:29 pgoyette Exp $ */ +/* $NetBSD: layer_vfsops.c,v 1.41 2012/05/31 16:08:14 pgoyette Exp $ */ /* * Copyright (c) 1999 National Aeronautics Space Administration @@ -74,7 +74,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: layer_vfsops.c,v 1.40 2012/05/31 15:07:29 pgoyette Exp $); +__KERNEL_RCSID(0, $NetBSD: layer_vfsops.c,v 1.41 2012/05/31 16:08:14 pgoyette Exp $); #include sys/param.h #include sys/sysctl.h @@ -275,12 +275,20 @@ SYSCTL_SETUP(sysctl_vfs_layerfs_setup, const struct sysctlnode *layerfs_node = NULL; sysctl_createv(clog, 0, NULL, NULL, +#ifdef _MODULE + 0, +#else CTLFLAG_PERMANENT, +#endif CTLTYPE_NODE, vfs, NULL, NULL, 0, NULL, 0, CTL_VFS, CTL_EOL); sysctl_createv(clog, 0, NULL, layerfs_node, +#ifdef _MODULE + 0, +#else CTLFLAG_PERMANENT, +#endif CTLTYPE_NODE, layerfs, SYSCTL_DESCR(Generic layered file system), NULL, 0, NULL, 0, @@ -288,7 +296,10 @@ SYSCTL_SETUP(sysctl_vfs_layerfs_setup, #ifdef LAYERFS_DIAGNOSTIC sysctl_createv(clog, 0, layerfs_node, NULL, - CTLFLAG_PERMANENT|CTLFLAG_READWRITE, +#ifndef _MODULE + CTLFLAG_PERMANENT | +#endif + CTLFLAG_READWRITE, CTLTYPE_INT, debug, SYSCTL_DESCR(Verbose debugging messages),
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: yamt Date: Tue May 22 14:20:40 UTC 2012 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: don't block on pager map for read-ahead. reduce code duplication. To generate a diff of this commit: cvs rdiff -u -r1.54 -r1.55 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.54 src/sys/miscfs/genfs/genfs_io.c:1.55 --- src/sys/miscfs/genfs/genfs_io.c:1.54 Sun Apr 29 22:54:00 2012 +++ src/sys/miscfs/genfs/genfs_io.c Tue May 22 14:20:39 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.54 2012/04/29 22:54:00 chs Exp $ */ +/* $NetBSD: genfs_io.c,v 1.55 2012/05/22 14:20:39 yamt Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.54 2012/04/29 22:54:00 chs Exp $); +__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.55 2012/05/22 14:20:39 yamt Exp $); #include sys/param.h #include sys/systm.h @@ -58,21 +58,22 @@ static void genfs_dio_iodone(struct buf static int genfs_do_io(struct vnode *, off_t, vaddr_t, size_t, int, enum uio_rw, void (*)(struct buf *)); -static void genfs_rel_pages(struct vm_page **, int); +static void genfs_rel_pages(struct vm_page **, unsigned int); static void genfs_markdirty(struct vnode *); int genfs_maxdio = MAXPHYS; static void -genfs_rel_pages(struct vm_page **pgs, int npages) +genfs_rel_pages(struct vm_page **pgs, unsigned int npages) { - int i; + unsigned int i; for (i = 0; i npages; i++) { struct vm_page *pg = pgs[i]; if (pg == NULL || pg == PGO_DONTCARE) continue; + KASSERT(uvm_page_locked_p(pg)); if (pg-flags PG_FAKE) { pg-flags |= PG_RELEASED; } @@ -437,7 +438,11 @@ startover: skipbytes = 0; kva = uvm_pagermapin(pgs, npages, - UVMPAGER_MAPIN_READ | UVMPAGER_MAPIN_WAITOK); + UVMPAGER_MAPIN_READ | (async ? 0 : UVMPAGER_MAPIN_WAITOK)); + if (kva == 0) { + error = EBUSY; + goto mapin_fail; + } mbp = getiobuf(vp, true); mbp-b_bufsize = totalbytes; @@ -651,13 +656,14 @@ loopdone: mutex_exit(uobj-vmobjlock); } } - if (!glocked) { - genfs_node_unlock(vp); - } putiobuf(mbp); } +mapin_fail: + if (!glocked) { + genfs_node_unlock(vp); + } mutex_enter(uobj-vmobjlock); /* @@ -668,21 +674,7 @@ loopdone: */ if (error) { - for (i = 0; i npages; i++) { - struct vm_page *pg = pgs[i]; - - if (pg == NULL) { -continue; - } - UVMHIST_LOG(ubchist, examining pg %p flags 0x%x, - pg, pg-flags, 0,0); - if (pg-flags PG_FAKE) { -pg-flags |= PG_RELEASED; - } - } - mutex_enter(uvm_pageqlock); - uvm_page_unbusy(pgs, npages); - mutex_exit(uvm_pageqlock); + genfs_rel_pages(pgs, npages); mutex_exit(uobj-vmobjlock); UVMHIST_LOG(ubchist, returning error %d, error,0,0,0); goto out_err_free;
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: njoly Date: Fri Mar 30 18:24:08 UTC 2012 Modified Files: src/sys/miscfs/genfs: genfs_vnops.c Log Message: uid mismatch for file flags changes is expected to fail with EPERM not EACCES. To generate a diff of this commit: cvs rdiff -u -r1.188 -r1.189 src/sys/miscfs/genfs/genfs_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/miscfs/genfs/genfs_vnops.c diff -u src/sys/miscfs/genfs/genfs_vnops.c:1.188 src/sys/miscfs/genfs/genfs_vnops.c:1.189 --- src/sys/miscfs/genfs/genfs_vnops.c:1.188 Tue Mar 13 18:40:57 2012 +++ src/sys/miscfs/genfs/genfs_vnops.c Fri Mar 30 18:24:08 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_vnops.c,v 1.188 2012/03/13 18:40:57 elad Exp $ */ +/* $NetBSD: genfs_vnops.c,v 1.189 2012/03/30 18:24:08 njoly Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: genfs_vnops.c,v 1.188 2012/03/13 18:40:57 elad Exp $); +__KERNEL_RCSID(0, $NetBSD: genfs_vnops.c,v 1.189 2012/03/30 18:24:08 njoly Exp $); #include sys/param.h #include sys/systm.h @@ -762,7 +762,7 @@ genfs_can_chflags(kauth_cred_t cred, enu /* The user must own the file. */ if (kauth_cred_geteuid(cred) != owner_uid) { - return EACCES; + return EPERM; } if (changing_sysflags) {
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: yamt Date: Mon Oct 31 12:49:32 UTC 2011 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: typo in a comment To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.52 src/sys/miscfs/genfs/genfs_io.c:1.53 --- src/sys/miscfs/genfs/genfs_io.c:1.52 Sun Oct 9 14:34:39 2011 +++ src/sys/miscfs/genfs/genfs_io.c Mon Oct 31 12:49:32 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.52 2011/10/09 14:34:39 uebayasi Exp $ */ +/* $NetBSD: genfs_io.c,v 1.53 2011/10/31 12:49:32 yamt Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.52 2011/10/09 14:34:39 uebayasi Exp $); +__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.53 2011/10/31 12:49:32 yamt Exp $); #include sys/param.h #include sys/systm.h @@ -1641,7 +1641,7 @@ genfs_directio(struct vnode *vp, struct /* * If the vnode is mapped, we would need to get the getpages lock - * to stabilize the bmap, but then we would get into trouble whil e + * to stabilize the bmap, but then we would get into trouble while * locking the pages if the pages belong to this same vnode (or a * multi-vnode cascade to the same effect). Just fall back to * buffered I/O if the vnode is mapped to avoid this mess.
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: matt Date: Thu Sep 1 16:55:08 UTC 2011 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: Use the new UVM_KMF_COLORMATCH flag to get a congruent mappings of the user buffer so we can use unmanaged mappings (pmap_kenter_pa/pmap_kremove). To generate a diff of this commit: cvs rdiff -u -r1.50 -r1.51 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.50 src/sys/miscfs/genfs/genfs_io.c:1.51 --- src/sys/miscfs/genfs/genfs_io.c:1.50 Wed Aug 31 22:16:54 2011 +++ src/sys/miscfs/genfs/genfs_io.c Thu Sep 1 16:55:08 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.50 2011/08/31 22:16:54 rmind Exp $ */ +/* $NetBSD: genfs_io.c,v 1.51 2011/09/01 16:55:08 matt Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.50 2011/08/31 22:16:54 rmind Exp $); +__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.51 2011/09/01 16:55:08 matt Exp $); #include sys/param.h #include sys/systm.h @@ -1748,8 +1748,6 @@ int error, rv, poff, koff; const int pgoflags = PGO_CLEANIT | PGO_SYNCIO | PGO_JOURNALLOCKED | (rw == UIO_WRITE ? PGO_FREE : 0); - struct vm_page *pg; - kmutex_t *slock; /* * For writes, verify that this range of the file already has fully @@ -1803,24 +1801,13 @@ map = vs-vm_map; upm = vm_map_pmap(map); kpm = vm_map_pmap(kernel_map); - kva = uvm_km_alloc(kernel_map, klen, 0, - UVM_KMF_VAONLY | UVM_KMF_WAITVA); puva = trunc_page(uva); + kva = uvm_km_alloc(kernel_map, klen, atop(puva) uvmexp.colormask, + UVM_KMF_VAONLY | UVM_KMF_WAITVA | UVM_KMF_COLORMATCH); for (poff = 0; poff klen; poff += PAGE_SIZE) { rv = pmap_extract(upm, puva + poff, pa); KASSERT(rv); - pg = PHYS_TO_VM_PAGE(pa); - -retry1: /* XXX: Rework to not use managed-mappings.. */ - mutex_enter(uvm_pageqlock); - slock = uvmpd_trylockowner(pg); - mutex_exit(uvm_pageqlock); - if (slock == NULL) { - kpause(gendiolk, false, 1, slock); - goto retry1; - } - pmap_enter(kpm, kva + poff, pa, prot, prot | PMAP_WIRED); - mutex_exit(slock); + pmap_kenter_pa(kva + poff, pa, prot, PMAP_WIRED); } pmap_update(kpm); @@ -1836,24 +1823,7 @@ * Tear down the kernel mapping. */ - for (koff = 0; koff klen; koff += PAGE_SIZE) { - vaddr_t sva = kva + koff; - - rv = pmap_extract(kpm, sva, pa); - KASSERT(rv); - pg = PHYS_TO_VM_PAGE(pa); - -retry2: /* XXX: Rework to not use managed-mappings.. */ - mutex_enter(uvm_pageqlock); - slock = uvmpd_trylockowner(pg); - mutex_exit(uvm_pageqlock); - if (slock == NULL) { - kpause(gendiolk, false, 1, slock); - goto retry2; - } - pmap_remove(kpm, sva, sva + PAGE_SIZE); - mutex_exit(slock); - } + pmap_kremove(kva, klen); pmap_update(kpm); uvm_km_free(kernel_map, kva, klen, UVM_KMF_VAONLY);
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: rmind Date: Wed Aug 31 22:16:54 UTC 2011 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: genfs_do_directio: acquire the lock of page owner for now and fix PR/45177. Will be revisited to avoid locking dance and be more efficient, e.g. we can use unmanaged-mapping by allocating with colouring in mind. To generate a diff of this commit: cvs rdiff -u -r1.49 -r1.50 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.49 src/sys/miscfs/genfs/genfs_io.c:1.50 --- src/sys/miscfs/genfs/genfs_io.c:1.49 Sun Jun 12 03:35:58 2011 +++ src/sys/miscfs/genfs/genfs_io.c Wed Aug 31 22:16:54 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.49 2011/06/12 03:35:58 rmind Exp $ */ +/* $NetBSD: genfs_io.c,v 1.50 2011/08/31 22:16:54 rmind Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.49 2011/06/12 03:35:58 rmind Exp $); +__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.50 2011/08/31 22:16:54 rmind Exp $); #include sys/param.h #include sys/systm.h @@ -1748,6 +1748,8 @@ int error, rv, poff, koff; const int pgoflags = PGO_CLEANIT | PGO_SYNCIO | PGO_JOURNALLOCKED | (rw == UIO_WRITE ? PGO_FREE : 0); + struct vm_page *pg; + kmutex_t *slock; /* * For writes, verify that this range of the file already has fully @@ -1804,13 +1806,22 @@ kva = uvm_km_alloc(kernel_map, klen, 0, UVM_KMF_VAONLY | UVM_KMF_WAITVA); puva = trunc_page(uva); - mutex_enter(vp-v_interlock); for (poff = 0; poff klen; poff += PAGE_SIZE) { rv = pmap_extract(upm, puva + poff, pa); KASSERT(rv); + pg = PHYS_TO_VM_PAGE(pa); + +retry1: /* XXX: Rework to not use managed-mappings.. */ + mutex_enter(uvm_pageqlock); + slock = uvmpd_trylockowner(pg); + mutex_exit(uvm_pageqlock); + if (slock == NULL) { + kpause(gendiolk, false, 1, slock); + goto retry1; + } pmap_enter(kpm, kva + poff, pa, prot, prot | PMAP_WIRED); + mutex_exit(slock); } - mutex_exit(vp-v_interlock); pmap_update(kpm); /* @@ -1825,9 +1836,24 @@ * Tear down the kernel mapping. */ - mutex_enter(vp-v_interlock); - pmap_remove(kpm, kva, kva + klen); - mutex_exit(vp-v_interlock); + for (koff = 0; koff klen; koff += PAGE_SIZE) { + vaddr_t sva = kva + koff; + + rv = pmap_extract(kpm, sva, pa); + KASSERT(rv); + pg = PHYS_TO_VM_PAGE(pa); + +retry2: /* XXX: Rework to not use managed-mappings.. */ + mutex_enter(uvm_pageqlock); + slock = uvmpd_trylockowner(pg); + mutex_exit(uvm_pageqlock); + if (slock == NULL) { + kpause(gendiolk, false, 1, slock); + goto retry2; + } + pmap_remove(kpm, sva, sva + PAGE_SIZE); + mutex_exit(slock); + } pmap_update(kpm); uvm_km_free(kernel_map, kva, klen, UVM_KMF_VAONLY); @@ -1838,4 +1864,3 @@ uvm_vsunlock(vs, (void *)uva, len); return error; } -
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: hannken Date: Mon Jul 11 08:34:01 UTC 2011 Modified Files: src/sys/miscfs/genfs: layer_vnops.c Log Message: Layer_fsync(): when syncing a device node call spec_fsync() to clean the layer node before descending to the lower file system. Adresses PR kern/38762 panic: vwakeup: neg numoutput To generate a diff of this commit: cvs rdiff -u -r1.49 -r1.50 src/sys/miscfs/genfs/layer_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/miscfs/genfs/layer_vnops.c diff -u src/sys/miscfs/genfs/layer_vnops.c:1.49 src/sys/miscfs/genfs/layer_vnops.c:1.50 --- src/sys/miscfs/genfs/layer_vnops.c:1.49 Mon Jul 11 08:27:38 2011 +++ src/sys/miscfs/genfs/layer_vnops.c Mon Jul 11 08:34:01 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: layer_vnops.c,v 1.49 2011/07/11 08:27:38 hannken Exp $ */ +/* $NetBSD: layer_vnops.c,v 1.50 2011/07/11 08:34:01 hannken Exp $ */ /* * Copyright (c) 1999 National Aeronautics Space Administration @@ -170,7 +170,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: layer_vnops.c,v 1.49 2011/07/11 08:27:38 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: layer_vnops.c,v 1.50 2011/07/11 08:34:01 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -186,6 +186,7 @@ #include miscfs/genfs/layer.h #include miscfs/genfs/layer_extern.h #include miscfs/genfs/genfs.h +#include miscfs/specfs/specdev.h /* * This is the 08-June-99 bypass routine, based on the 10-Apr-92 bypass @@ -529,10 +530,16 @@ off_t offhi; struct lwp *a_l; } */ *ap = v; + int error; if (ap-a_flags FSYNC_RECLAIM) { return 0; } + if (ap-a_vp-v_type == VBLK || ap-a_vp-v_type == VCHR) { + error = spec_fsync(v); + if (error) + return error; + } return LAYERFS_DO_BYPASS(ap-a_vp, ap); }
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: matt Date: Thu Apr 21 06:27:17 UTC 2011 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: Move some #ifdefs to prevent a code path change when DEBUG .vs. !DEBUG Solves problem an assert firing when using NFS on MIPS. To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.47 src/sys/miscfs/genfs/genfs_io.c:1.48 --- src/sys/miscfs/genfs/genfs_io.c:1.47 Mon Apr 18 15:53:04 2011 +++ src/sys/miscfs/genfs/genfs_io.c Thu Apr 21 06:27:17 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.47 2011/04/18 15:53:04 rmind Exp $ */ +/* $NetBSD: genfs_io.c,v 1.48 2011/04/21 06:27:17 matt Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.47 2011/04/18 15:53:04 rmind Exp $); +__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.48 2011/04/21 06:27:17 matt Exp $); #include sys/param.h #include sys/systm.h @@ -903,19 +903,19 @@ by_list = (uobj-uo_npages = ((endoff - startoff) PAGE_SHIFT) * UVM_PAGE_TREE_PENALTY); -#if !defined(DEBUG) /* * if this vnode is known not to have dirty pages, * don't bother to clean it out. */ if ((vp-v_iflag VI_ONWORKLST) == 0) { +#if !defined(DEBUG) if ((flags (PGO_FREE|PGO_DEACTIVATE)) == 0) { goto skip_scan; } +#endif /* !defined(DEBUG) */ flags = ~PGO_CLEANIT; } -#endif /* !defined(DEBUG) */ /* * start the loop. when scanning by list, hold the last page
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: hannken Date: Thu Jan 13 10:28:38 UTC 2011 Modified Files: src/sys/miscfs/genfs: layer_vnops.c Log Message: Layer_revoke(): change previous to always take an extra reference on the lower vnode before passing down the VOP_REVOKE(). This way VOP_REVOKE() on a layered file system always inactivates and closes the lower vnode. Should finally fix PR kern/43456. To generate a diff of this commit: cvs rdiff -u -r1.45 -r1.46 src/sys/miscfs/genfs/layer_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/miscfs/genfs/layer_vnops.c diff -u src/sys/miscfs/genfs/layer_vnops.c:1.45 src/sys/miscfs/genfs/layer_vnops.c:1.46 --- src/sys/miscfs/genfs/layer_vnops.c:1.45 Mon Jan 10 11:11:03 2011 +++ src/sys/miscfs/genfs/layer_vnops.c Thu Jan 13 10:28:38 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: layer_vnops.c,v 1.45 2011/01/10 11:11:03 hannken Exp $ */ +/* $NetBSD: layer_vnops.c,v 1.46 2011/01/13 10:28:38 hannken Exp $ */ /* * Copyright (c) 1999 National Aeronautics Space Administration @@ -170,7 +170,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: layer_vnops.c,v 1.45 2011/01/10 11:11:03 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: layer_vnops.c,v 1.46 2011/01/13 10:28:38 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -658,19 +658,16 @@ } */ *ap = v; struct vnode *vp = ap-a_vp; struct vnode *lvp = LAYERVPTOLOWERVP(vp); - int i, n, error; + int error; /* * We will most likely end up in vclean which uses the v_usecount - * to determine if a vnode is active. So we have to adjust the - * lower vp's usecount to be at least as high as our usecount. + * to determine if a vnode is active. Take an extra reference on + * the lower vnode so it will always close and inactivate. */ - n = vp-v_usecount - lvp-v_usecount; - for (i = 0; i n; i++) - vref(lvp); + vref(lvp); error = LAYERFS_DO_BYPASS(vp, ap); - for (i = 0; i n; i++) - vrele(lvp); + vrele(lvp); return error; }
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: uebayasi Date: Mon Dec 6 10:22:43 UTC 2010 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: Correct an assertion; pointed out by mrg@ and pooka@, thanks. To generate a diff of this commit: cvs rdiff -u -r1.45 -r1.46 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.45 src/sys/miscfs/genfs/genfs_io.c:1.46 --- src/sys/miscfs/genfs/genfs_io.c:1.45 Fri Dec 3 08:42:14 2010 +++ src/sys/miscfs/genfs/genfs_io.c Mon Dec 6 10:22:43 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.45 2010/12/03 08:42:14 hannken Exp $ */ +/* $NetBSD: genfs_io.c,v 1.46 2010/12/06 10:22:43 uebayasi Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.45 2010/12/03 08:42:14 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.46 2010/12/06 10:22:43 uebayasi Exp $); #include sys/param.h #include sys/systm.h @@ -240,7 +240,8 @@ if (pg != NULL pg != PGO_DONTCARE) { ap-a_m[i] = NULL; } -KASSERT(pg == NULL || pg == PGO_DONTCARE); +KASSERT(ap-a_m[i] == NULL || +ap-a_m[i] == PGO_DONTCARE); } } else { genfs_node_unlock(vp);
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: hannken Date: Fri Dec 3 08:42:14 UTC 2010 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: genfs_do_putpages(): When testing an uobject for dirty or modified pages skip uninitialized (PG_FAKE) pages (DEBUG only). To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.45 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.44 src/sys/miscfs/genfs/genfs_io.c:1.45 --- src/sys/miscfs/genfs/genfs_io.c:1.44 Tue Nov 30 10:55:25 2010 +++ src/sys/miscfs/genfs/genfs_io.c Fri Dec 3 08:42:14 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.44 2010/11/30 10:55:25 hannken Exp $ */ +/* $NetBSD: genfs_io.c,v 1.45 2010/12/03 08:42:14 hannken Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.44 2010/11/30 10:55:25 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.45 2010/12/03 08:42:14 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -1224,7 +1224,7 @@ (vp-v_iflag VI_ONWORKLST) != 0) { #if defined(DEBUG) TAILQ_FOREACH(pg, uobj-memq, listq.queue) { - if ((pg-flags PG_MARKER) != 0) { + if ((pg-flags (PG_FAKE | PG_MARKER)) != 0) { continue; } if ((pg-flags PG_CLEAN) == 0) {
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: uebayasi Date: Fri Nov 19 05:38:10 UTC 2010 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: Whitespace. To generate a diff of this commit: cvs rdiff -u -r1.42 -r1.43 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.42 src/sys/miscfs/genfs/genfs_io.c:1.43 --- src/sys/miscfs/genfs/genfs_io.c:1.42 Tue Nov 9 16:31:48 2010 +++ src/sys/miscfs/genfs/genfs_io.c Fri Nov 19 05:38:10 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.42 2010/11/09 16:31:48 hannken Exp $ */ +/* $NetBSD: genfs_io.c,v 1.43 2010/11/19 05:38:10 uebayasi Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.42 2010/11/09 16:31:48 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.43 2010/11/19 05:38:10 uebayasi Exp $); #include sys/param.h #include sys/systm.h @@ -453,7 +453,7 @@ } else { mbp-b_flags = B_READ; mbp-b_iodone = NULL; - } + } if (async) BIO_SETPRIO(mbp, BPRIO_TIMELIMITED); else
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: hannken Date: Tue Nov 9 16:31:48 UTC 2010 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: Genfs_getpages(): Break a deadlock where one thread runs VOP_GETPAGES(), has busy pages and wants the wapbl lock as reader from wapbl_begin(), another thread has the wapbl lock as reader and waits for a page from the first thread. Now a third thread calls wapbl_flush() and wants the wapbl lock as writer. Move the wapbl_begin() up to a point where genfs_getpages() has no busy pages yet. To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.41 src/sys/miscfs/genfs/genfs_io.c:1.42 --- src/sys/miscfs/genfs/genfs_io.c:1.41 Wed Nov 3 04:32:50 2010 +++ src/sys/miscfs/genfs/genfs_io.c Tue Nov 9 16:31:48 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.41 2010/11/03 04:32:50 uebayasi Exp $ */ +/* $NetBSD: genfs_io.c,v 1.42 2010/11/09 16:31:48 hannken Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.41 2010/11/03 04:32:50 uebayasi Exp $); +__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.42 2010/11/09 16:31:48 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -129,10 +129,11 @@ kauth_cred_t const cred = curlwp-l_cred; /* XXXUBC curlwp */ const bool async = (flags PGO_SYNCIO) == 0; const bool memwrite = (ap-a_access_type VM_PROT_WRITE) != 0; - bool has_trans = false; const bool overwrite = (flags PGO_OVERWRITE) != 0; const bool blockalloc = memwrite (flags PGO_NOBLOCKALLOC) == 0; const bool glocked = (flags PGO_GLOCKHELD) != 0; + const bool need_wapbl = blockalloc vp-v_mount-mnt_wapbl; + bool has_trans_wapbl = false; UVMHIST_FUNC(genfs_getpages); UVMHIST_CALLED(ubchist); UVMHIST_LOG(ubchist, vp %p off 0x%x/%x count %d, @@ -294,9 +295,20 @@ UVMHIST_LOG(ubchist, ridx %d npages %d startoff %ld endoff %ld, ridx, npages, startoffset, endoffset); - if (!has_trans) { + if (!has_trans_wapbl) { fstrans_start(vp-v_mount, FSTRANS_SHARED); - has_trans = true; + /* + * XXX: This assumes that we come here only via + * the mmio path + */ + if (need_wapbl) { + error = WAPBL_BEGIN(vp-v_mount); + if (error) { +fstrans_done(vp-v_mount); +goto out_err_free; + } + } + has_trans_wapbl = true; } /* @@ -621,22 +633,8 @@ */ if (!error sawhole blockalloc) { - /* - * XXX: This assumes that we come here only via - * the mmio path - */ - if (vp-v_mount-mnt_wapbl) { - error = WAPBL_BEGIN(vp-v_mount); - } - - if (!error) { - error = GOP_ALLOC(vp, startoffset, - npages PAGE_SHIFT, 0, cred); - if (vp-v_mount-mnt_wapbl) { -WAPBL_END(vp-v_mount); - } - } - + error = GOP_ALLOC(vp, startoffset, + npages PAGE_SHIFT, 0, cred); UVMHIST_LOG(ubchist, gop_alloc off 0x%x/0x%x - %d, startoffset, npages PAGE_SHIFT, error,0); if (!error) { @@ -738,8 +736,11 @@ if (pgs != NULL pgs != pgs_onstack) kmem_free(pgs, pgs_size); out_err: - if (has_trans) + if (has_trans_wapbl) { + if (need_wapbl) + WAPBL_END(vp-v_mount); fstrans_done(vp-v_mount); + } return error; }
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: uebayasi Date: Wed Nov 3 04:32:50 UTC 2010 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: genfs_getpages: restore vm_page array correctly in PGO_LOCKED error code path. To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.40 src/sys/miscfs/genfs/genfs_io.c:1.41 --- src/sys/miscfs/genfs/genfs_io.c:1.40 Wed Sep 1 16:56:19 2010 +++ src/sys/miscfs/genfs/genfs_io.c Wed Nov 3 04:32:50 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.40 2010/09/01 16:56:19 chs Exp $ */ +/* $NetBSD: genfs_io.c,v 1.41 2010/11/03 04:32:50 uebayasi Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.40 2010/09/01 16:56:19 chs Exp $); +__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.41 2010/11/03 04:32:50 uebayasi Exp $); #include sys/param.h #include sys/systm.h @@ -236,9 +236,10 @@ for (i = 0; i npages; i++) { pg = ap-a_m[i]; -if (pg != NULL || pg != PGO_DONTCARE) { +if (pg != NULL pg != PGO_DONTCARE) { ap-a_m[i] = NULL; } +KASSERT(pg == NULL || pg == PGO_DONTCARE); } } else { genfs_node_unlock(vp);
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: pooka Date: Thu Aug 19 02:10:02 UTC 2010 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: print more info in the past eof panic To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.38 src/sys/miscfs/genfs/genfs_io.c:1.39 --- src/sys/miscfs/genfs/genfs_io.c:1.38 Sun Aug 8 18:17:11 2010 +++ src/sys/miscfs/genfs/genfs_io.c Thu Aug 19 02:10:02 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.38 2010/08/08 18:17:11 chs Exp $ */ +/* $NetBSD: genfs_io.c,v 1.39 2010/08/19 02:10:02 pooka Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.38 2010/08/08 18:17:11 chs Exp $); +__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.39 2010/08/19 02:10:02 pooka Exp $); #include sys/param.h #include sys/systm.h @@ -160,7 +160,8 @@ #if defined(DIAGNOSTIC) GOP_SIZE(vp, vp-v_writesize, writeeof, GOP_SIZE_MEM); if (newsize round_page(writeeof)) { - panic(%s: past eof, __func__); + panic(%s: past eof: % PRId64 vs. % PRId64, + __func__, newsize, round_page(writeeof)); } #endif /* defined(DIAGNOSTIC) */ } else {
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: chs Date: Sun Aug 8 18:17:12 UTC 2010 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: in genfs_getpages(), mark the vnode dirty (ie. add to syncer worklist and set VI_WRMAPDIRTY) after we have busied the pages rather than before. this prevents other threads calling genfs_do_putpages() from marking the vnode clean again while we're in the process of creating new writable mappings, since such threads will wait for the page(s) to become unbusy before proceeding. fixes the problem recently reported by hannken@ on tech-kern. To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.37 src/sys/miscfs/genfs/genfs_io.c:1.38 --- src/sys/miscfs/genfs/genfs_io.c:1.37 Thu Jul 29 10:54:50 2010 +++ src/sys/miscfs/genfs/genfs_io.c Sun Aug 8 18:17:11 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.37 2010/07/29 10:54:50 hannken Exp $ */ +/* $NetBSD: genfs_io.c,v 1.38 2010/08/08 18:17:11 chs Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.37 2010/07/29 10:54:50 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.38 2010/08/08 18:17:11 chs Exp $); #include sys/param.h #include sys/systm.h @@ -62,11 +62,12 @@ static int genfs_do_io(struct vnode *, off_t, vaddr_t, size_t, int, enum uio_rw, void (*)(struct buf *)); -static inline void genfs_rel_pages(struct vm_page **, int); +static void genfs_rel_pages(struct vm_page **, int); +static void genfs_markdirty(struct vnode *); int genfs_maxdio = MAXPHYS; -static inline void +static void genfs_rel_pages(struct vm_page **pgs, int npages) { int i; @@ -85,6 +86,21 @@ mutex_exit(uvm_pageqlock); } +static void +genfs_markdirty(struct vnode *vp) +{ + struct genfs_node * const gp = VTOG(vp); + + KASSERT(mutex_owned(vp-v_interlock)); + gp-g_dirtygen++; + if ((vp-v_iflag VI_ONWORKLST) == 0) { + vn_syncer_add_to_worklist(vp, filedelay); + } + if ((vp-v_iflag (VI_WRMAP|VI_WRMAPDIRTY)) == VI_WRMAP) { + vp-v_iflag |= VI_WRMAPDIRTY; + } +} + /* * generic VM getpages routine. * Return PG_BUSY pages for the given range, @@ -186,16 +202,6 @@ } } - if (memwrite) { - gp-g_dirtygen++; - if ((vp-v_iflag VI_ONWORKLST) == 0) { - vn_syncer_add_to_worklist(vp, filedelay); - } - if ((vp-v_iflag (VI_WRMAP|VI_WRMAPDIRTY)) == VI_WRMAP) { - vp-v_iflag |= VI_WRMAPDIRTY; - } - } - /* * For PGO_LOCKED requests, just return whatever's in memory. */ @@ -236,6 +242,9 @@ genfs_node_unlock(vp); } error = (ap-a_m[ap-a_centeridx] == NULL ? EBUSY : 0); + if (error == 0 memwrite) { + genfs_markdirty(vp); + } goto out_err; } mutex_exit(uobj-vmobjlock); @@ -696,6 +705,9 @@ } } mutex_exit(uvm_pageqlock); + if (memwrite) { + genfs_markdirty(vp); + } mutex_exit(uobj-vmobjlock); if (ap-a_m != NULL) { memcpy(ap-a_m, pgs[ridx], @@ -708,7 +720,7 @@ out_err: if (has_trans) fstrans_done(vp-v_mount); - return (error); + return error; } /* @@ -1467,18 +1479,19 @@ orignpages = *ap-a_count; pgs = ap-a_m; - if (memwrite (vp-v_iflag VI_ONWORKLST) == 0) { - vn_syncer_add_to_worklist(vp, filedelay); - } if (ap-a_flags PGO_LOCKED) { uvn_findpages(uobj, origoffset, ap-a_count, ap-a_m, UFP_NOWAIT|UFP_NOALLOC| (memwrite ? UFP_NORDONLY : 0)); - return (ap-a_m[ap-a_centeridx] == NULL ? EBUSY : 0); + error = ap-a_m[ap-a_centeridx] == NULL ? EBUSY : 0; + if (error == 0 memwrite) { + genfs_markdirty(vp); + } + return error; } if (origoffset + (ap-a_centeridx PAGE_SHIFT) = vp-v_size) { mutex_exit(uobj-vmobjlock); - return (EINVAL); + return EINVAL; } if ((ap-a_flags PGO_SYNCIO) == 0) { mutex_exit(uobj-vmobjlock); @@ -1527,8 +1540,11 @@ uvm_page_unbusy(pgs, npages); } mutex_exit(uvm_pageqlock); + if (error == 0 memwrite) { + genfs_markdirty(vp); + } mutex_exit(uobj-vmobjlock); - return (error); + return error; } int
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: hannken Date: Thu Jun 24 10:39:35 UTC 2010 Modified Files: src/sys/miscfs/genfs: genfs_vnops.c Log Message: genfs_nolock(): LK_INTERLOCK flag no longer possible. To generate a diff of this commit: cvs rdiff -u -r1.179 -r1.180 src/sys/miscfs/genfs/genfs_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/miscfs/genfs/genfs_vnops.c diff -u src/sys/miscfs/genfs/genfs_vnops.c:1.179 src/sys/miscfs/genfs/genfs_vnops.c:1.180 --- src/sys/miscfs/genfs/genfs_vnops.c:1.179 Thu Jun 24 07:54:47 2010 +++ src/sys/miscfs/genfs/genfs_vnops.c Thu Jun 24 10:39:35 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_vnops.c,v 1.179 2010/06/24 07:54:47 hannken Exp $ */ +/* $NetBSD: genfs_vnops.c,v 1.180 2010/06/24 10:39:35 hannken Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: genfs_vnops.c,v 1.179 2010/06/24 07:54:47 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: genfs_vnops.c,v 1.180 2010/06/24 10:39:35 hannken Exp $); #include sys/param.h #include sys/systm.h @@ -329,18 +329,7 @@ int genfs_nolock(void *v) { - struct vop_lock_args /* { - struct vnode *a_vp; - int a_flags; - struct lwp *a_l; - } */ *ap = v; - /* - * Since we are not using the lock manager, we must clear - * the interlock here. - */ - if (ap-a_flags LK_INTERLOCK) - mutex_exit(ap-a_vp-v_interlock); return (0); }
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: pooka Date: Thu Apr 8 15:56:26 UTC 2010 Modified Files: src/sys/miscfs/genfs: genfs_vnops.c Log Message: Call VOP_ABORTOP in genfs_eopnotsupp. This prevents file system authors from having to get down on their knees and pray they won't get POGA'd(*) again. This plugs componentname leaks in at least smbfs and buggy puffs servers (buggy servers shouldn't be able to leak kernel memory). *) principle of greatest astonishment To generate a diff of this commit: cvs rdiff -u -r1.176 -r1.177 src/sys/miscfs/genfs/genfs_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/miscfs/genfs/genfs_vnops.c diff -u src/sys/miscfs/genfs/genfs_vnops.c:1.176 src/sys/miscfs/genfs/genfs_vnops.c:1.177 --- src/sys/miscfs/genfs/genfs_vnops.c:1.176 Wed Jan 27 15:52:31 2010 +++ src/sys/miscfs/genfs/genfs_vnops.c Thu Apr 8 15:56:26 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_vnops.c,v 1.176 2010/01/27 15:52:31 uebayasi Exp $ */ +/* $NetBSD: genfs_vnops.c,v 1.177 2010/04/08 15:56:26 pooka Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: genfs_vnops.c,v 1.176 2010/01/27 15:52:31 uebayasi Exp $); +__KERNEL_RCSID(0, $NetBSD: genfs_vnops.c,v 1.177 2010/04/08 15:56:26 pooka Exp $); #include sys/param.h #include sys/systm.h @@ -170,7 +170,8 @@ /* * Called when an fs doesn't support a particular vop. - * This takes care to vrele, vput, or vunlock passed in vnodes. + * This takes care to vrele, vput, or vunlock passed in vnodes + * and calls VOP_ABORTOP for a componentname (in non-rename VOP). */ int genfs_eopnotsupp(void *v) @@ -181,14 +182,35 @@ } */ *ap = v; struct vnodeop_desc *desc = ap-a_desc; struct vnode *vp, *vp_last = NULL; - int flags, i, j, offset; + int flags, i, j, offset_cnp, offset_vp; + + KASSERT(desc-vdesc_offset != VOP_LOOKUP_DESCOFFSET); + KASSERT(desc-vdesc_offset != VOP_ABORTOP_DESCOFFSET); + + /* + * Free componentname that lookup potentially SAVENAMEd. + * + * As is logical, componentnames for VOP_RENAME are handled by + * the caller of VOP_RENAME. Yay, rename! + */ + if (desc-vdesc_offset != VOP_RENAME_DESCOFFSET + (offset_vp = desc-vdesc_vp_offsets[0]) != VDESC_NO_OFFSET + (offset_cnp = desc-vdesc_componentname_offset) != VDESC_NO_OFFSET){ + struct componentname *cnp; + struct vnode *dvp; + + dvp = *VOPARG_OFFSETTO(struct vnode **, offset_vp, ap); + cnp = *VOPARG_OFFSETTO(struct componentname **, offset_cnp, ap); + + VOP_ABORTOP(dvp, cnp); + } flags = desc-vdesc_flags; for (i = 0; i VDESC_MAX_VPS; flags =1, i++) { - if ((offset = desc-vdesc_vp_offsets[i]) == VDESC_NO_OFFSET) + if ((offset_vp = desc-vdesc_vp_offsets[i]) == VDESC_NO_OFFSET) break; /* stop at end of list */ if ((j = flags VDESC_VP0_WILLPUT)) { - vp = *VOPARG_OFFSETTO(struct vnode **, offset, ap); + vp = *VOPARG_OFFSETTO(struct vnode **, offset_vp, ap); /* Skip if NULL */ if (!vp)
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: uebayasi Date: Sat Jan 30 12:06:20 UTC 2010 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: Reduce the diff between genfs_getpages() and genfs_do_io(). These should be merged eventually. To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.35 src/sys/miscfs/genfs/genfs_io.c:1.36 --- src/sys/miscfs/genfs/genfs_io.c:1.35 Sat Jan 30 05:19:20 2010 +++ src/sys/miscfs/genfs/genfs_io.c Sat Jan 30 12:06:20 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.35 2010/01/30 05:19:20 uebayasi Exp $ */ +/* $NetBSD: genfs_io.c,v 1.36 2010/01/30 12:06:20 uebayasi Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.35 2010/01/30 05:19:20 uebayasi Exp $); +__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.36 2010/01/30 12:06:20 uebayasi Exp $); #include sys/param.h #include sys/systm.h @@ -490,8 +490,9 @@ error = VOP_BMAP(vp, lbn, devvp, blkno, run); if (error) { UVMHIST_LOG(ubchist, VOP_BMAP lbn 0x%x - %d\n, - lbn, error,0,0); + lbn,error,0,0); skipbytes += bytes; + bytes = 0; goto loopdone; } @@ -521,7 +522,7 @@ * mark the pages we zeroed PG_RDONLY. */ - if (blkno 0) { + if (blkno == (daddr_t)-1) { int holepages = (round_page(offset + iobytes) - trunc_page(offset)) PAGE_SHIFT; UVMHIST_LOG(ubchist, lbn 0x%x - HOLE, lbn,0,0,0); @@ -551,6 +552,8 @@ if (offset == startoffset iobytes == bytes) { bp = mbp; } else { + UVMHIST_LOG(ubchist, vp %p bp %p num now %d, + vp, bp, vp-v_numoutput, 0); bp = getiobuf(vp, true); nestiobuf_setup(mbp, bp, offset - startoffset, iobytes); } @@ -562,7 +565,7 @@ UVMHIST_LOG(ubchist, bp %p offset 0x%x bcount 0x%x blkno 0x%x, - bp, offset, iobytes, bp-b_blkno); + bp, offset, bp-b_bcount, bp-b_blkno); VOP_STRATEGY(devvp, bp); } @@ -1283,13 +1286,11 @@ genfs_do_io(struct vnode *vp, off_t off, vaddr_t kva, size_t len, int flags, enum uio_rw rw, void (*iodone)(struct buf *)) { - int s, error, run; + int s, error; int fs_bshift, dev_bshift; off_t eof, offset, startoffset; size_t bytes, iobytes, skipbytes; - daddr_t lbn, blkno; struct buf *mbp, *bp; - struct vnode *devvp; const bool async = (flags PGO_SYNCIO) == 0; const bool iowrite = rw == UIO_WRITE; const int brw = iowrite ? B_WRITE : B_READ; @@ -1343,27 +1344,56 @@ for (offset = startoffset; bytes 0; offset += iobytes, bytes -= iobytes) { + int run; + daddr_t lbn, blkno; + struct vnode *devvp; + + /* + * bmap the file to find out the blkno to read from and + * how much we can read in one i/o. if bmap returns an error, + * skip the rest of the top-level i/o. + */ + lbn = offset fs_bshift; error = VOP_BMAP(vp, lbn, devvp, blkno, run); if (error) { - UVMHIST_LOG(ubchist, VOP_BMAP() - %d, error,0,0,0); + UVMHIST_LOG(ubchist, VOP_BMAP lbn 0x%x - %d\n, + lbn,error,0,0); skipbytes += bytes; bytes = 0; - break; + goto loopdone; } + /* + * see how many pages can be read with this i/o. + * reduce the i/o size if necessary to avoid + * overwriting pages with valid data. + */ + iobytes = MINoff_t)lbn + 1 + run) fs_bshift) - offset, bytes); + + /* + * if this block isn't allocated, zero it instead of + * reading it. unless we are going to allocate blocks, + * mark the pages we zeroed PG_RDONLY. + */ + if (blkno == (daddr_t)-1) { if (!iowrite) { memset((char *)kva + (offset - startoffset), 0, - iobytes); +iobytes); } skipbytes += iobytes; continue; } - /* if it's really one i/o, don't make a second buf */ + /* + * allocate a sub-buf for this piece of the i/o + * (or just use mbp if there's only 1 piece), + * and start it going. + */ + if (offset == startoffset iobytes == bytes) { bp = mbp; } else { @@ -1377,12 +1407,15 @@ /* adjust physical blkno for partial blocks */ bp-b_blkno = blkno + ((offset - ((off_t)lbn fs_bshift)) dev_bshift); + UVMHIST_LOG(ubchist, - vp %p offset 0x%x bcount 0x%x blkno 0x%x, - vp, offset, bp-b_bcount, bp-b_blkno); + bp %p offset 0x%x bcount 0x%x blkno 0x%x, + bp, offset, bp-b_bcount, bp-b_blkno); VOP_STRATEGY(devvp, bp); } + +loopdone: if (skipbytes) { UVMHIST_LOG(ubchist, skipbytes %d, skipbytes, 0,0,0); }
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: uebayasi Date: Sat Jan 30 05:19:20 UTC 2010 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: Slightly more descriptive local variable names. To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.34 src/sys/miscfs/genfs/genfs_io.c:1.35 --- src/sys/miscfs/genfs/genfs_io.c:1.34 Fri Jan 29 04:36:20 2010 +++ src/sys/miscfs/genfs/genfs_io.c Sat Jan 30 05:19:20 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.34 2010/01/29 04:36:20 uebayasi Exp $ */ +/* $NetBSD: genfs_io.c,v 1.35 2010/01/30 05:19:20 uebayasi Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.34 2010/01/29 04:36:20 uebayasi Exp $); +__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.35 2010/01/30 05:19:20 uebayasi Exp $); #include sys/param.h #include sys/systm.h @@ -113,10 +113,10 @@ struct uvm_object * const uobj = vp-v_uobj; kauth_cred_t const cred = curlwp-l_cred; /* XXXUBC curlwp */ const bool async = (flags PGO_SYNCIO) == 0; - const bool write = (ap-a_access_type VM_PROT_WRITE) != 0; + const bool memwrite = (ap-a_access_type VM_PROT_WRITE) != 0; bool has_trans = false; const bool overwrite = (flags PGO_OVERWRITE) != 0; - const bool blockalloc = write (flags PGO_NOBLOCKALLOC) == 0; + const bool blockalloc = memwrite (flags PGO_NOBLOCKALLOC) == 0; UVMHIST_FUNC(genfs_getpages); UVMHIST_CALLED(ubchist); UVMHIST_LOG(ubchist, vp %p off 0x%x/%x count %d, @@ -178,7 +178,7 @@ if ((vp-v_mount-mnt_flag MNT_NOATIME) == 0) { updflags = GOP_UPDATE_ACCESSED; } - if (write) { + if (memwrite) { updflags |= GOP_UPDATE_MODIFIED; } if (updflags != 0) { @@ -186,7 +186,7 @@ } } - if (write) { + if (memwrite) { gp-g_dirtygen++; if ((vp-v_iflag VI_ONWORKLST) == 0) { vn_syncer_add_to_worklist(vp, filedelay); @@ -212,7 +212,7 @@ } #endif /* defined(DEBUG) */ nfound = uvn_findpages(uobj, origoffset, npages, - ap-a_m, UFP_NOWAIT|UFP_NOALLOC|(write ? UFP_NORDONLY : 0)); + ap-a_m, UFP_NOWAIT|UFP_NOALLOC|(memwrite ? UFP_NORDONLY : 0)); KASSERT(npages == *ap-a_count); if (nfound == 0) { error = EBUSY; @@ -532,7 +532,7 @@ skipbytes += iobytes; for (i = 0; i holepages; i++) { -if (write) { +if (memwrite) { pgs[pidx + i]-flags = ~PG_CLEAN; } if (!blockalloc) { @@ -672,7 +672,7 @@ pg-flags = ~(PG_FAKE); pmap_clear_modify(pgs[i]); } - KASSERT(!write || !blockalloc || (pg-flags PG_RDONLY) == 0); + KASSERT(!memwrite || !blockalloc || (pg-flags PG_RDONLY) == 0); if (i ridx || i = ridx + orignmempages || async) { UVMHIST_LOG(ubchist, unbusy pg %p offset 0x%x, pg, pg-offset,0,0); @@ -1290,9 +1290,9 @@ daddr_t lbn, blkno; struct buf *mbp, *bp; struct vnode *devvp; - bool async = (flags PGO_SYNCIO) == 0; - bool write = rw == UIO_WRITE; - int brw = write ? B_WRITE : B_READ; + const bool async = (flags PGO_SYNCIO) == 0; + const bool iowrite = rw == UIO_WRITE; + const int brw = iowrite ? B_WRITE : B_READ; UVMHIST_FUNC(__func__); UVMHIST_CALLED(ubchist); UVMHIST_LOG(ubchist, vp %p kva %p len 0x%x flags 0x%x, @@ -1313,7 +1313,7 @@ skipbytes = 0; KASSERT(bytes != 0); - if (write) { + if (iowrite) { mutex_enter(vp-v_interlock); vp-v_numoutput += 2; mutex_exit(vp-v_interlock); @@ -1355,7 +1355,7 @@ iobytes = MINoff_t)lbn + 1 + run) fs_bshift) - offset, bytes); if (blkno == (daddr_t)-1) { - if (!write) { + if (!iowrite) { memset((char *)kva + (offset - startoffset), 0, iobytes); } @@ -1423,19 +1423,19 @@ struct iovec iov; struct uio uio; kauth_cred_t cred = curlwp-l_cred; - bool write = (ap-a_access_type VM_PROT_WRITE) != 0; + const bool memwrite = (ap-a_access_type VM_PROT_WRITE) != 0; error = 0; origoffset = ap-a_offset; orignpages = *ap-a_count; pgs = ap-a_m; - if (write (vp-v_iflag VI_ONWORKLST) == 0) { + if (memwrite (vp-v_iflag VI_ONWORKLST) == 0) { vn_syncer_add_to_worklist(vp, filedelay); } if (ap-a_flags PGO_LOCKED) { uvn_findpages(uobj, origoffset, ap-a_count, ap-a_m, - UFP_NOWAIT|UFP_NOALLOC| (write ? UFP_NORDONLY : 0)); + UFP_NOWAIT|UFP_NOALLOC| (memwrite ? UFP_NORDONLY : 0)); return (ap-a_m[ap-a_centeridx] == NULL ? EBUSY : 0); }
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: uebayasi Date: Thu Jan 28 08:02:12 UTC 2010 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: genfs_getpages: Constify orignpages. Don't override its meaning by the value re-calucated from GOP_SIZE(GOP_SIZE_MEM), but assign another variable (orignmempages). To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.28 src/sys/miscfs/genfs/genfs_io.c:1.29 --- src/sys/miscfs/genfs/genfs_io.c:1.28 Thu Jan 28 07:49:08 2010 +++ src/sys/miscfs/genfs/genfs_io.c Thu Jan 28 08:02:12 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.28 2010/01/28 07:49:08 uebayasi Exp $ */ +/* $NetBSD: genfs_io.c,v 1.29 2010/01/28 08:02:12 uebayasi Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.28 2010/01/28 07:49:08 uebayasi Exp $); +__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.29 2010/01/28 08:02:12 uebayasi Exp $); #include sys/param.h #include sys/systm.h @@ -107,7 +107,7 @@ off_t diskeof, memeof; off_t startoffset, endoffset; - int i, error, npages, orignpages, npgs, run, ridx; + int i, error, npages, npgs, run, ridx; const int flags = ap-a_flags; struct vnode * const vp = ap-a_vp; struct genfs_node * const gp = VTOG(vp); @@ -135,7 +135,7 @@ error = 0; const voff_t origvsize = vp-v_size; const off_t origoffset = ap-a_offset; - orignpages = *ap-a_count; + const int orignpages = *ap-a_count; GOP_SIZE(vp, origvsize, diskeof, 0); if (flags PGO_PASTEOF) { off_t newsize; @@ -255,9 +255,9 @@ vp-v_mount-mnt_dev_bshift : DEV_BSHIFT; const int fs_bsize = 1 fs_bshift; - orignpages = MIN(orignpages, + const int orignmempages = MIN(orignpages, round_page(memeof - origoffset) PAGE_SHIFT); - npages = orignpages; + npages = orignmempages; startoffset = origoffset ~(fs_bsize - 1); endoffset = round_page((origoffset + (npages PAGE_SHIFT) + fs_bsize - 1) ~(fs_bsize - 1)); @@ -307,10 +307,10 @@ } if (uvn_findpages(uobj, origoffset, npages, pgs[ridx], - async ? UFP_NOWAIT : UFP_ALL) != orignpages) { + async ? UFP_NOWAIT : UFP_ALL) != orignmempages) { genfs_node_unlock(vp); KASSERT(async != 0); - genfs_rel_pages(pgs[ridx], orignpages); + genfs_rel_pages(pgs[ridx], orignmempages); mutex_exit(uobj-vmobjlock); error = EBUSY; goto out_err; @@ -365,7 +365,7 @@ */ npages = (endoffset - startoffset) PAGE_SHIFT; - if (startoffset != origoffset || npages != orignpages) { + if (startoffset != origoffset || npages != orignmempages) { /* * we need to avoid deadlocks caused by locking @@ -373,7 +373,7 @@ * already have locked. unlock them all and start over. */ - genfs_rel_pages(pgs[ridx], orignpages); + genfs_rel_pages(pgs[ridx], orignmempages); memset(pgs, 0, pgs_size); UVMHIST_LOG(ubchist, reset npages start 0x%x end 0x%x, @@ -666,7 +666,7 @@ pmap_clear_modify(pgs[i]); } KASSERT(!write || !blockalloc || (pg-flags PG_RDONLY) == 0); - if (i ridx || i = ridx + orignpages || async) { + if (i ridx || i = ridx + orignmempages || async) { UVMHIST_LOG(ubchist, unbusy pg %p offset 0x%x, pg, pg-offset,0,0); if (pg-flags PG_WANTED) { @@ -689,7 +689,7 @@ mutex_exit(uobj-vmobjlock); if (ap-a_m != NULL) { memcpy(ap-a_m, pgs[ridx], - orignpages * sizeof(struct vm_page *)); + orignmempages * sizeof(struct vm_page *)); } out_err:
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: uebayasi Date: Thu Jan 28 08:20:00 UTC 2010 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: genfs_getpages: Constify 2 variables, move one. No functional changes. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.29 src/sys/miscfs/genfs/genfs_io.c:1.30 --- src/sys/miscfs/genfs/genfs_io.c:1.29 Thu Jan 28 08:02:12 2010 +++ src/sys/miscfs/genfs/genfs_io.c Thu Jan 28 08:20:00 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.29 2010/01/28 08:02:12 uebayasi Exp $ */ +/* $NetBSD: genfs_io.c,v 1.30 2010/01/28 08:20:00 uebayasi Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.29 2010/01/28 08:02:12 uebayasi Exp $); +__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.30 2010/01/28 08:20:00 uebayasi Exp $); #include sys/param.h #include sys/systm.h @@ -106,8 +106,7 @@ } */ * const ap = v; off_t diskeof, memeof; - off_t startoffset, endoffset; - int i, error, npages, npgs, run, ridx; + int i, error, npages, npgs, ridx; const int flags = ap-a_flags; struct vnode * const vp = ap-a_vp; struct genfs_node * const gp = VTOG(vp); @@ -254,14 +253,17 @@ const int dev_bshift = (vp-v_type != VBLK) ? vp-v_mount-mnt_dev_bshift : DEV_BSHIFT; const int fs_bsize = 1 fs_bshift; +#define blk_mask (fs_bsize - 1) +#define trunc_blk(x) ((x) ~blk_mask) +#define round_blk(x) (((x) + blk_mask) ~blk_mask) const int orignmempages = MIN(orignpages, round_page(memeof - origoffset) PAGE_SHIFT); npages = orignmempages; - startoffset = origoffset ~(fs_bsize - 1); - endoffset = round_page((origoffset + (npages PAGE_SHIFT) + - fs_bsize - 1) ~(fs_bsize - 1)); - endoffset = MIN(endoffset, round_page(memeof)); + const off_t startoffset = trunc_blk(origoffset); + const off_t endoffset = MIN( + round_page(round_blk(origoffset + (npages PAGE_SHIFT))), + round_page(memeof)); ridx = (origoffset - startoffset) PAGE_SHIFT; pgs_size = sizeof(struct vm_page *) * @@ -278,7 +280,6 @@ (void)memset(pgs, 0, pgs_size); } - UVMHIST_LOG(ubchist, ridx %d npages %d startoff %ld endoff %ld, ridx, npages, startoffset, endoffset); @@ -449,6 +450,7 @@ for (offset = startoffset; bytes 0; offset += iobytes, bytes -= iobytes) { + int run; daddr_t lbn, blkno; int pidx; struct vnode *devvp;
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: uebayasi Date: Thu Jan 28 13:43:53 UTC 2010 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: genfs_getpages: More constification localization. To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.30 src/sys/miscfs/genfs/genfs_io.c:1.31 --- src/sys/miscfs/genfs/genfs_io.c:1.30 Thu Jan 28 08:20:00 2010 +++ src/sys/miscfs/genfs/genfs_io.c Thu Jan 28 13:43:53 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.30 2010/01/28 08:20:00 uebayasi Exp $ */ +/* $NetBSD: genfs_io.c,v 1.31 2010/01/28 13:43:53 uebayasi Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.30 2010/01/28 08:20:00 uebayasi Exp $); +__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.31 2010/01/28 13:43:53 uebayasi Exp $); #include sys/param.h #include sys/systm.h @@ -106,14 +106,12 @@ } */ * const ap = v; off_t diskeof, memeof; - int i, error, npages, npgs, ridx; + int i, error, npages; const int flags = ap-a_flags; struct vnode * const vp = ap-a_vp; struct genfs_node * const gp = VTOG(vp); struct uvm_object * const uobj = vp-v_uobj; - struct vm_page *pg, **pgs, *pgs_onstack[UBC_MAX_PAGES]; - int pgs_size; - kauth_cred_t cred = curlwp-l_cred; /* XXXUBC curlwp */ + kauth_cred_t const cred = curlwp-l_cred; /* XXXUBC curlwp */ const bool async = (flags PGO_SYNCIO) == 0; const bool write = (ap-a_access_type VM_PROT_WRITE) != 0; bool has_trans = false; @@ -127,9 +125,6 @@ KASSERT(vp-v_type == VREG || vp-v_type == VDIR || vp-v_type == VLNK || vp-v_type == VBLK); - pgs = NULL; - pgs_size = 0; - startover: error = 0; const voff_t origvsize = vp-v_size; @@ -206,6 +201,7 @@ if (flags PGO_LOCKED) { int nfound; + struct vm_page *pg; npages = *ap-a_count; #if defined(DEBUG) @@ -264,16 +260,18 @@ const off_t endoffset = MIN( round_page(round_blk(origoffset + (npages PAGE_SHIFT))), round_page(memeof)); - ridx = (origoffset - startoffset) PAGE_SHIFT; + const int ridx = (origoffset - startoffset) PAGE_SHIFT; - pgs_size = sizeof(struct vm_page *) * + const int pgs_size = sizeof(struct vm_page *) * ((endoffset - startoffset) PAGE_SHIFT); + struct vm_page **pgs, *pgs_onstack[UBC_MAX_PAGES]; + if (pgs_size sizeof(pgs_onstack)) { pgs = kmem_zalloc(pgs_size, async ? KM_NOSLEEP : KM_SLEEP); if (pgs == NULL) { pgs = pgs_onstack; error = ENOMEM; - goto out_err; + goto out_err1; } } else { pgs = pgs_onstack; @@ -314,7 +312,7 @@ genfs_rel_pages(pgs[ridx], orignmempages); mutex_exit(uobj-vmobjlock); error = EBUSY; - goto out_err; + goto out_err1; } /* @@ -322,10 +320,10 @@ */ for (i = 0; i npages; i++) { - struct vm_page *pg1 = pgs[ridx + i]; + struct vm_page *pg = pgs[ridx + i]; - if ((pg1-flags PG_FAKE) || - (blockalloc (pg1-flags PG_RDONLY))) { + if ((pg-flags PG_FAKE) || + (blockalloc (pg-flags PG_RDONLY))) { break; } } @@ -345,9 +343,9 @@ UVMHIST_LOG(ubchist, PGO_OVERWRITE,0,0,0,0); for (i = 0; i npages; i++) { - struct vm_page *pg1 = pgs[ridx + i]; + struct vm_page *pg = pgs[ridx + i]; - pg1-flags = ~(PG_RDONLY|PG_CLEAN); + pg-flags = ~(PG_RDONLY|PG_CLEAN); } npages += ridx; goto out; @@ -367,6 +365,7 @@ npages = (endoffset - startoffset) PAGE_SHIFT; if (startoffset != origoffset || npages != orignmempages) { + int npgs; /* * we need to avoid deadlocks caused by locking @@ -387,7 +386,7 @@ genfs_rel_pages(pgs, npages); mutex_exit(uobj-vmobjlock); error = EBUSY; - goto out_err; + goto out_err1; } } mutex_exit(uobj-vmobjlock); @@ -572,7 +571,7 @@ UVMHIST_LOG(ubchist, returning 0 (async),0,0,0,0); genfs_node_unlock(vp); error = 0; - goto out_err; + goto out_err1; } if (bp != NULL) { error = biowait(mbp); @@ -610,12 +609,14 @@ startoffset, npages PAGE_SHIFT, error,0); if (!error) { for (i = 0; i npages; i++) { -if (pgs[i] == NULL) { +struct vm_page *pg = pgs[i]; + +if (pg == NULL) { continue; } -pgs[i]-flags = ~(PG_CLEAN|PG_RDONLY); +pg-flags = ~(PG_CLEAN|PG_RDONLY); UVMHIST_LOG(ubchist, mark dirty pg %p, -pgs[i],0,0,0); +pg,0,0,0); } } } @@ -634,13 +635,15 @@ if (error) { for (i = 0; i npages; i++) { - if (pgs[i] == NULL) { + struct vm_page *pg = pgs[i]; + + if (pg == NULL) { continue; } UVMHIST_LOG(ubchist, examining pg %p flags 0x%x, - pgs[i], pgs[i]-flags, 0,0); - if (pgs[i]-flags PG_FAKE) { -pgs[i]-flags |= PG_RELEASED; + pg, pg-flags, 0,0); + if (pg-flags PG_FAKE) { +pg-flags |=
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: uebayasi Date: Thu Jan 28 14:25:17 UTC 2010 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: Revert part which variable initializations within interleaved gotos. again: if (...) goto err; void *ptr = alloc(); if (...) goto again; if (...) goto err1; ... err1: if (ptr) free(ptr); err: return; This leaks memory if exited with goto again; - goto err;. To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.31 src/sys/miscfs/genfs/genfs_io.c:1.32 --- src/sys/miscfs/genfs/genfs_io.c:1.31 Thu Jan 28 13:43:53 2010 +++ src/sys/miscfs/genfs/genfs_io.c Thu Jan 28 14:25:17 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.31 2010/01/28 13:43:53 uebayasi Exp $ */ +/* $NetBSD: genfs_io.c,v 1.32 2010/01/28 14:25:17 uebayasi Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.31 2010/01/28 13:43:53 uebayasi Exp $); +__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.32 2010/01/28 14:25:17 uebayasi Exp $); #include sys/param.h #include sys/systm.h @@ -111,6 +111,8 @@ struct vnode * const vp = ap-a_vp; struct genfs_node * const gp = VTOG(vp); struct uvm_object * const uobj = vp-v_uobj; + struct vm_page **pgs, *pgs_onstack[UBC_MAX_PAGES]; + int pgs_size; kauth_cred_t const cred = curlwp-l_cred; /* XXXUBC curlwp */ const bool async = (flags PGO_SYNCIO) == 0; const bool write = (ap-a_access_type VM_PROT_WRITE) != 0; @@ -125,6 +127,9 @@ KASSERT(vp-v_type == VREG || vp-v_type == VDIR || vp-v_type == VLNK || vp-v_type == VBLK); + pgs = NULL; + pgs_size = 0; + startover: error = 0; const voff_t origvsize = vp-v_size; @@ -262,16 +267,15 @@ round_page(memeof)); const int ridx = (origoffset - startoffset) PAGE_SHIFT; - const int pgs_size = sizeof(struct vm_page *) * + pgs_size = sizeof(struct vm_page *) * ((endoffset - startoffset) PAGE_SHIFT); - struct vm_page **pgs, *pgs_onstack[UBC_MAX_PAGES]; if (pgs_size sizeof(pgs_onstack)) { pgs = kmem_zalloc(pgs_size, async ? KM_NOSLEEP : KM_SLEEP); if (pgs == NULL) { pgs = pgs_onstack; error = ENOMEM; - goto out_err1; + goto out_err; } } else { pgs = pgs_onstack; @@ -312,7 +316,7 @@ genfs_rel_pages(pgs[ridx], orignmempages); mutex_exit(uobj-vmobjlock); error = EBUSY; - goto out_err1; + goto out_err; } /* @@ -386,7 +390,7 @@ genfs_rel_pages(pgs, npages); mutex_exit(uobj-vmobjlock); error = EBUSY; - goto out_err1; + goto out_err; } } mutex_exit(uobj-vmobjlock); @@ -571,7 +575,7 @@ UVMHIST_LOG(ubchist, returning 0 (async),0,0,0,0); genfs_node_unlock(vp); error = 0; - goto out_err1; + goto out_err; } if (bp != NULL) { error = biowait(mbp); @@ -651,7 +655,7 @@ mutex_exit(uvm_pageqlock); mutex_exit(uobj-vmobjlock); UVMHIST_LOG(ubchist, returning error %d, error,0,0,0); - goto out_err1; + goto out_err; } } @@ -697,10 +701,9 @@ orignmempages * sizeof(struct vm_page *)); } -out_err1: +out_err: if (pgs != NULL pgs != pgs_onstack) kmem_free(pgs, pgs_size); -out_err: if (has_trans) fstrans_done(vp-v_mount); return (error);
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: uebayasi Date: Fri Jan 29 04:33:37 UTC 2010 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: genfs_getpages: Redo previous with a better goto label. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.32 src/sys/miscfs/genfs/genfs_io.c:1.33 --- src/sys/miscfs/genfs/genfs_io.c:1.32 Thu Jan 28 14:25:17 2010 +++ src/sys/miscfs/genfs/genfs_io.c Fri Jan 29 04:33:37 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.32 2010/01/28 14:25:17 uebayasi Exp $ */ +/* $NetBSD: genfs_io.c,v 1.33 2010/01/29 04:33:37 uebayasi Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.32 2010/01/28 14:25:17 uebayasi Exp $); +__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.33 2010/01/29 04:33:37 uebayasi Exp $); #include sys/param.h #include sys/systm.h @@ -111,8 +111,6 @@ struct vnode * const vp = ap-a_vp; struct genfs_node * const gp = VTOG(vp); struct uvm_object * const uobj = vp-v_uobj; - struct vm_page **pgs, *pgs_onstack[UBC_MAX_PAGES]; - int pgs_size; kauth_cred_t const cred = curlwp-l_cred; /* XXXUBC curlwp */ const bool async = (flags PGO_SYNCIO) == 0; const bool write = (ap-a_access_type VM_PROT_WRITE) != 0; @@ -127,14 +125,12 @@ KASSERT(vp-v_type == VREG || vp-v_type == VDIR || vp-v_type == VLNK || vp-v_type == VBLK); - pgs = NULL; - pgs_size = 0; - startover: error = 0; const voff_t origvsize = vp-v_size; const off_t origoffset = ap-a_offset; const int orignpages = *ap-a_count; + GOP_SIZE(vp, origvsize, diskeof, 0); if (flags PGO_PASTEOF) { off_t newsize; @@ -267,8 +263,9 @@ round_page(memeof)); const int ridx = (origoffset - startoffset) PAGE_SHIFT; - pgs_size = sizeof(struct vm_page *) * + const int pgs_size = sizeof(struct vm_page *) * ((endoffset - startoffset) PAGE_SHIFT); + struct vm_page **pgs, *pgs_onstack[UBC_MAX_PAGES]; if (pgs_size sizeof(pgs_onstack)) { pgs = kmem_zalloc(pgs_size, async ? KM_NOSLEEP : KM_SLEEP); @@ -316,7 +313,7 @@ genfs_rel_pages(pgs[ridx], orignmempages); mutex_exit(uobj-vmobjlock); error = EBUSY; - goto out_err; + goto out_err_free; } /* @@ -390,7 +387,7 @@ genfs_rel_pages(pgs, npages); mutex_exit(uobj-vmobjlock); error = EBUSY; - goto out_err; + goto out_err_free; } } mutex_exit(uobj-vmobjlock); @@ -575,7 +572,7 @@ UVMHIST_LOG(ubchist, returning 0 (async),0,0,0,0); genfs_node_unlock(vp); error = 0; - goto out_err; + goto out_err_free; } if (bp != NULL) { error = biowait(mbp); @@ -655,7 +652,7 @@ mutex_exit(uvm_pageqlock); mutex_exit(uobj-vmobjlock); UVMHIST_LOG(ubchist, returning error %d, error,0,0,0); - goto out_err; + goto out_err_free; } } @@ -701,9 +698,10 @@ orignmempages * sizeof(struct vm_page *)); } -out_err: +out_err_free: if (pgs != NULL pgs != pgs_onstack) kmem_free(pgs, pgs_size); +out_err: if (has_trans) fstrans_done(vp-v_mount); return (error);
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: uebayasi Date: Fri Jan 29 04:36:20 UTC 2010 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: genfs_getpages: Narrow clarify the context where I/O happens vmobjlock is dropped. To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.33 src/sys/miscfs/genfs/genfs_io.c:1.34 --- src/sys/miscfs/genfs/genfs_io.c:1.33 Fri Jan 29 04:33:37 2010 +++ src/sys/miscfs/genfs/genfs_io.c Fri Jan 29 04:36:20 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.33 2010/01/29 04:33:37 uebayasi Exp $ */ +/* $NetBSD: genfs_io.c,v 1.34 2010/01/29 04:36:20 uebayasi Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.33 2010/01/29 04:33:37 uebayasi Exp $); +__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.34 2010/01/29 04:36:20 uebayasi Exp $); #include sys/param.h #include sys/systm.h @@ -352,12 +352,6 @@ goto out; } -{ - size_t bytes, iobytes, tailstart, tailbytes, totalbytes, skipbytes; - vaddr_t kva; - struct buf *bp, *mbp; - bool sawhole = false; - /* * the page wasn't resident and we're not overwriting, * so we're going to have to do some i/o. @@ -390,8 +384,15 @@ goto out_err_free; } } + mutex_exit(uobj-vmobjlock); +{ + size_t bytes, iobytes, tailstart, tailbytes, totalbytes, skipbytes; + vaddr_t kva; + struct buf *bp, *mbp; + bool sawhole = false; + /* * read the desired page(s). */ @@ -624,6 +625,7 @@ genfs_node_unlock(vp); putiobuf(mbp); +} mutex_enter(uobj-vmobjlock); @@ -654,7 +656,6 @@ UVMHIST_LOG(ubchist, returning error %d, error,0,0,0); goto out_err_free; } -} out: UVMHIST_LOG(ubchist, succeeding, npages %d, npages,0,0,0);
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: uebayasi Date: Wed Jan 27 15:18:40 UTC 2010 Modified Files: src/sys/miscfs/genfs: genfs_node.h genfs_vnops.c Log Message: Add genfs_node_rdtrylock(). To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/miscfs/genfs/genfs_node.h cvs rdiff -u -r1.174 -r1.175 src/sys/miscfs/genfs/genfs_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/miscfs/genfs/genfs_node.h diff -u src/sys/miscfs/genfs/genfs_node.h:1.17 src/sys/miscfs/genfs/genfs_node.h:1.18 --- src/sys/miscfs/genfs/genfs_node.h:1.17 Wed May 14 16:49:47 2008 +++ src/sys/miscfs/genfs/genfs_node.h Wed Jan 27 15:18:40 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_node.h,v 1.17 2008/05/14 16:49:47 reinoud Exp $ */ +/* $NetBSD: genfs_node.h,v 1.18 2010/01/27 15:18:40 uebayasi Exp $ */ /* * Copyright (c) 2001 Chuck Silvers. @@ -91,6 +91,7 @@ void genfs_node_wrlock(struct vnode *); void genfs_node_rdlock(struct vnode *); +void genfs_node_rdtrylock(struct vnode *); void genfs_node_unlock(struct vnode *); #endif /* _MISCFS_GENFS_GENFS_NODE_H_ */ Index: src/sys/miscfs/genfs/genfs_vnops.c diff -u src/sys/miscfs/genfs/genfs_vnops.c:1.174 src/sys/miscfs/genfs/genfs_vnops.c:1.175 --- src/sys/miscfs/genfs/genfs_vnops.c:1.174 Fri Nov 20 13:42:43 2009 +++ src/sys/miscfs/genfs/genfs_vnops.c Wed Jan 27 15:18:40 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_vnops.c,v 1.174 2009/11/20 13:42:43 roy Exp $ */ +/* $NetBSD: genfs_vnops.c,v 1.175 2010/01/27 15:18:40 uebayasi Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: genfs_vnops.c,v 1.174 2009/11/20 13:42:43 roy Exp $); +__KERNEL_RCSID(0, $NetBSD: genfs_vnops.c,v 1.175 2010/01/27 15:18:40 uebayasi Exp $); #include sys/param.h #include sys/systm.h @@ -515,6 +515,14 @@ } void +genfs_node_rdtrylock(struct vnode *vp) +{ + struct genfs_node *gp = VTOG(vp); + + rw_tryenter(gp-g_glock, RW_READER); +} + +void genfs_node_unlock(struct vnode *vp) { struct genfs_node *gp = VTOG(vp);
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: uebayasi Date: Wed Jan 27 15:24:54 UTC 2010 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: Constify some pointers in genfs_getpages() and genfs_do_putpages(). To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.21 src/sys/miscfs/genfs/genfs_io.c:1.22 --- src/sys/miscfs/genfs/genfs_io.c:1.21 Wed Oct 21 21:12:06 2009 +++ src/sys/miscfs/genfs/genfs_io.c Wed Jan 27 15:24:54 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.21 2009/10/21 21:12:06 rmind Exp $ */ +/* $NetBSD: genfs_io.c,v 1.22 2010/01/27 15:24:54 uebayasi Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.21 2009/10/21 21:12:06 rmind Exp $); +__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.22 2010/01/27 15:24:54 uebayasi Exp $); #include sys/param.h #include sys/systm.h @@ -103,7 +103,7 @@ vm_prot_t a_access_type; int a_advice; int a_flags; - } */ *ap = v; + } */ * const ap = v; off_t newsize, diskeof, memeof; off_t offset, origoffset, startoffset, endoffset; @@ -114,10 +114,10 @@ size_t bytes, iobytes, tailstart, tailbytes, totalbytes, skipbytes; vaddr_t kva; struct buf *bp, *mbp; - struct vnode *vp = ap-a_vp; + struct vnode * const vp = ap-a_vp; struct vnode *devvp; - struct genfs_node *gp = VTOG(vp); - struct uvm_object *uobj = vp-v_uobj; + struct genfs_node * const gp = VTOG(vp); + struct uvm_object * const uobj = vp-v_uobj; struct vm_page *pg, **pgs, *pgs_onstack[UBC_MAX_PAGES]; int pgs_size; kauth_cred_t cred = curlwp-l_cred; /* XXXUBC curlwp */ @@ -753,7 +753,7 @@ voff_t a_offlo; voff_t a_offhi; int a_flags; - } */ *ap = v; + } */ * const ap = v; return genfs_do_putpages(ap-a_vp, ap-a_offlo, ap-a_offhi, ap-a_flags, NULL); @@ -763,8 +763,8 @@ genfs_do_putpages(struct vnode *vp, off_t startoff, off_t endoff, int origflags, struct vm_page **busypg) { - struct uvm_object *uobj = vp-v_uobj; - kmutex_t *slock = uobj-vmobjlock; + struct uvm_object * const uobj = vp-v_uobj; + kmutex_t * const slock = uobj-vmobjlock; off_t off; /* Even for strange MAXPHYS, the shift rounds down to a page */ #define maxpages (MAXPHYS PAGE_SHIFT) @@ -774,8 +774,8 @@ bool wasclean, by_list, needs_clean, yld; bool async = (origflags PGO_SYNCIO) == 0; bool pagedaemon = curlwp == uvm.pagedaemon_lwp; - struct lwp *l = curlwp ? curlwp : lwp0; - struct genfs_node *gp = VTOG(vp); + struct lwp * const l = curlwp ? curlwp : lwp0; + struct genfs_node * const gp = VTOG(vp); int flags; int dirtygen; bool modified;
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: uebayasi Date: Wed Jan 27 15:53:06 UTC 2010 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: Use genfs_node_*lock(). To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.22 src/sys/miscfs/genfs/genfs_io.c:1.23 --- src/sys/miscfs/genfs/genfs_io.c:1.22 Wed Jan 27 15:24:54 2010 +++ src/sys/miscfs/genfs/genfs_io.c Wed Jan 27 15:53:06 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.22 2010/01/27 15:24:54 uebayasi Exp $ */ +/* $NetBSD: genfs_io.c,v 1.23 2010/01/27 15:53:06 uebayasi Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.22 2010/01/27 15:24:54 uebayasi Exp $); +__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.23 2010/01/27 15:53:06 uebayasi Exp $); #include sys/param.h #include sys/systm.h @@ -229,7 +229,7 @@ error = EBUSY; goto out_err; } - if (!rw_tryenter(gp-g_glock, RW_READER)) { + if (!genfs_node_rdtrylock(vp)) { genfs_rel_pages(ap-a_m, npages); /* @@ -244,7 +244,7 @@ } } } else { - rw_exit(gp-g_glock); + genfs_node_unlock(vp); } error = (ap-a_m[ap-a_centeridx] == NULL ? EBUSY : 0); goto out_err; @@ -310,7 +310,7 @@ } mutex_enter(uobj-vmobjlock); if (vp-v_size origvsize) { - rw_exit(gp-g_glock); + genfs_node_unlock(vp); if (pgs != pgs_onstack) kmem_free(pgs, pgs_size); goto startover; @@ -318,7 +318,7 @@ if (uvn_findpages(uobj, origoffset, npages, pgs[ridx], async ? UFP_NOWAIT : UFP_ALL) != orignpages) { - rw_exit(gp-g_glock); + genfs_node_unlock(vp); KASSERT(async != 0); genfs_rel_pages(pgs[ridx], orignpages); mutex_exit(uobj-vmobjlock); @@ -339,7 +339,7 @@ } } if (i == npages) { - rw_exit(gp-g_glock); + genfs_node_unlock(vp); UVMHIST_LOG(ubchist, returning cached pages, 0,0,0,0); npages += ridx; goto out; @@ -350,7 +350,7 @@ */ if (overwrite) { - rw_exit(gp-g_glock); + genfs_node_unlock(vp); UVMHIST_LOG(ubchist, PGO_OVERWRITE,0,0,0,0); for (i = 0; i npages; i++) { @@ -385,7 +385,7 @@ npgs = npages; if (uvn_findpages(uobj, startoffset, npgs, pgs, async ? UFP_NOWAIT : UFP_ALL) != npages) { - rw_exit(gp-g_glock); + genfs_node_unlock(vp); KASSERT(async != 0); genfs_rel_pages(pgs, npages); mutex_exit(uobj-vmobjlock); @@ -566,7 +566,7 @@ nestiobuf_done(mbp, skipbytes, error); if (async) { UVMHIST_LOG(ubchist, returning 0 (async),0,0,0,0); - rw_exit(gp-g_glock); + genfs_node_unlock(vp); error = 0; goto out_err; } @@ -615,7 +615,7 @@ } } } - rw_exit(gp-g_glock); + genfs_node_unlock(vp); putiobuf(mbp);
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: uebayasi Date: Thu Jan 28 07:24:56 UTC 2010 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: genfs_putpages: Localize a few variables. No functional changes. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.23 src/sys/miscfs/genfs/genfs_io.c:1.24 --- src/sys/miscfs/genfs/genfs_io.c:1.23 Wed Jan 27 15:53:06 2010 +++ src/sys/miscfs/genfs/genfs_io.c Thu Jan 28 07:24:55 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.23 2010/01/27 15:53:06 uebayasi Exp $ */ +/* $NetBSD: genfs_io.c,v 1.24 2010/01/28 07:24:55 uebayasi Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.23 2010/01/27 15:53:06 uebayasi Exp $); +__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.24 2010/01/28 07:24:55 uebayasi Exp $); #include sys/param.h #include sys/systm.h @@ -105,10 +105,10 @@ int a_flags; } */ * const ap = v; - off_t newsize, diskeof, memeof; + off_t diskeof, memeof; off_t offset, origoffset, startoffset, endoffset; daddr_t lbn, blkno; - int i, error, npages, orignpages, npgs, run, ridx, pidx, pcount; + int i, error, npages, orignpages, npgs, run, ridx; int fs_bshift, fs_bsize, dev_bshift; const int flags = ap-a_flags; size_t bytes, iobytes, tailstart, tailbytes, totalbytes, skipbytes; @@ -146,6 +146,7 @@ orignpages = *ap-a_count; GOP_SIZE(vp, origvsize, diskeof, 0); if (flags PGO_PASTEOF) { + off_t newsize; #if defined(DIAGNOSTIC) off_t writeeof; #endif /* defined(DIAGNOSTIC) */ @@ -452,6 +453,7 @@ for (offset = startoffset; bytes 0; offset += iobytes, bytes -= iobytes) { + int pidx; /* * skip pages which don't need to be read. @@ -501,6 +503,8 @@ iobytes = MINoff_t)lbn + 1 + run) fs_bshift) - offset, bytes); if (offset + iobytes round_page(offset)) { + int pcount; + pcount = 1; while (pidx + pcount npages pgs[pidx + pcount]-flags PG_FAKE) {
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: uebayasi Date: Thu Jan 28 07:26:25 UTC 2010 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: genfs_getpages: Localize a few more variables. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.24 src/sys/miscfs/genfs/genfs_io.c:1.25 --- src/sys/miscfs/genfs/genfs_io.c:1.24 Thu Jan 28 07:24:55 2010 +++ src/sys/miscfs/genfs/genfs_io.c Thu Jan 28 07:26:25 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.24 2010/01/28 07:24:55 uebayasi Exp $ */ +/* $NetBSD: genfs_io.c,v 1.25 2010/01/28 07:26:25 uebayasi Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.24 2010/01/28 07:24:55 uebayasi Exp $); +__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.25 2010/01/28 07:26:25 uebayasi Exp $); #include sys/param.h #include sys/systm.h @@ -107,7 +107,6 @@ off_t diskeof, memeof; off_t offset, origoffset, startoffset, endoffset; - daddr_t lbn, blkno; int i, error, npages, orignpages, npgs, run, ridx; int fs_bshift, fs_bsize, dev_bshift; const int flags = ap-a_flags; @@ -453,6 +452,7 @@ for (offset = startoffset; bytes 0; offset += iobytes, bytes -= iobytes) { + daddr_t lbn, blkno; int pidx; /*
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: uebayasi Date: Thu Jan 28 07:38:32 UTC 2010 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: genfs_getpages: Move local variable declarations that are used only for I/O to where they're used. This helps to track what's going in this lengthy function. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.25 src/sys/miscfs/genfs/genfs_io.c:1.26 --- src/sys/miscfs/genfs/genfs_io.c:1.25 Thu Jan 28 07:26:25 2010 +++ src/sys/miscfs/genfs/genfs_io.c Thu Jan 28 07:38:32 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.25 2010/01/28 07:26:25 uebayasi Exp $ */ +/* $NetBSD: genfs_io.c,v 1.26 2010/01/28 07:38:32 uebayasi Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.25 2010/01/28 07:26:25 uebayasi Exp $); +__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.26 2010/01/28 07:38:32 uebayasi Exp $); #include sys/param.h #include sys/systm.h @@ -106,15 +106,11 @@ } */ * const ap = v; off_t diskeof, memeof; - off_t offset, origoffset, startoffset, endoffset; + off_t origoffset, startoffset, endoffset; int i, error, npages, orignpages, npgs, run, ridx; int fs_bshift, fs_bsize, dev_bshift; const int flags = ap-a_flags; - size_t bytes, iobytes, tailstart, tailbytes, totalbytes, skipbytes; - vaddr_t kva; - struct buf *bp, *mbp; struct vnode * const vp = ap-a_vp; - struct vnode *devvp; struct genfs_node * const gp = VTOG(vp); struct uvm_object * const uobj = vp-v_uobj; struct vm_page *pg, **pgs, *pgs_onstack[UBC_MAX_PAGES]; @@ -122,7 +118,6 @@ kauth_cred_t cred = curlwp-l_cred; /* XXXUBC curlwp */ const bool async = (flags PGO_SYNCIO) == 0; const bool write = (ap-a_access_type VM_PROT_WRITE) != 0; - bool sawhole = false; bool has_trans = false; const bool overwrite = (flags PGO_OVERWRITE) != 0; const bool blockalloc = write (flags PGO_NOBLOCKALLOC) == 0; @@ -362,6 +357,12 @@ goto out; } +{ + size_t bytes, iobytes, tailstart, tailbytes, totalbytes, skipbytes; + vaddr_t kva; + struct buf *bp, *mbp; + bool sawhole = false; + /* * the page wasn't resident and we're not overwriting, * so we're going to have to do some i/o. @@ -449,11 +450,12 @@ */ bp = NULL; - for (offset = startoffset; + for (off_t offset = startoffset; bytes 0; offset += iobytes, bytes -= iobytes) { daddr_t lbn, blkno; int pidx; + struct vnode *devvp; /* * skip pages which don't need to be read. @@ -650,6 +652,7 @@ UVMHIST_LOG(ubchist, returning error %d, error,0,0,0); goto out_err; } +} out: UVMHIST_LOG(ubchist, succeeding, npages %d, npages,0,0,0);
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: uebayasi Date: Thu Jan 28 07:44:54 UTC 2010 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: genfs_getpages: Constify localize more variables. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.26 src/sys/miscfs/genfs/genfs_io.c:1.27 --- src/sys/miscfs/genfs/genfs_io.c:1.26 Thu Jan 28 07:38:32 2010 +++ src/sys/miscfs/genfs/genfs_io.c Thu Jan 28 07:44:54 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.26 2010/01/28 07:38:32 uebayasi Exp $ */ +/* $NetBSD: genfs_io.c,v 1.27 2010/01/28 07:44:54 uebayasi Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.26 2010/01/28 07:38:32 uebayasi Exp $); +__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.27 2010/01/28 07:44:54 uebayasi Exp $); #include sys/param.h #include sys/systm.h @@ -106,9 +106,8 @@ } */ * const ap = v; off_t diskeof, memeof; - off_t origoffset, startoffset, endoffset; + off_t startoffset, endoffset; int i, error, npages, orignpages, npgs, run, ridx; - int fs_bshift, fs_bsize, dev_bshift; const int flags = ap-a_flags; struct vnode * const vp = ap-a_vp; struct genfs_node * const gp = VTOG(vp); @@ -121,7 +120,6 @@ bool has_trans = false; const bool overwrite = (flags PGO_OVERWRITE) != 0; const bool blockalloc = write (flags PGO_NOBLOCKALLOC) == 0; - voff_t origvsize; UVMHIST_FUNC(genfs_getpages); UVMHIST_CALLED(ubchist); UVMHIST_LOG(ubchist, vp %p off 0x%x/%x count %d, @@ -135,8 +133,8 @@ startover: error = 0; - origvsize = vp-v_size; - origoffset = ap-a_offset; + const voff_t origvsize = vp-v_size; + const off_t origoffset = ap-a_offset; orignpages = *ap-a_count; GOP_SIZE(vp, origvsize, diskeof, 0); if (flags PGO_PASTEOF) { @@ -251,14 +249,11 @@ * leave space in the page array for a whole block. */ - if (vp-v_type != VBLK) { - fs_bshift = vp-v_mount-mnt_fs_bshift; - dev_bshift = vp-v_mount-mnt_dev_bshift; - } else { - fs_bshift = DEV_BSHIFT; - dev_bshift = DEV_BSHIFT; - } - fs_bsize = 1 fs_bshift; + const int fs_bshift = (vp-v_type != VBLK) ? + vp-v_mount-mnt_fs_bshift : DEV_BSHIFT; + const int dev_bshift = (vp-v_type != VBLK) ? + vp-v_mount-mnt_dev_bshift : DEV_BSHIFT; + const int fs_bsize = 1 fs_bshift; orignpages = MIN(orignpages, round_page(memeof - origoffset) PAGE_SHIFT);
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: uebayasi Date: Thu Jan 28 07:49:08 UTC 2010 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: Unbreak modules build. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/sys/miscfs/genfs/genfs_io.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/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.27 src/sys/miscfs/genfs/genfs_io.c:1.28 --- src/sys/miscfs/genfs/genfs_io.c:1.27 Thu Jan 28 07:44:54 2010 +++ src/sys/miscfs/genfs/genfs_io.c Thu Jan 28 07:49:08 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.27 2010/01/28 07:44:54 uebayasi Exp $ */ +/* $NetBSD: genfs_io.c,v 1.28 2010/01/28 07:49:08 uebayasi Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.27 2010/01/28 07:44:54 uebayasi Exp $); +__KERNEL_RCSID(0, $NetBSD: genfs_io.c,v 1.28 2010/01/28 07:49:08 uebayasi Exp $); #include sys/param.h #include sys/systm.h @@ -445,7 +445,8 @@ */ bp = NULL; - for (off_t offset = startoffset; + off_t offset; + for (offset = startoffset; bytes 0; offset += iobytes, bytes -= iobytes) { daddr_t lbn, blkno;
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: pooka Date: Fri Nov 20 13:19:46 UTC 2009 Modified Files: src/sys/miscfs/genfs: genfs_vnops.c Log Message: Disallow chown for files the caller does not own. To generate a diff of this commit: cvs rdiff -u -r1.172 -r1.173 src/sys/miscfs/genfs/genfs_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/miscfs/genfs/genfs_vnops.c diff -u src/sys/miscfs/genfs/genfs_vnops.c:1.172 src/sys/miscfs/genfs/genfs_vnops.c:1.173 --- src/sys/miscfs/genfs/genfs_vnops.c:1.172 Tue Jun 23 19:36:38 2009 +++ src/sys/miscfs/genfs/genfs_vnops.c Fri Nov 20 13:19:46 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_vnops.c,v 1.172 2009/06/23 19:36:38 elad Exp $ */ +/* $NetBSD: genfs_vnops.c,v 1.173 2009/11/20 13:19:46 pooka Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: genfs_vnops.c,v 1.172 2009/06/23 19:36:38 elad Exp $); +__KERNEL_RCSID(0, $NetBSD: genfs_vnops.c,v 1.173 2009/11/20 13:19:46 pooka Exp $); #include sys/param.h #include sys/systm.h @@ -699,7 +699,7 @@ return (EPERM); } - return (0); + return (EPERM); } /*
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: roy Date: Fri Nov 20 13:42:43 UTC 2009 Modified Files: src/sys/miscfs/genfs: genfs_vnops.c Log Message: Allow chown if caller is in the new group. To generate a diff of this commit: cvs rdiff -u -r1.173 -r1.174 src/sys/miscfs/genfs/genfs_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/miscfs/genfs/genfs_vnops.c diff -u src/sys/miscfs/genfs/genfs_vnops.c:1.173 src/sys/miscfs/genfs/genfs_vnops.c:1.174 --- src/sys/miscfs/genfs/genfs_vnops.c:1.173 Fri Nov 20 13:19:46 2009 +++ src/sys/miscfs/genfs/genfs_vnops.c Fri Nov 20 13:42:43 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_vnops.c,v 1.173 2009/11/20 13:19:46 pooka Exp $ */ +/* $NetBSD: genfs_vnops.c,v 1.174 2009/11/20 13:42:43 roy Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: genfs_vnops.c,v 1.173 2009/11/20 13:19:46 pooka Exp $); +__KERNEL_RCSID(0, $NetBSD: genfs_vnops.c,v 1.174 2009/11/20 13:42:43 roy Exp $); #include sys/param.h #include sys/systm.h @@ -695,8 +695,8 @@ ismember = 0; error = kauth_cred_ismember_gid(cred, new_gid, ismember); - if (error || !ismember) - return (EPERM); + if (!error ismember) + return (0); } return (EPERM);