CVS commit: src/sys/miscfs/genfs

2023-04-09 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Apr  9 12:26:36 UTC 2023

Modified Files:
src/sys/miscfs/genfs: genfs_io.c

Log Message:
genfs: KASSERT(A && B) -> KASSERT(A); KASSERT(B)


To generate a diff of this commit:
cvs rdiff -u -r1.102 -r1.103 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.102 src/sys/miscfs/genfs/genfs_io.c:1.103
--- src/sys/miscfs/genfs/genfs_io.c:1.102	Fri Jan 14 21:59:50 2022
+++ src/sys/miscfs/genfs/genfs_io.c	Sun Apr  9 12:26:36 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_io.c,v 1.102 2022/01/14 21:59:50 riastradh Exp $	*/
+/*	$NetBSD: genfs_io.c,v 1.103 2023/04/09 12:26:36 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.102 2022/01/14 21:59:50 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.103 2023/04/09 12:26:36 riastradh Exp $");
 
 #include 
 #include 
@@ -184,7 +184,8 @@ startover:
 		GOP_SIZE(vp, origvsize, , GOP_SIZE_MEM);
 	}
 	KASSERT(ap->a_centeridx >= 0 || ap->a_centeridx <= orignpages);
-	KASSERT((origoffset & (PAGE_SIZE - 1)) == 0 && origoffset >= 0);
+	KASSERT((origoffset & (PAGE_SIZE - 1)) == 0);
+	KASSERT(origoffset >= 0);
 	KASSERT(orignpages > 0);
 
 	/*
@@ -890,7 +891,8 @@ genfs_do_putpages(struct vnode *vp, off_
 	UVMHIST_FUNC("genfs_putpages"); UVMHIST_CALLED(ubchist);
 
 	KASSERT(origflags & (PGO_CLEANIT|PGO_FREE|PGO_DEACTIVATE));
-	KASSERT((startoff & PAGE_MASK) == 0 && (endoff & PAGE_MASK) == 0);
+	KASSERT((startoff & PAGE_MASK) == 0);
+	KASSERT((endoff & PAGE_MASK) == 0);
 	KASSERT(startoff < endoff || endoff == 0);
 	KASSERT(rw_write_held(slock));
 



CVS commit: src/sys/miscfs/genfs

2023-04-09 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Apr  9 12:26:36 UTC 2023

Modified Files:
src/sys/miscfs/genfs: genfs_io.c

Log Message:
genfs: KASSERT(A && B) -> KASSERT(A); KASSERT(B)


To generate a diff of this commit:
cvs rdiff -u -r1.102 -r1.103 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.



CVS commit: src/sys/miscfs/genfs

2023-03-03 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Mar  3 10:02:51 UTC 2023

Modified Files:
src/sys/miscfs/genfs: genfs_vnops.c

Log Message:
Fix genfs_can_chtimes() to also handle the condition:

  If the time pointer is null, then write permission
  on the file is also sufficient.

>From FreeBSD.

Should fix PR kern/57246 "NFS group permissions regression"


To generate a diff of this commit:
cvs rdiff -u -r1.219 -r1.220 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.219 src/sys/miscfs/genfs/genfs_vnops.c:1.220
--- src/sys/miscfs/genfs/genfs_vnops.c:1.219	Sun Mar 27 17:10:55 2022
+++ src/sys/miscfs/genfs/genfs_vnops.c	Fri Mar  3 10:02:51 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_vnops.c,v 1.219 2022/03/27 17:10:55 christos Exp $	*/
+/*	$NetBSD: genfs_vnops.c,v 1.220 2023/03/03 10:02:51 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.219 2022/03/27 17:10:55 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.220 2023/03/03 10:02:51 hannken Exp $");
 
 #include 
 #include 
@@ -1315,23 +1315,14 @@ genfs_can_chtimes(vnode_t *vp, kauth_cre
 	 * will be allowed to set the times [..] to the current 
 	 * server time.
 	 */
-	if ((error = VOP_ACCESSX(vp, VWRITE_ATTRIBUTES, cred)) != 0)
-		return (vaflags & VA_UTIMES_NULL) == 0 ? EPERM : EACCES;
-
-	/* Must be owner, or... */
-	if (kauth_cred_geteuid(cred) == owner_uid)
-		return (0);
-
-	/* set the times to the current time, and... */
-	if ((vaflags & VA_UTIMES_NULL) == 0)
-		return (EPERM);
+	error = VOP_ACCESSX(vp, VWRITE_ATTRIBUTES, cred);
+	if (error != 0 && (vaflags & VA_UTIMES_NULL) != 0)
+		error = VOP_ACCESS(vp, VWRITE, cred);
 
-	/* have write access. */
-	error = VOP_ACCESS(vp, VWRITE, cred);
 	if (error)
-		return (error);
+		return (vaflags & VA_UTIMES_NULL) == 0 ? EPERM : EACCES;
 
-	return (0);
+	return 0;
 }
 
 /*



CVS commit: src/sys/miscfs/genfs

2023-03-03 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Mar  3 10:02:51 UTC 2023

Modified Files:
src/sys/miscfs/genfs: genfs_vnops.c

Log Message:
Fix genfs_can_chtimes() to also handle the condition:

  If the time pointer is null, then write permission
  on the file is also sufficient.

>From FreeBSD.

Should fix PR kern/57246 "NFS group permissions regression"


To generate a diff of this commit:
cvs rdiff -u -r1.219 -r1.220 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.



CVS commit: src/sys/miscfs/genfs

2022-03-19 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Mar 19 13:52:45 UTC 2022

Modified Files:
src/sys/miscfs/genfs: genfs_vnops.c

Log Message:
Remove now unused genfs_nolock(), genfs_nounlock() and genfs_noislocked().


To generate a diff of this commit:
cvs rdiff -u -r1.216 -r1.217 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.216 src/sys/miscfs/genfs/genfs_vnops.c:1.217
--- src/sys/miscfs/genfs/genfs_vnops.c:1.216	Wed Oct 20 03:08:18 2021
+++ src/sys/miscfs/genfs/genfs_vnops.c	Sat Mar 19 13:52:45 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_vnops.c,v 1.216 2021/10/20 03:08:18 thorpej Exp $	*/
+/*	$NetBSD: genfs_vnops.c,v 1.217 2022/03/19 13:52:45 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.216 2021/10/20 03:08:18 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.217 2022/03/19 13:52:45 hannken Exp $");
 
 #include 
 #include 
@@ -425,30 +425,6 @@ genfs_islocked(void *v)
 	return 0;
 }
 
-/*
- * Stubs to use when there is no locking to be done on the underlying object.
- */
-int
-genfs_nolock(void *v)
-{
-
-	return (0);
-}
-
-int
-genfs_nounlock(void *v)
-{
-
-	return (0);
-}
-
-int
-genfs_noislocked(void *v)
-{
-
-	return (0);
-}
-
 int
 genfs_mmap(void *v)
 {



CVS commit: src/sys/miscfs/genfs

2022-03-19 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Mar 19 13:52:45 UTC 2022

Modified Files:
src/sys/miscfs/genfs: genfs_vnops.c

Log Message:
Remove now unused genfs_nolock(), genfs_nounlock() and genfs_noislocked().


To generate a diff of this commit:
cvs rdiff -u -r1.216 -r1.217 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.



CVS commit: src/sys/miscfs/genfs

2022-01-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Jan 14 21:59:51 UTC 2022

Modified Files:
src/sys/miscfs/genfs: genfs_io.c

Log Message:
genfs(9): Prune dead branch.


To generate a diff of this commit:
cvs rdiff -u -r1.101 -r1.102 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.101 src/sys/miscfs/genfs/genfs_io.c:1.102
--- src/sys/miscfs/genfs/genfs_io.c:1.101	Wed Aug 19 07:29:00 2020
+++ src/sys/miscfs/genfs/genfs_io.c	Fri Jan 14 21:59:50 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_io.c,v 1.101 2020/08/19 07:29:00 simonb Exp $	*/
+/*	$NetBSD: genfs_io.c,v 1.102 2022/01/14 21:59:50 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.101 2020/08/19 07:29:00 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.102 2022/01/14 21:59:50 riastradh Exp $");
 
 #include 
 #include 
@@ -988,11 +988,8 @@ retry:
 	 */
 
 	if (nodirty) {
-#if !defined(DEBUG)
-		if (dirtyonly) {
-			goto skip_scan;
-		}
-#endif /* !defined(DEBUG) */
+		/* We handled the dirtyonly && nodirty case above.  */
+		KASSERT(!dirtyonly);
 		flags &= ~PGO_CLEANIT;
 	}
 
@@ -1331,10 +1328,6 @@ retry:
 		vn_syncer_remove_from_worklist(vp);
 	}
 
-#if !defined(DEBUG)
-skip_scan:
-#endif /* !defined(DEBUG) */
-
 	/* Wait for output to complete. */
 	rw_exit(slock);
 	if (!wasclean && !async && vp->v_numoutput != 0) {



CVS commit: src/sys/miscfs/genfs

2022-01-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Jan 14 21:59:51 UTC 2022

Modified Files:
src/sys/miscfs/genfs: genfs_io.c

Log Message:
genfs(9): Prune dead branch.


To generate a diff of this commit:
cvs rdiff -u -r1.101 -r1.102 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.



CVS commit: src/sys/miscfs/genfs

2021-10-20 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Oct 20 13:29:06 UTC 2021

Modified Files:
src/sys/miscfs/genfs: genfs_rename.c

Log Message:
Don't use genfs_rename_knote() in the "rename foo over hard-link to itself"
case, which simply results in removing the "from" name; there are assertions
in genfs_rename_knote() that are too strong for that case.

PR kern/56460


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 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.6 src/sys/miscfs/genfs/genfs_rename.c:1.7
--- src/sys/miscfs/genfs/genfs_rename.c:1.6	Wed Oct 20 03:08:18 2021
+++ src/sys/miscfs/genfs/genfs_rename.c	Wed Oct 20 13:29:06 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_rename.c,v 1.6 2021/10/20 03:08:18 thorpej Exp $	*/
+/*	$NetBSD: genfs_rename.c,v 1.7 2021/10/20 13:29:06 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfs_rename.c,v 1.6 2021/10/20 03:08:18 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_rename.c,v 1.7 2021/10/20 13:29:06 thorpej Exp $");
 
 #include 
 #include 
@@ -312,10 +312,14 @@ genfs_sane_rename(const struct genfs_ren
 			fcnp->cn_namelen) == 0))
 			/* Renaming an entry over itself does nothing.  */
 			error = 0;
-		else
+		else {
 			/* XXX Can't use VOP_REMOVE because of locking.  */
 			error = genfs_rename_remove(ops, mp, cred,
 			fdvp, fcnp, fde, fvp, _new_nlink);
+			VN_KNOTE(fdvp, NOTE_WRITE);
+			VN_KNOTE(fvp,
+			tvp_new_nlink == 0 ? NOTE_DELETE : NOTE_LINK);
+		}
 		goto out;
 	}
 	KASSERT(fvp != tvp);
@@ -370,10 +374,9 @@ genfs_sane_rename(const struct genfs_ren
 		goto out;
 
 	/* Success!  */
+	genfs_rename_knote(fdvp, fvp, tdvp, tvp, tvp_new_nlink);
 
-out:	if (error == 0) {
-		genfs_rename_knote(fdvp, fvp, tdvp, tvp, tvp_new_nlink);
-	}
+out:
 	genfs_rename_exit(ops, mp, fdvp, fvp, tdvp, tvp);
 	return error;
 }



CVS commit: src/sys/miscfs/genfs

2021-10-20 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Oct 20 13:29:06 UTC 2021

Modified Files:
src/sys/miscfs/genfs: genfs_rename.c

Log Message:
Don't use genfs_rename_knote() in the "rename foo over hard-link to itself"
case, which simply results in removing the "from" name; there are assertions
in genfs_rename_knote() that are too strong for that case.

PR kern/56460


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 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.



CVS commit: src/sys/miscfs/genfs

2020-08-10 Thread Rin Okuyama
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

2020-08-10 Thread Rin Okuyama
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.



CVS commit: src/sys/miscfs/genfs

2020-08-07 Thread Christos Zoulas
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

2020-08-07 Thread Christos Zoulas
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.



CVS commit: src/sys/miscfs/genfs

2020-06-13 Thread Andrew Doran
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.



CVS commit: src/sys/miscfs/genfs

2020-06-13 Thread Andrew Doran
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

2020-05-20 Thread Christos Zoulas
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

2020-05-20 Thread Christos Zoulas
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.



CVS commit: src/sys/miscfs/genfs

2020-05-18 Thread Christos Zoulas
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.



CVS commit: src/sys/miscfs/genfs

2020-05-18 Thread Christos Zoulas
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

2020-05-18 Thread Christos Zoulas
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

2020-05-18 Thread Christos Zoulas
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.



CVS commit: src/sys/miscfs/genfs

2020-04-25 Thread Christos Zoulas
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

2020-04-25 Thread Christos Zoulas
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.



CVS commit: src/sys/miscfs/genfs

2020-03-14 Thread Andrew Doran
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

2020-03-14 Thread Andrew Doran
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.



CVS commit: src/sys/miscfs/genfs

2020-03-14 Thread Andrew Doran
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

2020-03-14 Thread Andrew Doran
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.



CVS commit: src/sys/miscfs/genfs

2020-03-14 Thread Andrew Doran
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

2020-03-14 Thread Andrew Doran
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.



CVS commit: src/sys/miscfs/genfs

2020-02-24 Thread Andrew Doran
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

2020-02-24 Thread Andrew Doran
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.



CVS commit: src/sys/miscfs/genfs

2019-12-16 Thread Andrew Doran
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

2019-12-16 Thread Andrew Doran
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.



CVS commit: src/sys/miscfs/genfs

2019-12-16 Thread Andrew Doran
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.



CVS commit: src/sys/miscfs/genfs

2019-12-16 Thread Andrew Doran
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

2019-12-15 Thread Andrew Doran
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.



CVS commit: src/sys/miscfs/genfs

2019-12-15 Thread Andrew Doran
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

2019-07-11 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Jul 11 16:59:14 UTC 2019

Modified Files:
src/sys/miscfs/genfs: genfs_io.c

Log Message:
Fix (harmless) uninitialized variable: 'pg' could be 'endm', in which case
'pg->uobject' would not be initialized. Just invert the two last conditions
of the KASSERT.

ok hannken@


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 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.



CVS commit: src/sys/miscfs/genfs

2019-07-11 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Jul 11 16:59:14 UTC 2019

Modified Files:
src/sys/miscfs/genfs: genfs_io.c

Log Message:
Fix (harmless) uninitialized variable: 'pg' could be 'endm', in which case
'pg->uobject' would not be initialized. Just invert the two last conditions
of the KASSERT.

ok hannken@


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 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.74 src/sys/miscfs/genfs/genfs_io.c:1.75
--- src/sys/miscfs/genfs/genfs_io.c:1.74	Mon Dec 10 21:10:52 2018
+++ src/sys/miscfs/genfs/genfs_io.c	Thu Jul 11 16:59:14 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_io.c,v 1.74 2018/12/10 21:10:52 jdolecek Exp $	*/
+/*	$NetBSD: genfs_io.c,v 1.75 2019/07/11 16:59:14 maxv Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.74 2018/12/10 21:10:52 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.75 2019/07/11 16:59:14 maxv Exp $");
 
 #include 
 #include 
@@ -993,8 +993,8 @@ retry:
 		 * if the current page is not interesting, move on to the next.
 		 */
 
-		KASSERT(pg == NULL || pg->uobject == uobj ||
-		(pg->flags & PG_MARKER) != 0);
+		KASSERT(pg == NULL || (pg->flags & PG_MARKER) != 0 ||
+		pg->uobject == uobj);
 		KASSERT(pg == NULL ||
 		(pg->flags & (PG_RELEASED|PG_PAGEOUT)) == 0 ||
 		(pg->flags & (PG_BUSY|PG_MARKER)) != 0);



CVS commit: src/sys/miscfs/genfs

2018-12-10 Thread Jaromir Dolecek
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

2018-12-10 Thread Jaromir Dolecek
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.



CVS commit: src/sys/miscfs/genfs

2018-12-09 Thread Jaromir Dolecek
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

2018-12-09 Thread Jaromir Dolecek
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.



CVS commit: src/sys/miscfs/genfs

2017-07-01 Thread Christos Zoulas
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

2017-07-01 Thread Christos Zoulas
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.



CVS commit: src/sys/miscfs/genfs

2017-06-27 Thread Juergen Hannken-Illjes
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.



CVS commit: src/sys/miscfs/genfs

2017-06-27 Thread Juergen Hannken-Illjes
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

2017-06-04 Thread Juergen Hannken-Illjes
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

2017-06-04 Thread Juergen Hannken-Illjes
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.



CVS commit: src/sys/miscfs/genfs

2017-05-24 Thread Juergen Hannken-Illjes
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

2017-05-24 Thread Juergen Hannken-Illjes
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.



CVS commit: src/sys/miscfs/genfs

2017-05-07 Thread Juergen Hannken-Illjes
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

2017-05-07 Thread Juergen Hannken-Illjes
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.



CVS commit: src/sys/miscfs/genfs

2017-04-01 Thread David A. Holland
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

2017-04-01 Thread David A. Holland
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.



CVS commit: src/sys/miscfs/genfs

2017-04-01 Thread Taylor R Campbell
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

2017-04-01 Thread Taylor R Campbell
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.



CVS commit: src/sys/miscfs/genfs

2017-03-30 Thread Juergen Hannken-Illjes
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

2017-03-30 Thread Juergen Hannken-Illjes
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.



CVS commit: src/sys/miscfs/genfs

2017-03-09 Thread Juergen Hannken-Illjes
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.



CVS commit: src/sys/miscfs/genfs

2017-03-09 Thread Juergen Hannken-Illjes
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

2017-03-01 Thread Juergen Hannken-Illjes
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.



CVS commit: src/sys/miscfs/genfs

2017-03-01 Thread Juergen Hannken-Illjes
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

2016-09-29 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Sep 29 19:08:48 UTC 2016

Modified Files:
src/sys/miscfs/genfs: genfs_io.c

Log Message:
don't change the loop counts; noted by mrg@


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 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.



CVS commit: src/sys/miscfs/genfs

2015-04-12 Thread Nick Hudson
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

2015-04-12 Thread Nick Hudson
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.



CVS commit: src/sys/miscfs/genfs

2014-05-28 Thread Juergen Hannken-Illjes
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

2014-05-28 Thread Juergen Hannken-Illjes
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.



Re: CVS commit: src/sys/miscfs/genfs

2014-03-13 Thread Jukka Ruohonen
On Thu, Mar 13, 2014 at 04:01:33AM +, David Holland wrote:
 On Wed, Mar 12, 2014 at 08:11:26AM -0700, Paul Goyette wrote:
   Me, too. But I'd rather that we had the equivalent ISCLR() macro, too,
   to remove another negation/complement.
   
   So is ISCLR when passed two bits true if both are clear, or if it's just
   not the case that both are set?
   
   Arguably this points out that the ISSET docs should explain about using
   2 bits at once.
   
   Or might we need ISANYCLR() vs ISALLCLR() (technically, AREALLCLR()
   but that's just an English grammar nit!)
   
   :)
 
 By the time you finish with that you just have an alternate and less
 legible expression syntax...

Indeed, cf. iso646(3) :).

- Jukka.


Re: CVS commit: src/sys/miscfs/genfs

2014-03-12 Thread Jukka Ruohonen
On Wed, Mar 12, 2014 at 09:39:23AM +, Juergen Hannken-Illjes wrote:
 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.

As I wrote in the manual page, I'd rather see ISSET(3) et. al. disappear,
i.e. these obscure rather than clarify...

- Jukka.


Re: CVS commit: src/sys/miscfs/genfs

2014-03-12 Thread Greg Troxel

Taylor R Campbell campbell+netbsd-source-change...@mumble.net writes:

Date: Wed, 12 Mar 2014 16:16:32 +0200
From: Jukka Ruohonen jruoho...@iki.fi

On Wed, Mar 12, 2014 at 09:39:23AM +, Juergen Hannken-Illjes wrote:
 Restructure layer_lock() to always lock before testing for dead node.
 Use ISSET() to test flags, add assertions.

As I wrote in the manual page, I'd rather see ISSET(3) et. al. disappear,
i.e. these obscure rather than clarify...

 I disagree.  Phrases like `(vp-v_iflag  (VI_XLOCK | VI_CLEAN)) == 0'
 make my head's parser stumble -- there are just enough complements to
 juggle that it overwhelms my brain registers for the fast path.  I'd
 rather read `!ISSET(vp-v_iflag, (VI_XLOCK | VI_CLEAN))'.

FWIW, I agree with Taylor.


pgpSzcZOop3yS.pgp
Description: PGP signature


Re: CVS commit: src/sys/miscfs/genfs

2014-03-12 Thread Paul Goyette

On Wed, 12 Mar 2014, Greg Troxel wrote:



Taylor R Campbell campbell+netbsd-source-change...@mumble.net writes:


   Date: Wed, 12 Mar 2014 16:16:32 +0200
   From: Jukka Ruohonen jruoho...@iki.fi

   On Wed, Mar 12, 2014 at 09:39:23AM +, Juergen Hannken-Illjes wrote:
   Restructure layer_lock() to always lock before testing for dead node.
   Use ISSET() to test flags, add assertions.

   As I wrote in the manual page, I'd rather see ISSET(3) et. al. disappear,
   i.e. these obscure rather than clarify...

I disagree.  Phrases like `(vp-v_iflag  (VI_XLOCK | VI_CLEAN)) == 0'
make my head's parser stumble -- there are just enough complements to
juggle that it overwhelms my brain registers for the fast path.  I'd
rather read `!ISSET(vp-v_iflag, (VI_XLOCK | VI_CLEAN))'.


FWIW, I agree with Taylor.


Me, too. But I'd rather that we had the equivalent ISCLR() macro, too, 
to remove another negation/complement.


BTW, why do we have man pages for isset(9)/isclr(9)/setbit(9)/clrbit(9) 
and then a separate page for SET(9)?


And why do we not have manlinks for ISSET(9) and ISCLR(9)?

And no cross-refs?

:)  :)  :)


-
| Paul Goyette | PGP Key fingerprint: | E-mail addresses:   |
| Customer Service | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com|
| Network Engineer | 0786 F758 55DE 53BA 7731 | pgoyette at juniper.net |
| Kernel Developer |  | pgoyette at netbsd.org  |
-


Re: CVS commit: src/sys/miscfs/genfs

2014-03-12 Thread Greg Troxel

Paul Goyette p...@whooppee.com writes:

 Me, too. But I'd rather that we had the equivalent ISCLR() macro, too,
 to remove another negation/complement.

So is ISCLR when passed two bits true if both are clear, or if it's just
not the case that both are set?

Arguably this points out that the ISSET docs should explain about using
2 bits at once.


pgpZNQF7rHjXV.pgp
Description: PGP signature


Re: CVS commit: src/sys/miscfs/genfs

2014-03-12 Thread Mindaugas Rasiukevicius
Taylor R Campbell campbell+netbsd-source-change...@mumble.net wrote:
Date: Wed, 12 Mar 2014 16:16:32 +0200
From: Jukka Ruohonen jruoho...@iki.fi
 
On Wed, Mar 12, 2014 at 09:39:23AM +, Juergen Hannken-Illjes wrote:
 Restructure layer_lock() to always lock before testing for dead node.
 Use ISSET() to test flags, add assertions.
 
As I wrote in the manual page, I'd rather see ISSET(3) et. al.
 disappear, i.e. these obscure rather than clarify...
 
 I disagree.  Phrases like `(vp-v_iflag  (VI_XLOCK | VI_CLEAN)) == 0'
 make my head's parser stumble -- there are just enough complements to
 juggle that it overwhelms my brain registers for the fast path.  I'd
 rather read `!ISSET(vp-v_iflag, (VI_XLOCK | VI_CLEAN))'.

I disagree.  For kernel developers, that kind of bitwise arithmetics and
masking ought to be intuitive.  If there is more logic and it gets long,
then separate it:

const bool foobar = (mask  (FOO | BAR)) == 0;
const bool baz = (mask  BAZ) != 0;

if (foobar  baz) ...

ISSET() is somewhat okay (although I do not use it), but I particularly
dislike __BIT() as I forget whether the 1st bit is n = 0 or whether this
API tries to be fancy and it is n = 1.  1U  n is just straigtforward.

-- 
Mindaugas


Re: CVS commit: src/sys/miscfs/genfs

2014-03-12 Thread David Laight
On Thu, Mar 13, 2014 at 12:32:38AM +0900, Mindaugas Rasiukevicius wrote:
 Taylor R Campbell campbell+netbsd-source-change...@mumble.net wrote:
 Date: Wed, 12 Mar 2014 16:16:32 +0200
 From: Jukka Ruohonen jruoho...@iki.fi
  
 On Wed, Mar 12, 2014 at 09:39:23AM +, Juergen Hannken-Illjes wrote:
  Restructure layer_lock() to always lock before testing for dead node.
  Use ISSET() to test flags, add assertions.
  
 As I wrote in the manual page, I'd rather see ISSET(3) et. al.
  disappear, i.e. these obscure rather than clarify...
  
  I disagree.  Phrases like `(vp-v_iflag  (VI_XLOCK | VI_CLEAN)) == 0'
  make my head's parser stumble -- there are just enough complements to
  juggle that it overwhelms my brain registers for the fast path.  I'd
  rather read `!ISSET(vp-v_iflag, (VI_XLOCK | VI_CLEAN))'.
 
 I disagree.  For kernel developers, that kind of bitwise arithmetics and
 masking ought to be intuitive.  If there is more logic and it gets long,
 then separate it:
 
 const bool foobar = (mask  (FOO | BAR)) == 0;
 const bool baz = (mask  BAZ) != 0;
 
 if (foobar  baz) ...

Except you really don't want the compiler to convert the value to
a 'bool'.

 ISSET() is somewhat okay (although I do not use it), but I particularly
 dislike __BIT() as I forget whether the 1st bit is n = 0 or whether this
 API tries to be fancy and it is n = 1.  1U  n is just straigtforward.

Or number from the other end...

Indeed, I have to go away and find the definitions and then realise
that they are just longhand!

I don't normally compare bit masking against zero, just:
if (var  BIT)
or
if (!(var  BIT))
to me they read better that way.

David

-- 
David Laight: da...@l8s.co.uk


Re: CVS commit: src/sys/miscfs/genfs

2014-03-12 Thread David Holland
On Wed, Mar 12, 2014 at 08:11:26AM -0700, Paul Goyette wrote:
  Me, too. But I'd rather that we had the equivalent ISCLR() macro, too,
  to remove another negation/complement.
  
  So is ISCLR when passed two bits true if both are clear, or if it's just
  not the case that both are set?
  
  Arguably this points out that the ISSET docs should explain about using
  2 bits at once.
  
  Or might we need ISANYCLR() vs ISALLCLR() (technically, AREALLCLR()
  but that's just an English grammar nit!)
  
  :)

By the time you finish with that you just have an alternate and less
legible expression syntax...

If it were me I'd rewrite the offending code to not use flag bits at
all - bitfields generate equally good code in modern compilers and are
much less likely to cause confusion.

-- 
David A. Holland
dholl...@netbsd.org


CVS commit: src/sys/miscfs/genfs

2014-03-12 Thread Juergen Hannken-Illjes
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

2014-03-12 Thread Juergen Hannken-Illjes
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

2014-03-12 Thread Juergen Hannken-Illjes
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.



CVS commit: src/sys/miscfs/genfs

2014-03-12 Thread Juergen Hannken-Illjes
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.



CVS commit: src/sys/miscfs/genfs

2014-02-09 Thread Juergen Hannken-Illjes
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

2014-02-09 Thread Juergen Hannken-Illjes
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.



CVS commit: src/sys/miscfs/genfs

2014-01-29 Thread Juergen Hannken-Illjes
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

2014-01-29 Thread Juergen Hannken-Illjes
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.



CVS commit: src/sys/miscfs/genfs

2013-10-19 Thread Martin Husemann
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

2013-10-19 Thread Martin Husemann
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

2013-10-19 Thread Martin Husemann
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.



CVS commit: src/sys/miscfs/genfs

2013-10-19 Thread Martin Husemann
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.



CVS commit: src/sys/miscfs/genfs

2013-06-05 Thread David A. Holland
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

2013-06-05 Thread David A. Holland
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.



CVS commit: src/sys/miscfs/genfs

2013-05-02 Thread Taylor R Campbell
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

2013-05-02 Thread Taylor R Campbell
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.



CVS commit: src/sys/miscfs/genfs

2012-05-31 Thread Paul Goyette
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

2012-05-31 Thread Paul Goyette
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

2012-05-31 Thread Paul Goyette
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.



CVS commit: src/sys/miscfs/genfs

2012-05-31 Thread Paul Goyette
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.



CVS commit: src/sys/miscfs/genfs

2012-05-22 Thread YAMAMOTO Takashi
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

2012-05-22 Thread YAMAMOTO Takashi
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.



CVS commit: src/sys/miscfs/genfs

2012-03-30 Thread Nicolas Joly
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) {



  1   2   >