CVS commit: src/sys/ufs/lfs

2017-06-09 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Sat Jun 10 05:29:36 UTC 2017

Modified Files:
src/sys/ufs/lfs: lfs_accessors.h lfs_alloc.c lfs_balloc.c lfs_bio.c
lfs_inode.c lfs_inode.h lfs_itimes.c lfs_pages.c lfs_rename.c
lfs_segment.c lfs_subr.c lfs_vnops.c ulfs_inode.c ulfs_inode.h
ulfs_lookup.c ulfs_quota2.c ulfs_readwrite.c ulfs_vnops.c

Log Message:
Rename i_flag to i_state.

The similarity to i_flags has previously caused errors.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/ufs/lfs/lfs_accessors.h
cvs rdiff -u -r1.135 -r1.136 src/sys/ufs/lfs/lfs_alloc.c
cvs rdiff -u -r1.93 -r1.94 src/sys/ufs/lfs/lfs_balloc.c \
src/sys/ufs/lfs/lfs_subr.c
cvs rdiff -u -r1.140 -r1.141 src/sys/ufs/lfs/lfs_bio.c
cvs rdiff -u -r1.156 -r1.157 src/sys/ufs/lfs/lfs_inode.c
cvs rdiff -u -r1.22 -r1.23 src/sys/ufs/lfs/lfs_inode.h
cvs rdiff -u -r1.19 -r1.20 src/sys/ufs/lfs/lfs_itimes.c \
src/sys/ufs/lfs/ulfs_inode.c
cvs rdiff -u -r1.13 -r1.14 src/sys/ufs/lfs/lfs_pages.c
cvs rdiff -u -r1.21 -r1.22 src/sys/ufs/lfs/lfs_rename.c
cvs rdiff -u -r1.269 -r1.270 src/sys/ufs/lfs/lfs_segment.c
cvs rdiff -u -r1.316 -r1.317 src/sys/ufs/lfs/lfs_vnops.c
cvs rdiff -u -r1.23 -r1.24 src/sys/ufs/lfs/ulfs_inode.h \
src/sys/ufs/lfs/ulfs_readwrite.c
cvs rdiff -u -r1.40 -r1.41 src/sys/ufs/lfs/ulfs_lookup.c
cvs rdiff -u -r1.30 -r1.31 src/sys/ufs/lfs/ulfs_quota2.c
cvs rdiff -u -r1.48 -r1.49 src/sys/ufs/lfs/ulfs_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/ufs/lfs/lfs_accessors.h
diff -u src/sys/ufs/lfs/lfs_accessors.h:1.47 src/sys/ufs/lfs/lfs_accessors.h:1.48
--- src/sys/ufs/lfs/lfs_accessors.h:1.47	Thu Jan 12 18:40:02 2017
+++ src/sys/ufs/lfs/lfs_accessors.h	Sat Jun 10 05:29:36 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_accessors.h,v 1.47 2017/01/12 18:40:02 christos Exp $	*/
+/*	$NetBSD: lfs_accessors.h,v 1.48 2017/06/10 05:29:36 maya Exp $	*/
 
 /*  from NetBSD: lfs.h,v 1.165 2015/07/24 06:59:32 dholland Exp  */
 /*  from NetBSD: dinode.h,v 1.25 2016/01/22 23:06:10 dholland Exp  */
@@ -619,31 +619,31 @@ lfs_iblock_set(STRUCT_LFS *fs, void *blo
  * "struct inode" associated definitions
  */
 
-#define LFS_SET_UINO(ip, flags) do {	\
-	if (((flags) & IN_ACCESSED) && !((ip)->i_flag & IN_ACCESSED))	\
+#define LFS_SET_UINO(ip, states) do {	\
+	if (((states) & IN_ACCESSED) && !((ip)->i_state & IN_ACCESSED))	\
 		lfs_sb_adduinodes((ip)->i_lfs, 1);			\
-	if (((flags) & IN_CLEANING) && !((ip)->i_flag & IN_CLEANING))	\
+	if (((states) & IN_CLEANING) && !((ip)->i_state & IN_CLEANING))	\
 		lfs_sb_adduinodes((ip)->i_lfs, 1);			\
-	if (((flags) & IN_MODIFIED) && !((ip)->i_flag & IN_MODIFIED))	\
+	if (((states) & IN_MODIFIED) && !((ip)->i_state & IN_MODIFIED))	\
 		lfs_sb_adduinodes((ip)->i_lfs, 1);			\
-	(ip)->i_flag |= (flags);	\
+	(ip)->i_state |= (states);	\
 } while (0)
 
-#define LFS_CLR_UINO(ip, flags) do {	\
-	if (((flags) & IN_ACCESSED) && ((ip)->i_flag & IN_ACCESSED))	\
+#define LFS_CLR_UINO(ip, states) do {	\
+	if (((states) & IN_ACCESSED) && ((ip)->i_state & IN_ACCESSED))	\
 		lfs_sb_subuinodes((ip)->i_lfs, 1);			\
-	if (((flags) & IN_CLEANING) && ((ip)->i_flag & IN_CLEANING))	\
+	if (((states) & IN_CLEANING) && ((ip)->i_state & IN_CLEANING))	\
 		lfs_sb_subuinodes((ip)->i_lfs, 1);			\
-	if (((flags) & IN_MODIFIED) && ((ip)->i_flag & IN_MODIFIED))	\
+	if (((states) & IN_MODIFIED) && ((ip)->i_state & IN_MODIFIED))	\
 		lfs_sb_subuinodes((ip)->i_lfs, 1);			\
-	(ip)->i_flag &= ~(flags);	\
+	(ip)->i_state &= ~(states);	\
 	if (lfs_sb_getuinodes((ip)->i_lfs) < 0) {			\
 		panic("lfs_uinodes < 0");\
 	}\
 } while (0)
 
 #define LFS_ITIMES(ip, acc, mod, cre) \
-	while ((ip)->i_flag & (IN_ACCESS | IN_CHANGE | IN_UPDATE | IN_MODIFY)) \
+	while ((ip)->i_state & (IN_ACCESS | IN_CHANGE | IN_UPDATE | IN_MODIFY)) \
 		lfs_itimes(ip, acc, mod, cre)
 
 /*
@@ -672,7 +672,7 @@ lfs_iblock_set(STRUCT_LFS *fs, void *blo
 #define	LFS_SEGENTRY(SP, F, IN, BP) do {\
 	int _e;\
 	SHARE_IFLOCK(F);		\
-	VTOI((F)->lfs_ivnode)->i_flag |= IN_ACCESS;			\
+	VTOI((F)->lfs_ivnode)->i_state |= IN_ACCESS;			\
 	if ((_e = bread((F)->lfs_ivnode,\
 	((IN) / lfs_sb_getsepb(F)) + lfs_sb_getcleansz(F),		\
 	lfs_sb_getbsize(F), 0, &(BP))) != 0)			\
@@ -825,7 +825,7 @@ lfs_ii_setblock(STRUCT_LFS *fs, IINFO *i
 #define	LFS_IENTRY(IP, F, IN, BP) do {	\
 	int _e;\
 	SHARE_IFLOCK(F);		\
-	VTOI((F)->lfs_ivnode)->i_flag |= IN_ACCESS;			\
+	VTOI((F)->lfs_ivnode)->i_state |= IN_ACCESS;			\
 	if ((_e = bread((F)->lfs_ivnode,\
 	(IN) / lfs_sb_getifpb(F) + lfs_sb_getcleansz(F) + lfs_sb_getsegtabsz(F), \
 	lfs_sb_getbsize(F), 0, &(BP))) != 0)\
@@ -941,7 +941,7 @@ lfs_ci_shiftdirtytoclean(STRUCT_LFS *fs,
 #define LFS_CLEANERINFO(CP, F, BP) do {	\
 	int _e;\
 	SHARE_IFLOCK(F);		\
-	

CVS commit: src/sys/ufs/lfs

2017-06-05 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Mon Jun  5 07:47:32 UTC 2017

Modified Files:
src/sys/ufs/lfs: lfs_inode.h

Log Message:
Add an XXX about the missing flags so it's not buried in a commit
message.

now the XXX count for LFS is 260


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/ufs/lfs/lfs_inode.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/ufs/lfs/lfs_inode.h
diff -u src/sys/ufs/lfs/lfs_inode.h:1.20 src/sys/ufs/lfs/lfs_inode.h:1.21
--- src/sys/ufs/lfs/lfs_inode.h:1.20	Mon Jun  5 01:01:42 2017
+++ src/sys/ufs/lfs/lfs_inode.h	Mon Jun  5 07:47:32 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_inode.h,v 1.20 2017/06/05 01:01:42 maya Exp $	*/
+/*	$NetBSD: lfs_inode.h,v 1.21 2017/06/05 07:47:32 maya Exp $	*/
 /*  from NetBSD: ulfs_inode.h,v 1.5 2013/06/06 00:51:50 dholland Exp  */
 /*  from NetBSD: inode.h,v 1.72 2016/06/03 15:36:03 christos Exp  */
 
@@ -170,6 +170,7 @@ struct inode {
 #define	IN_PAGING   0x1000		/* LFS: file is on paging queue */
 #define IN_CDIROP   0x4000  /* LFS: dirop completed pending i/o */
 
+/* XXX this is missing some of the flags */
 #define IN_ALLMOD (IN_MODIFIED|IN_ACCESS|IN_CHANGE|IN_UPDATE|IN_MODIFY|IN_ACCESSED|IN_CLEANING)
 
 /*



CVS commit: src/sys/ufs/lfs

2017-06-04 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Mon Jun  5 01:29:21 UTC 2017

Modified Files:
src/sys/ufs/lfs: lfs_inode.c lfs_pages.c lfs_vnops.c

Log Message:
Correct confusion between i_flag and i_flags
These will have to be renamed.

Spotted by Riastradh, thanks!


To generate a diff of this commit:
cvs rdiff -u -r1.155 -r1.156 src/sys/ufs/lfs/lfs_inode.c
cvs rdiff -u -r1.12 -r1.13 src/sys/ufs/lfs/lfs_pages.c
cvs rdiff -u -r1.315 -r1.316 src/sys/ufs/lfs/lfs_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/ufs/lfs/lfs_inode.c
diff -u src/sys/ufs/lfs/lfs_inode.c:1.155 src/sys/ufs/lfs/lfs_inode.c:1.156
--- src/sys/ufs/lfs/lfs_inode.c:1.155	Sat Apr  1 00:40:42 2017
+++ src/sys/ufs/lfs/lfs_inode.c	Mon Jun  5 01:29:21 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_inode.c,v 1.155 2017/04/01 00:40:42 maya Exp $	*/
+/*	$NetBSD: lfs_inode.c,v 1.156 2017/06/05 01:29:21 maya Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.155 2017/04/01 00:40:42 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.156 2017/06/05 01:29:21 maya Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_quota.h"
@@ -592,8 +592,8 @@ done:
 	/*
 	 * If we truncated to zero, take us off the paging queue.
 	 */
-	if (oip->i_size == 0 && oip->i_flags & IN_PAGING) {
-		oip->i_flags &= ~IN_PAGING;
+	if (oip->i_size == 0 && oip->i_flag & IN_PAGING) {
+		oip->i_flag &= ~IN_PAGING;
 		TAILQ_REMOVE(>lfs_pchainhd, oip, i_lfs_pchain);
 	}
 	mutex_exit(_lock);

Index: src/sys/ufs/lfs/lfs_pages.c
diff -u src/sys/ufs/lfs/lfs_pages.c:1.12 src/sys/ufs/lfs/lfs_pages.c:1.13
--- src/sys/ufs/lfs/lfs_pages.c:1.12	Sun Jun  4 08:05:42 2017
+++ src/sys/ufs/lfs/lfs_pages.c	Mon Jun  5 01:29:21 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_pages.c,v 1.12 2017/06/04 08:05:42 hannken Exp $	*/
+/*	$NetBSD: lfs_pages.c,v 1.13 2017/06/05 01:29:21 maya Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_pages.c,v 1.12 2017/06/04 08:05:42 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_pages.c,v 1.13 2017/06/05 01:29:21 maya Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -506,8 +506,8 @@ retry:
 		
 		/* Remove us from paging queue, if we were on it */
 		mutex_enter(_lock);
-		if (ip->i_flags & IN_PAGING) {
-			ip->i_flags &= ~IN_PAGING;
+		if (ip->i_flag & IN_PAGING) {
+			ip->i_flag &= ~IN_PAGING;
 			TAILQ_REMOVE(>lfs_pchainhd, ip, i_lfs_pchain);
 		}
 		mutex_exit(_lock);
@@ -688,8 +688,8 @@ retry:
 	if (pagedaemon) {
 		mutex_exit(vp->v_interlock);
 		mutex_enter(_lock);
-		if (!(ip->i_flags & IN_PAGING)) {
-			ip->i_flags |= IN_PAGING;
+		if (!(ip->i_flag & IN_PAGING)) {
+			ip->i_flag |= IN_PAGING;
 			TAILQ_INSERT_TAIL(>lfs_pchainhd, ip, i_lfs_pchain);
 		}
 		cv_broadcast(_writerd_cv);
@@ -898,8 +898,8 @@ retry:
 	 */
 	if (origendoffset == 0 || ap->a_flags & PGO_ALLPAGES) {
 		mutex_enter(_lock);
-		if (ip->i_flags & IN_PAGING) {
-			ip->i_flags &= ~IN_PAGING;
+		if (ip->i_flag & IN_PAGING) {
+			ip->i_flag &= ~IN_PAGING;
 			TAILQ_REMOVE(>lfs_pchainhd, ip, i_lfs_pchain);
 		}
 		mutex_exit(_lock);

Index: src/sys/ufs/lfs/lfs_vnops.c
diff -u src/sys/ufs/lfs/lfs_vnops.c:1.315 src/sys/ufs/lfs/lfs_vnops.c:1.316
--- src/sys/ufs/lfs/lfs_vnops.c:1.315	Fri May 26 14:21:02 2017
+++ src/sys/ufs/lfs/lfs_vnops.c	Mon Jun  5 01:29:21 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_vnops.c,v 1.315 2017/05/26 14:21:02 riastradh Exp $	*/
+/*	$NetBSD: lfs_vnops.c,v 1.316 2017/06/05 01:29:21 maya Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -125,7 +125,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.315 2017/05/26 14:21:02 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.316 2017/06/05 01:29:21 maya Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -461,8 +461,8 @@ lfs_fsync(void *v)
 	if (ap->a_flags & FSYNC_LAZY) {
 		if (lfs_ignore_lazy_sync == 0) {
 			mutex_enter(_lock);
-			if (!(ip->i_flags & IN_PAGING)) {
-ip->i_flags |= IN_PAGING;
+			if (!(ip->i_flag & IN_PAGING)) {
+ip->i_flag |= IN_PAGING;
 TAILQ_INSERT_TAIL(>lfs_pchainhd, ip,
 		  i_lfs_pchain);
 			}
@@ -477,7 +477,7 @@ lfs_fsync(void *v)
 	 * reuse it.  This prevents the cleaner from writing files twice
 	 * in the same partial segment, causing an accounting underflow.
 	 */
-	if (ap->a_flags & FSYNC_RECLAIM && ip->i_flags & IN_CLEANING) {
+	if (ap->a_flags & FSYNC_RECLAIM && ip->i_flag & IN_CLEANING) {
 		lfs_vflush(vp);
 	}
 
@@ -1446,10 +1446,10 @@ lfs_reclaim(void *v)
 	 * We shouldn't be on them.
 	 */
 	mutex_enter(_lock);
-	if (ip->i_flags & IN_PAGING) {
+	if (ip->i_flag & IN_PAGING) {
 		log(LOG_WARNING, "%s: reclaimed vnode is IN_PAGING\n",
 		

CVS commit: src/sys/ufs/lfs

2017-06-04 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Mon Jun  5 01:01:42 UTC 2017

Modified Files:
src/sys/ufs/lfs: lfs.h lfs_inode.h

Log Message:
Move definition of IN_ALLMOD near the flag it's a mask for.

Now we can see that it doesn't match all the flags, but changing that will
require more careful thought.


To generate a diff of this commit:
cvs rdiff -u -r1.201 -r1.202 src/sys/ufs/lfs/lfs.h
cvs rdiff -u -r1.19 -r1.20 src/sys/ufs/lfs/lfs_inode.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/ufs/lfs/lfs.h
diff -u src/sys/ufs/lfs/lfs.h:1.201 src/sys/ufs/lfs/lfs.h:1.202
--- src/sys/ufs/lfs/lfs.h:1.201	Sat Apr  1 14:43:00 2017
+++ src/sys/ufs/lfs/lfs.h	Mon Jun  5 01:01:42 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs.h,v 1.201 2017/04/01 14:43:00 maya Exp $	*/
+/*	$NetBSD: lfs.h,v 1.202 2017/06/05 01:01:42 maya Exp $	*/
 
 /*  from NetBSD: dinode.h,v 1.25 2016/01/22 23:06:10 dholland Exp  */
 /*  from NetBSD: dir.h,v 1.25 2015/09/01 06:16:03 dholland Exp  */
@@ -511,13 +511,6 @@ union lfs_dinode {
 #define LFS_UNUSED_LBN	-1
 
 /*
- * "struct inode" associated definitions
- */
-
-/* For convenience */
-#define IN_ALLMOD (IN_MODIFIED|IN_ACCESS|IN_CHANGE|IN_UPDATE|IN_MODIFY|IN_ACCESSED|IN_CLEANING)
-
-/*
  * On-disk and in-memory checkpoint segment usage structure.
  */
 typedef struct segusage SEGUSE;

Index: src/sys/ufs/lfs/lfs_inode.h
diff -u src/sys/ufs/lfs/lfs_inode.h:1.19 src/sys/ufs/lfs/lfs_inode.h:1.20
--- src/sys/ufs/lfs/lfs_inode.h:1.19	Thu Apr  6 03:21:01 2017
+++ src/sys/ufs/lfs/lfs_inode.h	Mon Jun  5 01:01:42 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_inode.h,v 1.19 2017/04/06 03:21:01 maya Exp $	*/
+/*	$NetBSD: lfs_inode.h,v 1.20 2017/06/05 01:01:42 maya Exp $	*/
 /*  from NetBSD: ulfs_inode.h,v 1.5 2013/06/06 00:51:50 dholland Exp  */
 /*  from NetBSD: inode.h,v 1.72 2016/06/03 15:36:03 christos Exp  */
 
@@ -170,6 +170,8 @@ struct inode {
 #define	IN_PAGING   0x1000		/* LFS: file is on paging queue */
 #define IN_CDIROP   0x4000  /* LFS: dirop completed pending i/o */
 
+#define IN_ALLMOD (IN_MODIFIED|IN_ACCESS|IN_CHANGE|IN_UPDATE|IN_MODIFY|IN_ACCESSED|IN_CLEANING)
+
 /*
  * LFS inode extensions.
  */



CVS commit: src/sys/ufs/ext2fs

2017-05-28 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sun May 28 16:38:55 UTC 2017

Modified Files:
src/sys/ufs/ext2fs: ext2fs_alloc.c ext2fs_extern.h ext2fs_vfsops.c
ext2fs_vnops.c

Log Message:
Change ext2fs to use vcache_new like we did for ffs:
- Change ext2fs_valloc to return an inode number.
- Make ext2fs_makeinode private to ext2fs_vnops.c and
  pass vattr instead of mode.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/ufs/ext2fs/ext2fs_alloc.c
cvs rdiff -u -r1.55 -r1.56 src/sys/ufs/ext2fs/ext2fs_extern.h
cvs rdiff -u -r1.208 -r1.209 src/sys/ufs/ext2fs/ext2fs_vfsops.c
cvs rdiff -u -r1.127 -r1.128 src/sys/ufs/ext2fs/ext2fs_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/ufs/ext2fs/ext2fs_alloc.c
diff -u src/sys/ufs/ext2fs/ext2fs_alloc.c:1.51 src/sys/ufs/ext2fs/ext2fs_alloc.c:1.52
--- src/sys/ufs/ext2fs/ext2fs_alloc.c:1.51	Sat Aug 20 19:53:43 2016
+++ src/sys/ufs/ext2fs/ext2fs_alloc.c	Sun May 28 16:38:55 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_alloc.c,v 1.51 2016/08/20 19:53:43 jdolecek Exp $	*/
+/*	$NetBSD: ext2fs_alloc.c,v 1.52 2017/05/28 16:38:55 hannken Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_alloc.c,v 1.51 2016/08/20 19:53:43 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_alloc.c,v 1.52 2017/05/28 16:38:55 hannken Exp $");
 
 #include 
 #include 
@@ -167,16 +167,13 @@ nospace:
  *	  available inode is located.
  */
 int
-ext2fs_valloc(struct vnode *pvp, int mode, kauth_cred_t cred,
-struct vnode **vpp)
+ext2fs_valloc(struct vnode *pvp, int mode, kauth_cred_t cred, ino_t *inop)
 {
 	struct inode *pip;
 	struct m_ext2fs *fs;
-	struct inode *ip;
 	ino_t ino, ipref;
-	int cg, error;
+	int cg;
 
-	*vpp = NULL;
 	pip = VTOI(pvp);
 	fs = pip->i_e2fs;
 	if (fs->e2fs.e2fs_ficount == 0)
@@ -190,32 +187,10 @@ ext2fs_valloc(struct vnode *pvp, int mod
 	ino = (ino_t)ext2fs_hashalloc(pip, cg, (long)ipref, mode, ext2fs_nodealloccg);
 	if (ino == 0)
 		goto noinodes;
-	error = VFS_VGET(pvp->v_mount, ino, vpp);
-	if (error) {
-		ext2fs_vfree(pvp, ino, mode);
-		return error;
-	}
-	ip = VTOI(*vpp);
-
-	KASSERT(!E2FS_HAS_GD_CSUM(fs) || (fs->e2fs_gd[ino_to_cg(fs, ino)].ext2bgd_flags & h2fs16(E2FS_BG_INODE_ZEROED)) != 0);
-
-	/* check for already used inode; makes sense only for ZEROED itable */
-	if (__predict_false(ip->i_e2fs_mode && ip->i_e2fs_nlink != 0)) {
-		printf("mode = 0%o, nlinks %d, inum = %llu, fs = %s\n",
-		ip->i_e2fs_mode, ip->i_e2fs_nlink,
-		(unsigned long long)ip->i_number, fs->e2fs_fsmnt);
-		panic("ext2fs_valloc: dup alloc");
-	}
-
-	memset(ip->i_din.e2fs_din, 0, EXT2_DINODE_SIZE(fs));
 
-	/*
-	 * Set up a new generation number for this inode.
-	 */
-	if (++ext2gennumber < time_second)
-		ext2gennumber = time_second;
-	ip->i_e2fs_gen = ext2gennumber;
+	*inop = ino;
 	return 0;
+
 noinodes:
 	ext2fs_fserr(fs, kauth_cred_geteuid(cred), "out of inodes");
 	uprintf("\n%s: create/symlink failed, no inodes free\n", fs->e2fs_fsmnt);

Index: src/sys/ufs/ext2fs/ext2fs_extern.h
diff -u src/sys/ufs/ext2fs/ext2fs_extern.h:1.55 src/sys/ufs/ext2fs/ext2fs_extern.h:1.56
--- src/sys/ufs/ext2fs/ext2fs_extern.h:1.55	Sat Aug 20 19:47:44 2016
+++ src/sys/ufs/ext2fs/ext2fs_extern.h	Sun May 28 16:38:55 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_extern.h,v 1.55 2016/08/20 19:47:44 jdolecek Exp $	*/
+/*	$NetBSD: ext2fs_extern.h,v 1.56 2017/05/28 16:38:55 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -95,7 +95,7 @@ int ext2fs_alloc(struct inode *, daddr_t
 		   daddr_t *);
 int ext2fs_realloccg(struct inode *, daddr_t, daddr_t, int, int ,
 			  kauth_cred_t, struct buf **);
-int ext2fs_valloc(struct vnode *, int, kauth_cred_t, struct vnode **);
+int ext2fs_valloc(struct vnode *, int, kauth_cred_t, ino_t *);
 /* XXX ondisk32 */
 daddr_t ext2fs_blkpref(struct inode *, daddr_t, int, int32_t *);
 void ext2fs_blkfree(struct inode *, daddr_t);
@@ -176,8 +176,6 @@ int ext2fs_advlock(void *);
 int ext2fs_fsync(void *);
 int ext2fs_vinit(struct mount *, int (**specops)(void *),
 		  int (**fifoops)(void *), struct vnode **);
-int ext2fs_makeinode(int, struct vnode *, struct vnode **,
-			  struct componentname *cnp, int);
 int ext2fs_reclaim(void *);
 
 /* ext2fs_hash.c */

Index: src/sys/ufs/ext2fs/ext2fs_vfsops.c
diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.208 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.209
--- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.208	Mon Apr 17 08:32:01 2017
+++ src/sys/ufs/ext2fs/ext2fs_vfsops.c	Sun May 28 16:38:55 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_vfsops.c,v 1.208 2017/04/17 08:32:01 hannken Exp $	*/
+/*	$NetBSD: ext2fs_vfsops.c,v 1.209 2017/05/28 16:38:55 hannken Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1994
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.208 2017/04/17 08:32:01 

CVS commit: src/sys/ufs/ffs

2017-05-28 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sun May 28 16:37:55 UTC 2017

Modified Files:
src/sys/ufs/ffs: ffs_wapbl.c

Log Message:
No need to call vgone() on the just created in file system log vnode,
vput() is sufficient.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/ufs/ffs/ffs_wapbl.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/ufs/ffs/ffs_wapbl.c
diff -u src/sys/ufs/ffs/ffs_wapbl.c:1.40 src/sys/ufs/ffs/ffs_wapbl.c:1.41
--- src/sys/ufs/ffs/ffs_wapbl.c:1.40	Wed Mar 22 21:30:59 2017
+++ src/sys/ufs/ffs/ffs_wapbl.c	Sun May 28 16:37:55 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_wapbl.c,v 1.40 2017/03/22 21:30:59 jdolecek Exp $	*/
+/*	$NetBSD: ffs_wapbl.c,v 1.41 2017/05/28 16:37:55 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2003,2006,2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_wapbl.c,v 1.40 2017/03/22 21:30:59 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_wapbl.c,v 1.41 2017/05/28 16:37:55 hannken Exp $");
 
 #define WAPBL_INTERNAL
 
@@ -686,8 +686,7 @@ wapbl_create_infs_log(struct mount *mp, 
 		 */
 		ip->i_nlink = 0;
 		DIP_ASSIGN(ip, nlink, 0);
-		VOP_UNLOCK(vp);
-		vgone(vp);
+		vput(vp);
 
 		return error;
 	}
@@ -696,8 +695,7 @@ wapbl_create_infs_log(struct mount *mp, 
 	 * Now that we have the place-holder inode for the journal,
 	 * we don't need the vnode ever again.
 	 */
-	VOP_UNLOCK(vp);
-	vgone(vp);
+	vput(vp);
 
 	return 0;
 }



CVS commit: src/sys/ufs/lfs

2017-04-13 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Apr 13 09:57:28 UTC 2017

Modified Files:
src/sys/ufs/lfs: lfs_bio.c lfs_vfsops.c

Log Message:
Switch lfs_flush() and lfs_writerd() to mountlist iterator.


To generate a diff of this commit:
cvs rdiff -u -r1.137 -r1.138 src/sys/ufs/lfs/lfs_bio.c
cvs rdiff -u -r1.356 -r1.357 src/sys/ufs/lfs/lfs_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/ufs/lfs/lfs_bio.c
diff -u src/sys/ufs/lfs/lfs_bio.c:1.137 src/sys/ufs/lfs/lfs_bio.c:1.138
--- src/sys/ufs/lfs/lfs_bio.c:1.137	Sat Apr  1 17:34:21 2017
+++ src/sys/ufs/lfs/lfs_bio.c	Thu Apr 13 09:57:28 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_bio.c,v 1.137 2017/04/01 17:34:21 maya Exp $	*/
+/*	$NetBSD: lfs_bio.c,v 1.138 2017/04/13 09:57:28 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2008 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_bio.c,v 1.137 2017/04/01 17:34:21 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_bio.c,v 1.138 2017/04/13 09:57:28 hannken Exp $");
 
 #include 
 #include 
@@ -514,7 +514,8 @@ void
 lfs_flush(struct lfs *fs, int flags, int only_onefs)
 {
 	extern u_int64_t locked_fakequeue_count;
-	struct mount *mp, *nmp;
+	mount_iterator_t *iter;
+	struct mount *mp;
 	struct lfs *tfs;
 
 	KASSERT(mutex_owned(_lock));
@@ -543,12 +544,8 @@ lfs_flush(struct lfs *fs, int flags, int
 		vfs_unbusy(fs->lfs_ivnode->v_mount, false, NULL);
 	} else {
 		locked_fakequeue_count = 0;
-		mutex_enter(_lock);
-		for (mp = TAILQ_FIRST(); mp != NULL; mp = nmp) {
-			if (vfs_busy(mp, )) {
-DLOG((DLOG_FLUSH, "lfs_flush: fs vfs_busy\n"));
-continue;
-			}
+		mountlist_iterator_init();
+		while ((mp = mountlist_iterator_next(iter)) != NULL) {
 			if (strncmp(>mnt_stat.f_fstypename[0], MOUNT_LFS,
 			sizeof(mp->mnt_stat.f_fstypename)) == 0) {
 tfs = VFSTOULFS(mp)->um_lfs;
@@ -556,9 +553,8 @@ lfs_flush(struct lfs *fs, int flags, int
 lfs_flush_fs(tfs, flags);
 mutex_exit(_lock);
 			}
-			vfs_unbusy(mp, false, );
 		}
-		mutex_exit(_lock);
+		mountlist_iterator_destroy(iter);
 	}
 	LFS_DEBUG_COUNTLOCKED("flush");
 	wakeup(_subsys_pages);

Index: src/sys/ufs/lfs/lfs_vfsops.c
diff -u src/sys/ufs/lfs/lfs_vfsops.c:1.356 src/sys/ufs/lfs/lfs_vfsops.c:1.357
--- src/sys/ufs/lfs/lfs_vfsops.c:1.356	Sat Apr  1 17:34:21 2017
+++ src/sys/ufs/lfs/lfs_vfsops.c	Thu Apr 13 09:57:28 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_vfsops.c,v 1.356 2017/04/01 17:34:21 maya Exp $	*/
+/*	$NetBSD: lfs_vfsops.c,v 1.357 2017/04/13 09:57:28 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007, 2007
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.356 2017/04/01 17:34:21 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.357 2017/04/13 09:57:28 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_lfs.h"
@@ -387,11 +387,11 @@ struct pool lfs_lbnentry_pool;
 static void
 lfs_writerd(void *arg)
 {
- 	struct mount *mp, *nmp;
+	mount_iterator_t *iter;
+ 	struct mount *mp;
  	struct lfs *fs;
 	struct vfsops *vfs = NULL;
  	int fsflags;
-	int skipc;
 	int lfsc;
 	int wrote_something = 0;
  
@@ -446,14 +446,9 @@ lfs_writerd(void *arg)
  		 * Look through the list of LFSs to see if any of them
  		 * have requested pageouts.
  		 */
- 		mutex_enter(_lock);
+ 		mountlist_iterator_init();
 		lfsc = 0;
-		skipc = 0;
- 		for (mp = TAILQ_FIRST(); mp != NULL; mp = nmp) {
- 			if (vfs_busy(mp, )) {
-++skipc;
- continue;
- 			}
+		while ((mp = mountlist_iterator_next(iter)) != NULL) {
 			KASSERT(!mutex_owned(_lock));
  			if (strncmp(mp->mnt_stat.f_fstypename, MOUNT_LFS,
  			sizeof(mp->mnt_stat.f_fstypename)) == 0) {
@@ -468,7 +463,6 @@ lfs_writerd(void *arg)
 if (lfs_sb_getnextseg(fs) < lfs_sb_getcurseg(fs) && fs->lfs_nowrap) {
 	/* Don't try to write if we're suspended */
 	mutex_exit(_lock);
-	vfs_unbusy(mp, false, );
 	continue;
 }
 if (LFS_STARVED_FOR_SEGS(fs)) {
@@ -476,7 +470,6 @@ lfs_writerd(void *arg)
 
 	DLOG((DLOG_FLUSH, "lfs_writerd: need cleaning before writing possible\n"));
 	lfs_wakeup_cleaner(fs);
-	vfs_unbusy(mp, false, );
 	continue;
 }
 
@@ -503,21 +496,19 @@ lfs_writerd(void *arg)
 mutex_exit(_lock);
  			}
 			KASSERT(!mutex_owned(_lock));
- 			vfs_unbusy(mp, false, );
  		}
-		if (lfsc + skipc == 0) {
+		if (lfsc == 0) {
 			mutex_enter(_lock);
 			lfs_writer_daemon = NULL;
 			mutex_exit(_lock);
-			mutex_exit(_lock);
+			mountlist_iterator_destroy(iter);
 			break;
 		}
- 		mutex_exit(_lock);
+ 		mountlist_iterator_destroy(iter);
  
  		mutex_enter(_lock);
  	}
 	KASSERT(!mutex_owned(_lock));
-	KASSERT(!mutex_owned(_lock));
 
 	/* Give up our extra reference so the module can be unloaded. */
 	mutex_enter(_list_lock);



CVS commit: src/sys/ufs/lfs

2017-04-11 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Apr 11 06:01:04 UTC 2017

Modified Files:
src/sys/ufs/lfs: lfs_vnops.c

Log Message:
Fix non-DIAGNOSTIC build by using vp outside KASSERT too.


To generate a diff of this commit:
cvs rdiff -u -r1.311 -r1.312 src/sys/ufs/lfs/lfs_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/ufs/lfs/lfs_vnops.c
diff -u src/sys/ufs/lfs/lfs_vnops.c:1.311 src/sys/ufs/lfs/lfs_vnops.c:1.312
--- src/sys/ufs/lfs/lfs_vnops.c:1.311	Tue Apr 11 05:48:04 2017
+++ src/sys/ufs/lfs/lfs_vnops.c	Tue Apr 11 06:01:03 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_vnops.c,v 1.311 2017/04/11 05:48:04 riastradh Exp $	*/
+/*	$NetBSD: lfs_vnops.c,v 1.312 2017/04/11 06:01:03 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -125,7 +125,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.311 2017/04/11 05:48:04 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.312 2017/04/11 06:01:03 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -2272,7 +2272,7 @@ lfs_closeextattr(void *v)
 
 	KASSERT(VOP_ISLOCKED(vp) == LK_EXCLUSIVE);
 
-	ip = VTOI(ap->a_vp);
+	ip = VTOI(vp);
 	ump = ip->i_ump;
 
 	/* Not supported for ULFS1 file systems. */



CVS commit: src/sys/ufs/lfs

2017-04-10 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Apr 11 05:48:04 UTC 2017

Modified Files:
src/sys/ufs/lfs: lfs_vnops.c ulfs_vnops.c

Log Message:
Sprinkle lock ownership assertions.


To generate a diff of this commit:
cvs rdiff -u -r1.310 -r1.311 src/sys/ufs/lfs/lfs_vnops.c
cvs rdiff -u -r1.46 -r1.47 src/sys/ufs/lfs/ulfs_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/ufs/lfs/lfs_vnops.c
diff -u src/sys/ufs/lfs/lfs_vnops.c:1.310 src/sys/ufs/lfs/lfs_vnops.c:1.311
--- src/sys/ufs/lfs/lfs_vnops.c:1.310	Sat Apr  1 17:34:21 2017
+++ src/sys/ufs/lfs/lfs_vnops.c	Tue Apr 11 05:48:04 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_vnops.c,v 1.310 2017/04/01 17:34:21 maya Exp $	*/
+/*	$NetBSD: lfs_vnops.c,v 1.311 2017/04/11 05:48:04 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -125,7 +125,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.310 2017/04/01 17:34:21 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.311 2017/04/11 05:48:04 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -407,6 +407,7 @@ lfs_makeinode(struct vattr *vap, struct 
 	if (error)
 		goto bad;
 	*vpp = tvp;
+	KASSERT(VOP_ISLOCKED(*vpp) == LK_EXCLUSIVE);
 	return (0);
 
  bad:
@@ -438,17 +439,20 @@ lfs_fsync(void *v)
 		off_t offhi;
 	} */ *ap = v;
 	struct vnode *vp = ap->a_vp;
-	int error, wait;
+	int wait;
 	struct inode *ip = VTOI(vp);
 	struct lfs *fs = ip->i_lfs;
+	int error = 0;
+
+	KASSERT(VOP_ISLOCKED(vp) == LK_EXCLUSIVE);
 
 	/* If we're mounted read-only, don't try to sync. */
 	if (fs->lfs_ronly)
-		return 0;
+		goto out;
 
 	/* If a removed vnode is being cleaned, no need to sync here. */
 	if ((ap->a_flags & FSYNC_RECLAIM) != 0 && ip->i_mode == 0)
-		return 0;
+		goto out;
 
 	/*
 	 * Trickle sync simply adds this vnode to the pager list, as if
@@ -465,7 +469,7 @@ lfs_fsync(void *v)
 			cv_broadcast(_writerd_cv);
 			mutex_exit(_lock);
 		}
-		return 0;
+		goto out;
 	}
 
 	/*
@@ -491,7 +495,7 @@ lfs_fsync(void *v)
 		}
 	} while (error == EAGAIN);
 	if (error)
-		return error;
+		goto out;
 
 	if ((ap->a_flags & FSYNC_DATAONLY) == 0)
 		error = lfs_update(vp, NULL, NULL, wait ? UPDATE_WAIT : 0);
@@ -504,6 +508,8 @@ lfs_fsync(void *v)
 	if (wait && !VPISEMPTY(vp))
 		LFS_SET_UINO(ip, IN_MODIFIED);
 
+out:
+	KASSERT(VOP_ISLOCKED(vp) == LK_EXCLUSIVE);
 	return error;
 }
 
@@ -517,6 +523,8 @@ lfs_inactive(void *v)
 		struct vnode *a_vp;
 	} */ *ap = v;
 
+	KASSERT(VOP_ISLOCKED(ap->a_vp) == LK_EXCLUSIVE);
+
 	lfs_unmark_vnode(ap->a_vp);
 
 	/*
@@ -552,8 +560,8 @@ lfs_set_dirop(struct vnode *dvp, struct 
 	struct lfs *fs;
 	int error;
 
-	KASSERT(VOP_ISLOCKED(dvp));
-	KASSERT(vp == NULL || VOP_ISLOCKED(vp));
+	KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE);
+	KASSERT(vp == NULL || VOP_ISLOCKED(vp) == LK_EXCLUSIVE);
 
 	fs = VTOI(dvp)->i_lfs;
 
@@ -701,6 +709,7 @@ lfs_symlink(void *v)
 	dvp = ap->a_dvp;
 	vpp = ap->a_vpp;
 
+	KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE);
 	KASSERT(vpp != NULL);
 	KASSERT(*vpp == NULL);
 	KASSERT(ap->a_vap->va_type == VLNK);
@@ -723,6 +732,7 @@ lfs_symlink(void *v)
 	if (error) {
 		goto out;
 	}
+	KASSERT(VOP_ISLOCKED(*vpp) == LK_EXCLUSIVE);
 
 	VN_KNOTE(ap->a_dvp, NOTE_WRITE);
 	ip = VTOI(*vpp);
@@ -787,9 +797,10 @@ lfs_mknod(void *v)
 	vpp = ap->a_vpp;
 	vap = ap->a_vap;
 
+	KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE);
 	KASSERT(vpp != NULL);
 	KASSERT(*vpp == NULL);
-	
+
 	/* XXX should handle this material another way */
 	ulr = (dvp)->i_crap;
 	ULFS_CHECK_CRAPCOUNTER(VTOI(dvp));
@@ -816,6 +827,7 @@ lfs_mknod(void *v)
 		*vpp = NULL;
 		return (error);
 	}
+	KASSERT(VOP_ISLOCKED(*vpp) == LK_EXCLUSIVE);
 
 	VN_KNOTE(dvp, NOTE_WRITE);
 	ip = VTOI(*vpp);
@@ -864,6 +876,7 @@ lfs_create(void *v)
 	vpp = ap->a_vpp;
 	vap = ap->a_vap;
 
+	KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE);
 	KASSERT(vpp != NULL);
 	KASSERT(*vpp == NULL);
 
@@ -885,6 +898,7 @@ lfs_create(void *v)
 	if (error) {
 		goto out;
 	}
+	KASSERT(VOP_ISLOCKED(*vpp) == LK_EXCLUSIVE);
 	VN_KNOTE(dvp, NOTE_WRITE);
 	VOP_UNLOCK(*vpp);
 
@@ -927,6 +941,8 @@ lfs_mkdir(void *v)
 	cnp = ap->a_cnp;
 	vap = ap->a_vap;
 
+	KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE);
+
 	dp = VTOI(dvp);
 	ip = NULL;
 
@@ -1078,6 +1094,10 @@ lfs_remove(void *v)
 
 	dvp = ap->a_dvp;
 	vp = ap->a_vp;
+
+	KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE);
+	KASSERT(VOP_ISLOCKED(vp) == LK_EXCLUSIVE);
+
 	ip = VTOI(vp);
 	if ((error = lfs_set_dirop(dvp, vp)) != 0) {
 		if (dvp == vp)
@@ -1118,6 +1138,10 @@ lfs_rmdir(void *v)
 	int error;
 
 	vp = ap->a_vp;
+
+	KASSERT(VOP_ISLOCKED(ap->a_dvp) == LK_EXCLUSIVE);
+	KASSERT(VOP_ISLOCKED(vp) == LK_EXCLUSIVE);
+
 	ip = VTOI(vp);
 	if ((error = lfs_set_dirop(ap->a_dvp, ap->a_vp)) != 0) {
 		if (ap->a_dvp == vp)
@@ -1158,6 +1182,8 @@ lfs_link(void *v)
 
 	dvp = ap->a_dvp;
 
+	KASSERT(VOP_ISLOCKED(dvp) == 

CVS commit: src/sys/ufs/lfs

2017-04-05 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Thu Apr  6 03:21:01 UTC 2017

Modified Files:
src/sys/ufs/lfs: lfs_inode.h lfs_segment.c lfs_subr.c

Log Message:
don't guard lfs_sbactive or lfs_log with splbio, lfs_lock is plenty.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/ufs/lfs/lfs_inode.h
cvs rdiff -u -r1.268 -r1.269 src/sys/ufs/lfs/lfs_segment.c
cvs rdiff -u -r1.91 -r1.92 src/sys/ufs/lfs/lfs_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/ufs/lfs/lfs_inode.h
diff -u src/sys/ufs/lfs/lfs_inode.h:1.18 src/sys/ufs/lfs/lfs_inode.h:1.19
--- src/sys/ufs/lfs/lfs_inode.h:1.18	Thu Apr  6 02:38:08 2017
+++ src/sys/ufs/lfs/lfs_inode.h	Thu Apr  6 03:21:01 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_inode.h,v 1.18 2017/04/06 02:38:08 maya Exp $	*/
+/*	$NetBSD: lfs_inode.h,v 1.19 2017/04/06 03:21:01 maya Exp $	*/
 /*  from NetBSD: ulfs_inode.h,v 1.5 2013/06/06 00:51:50 dholland Exp  */
 /*  from NetBSD: inode.h,v 1.72 2016/06/03 15:36:03 christos Exp  */
 
@@ -238,10 +238,8 @@ extern int lfs_lognum;
 extern struct lfs_log_entry lfs_log[LFS_LOGLENGTH];
 #  define LFS_BWRITE_LOG(bp) lfs_bwrite_log((bp), __FILE__, __LINE__)
 #  define LFS_ENTER_LOG(theop, thefile, theline, lbn, theflags, thepid) do {\
-	int _s;\
 	\
 	mutex_enter(_lock);		\
-	_s = splbio();			\
 	lfs_log[lfs_lognum].op = theop;	\
 	lfs_log[lfs_lognum].file = thefile;\
 	lfs_log[lfs_lognum].line = (theline);\
@@ -249,7 +247,6 @@ extern struct lfs_log_entry lfs_log[LFS_
 	lfs_log[lfs_lognum].block = (lbn);\
 	lfs_log[lfs_lognum].flags = (theflags);\
 	lfs_lognum = (lfs_lognum + 1) % LFS_LOGLENGTH;			\
-	splx(_s);			\
 	mutex_exit(_lock);		\
 } while (0)
 

Index: src/sys/ufs/lfs/lfs_segment.c
diff -u src/sys/ufs/lfs/lfs_segment.c:1.268 src/sys/ufs/lfs/lfs_segment.c:1.269
--- src/sys/ufs/lfs/lfs_segment.c:1.268	Thu Apr  6 03:15:03 2017
+++ src/sys/ufs/lfs/lfs_segment.c	Thu Apr  6 03:21:01 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_segment.c,v 1.268 2017/04/06 03:15:03 maya Exp $	*/
+/*	$NetBSD: lfs_segment.c,v 1.269 2017/04/06 03:21:01 maya Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_segment.c,v 1.268 2017/04/06 03:15:03 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_segment.c,v 1.269 2017/04/06 03:21:01 maya Exp $");
 
 #ifdef DEBUG
 # define vndebug(vp, str) do {		\
@@ -2384,7 +2384,6 @@ lfs_writesuper(struct lfs *fs, daddr_t d
 {
 	struct buf *bp;
 	struct vnode *devvp = VTOI(fs->lfs_ivnode)->i_devvp;
-	int s;
 
 	ASSERT_MAYBE_SEGLOCK(fs);
 	if (fs->lfs_is64) {
@@ -2398,13 +2397,11 @@ lfs_writesuper(struct lfs *fs, daddr_t d
 	 * So, block here if a superblock write is in progress.
 	 */
 	mutex_enter(_lock);
-	s = splbio();
 	while (fs->lfs_sbactive) {
 		mtsleep(>lfs_sbactive, PRIBIO+1, "lfs sb", 0,
 			_lock);
 	}
 	fs->lfs_sbactive = daddr;
-	splx(s);
 	mutex_exit(_lock);
 
 	/* Set timestamp of this version of the superblock */

Index: src/sys/ufs/lfs/lfs_subr.c
diff -u src/sys/ufs/lfs/lfs_subr.c:1.91 src/sys/ufs/lfs/lfs_subr.c:1.92
--- src/sys/ufs/lfs/lfs_subr.c:1.91	Thu Apr  6 03:12:48 2017
+++ src/sys/ufs/lfs/lfs_subr.c	Thu Apr  6 03:21:01 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_subr.c,v 1.91 2017/04/06 03:12:48 maya Exp $	*/
+/*	$NetBSD: lfs_subr.c,v 1.92 2017/04/06 03:21:01 maya Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_subr.c,v 1.91 2017/04/06 03:12:48 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_subr.c,v 1.92 2017/04/06 03:21:01 maya Exp $");
 
 #include 
 #include 
@@ -378,7 +378,7 @@ lfs_unmark_dirop(struct lfs *fs)
 static void
 lfs_auto_segclean(struct lfs *fs)
 {
-	int i, error, s, waited;
+	int i, error, waited;
 
 	ASSERT_SEGLOCK(fs);
 	/*
@@ -398,11 +398,9 @@ lfs_auto_segclean(struct lfs *fs)
 
 			/* Make sure the sb is written before we clean */
 			mutex_enter(_lock);
-			s = splbio();
 			while (waited == 0 && fs->lfs_sbactive)
 mtsleep(>lfs_sbactive, PRIBIO+1, "lfs asb",
 	0, _lock);
-			splx(s);
 			mutex_exit(_lock);
 			waited = 1;
 



CVS commit: src/sys/ufs/lfs

2017-04-05 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Thu Apr  6 03:15:03 UTC 2017

Modified Files:
src/sys/ufs/lfs: lfs_segment.c

Log Message:
remove deprecated comment (and move it below assert)
there's no spl dance for I/O here.


To generate a diff of this commit:
cvs rdiff -u -r1.267 -r1.268 src/sys/ufs/lfs/lfs_segment.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/ufs/lfs/lfs_segment.c
diff -u src/sys/ufs/lfs/lfs_segment.c:1.267 src/sys/ufs/lfs/lfs_segment.c:1.268
--- src/sys/ufs/lfs/lfs_segment.c:1.267	Thu Apr  6 02:38:08 2017
+++ src/sys/ufs/lfs/lfs_segment.c	Thu Apr  6 03:15:03 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_segment.c,v 1.267 2017/04/06 02:38:08 maya Exp $	*/
+/*	$NetBSD: lfs_segment.c,v 1.268 2017/04/06 03:15:03 maya Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_segment.c,v 1.267 2017/04/06 02:38:08 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_segment.c,v 1.268 2017/04/06 03:15:03 maya Exp $");
 
 #ifdef DEBUG
 # define vndebug(vp, str) do {		\
@@ -1304,12 +1304,10 @@ lfs_gatherblock(struct segment *sp, stru
 	int j, blksinblk;
 
 	ASSERT_SEGLOCK(sp->fs);
-	/*
-	 * If full, finish this segment.  We may be doing I/O, so
-	 * release and reacquire the splbio().
-	 */
 	KASSERTMSG((sp->vp != NULL),
 	"lfs_gatherblock: Null vp in segment");
+
+	/* If full, finish this segment. */
 	fs = sp->fs;
 	blksinblk = howmany(bp->b_bcount, lfs_sb_getbsize(fs));
 	if (sp->sum_bytes_left < sizeof(int32_t) * blksinblk ||



CVS commit: src/sys/ufs/lfs

2017-04-05 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Thu Apr  6 03:12:48 UTC 2017

Modified Files:
src/sys/ufs/lfs: lfs_subr.c

Log Message:
don't guard lfs_reshash with splbio, lfs_lock is plenty


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/sys/ufs/lfs/lfs_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/ufs/lfs/lfs_subr.c
diff -u src/sys/ufs/lfs/lfs_subr.c:1.90 src/sys/ufs/lfs/lfs_subr.c:1.91
--- src/sys/ufs/lfs/lfs_subr.c:1.90	Thu Apr  6 02:55:22 2017
+++ src/sys/ufs/lfs/lfs_subr.c	Thu Apr  6 03:12:48 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_subr.c,v 1.90 2017/04/06 02:55:22 maya Exp $	*/
+/*	$NetBSD: lfs_subr.c,v 1.91 2017/04/06 03:12:48 maya Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_subr.c,v 1.90 2017/04/06 02:55:22 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_subr.c,v 1.91 2017/04/06 03:12:48 maya Exp $");
 
 #include 
 #include 
@@ -188,7 +188,7 @@ lfs_malloc(struct lfs *fs, size_t size, 
 {
 	struct lfs_res_blk *re;
 	void *r;
-	int i, s, start;
+	int i, start;
 	unsigned int h;
 
 	ASSERT_MAYBE_SEGLOCK(fs);
@@ -224,9 +224,7 @@ lfs_malloc(struct lfs *fs, size_t size, 
 r = re->p;
 KASSERT(re->size >= size);
 h = lfs_mhash(r);
-s = splbio();
 LIST_INSERT_HEAD(>lfs_reshash[h], re, res);
-splx(s);
 mutex_exit(_lock);
 return r;
 			}
@@ -246,32 +244,28 @@ lfs_malloc(struct lfs *fs, size_t size, 
 void
 lfs_free(struct lfs *fs, void *p, int type)
 {
-	int s;
 	unsigned int h;
 	res_t *re;
 
 	ASSERT_MAYBE_SEGLOCK(fs);
 	h = lfs_mhash(p);
 	mutex_enter(_lock);
-	s = splbio();
 	LIST_FOREACH(re, >lfs_reshash[h], res) {
 		if (re->p == p) {
 			KASSERT(re->inuse == 1);
 			LIST_REMOVE(re, res);
 			re->inuse = 0;
 			wakeup(>lfs_resblk);
-			splx(s);
 			mutex_exit(_lock);
 			return;
 		}
 	}
 
 	for (int i = 0; i < LFS_N_TOTAL; i++) {
-		KDASSERTMSG(fs->lfs_resblk[i].p != p,
+		KDASSERTMSG(fs->lfs_resblk[i].p == p,
 		"lfs_free: inconsistent reserved block");
 	}
 
-	splx(s);
 	mutex_exit(_lock);
 
 	/*



CVS commit: src/sys/ufs/lfs

2017-04-05 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Thu Apr  6 02:55:22 UTC 2017

Modified Files:
src/sys/ufs/lfs: lfs_subr.c

Log Message:
if DEBUG panic => KDASSERT. reduces ifdefs. NFC


To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.90 src/sys/ufs/lfs/lfs_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/ufs/lfs/lfs_subr.c
diff -u src/sys/ufs/lfs/lfs_subr.c:1.89 src/sys/ufs/lfs/lfs_subr.c:1.90
--- src/sys/ufs/lfs/lfs_subr.c:1.89	Thu Apr  6 02:38:08 2017
+++ src/sys/ufs/lfs/lfs_subr.c	Thu Apr  6 02:55:22 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_subr.c,v 1.89 2017/04/06 02:38:08 maya Exp $	*/
+/*	$NetBSD: lfs_subr.c,v 1.90 2017/04/06 02:55:22 maya Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_subr.c,v 1.89 2017/04/06 02:38:08 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_subr.c,v 1.90 2017/04/06 02:55:22 maya Exp $");
 
 #include 
 #include 
@@ -249,9 +249,6 @@ lfs_free(struct lfs *fs, void *p, int ty
 	int s;
 	unsigned int h;
 	res_t *re;
-#ifdef DEBUG
-	int i;
-#endif
 
 	ASSERT_MAYBE_SEGLOCK(fs);
 	h = lfs_mhash(p);
@@ -268,15 +265,15 @@ lfs_free(struct lfs *fs, void *p, int ty
 			return;
 		}
 	}
-#ifdef DEBUG
-	for (i = 0; i < LFS_N_TOTAL; i++) {
-		if (fs->lfs_resblk[i].p == p)
-			panic("lfs_free: inconsistent reserved block");
+
+	for (int i = 0; i < LFS_N_TOTAL; i++) {
+		KDASSERTMSG(fs->lfs_resblk[i].p != p,
+		"lfs_free: inconsistent reserved block");
 	}
-#endif
+
 	splx(s);
 	mutex_exit(_lock);
-	
+
 	/*
 	 * If we didn't find it, free it.
 	 */



CVS commit: src/sys/ufs/lfs

2017-04-05 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Thu Apr  6 02:38:08 UTC 2017

Modified Files:
src/sys/ufs/lfs: lfs_balloc.c lfs_inode.h lfs_segment.c lfs_subr.c

Log Message:
Provide a LFS_ENTER_LOG (__nothing) in the !DEBUG case.
so I can drop lots of #ifdef DEBUG around this macro. NFCI


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/sys/ufs/lfs/lfs_balloc.c
cvs rdiff -u -r1.17 -r1.18 src/sys/ufs/lfs/lfs_inode.h
cvs rdiff -u -r1.266 -r1.267 src/sys/ufs/lfs/lfs_segment.c
cvs rdiff -u -r1.88 -r1.89 src/sys/ufs/lfs/lfs_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/ufs/lfs/lfs_balloc.c
diff -u src/sys/ufs/lfs/lfs_balloc.c:1.91 src/sys/ufs/lfs/lfs_balloc.c:1.92
--- src/sys/ufs/lfs/lfs_balloc.c:1.91	Sun Aug  7 02:42:32 2016
+++ src/sys/ufs/lfs/lfs_balloc.c	Thu Apr  6 02:38:08 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_balloc.c,v 1.91 2016/08/07 02:42:32 dholland Exp $	*/
+/*	$NetBSD: lfs_balloc.c,v 1.92 2017/04/06 02:38:08 maya Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_balloc.c,v 1.91 2016/08/07 02:42:32 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_balloc.c,v 1.92 2017/04/06 02:38:08 maya Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_quota.h"
@@ -368,13 +368,12 @@ lfs_balloc(struct vnode *vp, off_t start
 
 /* get the block for the next iteration */
 idaddr = lfs_iblock_get(fs, ibp->b_data, indirs[i].in_off);
-#ifdef DEBUG
+
 if (vp == fs->lfs_ivnode) {
 	LFS_ENTER_LOG("balloc", __FILE__,
 		__LINE__, indirs[i].in_lbn,
 		ibp->b_flags, curproc->p_pid);
 }
-#endif
 /*
  * Write out the updated indirect block. Note
  * that this writes it out even if we didn't
@@ -450,13 +449,13 @@ lfs_balloc(struct vnode *vp, off_t start
 panic("lfs_balloc: bread bno %lld",
 (long long)idp->in_lbn);
 			lfs_iblock_set(fs, ibp->b_data, idp->in_off, UNWRITTEN);
-#ifdef DEBUG
+
 			if (vp == fs->lfs_ivnode) {
 LFS_ENTER_LOG("balloc", __FILE__,
 	__LINE__, idp->in_lbn,
 	ibp->b_flags, curproc->p_pid);
 			}
-#endif
+
 			VOP_BWRITE(ibp->b_vp, ibp);
 		}
 	} else if (bpp && !(bp->b_oflags & (BO_DONE|BO_DELWRI))) {

Index: src/sys/ufs/lfs/lfs_inode.h
diff -u src/sys/ufs/lfs/lfs_inode.h:1.17 src/sys/ufs/lfs/lfs_inode.h:1.18
--- src/sys/ufs/lfs/lfs_inode.h:1.17	Thu Apr  6 01:54:23 2017
+++ src/sys/ufs/lfs/lfs_inode.h	Thu Apr  6 02:38:08 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_inode.h,v 1.17 2017/04/06 01:54:23 maya Exp $	*/
+/*	$NetBSD: lfs_inode.h,v 1.18 2017/04/06 02:38:08 maya Exp $	*/
 /*  from NetBSD: ulfs_inode.h,v 1.5 2013/06/06 00:51:50 dholland Exp  */
 /*  from NetBSD: inode.h,v 1.72 2016/06/03 15:36:03 christos Exp  */
 
@@ -273,6 +273,7 @@ extern struct lfs_log_entry lfs_log[LFS_
 # else /* ! DEBUG */
 #  define LFS_BCLEAN_LOG(fs, bp)
 #  define LFS_BWRITE_LOG(bp)		VOP_BWRITE((bp)->b_vp, (bp))
+#  define LFS_ENTER_LOG(theop, thefile, theline, lbn, theflags, thepid) __nothing
 #  define DLOG(a)
 # endif /* ! DEBUG */
 #else /* ! _KERNEL */

Index: src/sys/ufs/lfs/lfs_segment.c
diff -u src/sys/ufs/lfs/lfs_segment.c:1.266 src/sys/ufs/lfs/lfs_segment.c:1.267
--- src/sys/ufs/lfs/lfs_segment.c:1.266	Thu Apr  6 01:54:23 2017
+++ src/sys/ufs/lfs/lfs_segment.c	Thu Apr  6 02:38:08 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_segment.c,v 1.266 2017/04/06 01:54:23 maya Exp $	*/
+/*	$NetBSD: lfs_segment.c,v 1.267 2017/04/06 02:38:08 maya Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_segment.c,v 1.266 2017/04/06 01:54:23 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_segment.c,v 1.267 2017/04/06 02:38:08 maya Exp $");
 
 #ifdef DEBUG
 # define vndebug(vp, str) do {		\
@@ -730,9 +730,9 @@ lfs_segwrite(struct mount *mp, int flags
 		int loopcount = 0;
 #endif
 		do {
-#ifdef DEBUG
+
 			LFS_ENTER_LOG("pretend", __FILE__, __LINE__, 0, 0, curproc->p_pid);
-#endif
+
 			mutex_enter(_lock);
 			fs->lfs_flags &= ~LFS_IFDIRTY;
 			mutex_exit(_lock);

Index: src/sys/ufs/lfs/lfs_subr.c
diff -u src/sys/ufs/lfs/lfs_subr.c:1.88 src/sys/ufs/lfs/lfs_subr.c:1.89
--- src/sys/ufs/lfs/lfs_subr.c:1.88	Sat Apr  1 14:53:48 2017
+++ src/sys/ufs/lfs/lfs_subr.c	Thu Apr  6 02:38:08 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_subr.c,v 1.88 2017/04/01 14:53:48 maya Exp $	*/
+/*	$NetBSD: lfs_subr.c,v 1.89 2017/04/06 02:38:08 maya Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_subr.c,v 1.88 2017/04/01 14:53:48 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_subr.c,v 1.89 2017/04/06 02:38:08 maya Exp $");
 
 #include 
 #include 
@@ -317,9 +317,8 @@ lfs_seglock(struct lfs *fs, unsigned lon
 	mutex_exit(_lock);
 	fs->lfs_cleanind = 

CVS commit: src/sys/ufs/lfs

2017-04-05 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Thu Apr  6 01:54:23 UTC 2017

Modified Files:
src/sys/ufs/lfs: lfs_inode.h lfs_segment.c

Log Message:
Drop single use macro LFS_BCLEAN_LOG with an inlined implementation.

LFS_ENTER_LOG currently macro grabs lfs_lock, so I'd like to have just one
name for it.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/ufs/lfs/lfs_inode.h
cvs rdiff -u -r1.265 -r1.266 src/sys/ufs/lfs/lfs_segment.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/ufs/lfs/lfs_inode.h
diff -u src/sys/ufs/lfs/lfs_inode.h:1.16 src/sys/ufs/lfs/lfs_inode.h:1.17
--- src/sys/ufs/lfs/lfs_inode.h:1.16	Mon Jun 20 03:29:52 2016
+++ src/sys/ufs/lfs/lfs_inode.h	Thu Apr  6 01:54:23 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_inode.h,v 1.16 2016/06/20 03:29:52 dholland Exp $	*/
+/*	$NetBSD: lfs_inode.h,v 1.17 2017/04/06 01:54:23 maya Exp $	*/
 /*  from NetBSD: ulfs_inode.h,v 1.5 2013/06/06 00:51:50 dholland Exp  */
 /*  from NetBSD: inode.h,v 1.72 2016/06/03 15:36:03 christos Exp  */
 
@@ -253,12 +253,6 @@ extern struct lfs_log_entry lfs_log[LFS_
 	mutex_exit(_lock);		\
 } while (0)
 
-#  define LFS_BCLEAN_LOG(fs, bp) do {	\
-	if ((bp)->b_vp == (fs)->lfs_ivnode)\
-		LFS_ENTER_LOG("clear", __FILE__, __LINE__,		\
-			  bp->b_lblkno, bp->b_flags, curproc->p_pid);\
-} while (0)
-
 /* Must match list in lfs_vfsops.c ! */
 #  define DLOG_RF 0  /* roll forward */
 #  define DLOG_ALLOC  1  /* inode alloc */

Index: src/sys/ufs/lfs/lfs_segment.c
diff -u src/sys/ufs/lfs/lfs_segment.c:1.265 src/sys/ufs/lfs/lfs_segment.c:1.266
--- src/sys/ufs/lfs/lfs_segment.c:1.265	Sat Apr  1 19:35:56 2017
+++ src/sys/ufs/lfs/lfs_segment.c	Thu Apr  6 01:54:23 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_segment.c,v 1.265 2017/04/01 19:35:56 riastradh Exp $	*/
+/*	$NetBSD: lfs_segment.c,v 1.266 2017/04/06 01:54:23 maya Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_segment.c,v 1.265 2017/04/01 19:35:56 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_segment.c,v 1.266 2017/04/06 01:54:23 maya Exp $");
 
 #ifdef DEBUG
 # define vndebug(vp, str) do {		\
@@ -2572,7 +2572,11 @@ lfs_cluster_aiodone(struct buf *bp)
 
 		tbp->b_flags &= ~B_GATHERED;
 
-		LFS_BCLEAN_LOG(fs, tbp);
+#ifdef DEBUG
+		if ((tbp)->b_vp == (fs)->lfs_ivnode)
+			LFS_ENTER_LOG("clear", __FILE__, __LINE__,
+			tbp->b_lblkno, tbp->b_flags, curproc->p_pid);
+#endif
 
 		mutex_enter(_lock);
 		if (tbp->b_iodone == NULL) {



CVS commit: src/sys/ufs/lfs

2017-04-01 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Sat Apr  1 17:34:21 UTC 2017

Modified Files:
src/sys/ufs/lfs: lfs_bio.c lfs_pages.c lfs_vfsops.c lfs_vnops.c

Log Message:
Switch lfs_writer_daemon to use condvar instead of mtsleep.
track thread existence with struct lwp instead of pid + lid,
it's more useful from ddb.


To generate a diff of this commit:
cvs rdiff -u -r1.136 -r1.137 src/sys/ufs/lfs/lfs_bio.c
cvs rdiff -u -r1.10 -r1.11 src/sys/ufs/lfs/lfs_pages.c
cvs rdiff -u -r1.355 -r1.356 src/sys/ufs/lfs/lfs_vfsops.c
cvs rdiff -u -r1.309 -r1.310 src/sys/ufs/lfs/lfs_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/ufs/lfs/lfs_bio.c
diff -u src/sys/ufs/lfs/lfs_bio.c:1.136 src/sys/ufs/lfs/lfs_bio.c:1.137
--- src/sys/ufs/lfs/lfs_bio.c:1.136	Mon Mar 13 14:24:20 2017
+++ src/sys/ufs/lfs/lfs_bio.c	Sat Apr  1 17:34:21 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_bio.c,v 1.136 2017/03/13 14:24:20 riastradh Exp $	*/
+/*	$NetBSD: lfs_bio.c,v 1.137 2017/04/01 17:34:21 maya Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2008 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_bio.c,v 1.136 2017/03/13 14:24:20 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_bio.c,v 1.137 2017/04/01 17:34:21 maya Exp $");
 
 #include 
 #include 
@@ -583,7 +583,7 @@ lfs_check(struct vnode *vp, daddr_t blkn
 	int error;
 	struct lfs *fs;
 	struct inode *ip;
-	extern pid_t lfs_writer_daemon;
+	extern kcondvar_t lfs_writerd_cv;
 
 	error = 0;
 	ip = VTOI(vp);
@@ -660,7 +660,7 @@ lfs_check(struct vnode *vp, daddr_t blkn
 		 * still might want to be flushed.
 		 */
 		++fs->lfs_pdflush;
-		wakeup(_writer_daemon);
+		cv_broadcast(_writerd_cv);
 	}
 
 	while (locked_queue_count + INOCOUNT(fs) >= LFS_WAIT_BUFS ||

Index: src/sys/ufs/lfs/lfs_pages.c
diff -u src/sys/ufs/lfs/lfs_pages.c:1.10 src/sys/ufs/lfs/lfs_pages.c:1.11
--- src/sys/ufs/lfs/lfs_pages.c:1.10	Thu Mar 30 09:10:08 2017
+++ src/sys/ufs/lfs/lfs_pages.c	Sat Apr  1 17:34:21 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_pages.c,v 1.10 2017/03/30 09:10:08 hannken Exp $	*/
+/*	$NetBSD: lfs_pages.c,v 1.11 2017/04/01 17:34:21 maya Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_pages.c,v 1.10 2017/03/30 09:10:08 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_pages.c,v 1.11 2017/04/01 17:34:21 maya Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -103,7 +103,7 @@ __KERNEL_RCSID(0, "$NetBSD: lfs_pages.c,
 #include 
 #include 
 
-extern pid_t lfs_writer_daemon;
+extern kcondvar_t lfs_writerd_cv;
 
 static int check_dirty(struct lfs *, struct vnode *, off_t, off_t, off_t, int, int, struct vm_page **);
 
@@ -691,8 +691,8 @@ retry:
 		if (!(ip->i_flags & IN_PAGING)) {
 			ip->i_flags |= IN_PAGING;
 			TAILQ_INSERT_TAIL(>lfs_pchainhd, ip, i_lfs_pchain);
-		} 
-		wakeup(_writer_daemon);
+		}
+		cv_broadcast(_writerd_cv);
 		mutex_exit(_lock);
 		preempt();
 		KASSERT(!mutex_owned(vp->v_interlock));

Index: src/sys/ufs/lfs/lfs_vfsops.c
diff -u src/sys/ufs/lfs/lfs_vfsops.c:1.355 src/sys/ufs/lfs/lfs_vfsops.c:1.356
--- src/sys/ufs/lfs/lfs_vfsops.c:1.355	Sat Apr  1 14:43:00 2017
+++ src/sys/ufs/lfs/lfs_vfsops.c	Sat Apr  1 17:34:21 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_vfsops.c,v 1.355 2017/04/01 14:43:00 maya Exp $	*/
+/*	$NetBSD: lfs_vfsops.c,v 1.356 2017/04/01 17:34:21 maya Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007, 2007
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.355 2017/04/01 14:43:00 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.356 2017/04/01 17:34:21 maya Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_lfs.h"
@@ -128,8 +128,9 @@ extern const struct vnodeopv_desc lfs_vn
 extern const struct vnodeopv_desc lfs_specop_opv_desc;
 extern const struct vnodeopv_desc lfs_fifoop_opv_desc;
 
-pid_t lfs_writer_daemon = 0;
-lwpid_t lfs_writer_lid = 0;
+struct lwp * lfs_writer_daemon = NULL;
+kcondvar_t lfs_writerd_cv;
+
 int lfs_do_flush = 0;
 #ifdef LFS_KERNEL_RFW
 int lfs_do_rfw = 0;
@@ -395,8 +396,8 @@ lfs_writerd(void *arg)
 	int wrote_something = 0;
  
 	mutex_enter(_lock);
- 	lfs_writer_daemon = curproc->p_pid;
-	lfs_writer_lid = curlwp->l_lid;
+	KASSERTMSG(lfs_writer_daemon == NULL, "more than one LFS writer daemon");
+	lfs_writer_daemon = curlwp;
 	mutex_exit(_lock);
 
 	/* Take an extra reference to the LFS vfsops. */
@@ -406,9 +407,7 @@ lfs_writerd(void *arg)
  	for (;;) {
 		KASSERT(mutex_owned(_lock));
 		if (wrote_something == 0)
-			mtsleep(_writer_daemon, PVM, "lfswriter", hz/10 + 1,
-_lock);
-
+			cv_timedwait(_writerd_cv, _lock, hz/10 + 1);
 		KASSERT(mutex_owned(_lock));
 		wrote_something = 0;
 
@@ -508,8 +507,7 @@ lfs_writerd(void *arg)
  		}
 		if (lfsc + skipc == 0) {
 			mutex_enter(_lock);
-			

CVS commit: src/sys/ufs/lfs

2017-04-01 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Sat Apr  1 14:53:48 UTC 2017

Modified Files:
src/sys/ufs/lfs: lfs_subr.c

Log Message:
Keep on holding lfs_lock when calling cv_broadcast

pointed out by skrll, thanks.


To generate a diff of this commit:
cvs rdiff -u -r1.87 -r1.88 src/sys/ufs/lfs/lfs_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/ufs/lfs/lfs_subr.c
diff -u src/sys/ufs/lfs/lfs_subr.c:1.87 src/sys/ufs/lfs/lfs_subr.c:1.88
--- src/sys/ufs/lfs/lfs_subr.c:1.87	Sat Apr  1 14:43:00 2017
+++ src/sys/ufs/lfs/lfs_subr.c	Sat Apr  1 14:53:48 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_subr.c,v 1.87 2017/04/01 14:43:00 maya Exp $	*/
+/*	$NetBSD: lfs_subr.c,v 1.88 2017/04/01 14:53:48 maya Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_subr.c,v 1.87 2017/04/01 14:43:00 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_subr.c,v 1.88 2017/04/01 14:53:48 maya Exp $");
 
 #include 
 #include 
@@ -595,9 +595,9 @@ lfs_writer_leave(struct lfs *fs)
 	ASSERT_MAYBE_SEGLOCK(fs);
 	mutex_enter(_lock);
 	dowakeup = !(--fs->lfs_writer);
-	mutex_exit(_lock);
 	if (dowakeup)
 		cv_broadcast(>lfs_diropscv);
+	mutex_exit(_lock);
 }
 
 /*



CVS commit: src/sys/ufs/lfs

2017-04-01 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Sat Apr  1 14:43:00 UTC 2017

Modified Files:
src/sys/ufs/lfs: lfs.h lfs_subr.c lfs_vfsops.c lfs_vnops.c

Log Message:
switch lfs_dirops to condvar (from mtsleep)


To generate a diff of this commit:
cvs rdiff -u -r1.200 -r1.201 src/sys/ufs/lfs/lfs.h
cvs rdiff -u -r1.86 -r1.87 src/sys/ufs/lfs/lfs_subr.c
cvs rdiff -u -r1.354 -r1.355 src/sys/ufs/lfs/lfs_vfsops.c
cvs rdiff -u -r1.308 -r1.309 src/sys/ufs/lfs/lfs_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/ufs/lfs/lfs.h
diff -u src/sys/ufs/lfs/lfs.h:1.200 src/sys/ufs/lfs/lfs.h:1.201
--- src/sys/ufs/lfs/lfs.h:1.200	Sat Apr  1 01:50:02 2017
+++ src/sys/ufs/lfs/lfs.h	Sat Apr  1 14:43:00 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs.h,v 1.200 2017/04/01 01:50:02 maya Exp $	*/
+/*	$NetBSD: lfs.h,v 1.201 2017/04/01 14:43:00 maya Exp $	*/
 
 /*  from NetBSD: dinode.h,v 1.25 2016/01/22 23:06:10 dholland Exp  */
 /*  from NetBSD: dir.h,v 1.25 2015/09/01 06:16:03 dholland Exp  */
@@ -976,6 +976,7 @@ struct lfs {
 	uint32_t lfs_iocount;		/* number of ios pending */
 	uint32_t lfs_writer;		/* don't allow any dirops to start */
 	uint32_t lfs_dirops;		/* count of active directory ops */
+	kcondvar_t lfs_diropscv;	/* condvar of active directory ops */
 	uint32_t lfs_dirvcount;		/* count of VDIROP nodes in this fs */
 	uint32_t lfs_doifile;		/* Write ifile blocks on next write */
 	uint32_t lfs_nactive;		/* Number of segments since last ckp */

Index: src/sys/ufs/lfs/lfs_subr.c
diff -u src/sys/ufs/lfs/lfs_subr.c:1.86 src/sys/ufs/lfs/lfs_subr.c:1.87
--- src/sys/ufs/lfs/lfs_subr.c:1.86	Sat Oct  3 08:28:16 2015
+++ src/sys/ufs/lfs/lfs_subr.c	Sat Apr  1 14:43:00 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_subr.c,v 1.86 2015/10/03 08:28:16 dholland Exp $	*/
+/*	$NetBSD: lfs_subr.c,v 1.87 2017/04/01 14:43:00 maya Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_subr.c,v 1.86 2015/10/03 08:28:16 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_subr.c,v 1.87 2017/04/01 14:43:00 maya Exp $");
 
 #include 
 #include 
@@ -597,7 +597,7 @@ lfs_writer_leave(struct lfs *fs)
 	dowakeup = !(--fs->lfs_writer);
 	mutex_exit(_lock);
 	if (dowakeup)
-		wakeup(>lfs_dirops);
+		cv_broadcast(>lfs_diropscv);
 }
 
 /*

Index: src/sys/ufs/lfs/lfs_vfsops.c
diff -u src/sys/ufs/lfs/lfs_vfsops.c:1.354 src/sys/ufs/lfs/lfs_vfsops.c:1.355
--- src/sys/ufs/lfs/lfs_vfsops.c:1.354	Sat Apr  1 01:50:02 2017
+++ src/sys/ufs/lfs/lfs_vfsops.c	Sat Apr  1 14:43:00 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_vfsops.c,v 1.354 2017/04/01 01:50:02 maya Exp $	*/
+/*	$NetBSD: lfs_vfsops.c,v 1.355 2017/04/01 14:43:00 maya Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007, 2007
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.354 2017/04/01 01:50:02 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.355 2017/04/01 14:43:00 maya Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_lfs.h"
@@ -1098,6 +1098,7 @@ lfs_mountfs(struct vnode *devvp, struct 
 	rw_init(>lfs_fraglock);
 	rw_init(>lfs_iflock);
 	cv_init(>lfs_sleeperscv, "lfs_slp");
+	cv_init(>lfs_diropscv, "lfs_dirop");
 	cv_init(>lfs_stopcv, "lfsstop");
 
 	/* Set the file system readonly/modify bits. */
@@ -1415,6 +1416,7 @@ lfs_unmount(struct mount *mp, int mntfla
 	free(fs->lfs_suflags, M_SEGMENT);
 	lfs_free_resblks(fs);
 	cv_destroy(>lfs_sleeperscv);
+	cv_destroy(>lfs_diropscv);
 	cv_destroy(>lfs_stopcv);
 	rw_destroy(>lfs_fraglock);
 	rw_destroy(>lfs_iflock);

Index: src/sys/ufs/lfs/lfs_vnops.c
diff -u src/sys/ufs/lfs/lfs_vnops.c:1.308 src/sys/ufs/lfs/lfs_vnops.c:1.309
--- src/sys/ufs/lfs/lfs_vnops.c:1.308	Sat Apr  1 01:50:02 2017
+++ src/sys/ufs/lfs/lfs_vnops.c	Sat Apr  1 14:43:00 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_vnops.c,v 1.308 2017/04/01 01:50:02 maya Exp $	*/
+/*	$NetBSD: lfs_vnops.c,v 1.309 2017/04/01 14:43:00 maya Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -125,7 +125,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.308 2017/04/01 01:50:02 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.309 2017/04/01 14:43:00 maya Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -573,8 +573,7 @@ lfs_set_dirop(struct vnode *dvp, struct 
 		mutex_enter(_lock);
 	}
 	while (fs->lfs_writer) {
-		error = mtsleep(>lfs_dirops, (PRIBIO + 1) | PCATCH,
-		"lfs_sdirop", 0, _lock);
+		error = cv_wait_sig(>lfs_diropscv, _lock);
 		if (error == EINTR) {
 			mutex_exit(_lock);
 			goto unreserve;



CVS commit: src/sys/ufs/lfs

2017-03-31 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Sat Apr  1 01:50:02 UTC 2017

Modified Files:
src/sys/ufs/lfs: lfs.h lfs_vfsops.c lfs_vnops.c

Log Message:
switch lfs_sleepers to condvar (from mtsleep)


To generate a diff of this commit:
cvs rdiff -u -r1.199 -r1.200 src/sys/ufs/lfs/lfs.h
cvs rdiff -u -r1.353 -r1.354 src/sys/ufs/lfs/lfs_vfsops.c
cvs rdiff -u -r1.307 -r1.308 src/sys/ufs/lfs/lfs_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/ufs/lfs/lfs.h
diff -u src/sys/ufs/lfs/lfs.h:1.199 src/sys/ufs/lfs/lfs.h:1.200
--- src/sys/ufs/lfs/lfs.h:1.199	Mon Jun 20 03:25:46 2016
+++ src/sys/ufs/lfs/lfs.h	Sat Apr  1 01:50:02 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs.h,v 1.199 2016/06/20 03:25:46 dholland Exp $	*/
+/*	$NetBSD: lfs.h,v 1.200 2017/04/01 01:50:02 maya Exp $	*/
 
 /*  from NetBSD: dinode.h,v 1.25 2016/01/22 23:06:10 dholland Exp  */
 /*  from NetBSD: dir.h,v 1.25 2015/09/01 06:16:03 dholland Exp  */
@@ -1018,6 +1018,7 @@ struct lfs {
 	daddr_t  lfs_cleanint[LFS_MAX_CLEANIND]; /* Active cleaning intervals */
 	int 	 lfs_cleanind;		/* Index into intervals */
 	int lfs_sleepers;		/* # procs sleeping this fs */
+	kcondvar_t lfs_sleeperscv;	
 	int lfs_pages;			/* dirty pages blaming this fs */
 	lfs_bm_t *lfs_ino_bitmap;	/* Inuse inodes bitmap */
 	int lfs_nowrap;			/* Suspend log wrap */

Index: src/sys/ufs/lfs/lfs_vfsops.c
diff -u src/sys/ufs/lfs/lfs_vfsops.c:1.353 src/sys/ufs/lfs/lfs_vfsops.c:1.354
--- src/sys/ufs/lfs/lfs_vfsops.c:1.353	Mon Mar 13 14:24:20 2017
+++ src/sys/ufs/lfs/lfs_vfsops.c	Sat Apr  1 01:50:02 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_vfsops.c,v 1.353 2017/03/13 14:24:20 riastradh Exp $	*/
+/*	$NetBSD: lfs_vfsops.c,v 1.354 2017/04/01 01:50:02 maya Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007, 2007
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.353 2017/03/13 14:24:20 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.354 2017/04/01 01:50:02 maya Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_lfs.h"
@@ -1097,6 +1097,7 @@ lfs_mountfs(struct vnode *devvp, struct 
 	fs->lfs_pages = 0;
 	rw_init(>lfs_fraglock);
 	rw_init(>lfs_iflock);
+	cv_init(>lfs_sleeperscv, "lfs_slp");
 	cv_init(>lfs_stopcv, "lfsstop");
 
 	/* Set the file system readonly/modify bits. */
@@ -1349,8 +1350,7 @@ lfs_unmount(struct mount *mp, int mntfla
 	lfs_wakeup_cleaner(fs);
 	mutex_enter(_lock);
 	while (fs->lfs_sleepers)
-		mtsleep(>lfs_sleepers, PRIBIO + 1, "lfs_sleepers", 0,
-			_lock);
+		cv_wait(>lfs_sleeperscv, _lock);
 	mutex_exit(_lock);
 
 #ifdef LFS_EXTATTR
@@ -1414,6 +1414,7 @@ lfs_unmount(struct mount *mp, int mntfla
 	free(fs->lfs_suflags[1], M_SEGMENT);
 	free(fs->lfs_suflags, M_SEGMENT);
 	lfs_free_resblks(fs);
+	cv_destroy(>lfs_sleeperscv);
 	cv_destroy(>lfs_stopcv);
 	rw_destroy(>lfs_fraglock);
 	rw_destroy(>lfs_iflock);

Index: src/sys/ufs/lfs/lfs_vnops.c
diff -u src/sys/ufs/lfs/lfs_vnops.c:1.307 src/sys/ufs/lfs/lfs_vnops.c:1.308
--- src/sys/ufs/lfs/lfs_vnops.c:1.307	Thu Mar 30 09:10:08 2017
+++ src/sys/ufs/lfs/lfs_vnops.c	Sat Apr  1 01:50:02 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_vnops.c,v 1.307 2017/03/30 09:10:08 hannken Exp $	*/
+/*	$NetBSD: lfs_vnops.c,v 1.308 2017/04/01 01:50:02 maya Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -125,7 +125,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.307 2017/03/30 09:10:08 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.308 2017/04/01 01:50:02 maya Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -1890,7 +1890,7 @@ segwait_common:
 
 		mutex_enter(_lock);
 		if (--fs->lfs_sleepers == 0)
-			wakeup(>lfs_sleepers);
+			cv_broadcast(>lfs_sleeperscv);
 		mutex_exit(_lock);
 		return error;
 
@@ -1933,7 +1933,7 @@ segwait_common:
 		}
 		mutex_enter(_lock);
 		if (--fs->lfs_sleepers == 0)
-			wakeup(>lfs_sleepers);
+			cv_broadcast(>lfs_sleeperscv);
 		mutex_exit(_lock);
 		lfs_free(fs, blkiov, LFS_NB_BLKIOV);
 		return error;
@@ -1964,7 +1964,7 @@ segwait_common:
 	blkcnt * sizeof(BLOCK_INFO));
 		mutex_enter(_lock);
 		if (--fs->lfs_sleepers == 0)
-			wakeup(>lfs_sleepers);
+			cv_broadcast(>lfs_sleeperscv);
 		mutex_exit(_lock);
 		lfs_free(fs, blkiov, LFS_NB_BLKIOV);
 		return error;



CVS commit: src/sys/ufs/lfs

2017-03-31 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Sat Apr  1 00:40:42 UTC 2017

Modified Files:
src/sys/ufs/lfs: lfs_inode.c

Log Message:
Simplify locking


To generate a diff of this commit:
cvs rdiff -u -r1.154 -r1.155 src/sys/ufs/lfs/lfs_inode.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/ufs/lfs/lfs_inode.c
diff -u src/sys/ufs/lfs/lfs_inode.c:1.154 src/sys/ufs/lfs/lfs_inode.c:1.155
--- src/sys/ufs/lfs/lfs_inode.c:1.154	Fri Mar 31 23:00:21 2017
+++ src/sys/ufs/lfs/lfs_inode.c	Sat Apr  1 00:40:42 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_inode.c,v 1.154 2017/03/31 23:00:21 maya Exp $	*/
+/*	$NetBSD: lfs_inode.c,v 1.155 2017/04/01 00:40:42 maya Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.154 2017/03/31 23:00:21 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.155 2017/04/01 00:40:42 maya Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_quota.h"
@@ -856,7 +856,7 @@ static int
 lfs_vtruncbuf(struct vnode *vp, daddr_t lbn, bool catch, int slptimeo)
 {
 	struct buf *bp, *nbp;
-	int error;
+	int error = 0;
 	struct lfs *fs;
 	voff_t off;
 
@@ -879,10 +879,9 @@ restart:	
 		error = bbusy(bp, catch, slptimeo, NULL);
 		if (error == EPASSTHROUGH)
 			goto restart;
-		if (error != 0) {
-			mutex_exit(_lock);
-			return (error);
-		}
+		if (error)
+			goto exit;
+
 		mutex_enter(bp->b_objlock);
 		if (bp->b_oflags & BO_DELWRI) {
 			bp->b_oflags &= ~BO_DELWRI;
@@ -901,10 +900,9 @@ restart:	
 		error = bbusy(bp, catch, slptimeo, NULL);
 		if (error == EPASSTHROUGH)
 			goto restart;
-		if (error != 0) {
-			mutex_exit(_lock);
-			return (error);
-		}
+		if (error)
+			goto exit;
+
 		mutex_enter(bp->b_objlock);
 		if (bp->b_oflags & BO_DELWRI) {
 			bp->b_oflags &= ~BO_DELWRI;
@@ -915,8 +913,9 @@ restart:	
 		LFS_UNLOCK_BUF(bp);
 		brelsel(bp, BC_INVAL | BC_VFLUSH);
 	}
+exit:
 	mutex_exit(_lock);
 
-	return (0);
+	return error;
 }
 



CVS commit: src/sys/ufs/lfs

2017-03-31 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Fri Mar 31 23:00:21 UTC 2017

Modified Files:
src/sys/ufs/lfs: lfs_inode.c

Log Message:
stopgap fix- move lfs_lock to include calls to lfs_dino_{set,get}block

blocks new users that need seglock (need to take lfs_lock) that
setblock before the assert (truncate to 0 but 31 blks/31 effblks)

not proper, but lets me run firefox on lfs


To generate a diff of this commit:
cvs rdiff -u -r1.153 -r1.154 src/sys/ufs/lfs/lfs_inode.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/ufs/lfs/lfs_inode.c
diff -u src/sys/ufs/lfs/lfs_inode.c:1.153 src/sys/ufs/lfs/lfs_inode.c:1.154
--- src/sys/ufs/lfs/lfs_inode.c:1.153	Tue Mar 21 09:53:00 2017
+++ src/sys/ufs/lfs/lfs_inode.c	Fri Mar 31 23:00:21 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_inode.c,v 1.153 2017/03/21 09:53:00 maya Exp $	*/
+/*	$NetBSD: lfs_inode.c,v 1.154 2017/03/31 23:00:21 maya Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.153 2017/03/21 09:53:00 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.154 2017/03/31 23:00:21 maya Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_quota.h"
@@ -573,11 +573,11 @@ done:
 	oip->i_size = length;
 	lfs_dino_setsize(fs, oip->i_din, oip->i_size);
 	oip->i_lfs_effnblks -= blocksreleased;
+
+	mutex_enter(_lock);
 	lfs_dino_setblocks(fs, oip->i_din,
 	lfs_dino_getblocks(fs, oip->i_din) - real_released);
-	mutex_enter(_lock);
 	lfs_sb_addbfree(fs, blocksreleased);
-	mutex_exit(_lock);
 
 	KASSERTMSG((oip->i_size != 0 ||
 		lfs_dino_getblocks(fs, oip->i_din) == 0),
@@ -592,7 +592,6 @@ done:
 	/*
 	 * If we truncated to zero, take us off the paging queue.
 	 */
-	mutex_enter(_lock);
 	if (oip->i_size == 0 && oip->i_flags & IN_PAGING) {
 		oip->i_flags &= ~IN_PAGING;
 		TAILQ_REMOVE(>lfs_pchainhd, oip, i_lfs_pchain);



CVS commit: src/sys/ufs/ufs

2017-03-30 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Mar 30 09:11:45 UTC 2017

Modified Files:
src/sys/ufs/ufs: ufs_lookup.c

Log Message:
Remove now redundant calls to fstrans_start()/fstrans_done().


To generate a diff of this commit:
cvs rdiff -u -r1.145 -r1.146 src/sys/ufs/ufs/ufs_lookup.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/ufs/ufs/ufs_lookup.c
diff -u src/sys/ufs/ufs/ufs_lookup.c:1.145 src/sys/ufs/ufs/ufs_lookup.c:1.146
--- src/sys/ufs/ufs/ufs_lookup.c:1.145	Fri Apr 29 02:38:19 2016
+++ src/sys/ufs/ufs/ufs_lookup.c	Thu Mar 30 09:11:45 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_lookup.c,v 1.145 2016/04/29 02:38:19 christos Exp $	*/
+/*	$NetBSD: ufs_lookup.c,v 1.146 2017/03/30 09:11:45 hannken Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.145 2016/04/29 02:38:19 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.146 2017/03/30 09:11:45 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ffs.h"
@@ -54,7 +54,6 @@ __KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
@@ -376,8 +375,6 @@ ufs_lookup(void *v)
 		cnp->cn_flags |= ISWHITEOUT;
 	}
 
-	fstrans_start(vdp->v_mount, FSTRANS_SHARED);
-
 	/*
 	 * Suppress search for slots unless creating
 	 * file and at end of pathname, in which case
@@ -695,7 +692,6 @@ found:
 	error = 0;
 
 out:
-	fstrans_done(vdp->v_mount);
 	return error;
 }
 



CVS commit: src/sys/ufs/chfs

2017-03-30 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Mar 30 09:10:47 UTC 2017

Modified Files:
src/sys/ufs/chfs: chfs_vnops.c

Log Message:
Remove now redundant calls to fstrans_start()/fstrans_done().


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/ufs/chfs/chfs_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/ufs/chfs/chfs_vnops.c
diff -u src/sys/ufs/chfs/chfs_vnops.c:1.29 src/sys/ufs/chfs/chfs_vnops.c:1.30
--- src/sys/ufs/chfs/chfs_vnops.c:1.29	Sat Aug 20 12:37:09 2016
+++ src/sys/ufs/chfs/chfs_vnops.c	Thu Mar 30 09:10:46 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: chfs_vnops.c,v 1.29 2016/08/20 12:37:09 hannken Exp $	*/
+/*	$NetBSD: chfs_vnops.c,v 1.30 2017/03/30 09:10:46 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2010 Department of Software Engineering,
@@ -43,7 +43,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include "chfs.h"
@@ -653,8 +652,6 @@ chfs_read(void *v)
 	if (uio->uio_resid == 0)
 		return (0);
 
-	fstrans_start(vp->v_mount, FSTRANS_SHARED);
-
 	if (uio->uio_offset >= ip->size)
 		goto out;
 
@@ -737,7 +734,6 @@ out:
 		ip->iflag |= IN_ACCESS;
 		if ((ap->a_ioflag & IO_SYNC) == IO_SYNC) {
 			if (error) {
-fstrans_done(vp->v_mount);
 return error;
 			}
 			error = chfs_update(vp, NULL, NULL, UPDATE_WAIT);
@@ -745,7 +741,6 @@ out:
 	}
 
 	dbg("[END]\n");
-	fstrans_done(vp->v_mount);
 
 	return (error);
 }
@@ -833,8 +828,6 @@ chfs_write(void *v)
 	if (uio->uio_resid == 0)
 		return (0);
 
-	fstrans_start(vp->v_mount, FSTRANS_SHARED);
-
 	flags = ioflag & IO_SYNC ? B_SYNC : 0;
 	async = vp->v_mount->mnt_flag & MNT_ASYNC;
 	origoff = uio->uio_offset;
@@ -1003,7 +996,6 @@ out:
 
 
 	KASSERT(vp->v_size == ip->size);
-	fstrans_done(vp->v_mount);
 
 	mutex_enter(>chm_lock_mountfields);
 	error = chfs_write_flash_vnode(chmp, ip, ALLOC_NORMAL);



CVS commit: src/sys/ufs/lfs

2017-03-30 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Mar 30 09:10:08 UTC 2017

Modified Files:
src/sys/ufs/lfs: lfs_pages.c lfs_vnops.c ulfs_bmap.c ulfs_inode.c
ulfs_lookup.c ulfs_quota2.c ulfs_readwrite.c ulfs_vnops.c

Log Message:
Remove now redundant calls to fstrans_start()/fstrans_done().

Add fstrans_start()/fstrans_done() to lfs_putpages().


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/ufs/lfs/lfs_pages.c
cvs rdiff -u -r1.306 -r1.307 src/sys/ufs/lfs/lfs_vnops.c
cvs rdiff -u -r1.8 -r1.9 src/sys/ufs/lfs/ulfs_bmap.c
cvs rdiff -u -r1.16 -r1.17 src/sys/ufs/lfs/ulfs_inode.c
cvs rdiff -u -r1.39 -r1.40 src/sys/ufs/lfs/ulfs_lookup.c
cvs rdiff -u -r1.29 -r1.30 src/sys/ufs/lfs/ulfs_quota2.c
cvs rdiff -u -r1.22 -r1.23 src/sys/ufs/lfs/ulfs_readwrite.c
cvs rdiff -u -r1.45 -r1.46 src/sys/ufs/lfs/ulfs_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/ufs/lfs/lfs_pages.c
diff -u src/sys/ufs/lfs/lfs_pages.c:1.9 src/sys/ufs/lfs/lfs_pages.c:1.10
--- src/sys/ufs/lfs/lfs_pages.c:1.9	Tue Oct  4 16:46:20 2016
+++ src/sys/ufs/lfs/lfs_pages.c	Thu Mar 30 09:10:08 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_pages.c,v 1.9 2016/10/04 16:46:20 christos Exp $	*/
+/*	$NetBSD: lfs_pages.c,v 1.10 2017/03/30 09:10:08 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_pages.c,v 1.9 2016/10/04 16:46:20 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_pages.c,v 1.10 2017/03/30 09:10:08 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -466,6 +466,7 @@ lfs_putpages(void *v)
 	bool seglocked, sync, pagedaemon, reclaim;
 	struct vm_page *pg, *busypg;
 	UVMHIST_FUNC("lfs_putpages"); UVMHIST_CALLED(ubchist);
+	struct mount *trans_mp;
 	int oreclaim = 0;
 	int donewriting = 0;
 #ifdef DEBUG
@@ -478,6 +479,7 @@ lfs_putpages(void *v)
 	sync = (ap->a_flags & PGO_SYNCIO) != 0;
 	reclaim = (ap->a_flags & PGO_RECLAIM) != 0;
 	pagedaemon = (curlwp == uvm.pagedaemon_lwp);
+	trans_mp = NULL;
 
 	KASSERT(mutex_owned(vp->v_interlock));
 
@@ -487,6 +489,7 @@ lfs_putpages(void *v)
 		return 0;
 	}
 
+retry:
 	/*
 	 * If there are no pages, don't do anything.
 	 */
@@ -497,6 +500,8 @@ lfs_putpages(void *v)
 			vp->v_iflag &= ~VI_WRMAPDIRTY;
 			vn_syncer_remove_from_worklist(vp);
 		}
+		if (trans_mp)
+			fstrans_done(trans_mp);
 		mutex_exit(vp->v_interlock);
 		
 		/* Remove us from paging queue, if we were on it */
@@ -587,6 +592,33 @@ lfs_putpages(void *v)
 		return r;
 	}
 
+	if (trans_mp /* && (ap->a_flags & PGO_CLEANIT) != 0 */) {
+		if (pagedaemon) {
+			/* Pagedaemon must not sleep here. */
+			trans_mp = vp->v_mount;
+			error = fstrans_start_nowait(trans_mp, FSTRANS_SHARED);
+			if (error) {
+mutex_exit(vp->v_interlock);
+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(vp->v_interlock);
+			trans_mp = vp->v_mount;
+			fstrans_start(trans_mp, FSTRANS_SHARED);
+			if (vp->v_mount != trans_mp) {
+fstrans_done(trans_mp);
+trans_mp = NULL;
+			}
+		}
+		mutex_enter(vp->v_interlock);
+		goto retry;
+	}
+
 	/* Set PGO_BUSYFAIL to avoid deadlocks */
 	ap->a_flags |= PGO_BUSYFAIL;
 
@@ -607,7 +639,8 @@ lfs_putpages(void *v)
 		if (r < 0) {
 			/* Pages are busy with another process */
 			mutex_exit(vp->v_interlock);
-			return EDEADLK;
+			error = EDEADLK;
+			goto out;
 		}
 		if (r > 0) /* Some pages are dirty */
 			break;
@@ -624,7 +657,8 @@ lfs_putpages(void *v)
 		ip->i_lfs_iflags &= ~LFSI_NO_GOP_WRITE;
 		if (r != EDEADLK) {
 			KASSERT(!mutex_owned(vp->v_interlock));
- 			return r;
+ 			error = r;
+			goto out;
 		}
 
 		/* One of the pages was busy.  Start over. */
@@ -662,7 +696,8 @@ lfs_putpages(void *v)
 		mutex_exit(_lock);
 		preempt();
 		KASSERT(!mutex_owned(vp->v_interlock));
-		return EWOULDBLOCK;
+		error = EWOULDBLOCK;
+		goto out;
 	}
 
 	/*
@@ -724,7 +759,7 @@ lfs_putpages(void *v)
 		error = lfs_seglock(fs, SEGM_PROT | (sync ? SEGM_SYNC : 0));
 		if (error != 0) {
 			KASSERT(!mutex_owned(vp->v_interlock));
- 			return error;
+ 			goto out;
 		}
 		mutex_enter(vp->v_interlock);
 		lfs_acquire_finfo(fs, ip->i_number, ip->i_gen);
@@ -851,7 +886,7 @@ lfs_putpages(void *v)
 	 */
 	if (seglocked) {
 		KASSERT(!mutex_owned(vp->v_interlock));
-		return error;
+		goto out;
 	}
 
 	/* Clean up FIP and send it to disk. */
@@ -892,6 +927,10 @@ lfs_putpages(void *v)
 		}
 		mutex_exit(vp->v_interlock);
 	}
+
+out:;
+	if (trans_mp)
+		fstrans_done(trans_mp);
 	KASSERT(!mutex_owned(vp->v_interlock));
 	return error;
 }

Index: src/sys/ufs/lfs/lfs_vnops.c
diff -u src/sys/ufs/lfs/lfs_vnops.c:1.306 src/sys/ufs/lfs/lfs_vnops.c:1.307
--- 

CVS commit: src/sys/ufs/ffs

2017-03-22 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Wed Mar 22 21:31:00 UTC 2017

Modified Files:
src/sys/ufs/ffs: ffs_wapbl.c

Log Message:
move the ffs_sync() after wapbl_log_position() call, since that can still
create delayed writes with MNT_ASYNC when log is created


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/ufs/ffs/ffs_wapbl.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/ufs/ffs/ffs_wapbl.c
diff -u src/sys/ufs/ffs/ffs_wapbl.c:1.39 src/sys/ufs/ffs/ffs_wapbl.c:1.40
--- src/sys/ufs/ffs/ffs_wapbl.c:1.39	Thu Mar 16 22:09:19 2017
+++ src/sys/ufs/ffs/ffs_wapbl.c	Wed Mar 22 21:30:59 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_wapbl.c,v 1.39 2017/03/16 22:09:19 jdolecek Exp $	*/
+/*	$NetBSD: ffs_wapbl.c,v 1.40 2017/03/22 21:30:59 jdolecek Exp $	*/
 
 /*-
  * Copyright (c) 2003,2006,2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_wapbl.c,v 1.39 2017/03/16 22:09:19 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_wapbl.c,v 1.40 2017/03/22 21:30:59 jdolecek Exp $");
 
 #define WAPBL_INTERNAL
 
@@ -338,6 +338,11 @@ ffs_wapbl_start(struct mount *mp)
 return EINVAL;
 			}
 
+			error = wapbl_log_position(mp, fs, devvp, ,
+			, , );
+			if (error)
+return error;
+
 			/*
 			 * Make sure we don't carry over any delayed write
 			 * buffers when updating to log. Need to turn off
@@ -351,11 +356,6 @@ ffs_wapbl_start(struct mount *mp)
 mp->mnt_flag |= saveflag;
 			}
 
-			error = wapbl_log_position(mp, fs, devvp, ,
-			, , );
-			if (error)
-return error;
-
 			error = wapbl_start(>mnt_wapbl, mp, devvp, off,
 			count, blksize, mp->mnt_wapbl_replay,
 			ffs_wapbl_sync_metadata,



CVS commit: src/sys/ufs/lfs

2017-03-21 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Tue Mar 21 09:53:01 UTC 2017

Modified Files:
src/sys/ufs/lfs: lfs_inode.c

Log Message:
Update mtime even if oip->i_size == length

PR kern/51762, LFS version.


To generate a diff of this commit:
cvs rdiff -u -r1.152 -r1.153 src/sys/ufs/lfs/lfs_inode.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/ufs/lfs/lfs_inode.c
diff -u src/sys/ufs/lfs/lfs_inode.c:1.152 src/sys/ufs/lfs/lfs_inode.c:1.153
--- src/sys/ufs/lfs/lfs_inode.c:1.152	Sun Mar 19 22:48:00 2017
+++ src/sys/ufs/lfs/lfs_inode.c	Tue Mar 21 09:53:00 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_inode.c,v 1.152 2017/03/19 22:48:00 riastradh Exp $	*/
+/*	$NetBSD: lfs_inode.c,v 1.153 2017/03/21 09:53:00 maya Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.152 2017/03/19 22:48:00 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.153 2017/03/21 09:53:00 maya Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_quota.h"
@@ -228,15 +228,6 @@ lfs_truncate(struct vnode *ovp, off_t le
 	if (length < 0)
 		return (EINVAL);
 
-	/*
-	 * Just return and not update modification times.
-	 */
-	if (oip->i_size == length) {
-		/* still do a uvm_vnp_setsize() as writesize may be larger */
-		uvm_vnp_setsize(ovp, length);
-		return (0);
-	}
-
 	fs = oip->i_lfs;
 
 	if (ovp->v_type == VLNK &&
@@ -252,6 +243,8 @@ lfs_truncate(struct vnode *ovp, off_t le
 		return (lfs_update(ovp, NULL, NULL, 0));
 	}
 	if (oip->i_size == length) {
+		/* still do a uvm_vnp_setsize() as writesize may be larger */
+		uvm_vnp_setsize(ovp, length);
 		oip->i_flag |= IN_CHANGE | IN_UPDATE;
 		return (lfs_update(ovp, NULL, NULL, 0));
 	}



CVS commit: src/sys/ufs/lfs

2017-03-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Mar 19 22:48:00 UTC 2017

Modified Files:
src/sys/ufs/lfs: lfs_inode.c

Log Message:
Fix inadvertently reversed sense of comparisons.


To generate a diff of this commit:
cvs rdiff -u -r1.151 -r1.152 src/sys/ufs/lfs/lfs_inode.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/ufs/lfs/lfs_inode.c
diff -u src/sys/ufs/lfs/lfs_inode.c:1.151 src/sys/ufs/lfs/lfs_inode.c:1.152
--- src/sys/ufs/lfs/lfs_inode.c:1.151	Sat Mar 18 05:43:16 2017
+++ src/sys/ufs/lfs/lfs_inode.c	Sun Mar 19 22:48:00 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_inode.c,v 1.151 2017/03/18 05:43:16 riastradh Exp $	*/
+/*	$NetBSD: lfs_inode.c,v 1.152 2017/03/19 22:48:00 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.151 2017/03/18 05:43:16 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.152 2017/03/19 22:48:00 riastradh Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_quota.h"
@@ -562,11 +562,11 @@ done:
 	/* Finish segment accounting corrections */
 	lfs_update_seguse(fs, oip, lastseg, bc);
 	for (level = SINGLE; level <= TRIPLE; level++)
-		KASSERTMSG(((newblks[ULFS_NDADDR + level] == 0) !=
+		KASSERTMSG(((newblks[ULFS_NDADDR + level] == 0) ==
 			(lfs_dino_getib(fs, oip->i_din, level) == 0)),
 		"lfs itrunc1");
 	for (i = 0; i < ULFS_NDADDR; i++)
-		KASSERTMSG(((newblks[i] == 0) !=
+		KASSERTMSG(((newblks[i] == 0) ==
 			(lfs_dino_getdb(fs, oip->i_din, i) == 0)),
 		"lfs itrunc2");
 	KASSERTMSG((length != 0 || LIST_EMPTY(>v_cleanblkhd)),



CVS commit: src/sys/ufs/lfs

2017-03-17 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Mar 18 05:43:16 UTC 2017

Modified Files:
src/sys/ufs/lfs: lfs_inode.c

Log Message:
#if DIAGNOSTIC panic ---> KASSERT


To generate a diff of this commit:
cvs rdiff -u -r1.150 -r1.151 src/sys/ufs/lfs/lfs_inode.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/ufs/lfs/lfs_inode.c
diff -u src/sys/ufs/lfs/lfs_inode.c:1.150 src/sys/ufs/lfs/lfs_inode.c:1.151
--- src/sys/ufs/lfs/lfs_inode.c:1.150	Thu Mar 16 01:09:24 2017
+++ src/sys/ufs/lfs/lfs_inode.c	Sat Mar 18 05:43:16 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_inode.c,v 1.150 2017/03/16 01:09:24 maya Exp $	*/
+/*	$NetBSD: lfs_inode.c,v 1.151 2017/03/18 05:43:16 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.150 2017/03/16 01:09:24 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.151 2017/03/18 05:43:16 riastradh Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_quota.h"
@@ -561,21 +561,19 @@ lfs_truncate(struct vnode *ovp, off_t le
 done:
 	/* Finish segment accounting corrections */
 	lfs_update_seguse(fs, oip, lastseg, bc);
-#ifdef DIAGNOSTIC
 	for (level = SINGLE; level <= TRIPLE; level++)
-		if ((newblks[ULFS_NDADDR + level] == 0) !=
-		(lfs_dino_getib(fs, oip->i_din, level) == 0)) {
-			panic("lfs itrunc1");
-		}
+		KASSERTMSG(((newblks[ULFS_NDADDR + level] == 0) !=
+			(lfs_dino_getib(fs, oip->i_din, level) == 0)),
+		"lfs itrunc1");
 	for (i = 0; i < ULFS_NDADDR; i++)
-		if ((newblks[i] == 0) !=
-		(lfs_dino_getdb(fs, oip->i_din, i) == 0)) {
-			panic("lfs itrunc2");
-		}
-	if (length == 0 &&
-	(!LIST_EMPTY(>v_cleanblkhd) || !LIST_EMPTY(>v_dirtyblkhd)))
-		panic("lfs itrunc3");
-#endif /* DIAGNOSTIC */
+		KASSERTMSG(((newblks[i] == 0) !=
+			(lfs_dino_getdb(fs, oip->i_din, i) == 0)),
+		"lfs itrunc2");
+	KASSERTMSG((length != 0 || LIST_EMPTY(>v_cleanblkhd)),
+	"lfs itrunc3a");
+	KASSERTMSG((length != 0 || LIST_EMPTY(>v_dirtyblkhd)),
+	"lfs itrunc3b");
+
 	/*
 	 * Put back the real size.
 	 */



CVS commit: src/sys/ufs/ufs

2017-03-17 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Mar 18 05:39:06 UTC 2017

Modified Files:
src/sys/ufs/ufs: ufs_vnops.c

Log Message:
#if DIAGNOSTIC panic ---> KASSERT


To generate a diff of this commit:
cvs rdiff -u -r1.235 -r1.236 src/sys/ufs/ufs/ufs_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/ufs/ufs/ufs_vnops.c
diff -u src/sys/ufs/ufs/ufs_vnops.c:1.235 src/sys/ufs/ufs/ufs_vnops.c:1.236
--- src/sys/ufs/ufs/ufs_vnops.c:1.235	Wed Mar  1 10:42:45 2017
+++ src/sys/ufs/ufs/ufs_vnops.c	Sat Mar 18 05:39:06 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_vnops.c,v 1.235 2017/03/01 10:42:45 hannken Exp $	*/
+/*	$NetBSD: ufs_vnops.c,v 1.236 2017/03/18 05:39:06 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.235 2017/03/01 10:42:45 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.236 2017/03/18 05:39:06 riastradh Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -865,10 +865,9 @@ ufs_whiteout(void *v)
 		error = UFS_WAPBL_BEGIN(dvp->v_mount);
 		if (error)
 			break;
-#ifdef DIAGNOSTIC
-		if (ump->um_maxsymlinklen <= 0)
-			panic("ufs_whiteout: old format filesystem");
-#endif
+
+		KASSERTMSG((ump->um_maxsymlinklen > 0),
+		"ufs_whiteout: old format filesystem");
 
 		newdir = pool_cache_get(ufs_direct_cache, PR_WAITOK);
 		newdir->d_ino = UFS_WINO;
@@ -886,10 +885,9 @@ ufs_whiteout(void *v)
 		error = UFS_WAPBL_BEGIN(dvp->v_mount);
 		if (error)
 			break;
-#ifdef DIAGNOSTIC
-		if (ump->um_maxsymlinklen <= 0)
-			panic("ufs_whiteout: old format filesystem");
-#endif
+
+		KASSERTMSG((ump->um_maxsymlinklen > 0),
+		"ufs_whiteout: old format filesystem");
 
 		cnp->cn_flags &= ~DOWHITEOUT;
 		error = ufs_dirremove(dvp, ulr, NULL, cnp->cn_flags, 0);



CVS commit: src/sys/ufs/ufs

2017-03-17 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Mar 18 05:33:07 UTC 2017

Modified Files:
src/sys/ufs/ufs: ufs_bmap.c

Log Message:
#if DIAGNOSTIC panic ---> KASSERT


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/ufs/ufs/ufs_bmap.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/ufs/ufs/ufs_bmap.c
diff -u src/sys/ufs/ufs/ufs_bmap.c:1.51 src/sys/ufs/ufs/ufs_bmap.c:1.52
--- src/sys/ufs/ufs/ufs_bmap.c:1.51	Wed Mar  1 10:42:45 2017
+++ src/sys/ufs/ufs/ufs_bmap.c	Sat Mar 18 05:33:06 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_bmap.c,v 1.51 2017/03/01 10:42:45 hannken Exp $	*/
+/*	$NetBSD: ufs_bmap.c,v 1.52 2017/03/18 05:33:06 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_bmap.c,v 1.51 2017/03/01 10:42:45 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_bmap.c,v 1.52 2017/03/18 05:33:06 riastradh Exp $");
 
 #include 
 #include 
@@ -127,10 +127,8 @@ ufs_bmaparray(struct vnode *vp, daddr_t 
 	ip = VTOI(vp);
 	mp = vp->v_mount;
 	ump = ip->i_ump;
-#ifdef DIAGNOSTIC
-	if ((ap != NULL && nump == NULL) || (ap == NULL && nump != NULL))
-		panic("ufs_bmaparray: invalid arguments");
-#endif
+	KASSERTMSG(((ap == NULL) == (nump == NULL)),
+	"ufs_bmaparray: invalid arguments: ap = %p, nump = %p", ap, nump);
 
 	if (runp) {
 		/*
@@ -249,12 +247,9 @@ ufs_bmaparray(struct vnode *vp, daddr_t 
 		}
 		if (bp->b_oflags & (BO_DONE | BO_DELWRI)) {
 			trace(TR_BREADHIT, pack(vp, size), metalbn);
-		}
-#ifdef DIAGNOSTIC
-		else if (!daddr)
-			panic("ufs_bmaparray: indirect block not in cache");
-#endif
-		else {
+		} else {
+			KASSERTMSG((daddr != 0),
+			"ufs_bmaparray: indirect block not in cache");
 			trace(TR_BREADMISS, pack(vp, size), metalbn);
 			bp->b_blkno = blkptrtodb(ump, daddr);
 			bp->b_flags |= B_READ;



CVS commit: src/sys/ufs/ffs

2017-03-17 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Mar 18 05:29:16 UTC 2017

Modified Files:
src/sys/ufs/ffs: ffs_snapshot.c

Log Message:
#if DIAGNOSTIC panic ---> KASSERT


To generate a diff of this commit:
cvs rdiff -u -r1.146 -r1.147 src/sys/ufs/ffs/ffs_snapshot.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/ufs/ffs/ffs_snapshot.c
diff -u src/sys/ufs/ffs/ffs_snapshot.c:1.146 src/sys/ufs/ffs/ffs_snapshot.c:1.147
--- src/sys/ufs/ffs/ffs_snapshot.c:1.146	Wed Mar  1 10:42:45 2017
+++ src/sys/ufs/ffs/ffs_snapshot.c	Sat Mar 18 05:29:16 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_snapshot.c,v 1.146 2017/03/01 10:42:45 hannken Exp $	*/
+/*	$NetBSD: ffs_snapshot.c,v 1.147 2017/03/18 05:29:16 riastradh Exp $	*/
 
 /*
  * Copyright 2000 Marshall Kirk McKusick. All Rights Reserved.
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_snapshot.c,v 1.146 2017/03/01 10:42:45 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_snapshot.c,v 1.147 2017/03/18 05:29:16 riastradh Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -1993,10 +1993,9 @@ retry:
 			if (gen != si->si_gen)
 goto retry;
 		}
-#ifdef DIAGNOSTIC
-		if (blkno == BLK_SNAP && bp->b_lblkno >= 0)
-			panic("ffs_copyonwrite: bad copy block");
-#endif
+		KASSERTMSG((blkno != BLK_SNAP || bp->b_lblkno < 0),
+		"ffs_copyonwrite: bad copy block: blkno %jd, lblkno %jd",
+		(intmax_t)blkno, (intmax_t)bp->b_lblkno);
 		if (blkno != 0)
 			continue;
 



CVS commit: src/sys/ufs/ffs

2017-03-17 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Mar 18 05:26:40 UTC 2017

Modified Files:
src/sys/ufs/ffs: ffs_inode.c

Log Message:
#if DIAGNOSTIC panic ---> KASSERT


To generate a diff of this commit:
cvs rdiff -u -r1.123 -r1.124 src/sys/ufs/ffs/ffs_inode.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/ufs/ffs/ffs_inode.c
diff -u src/sys/ufs/ffs/ffs_inode.c:1.123 src/sys/ufs/ffs/ffs_inode.c:1.124
--- src/sys/ufs/ffs/ffs_inode.c:1.123	Fri Nov 11 10:50:16 2016
+++ src/sys/ufs/ffs/ffs_inode.c	Sat Mar 18 05:26:40 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_inode.c,v 1.123 2016/11/11 10:50:16 hannken Exp $	*/
+/*	$NetBSD: ffs_inode.c,v 1.124 2017/03/18 05:26:40 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_inode.c,v 1.123 2016/11/11 10:50:16 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_inode.c,v 1.124 2017/03/18 05:26:40 riastradh Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -527,17 +527,19 @@ ffs_truncate(struct vnode *ovp, off_t le
 	}
 
 done:
-#ifdef DIAGNOSTIC
 	for (level = SINGLE; level <= TRIPLE; level++)
-		if (blks[UFS_NDADDR + level] != DIP(oip, ib[level]))
-			panic("itrunc1");
+		KASSERTMSG((blks[UFS_NDADDR + level] == DIP(oip, ib[level])),
+		"itrunc1 blk mismatch: %jx != %jx",
+		(uintmax_t)blks[UFS_NDADDR + level],
+		(uintmax_t)DIP(oip, ib[level]));
 	for (i = 0; i < UFS_NDADDR; i++)
-		if (blks[i] != DIP(oip, db[i]))
-			panic("itrunc2");
-	if (length == 0 &&
-	(!LIST_EMPTY(>v_cleanblkhd) || !LIST_EMPTY(>v_dirtyblkhd)))
-		panic("itrunc3");
-#endif /* DIAGNOSTIC */
+		KASSERTMSG((blks[i] == DIP(oip, db[i])),
+		"itrunc2 blk mismatch: %jx != %jx",
+		(uintmax_t)blks[i], (uintmax_t)DIP(oip, db[i]));
+	KASSERTMSG((length != 0 || LIST_EMPTY(>v_cleanblkhd)),
+	"itrunc3: zero length and nonempty cleanblkhd");
+	KASSERTMSG((length != 0 || LIST_EMPTY(>v_dirtyblkhd)),
+	"itrunc3: zero length and nonempty dirtyblkhd");
 
 out:
 	/*



CVS commit: src/sys/ufs/ffs

2017-03-17 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Mar 18 05:20:04 UTC 2017

Modified Files:
src/sys/ufs/ffs: ffs_alloc.c

Log Message:
#if DIAGNOSTIC panic ---> KASSERT


To generate a diff of this commit:
cvs rdiff -u -r1.155 -r1.156 src/sys/ufs/ffs/ffs_alloc.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/ufs/ffs/ffs_alloc.c
diff -u src/sys/ufs/ffs/ffs_alloc.c:1.155 src/sys/ufs/ffs/ffs_alloc.c:1.156
--- src/sys/ufs/ffs/ffs_alloc.c:1.155	Wed Mar  1 10:42:45 2017
+++ src/sys/ufs/ffs/ffs_alloc.c	Sat Mar 18 05:20:04 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_alloc.c,v 1.155 2017/03/01 10:42:45 hannken Exp $	*/
+/*	$NetBSD: ffs_alloc.c,v 1.156 2017/03/18 05:20:04 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.155 2017/03/01 10:42:45 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.156 2017/03/18 05:20:04 riastradh Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -226,15 +226,15 @@ ffs_alloc(struct inode *ip, daddr_t lbn,
 #endif
 
 	*bnp = 0;
-#ifdef DIAGNOSTIC
-	if (cred == NOCRED)
-		panic("%s: missing credential", __func__);
-	if ((u_int)size > fs->fs_bsize || ffs_fragoff(fs, size) != 0) {
-		panic("%s: bad size: dev = 0x%llx, bsize = %d, size = %d, "
-		"fs = %s", __func__, (unsigned long long)ip->i_dev,
-		fs->fs_bsize, size, fs->fs_fsmnt);
-	}
-#endif /* DIAGNOSTIC */
+
+	KASSERTMSG((cred != NOCRED), "missing credential");
+	KASSERTMSG(((u_int)size <= fs->fs_bsize),
+	"bad size: dev = 0x%llx, bsize = %d, size = %d, fs = %s",
+	(unsigned long long)ip->i_dev, fs->fs_bsize, size, fs->fs_fsmnt);
+	KASSERTMSG((ffs_fragoff(fs, size) == 0),
+	"bad size: dev = 0x%llx, bsize = %d, size = %d, fs = %s",
+	(unsigned long long)ip->i_dev, fs->fs_bsize, size, fs->fs_fsmnt);
+
 	if (size == fs->fs_bsize && fs->fs_cstotal.cs_nbfree == 0)
 		goto nospace;
 	if (freespace(fs, fs->fs_minfree) <= 0 &&
@@ -344,17 +344,24 @@ ffs_realloccg(struct inode *ip, daddr_t 
 	}
 #endif
 
-#ifdef DIAGNOSTIC
-	if (cred == NOCRED)
-		panic("%s: missing credential", __func__);
-	if ((u_int)osize > fs->fs_bsize || ffs_fragoff(fs, osize) != 0 ||
-	(u_int)nsize > fs->fs_bsize || ffs_fragoff(fs, nsize) != 0) {
-		panic("%s: bad size: dev = 0x%llx, bsize = %d, osize = %d, "
-		"nsize = %d, fs = %s", __func__,
-		(unsigned long long)ip->i_dev, fs->fs_bsize, osize, nsize,
-		fs->fs_fsmnt);
-	}
-#endif /* DIAGNOSTIC */
+	KASSERTMSG((cred != NOCRED), "missing credential");
+	KASSERTMSG(((u_int)osize <= fs->fs_bsize),
+	"bad size: dev=0x%llx, bsize=%d, osize=%d, nsize=%d, fs=%s",
+	(unsigned long long)ip->i_dev, fs->fs_bsize, osize, nsize,
+	fs->fs_fsmnt);
+	KASSERTMSG((ffs_fragoff(fs, osize) == 0),
+	"bad size: dev=0x%llx, bsize=%d, osize=%d, nsize=%d, fs=%s",
+	(unsigned long long)ip->i_dev, fs->fs_bsize, osize, nsize,
+	fs->fs_fsmnt);
+	KASSERTMSG(((u_int)nsize <= fs->fs_bsize),
+	"bad size: dev=0x%llx, bsize=%d, osize=%d, nsize=%d, fs=%s",
+	(unsigned long long)ip->i_dev, fs->fs_bsize, osize, nsize,
+	fs->fs_fsmnt);
+	KASSERTMSG((ffs_fragoff(fs, nsize) == 0),
+	"bad size: dev=0x%llx, bsize=%d, osize=%d, nsize=%d, fs=%s",
+	(unsigned long long)ip->i_dev, fs->fs_bsize, osize, nsize,
+	fs->fs_fsmnt);
+
 	if (freespace(fs, fs->fs_minfree) <= 0 &&
 	kauth_authorize_system(cred, KAUTH_SYSTEM_FS_RESERVEDSPACE, 0, NULL,
 	NULL, NULL) != 0) {



CVS commit: src/sys/ufs/ffs

2017-03-16 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Thu Mar 16 22:09:19 UTC 2017

Modified Files:
src/sys/ufs/ffs: ffs_wapbl.c

Log Message:
need to turn off async during ffs_sync(), otherwise its bwrite() calls are
themselves turned to bdwrite(), creating dirty delayed writes

fixes panic for 'mount -o log,async ...' reported by Masanobu SAITOH
on current-users; fix help by hannken@, thank you


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/ufs/ffs/ffs_wapbl.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/ufs/ffs/ffs_wapbl.c
diff -u src/sys/ufs/ffs/ffs_wapbl.c:1.38 src/sys/ufs/ffs/ffs_wapbl.c:1.39
--- src/sys/ufs/ffs/ffs_wapbl.c:1.38	Fri Mar 10 22:43:03 2017
+++ src/sys/ufs/ffs/ffs_wapbl.c	Thu Mar 16 22:09:19 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_wapbl.c,v 1.38 2017/03/10 22:43:03 jdolecek Exp $	*/
+/*	$NetBSD: ffs_wapbl.c,v 1.39 2017/03/16 22:09:19 jdolecek Exp $	*/
 
 /*-
  * Copyright (c) 2003,2006,2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_wapbl.c,v 1.38 2017/03/10 22:43:03 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_wapbl.c,v 1.39 2017/03/16 22:09:19 jdolecek Exp $");
 
 #define WAPBL_INTERNAL
 
@@ -340,10 +340,16 @@ ffs_wapbl_start(struct mount *mp)
 
 			/*
 			 * Make sure we don't carry over any delayed write
-			 * buffers when updating to log.
+			 * buffers when updating to log. Need to turn off
+			 * async termporarily, to prevent ffs_sync() writes
+			 * themselves being turned into delayed writes.
 			 */
-			if (mp->mnt_flag & MNT_UPDATE)
+			if (mp->mnt_flag & MNT_UPDATE) {
+int saveflag = mp->mnt_flag & MNT_ASYNC;
+mp->mnt_flag &= ~MNT_ASYNC;
 ffs_sync(mp, MNT_WAIT, FSCRED);
+mp->mnt_flag |= saveflag;
+			}
 
 			error = wapbl_log_position(mp, fs, devvp, ,
 			, , );



CVS commit: src/sys/ufs/lfs

2017-03-15 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Thu Mar 16 01:09:24 UTC 2017

Modified Files:
src/sys/ufs/lfs: lfs_inode.c lfs_vnops.c

Log Message:
actually cast to unsigned long long and use %llu. certainly not use hex (oops)
suggested by dh


To generate a diff of this commit:
cvs rdiff -u -r1.149 -r1.150 src/sys/ufs/lfs/lfs_inode.c
cvs rdiff -u -r1.305 -r1.306 src/sys/ufs/lfs/lfs_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/ufs/lfs/lfs_inode.c
diff -u src/sys/ufs/lfs/lfs_inode.c:1.149 src/sys/ufs/lfs/lfs_inode.c:1.150
--- src/sys/ufs/lfs/lfs_inode.c:1.149	Wed Mar 15 21:28:41 2017
+++ src/sys/ufs/lfs/lfs_inode.c	Thu Mar 16 01:09:24 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_inode.c,v 1.149 2017/03/15 21:28:41 maya Exp $	*/
+/*	$NetBSD: lfs_inode.c,v 1.150 2017/03/16 01:09:24 maya Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.149 2017/03/15 21:28:41 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.150 2017/03/16 01:09:24 maya Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_quota.h"
@@ -149,8 +149,8 @@ lfs_update(struct vnode *vp, const struc
 	mutex_enter(vp->v_interlock);
 	while ((updflags & (UPDATE_WAIT|UPDATE_DIROP)) == UPDATE_WAIT &&
 	WRITEINPROG(vp)) {
-		DLOG((DLOG_SEG, "lfs_update: sleeping on ino %"PRIx64
-		  " (in progress)\n", ip->i_number));
+		DLOG((DLOG_SEG, "lfs_update: sleeping on ino %llu"
+		  " (in progress)\n", (unsigned long long) ip->i_number));
 		cv_wait(>v_cv, vp->v_interlock);
 	}
 	mutex_exit(vp->v_interlock);
@@ -168,8 +168,8 @@ lfs_update(struct vnode *vp, const struc
 		mutex_enter(_lock);
 		++fs->lfs_diropwait;
 		while (vp->v_uflag & VU_DIROP) {
-			DLOG((DLOG_DIROP, "lfs_update: sleeping on inode %"PRIx64
-			  " (dirops)\n", ip->i_number));
+			DLOG((DLOG_DIROP, "lfs_update: sleeping on inode %llu "
+			  "(dirops)\n", (unsigned long long) ip->i_number));
 			DLOG((DLOG_DIROP, "lfs_update: vflags 0x%x, iflags"
 			  " 0x%x\n",
 			  vp->v_iflag | vp->v_vflag | vp->v_uflag,
@@ -590,13 +590,13 @@ done:
 
 	KASSERTMSG((oip->i_size != 0 ||
 		lfs_dino_getblocks(fs, oip->i_din) == 0),
-	"ino %"PRIx64" truncate to 0 but %jd blks/%jd effblks",
-	oip->i_number, lfs_dino_getblocks(fs, oip->i_din),
-	oip->i_lfs_effnblks);
+	"ino %llu truncate to 0 but %jd blks/%jd effblks",
+	(unsigned long long) oip->i_number,
+	lfs_dino_getblocks(fs, oip->i_din), oip->i_lfs_effnblks);
 	KASSERTMSG((oip->i_size != 0 || oip->i_lfs_effnblks == 0),
-	"ino %"PRIx64" truncate to 0 but %jd blks/%jd effblks",
-	oip->i_number, lfs_dino_getblocks(fs, oip->i_din),
-	oip->i_lfs_effnblks);
+	"ino %llu truncate to 0 but %jd blks/%jd effblks",
+	(unsigned long long) oip->i_number,
+	lfs_dino_getblocks(fs, oip->i_din), oip->i_lfs_effnblks);
 
 	/*
 	 * If we truncated to zero, take us off the paging queue.

Index: src/sys/ufs/lfs/lfs_vnops.c
diff -u src/sys/ufs/lfs/lfs_vnops.c:1.305 src/sys/ufs/lfs/lfs_vnops.c:1.306
--- src/sys/ufs/lfs/lfs_vnops.c:1.305	Wed Mar 15 21:28:41 2017
+++ src/sys/ufs/lfs/lfs_vnops.c	Thu Mar 16 01:09:24 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_vnops.c,v 1.305 2017/03/15 21:28:41 maya Exp $	*/
+/*	$NetBSD: lfs_vnops.c,v 1.306 2017/03/16 01:09:24 maya Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -125,7 +125,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.305 2017/03/15 21:28:41 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.306 2017/03/16 01:09:24 maya Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -539,7 +539,8 @@ lfs_inactive(void *v)
 	 */
 	if (ap->a_vp->v_uflag & VU_DIROP) {
 		struct inode *ip = VTOI(ap->a_vp);
-		printf("lfs_inactive: inactivating VU_DIROP? ino = %"PRIx64"\n", ip->i_number);
+		printf("lfs_inactive: inactivating VU_DIROP? ino = %llu\n",
+		(unsigned long long) ip->i_number);
 	}
 #endif /* DIAGNOSTIC */
 
@@ -837,7 +838,8 @@ lfs_mknod(void *v)
 	 * Can this ever happen (barring hardware failure)?
 	 */
 	if ((error = VOP_FSYNC(*vpp, NOCRED, FSYNC_WAIT, 0, 0)) != 0) {
-		panic("lfs_mknod: couldn't fsync (ino %"PRIx64")", ino);
+		panic("lfs_mknod: couldn't fsync (ino %llu)",
+		(unsigned long long) ino);
 		/* return (error); */
 	}
 
@@ -1519,15 +1521,18 @@ lfs_strategy(void *v)
 			if (sn == lfs_dtosn(fs, fs->lfs_cleanint[i]) &&
 			tbn >= fs->lfs_cleanint[i]) {
 DLOG((DLOG_CLEAN,
-  "lfs_strategy: ino %"PRIx64" lbn %" PRId64
+  "lfs_strategy: ino %llu lbn %" PRId64
   " ind %d sn %d fsb %" PRIx64
   " given sn %d fsb %" PRIx64 "\n",
-  ip->i_number, bp->b_lblkno, i,
+  (unsigned long long) ip->i_number,
+  bp->b_lblkno, i,
   lfs_dtosn(fs, 

CVS commit: src/sys/ufs/lfs

2017-03-15 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Wed Mar 15 21:28:41 UTC 2017

Modified Files:
src/sys/ufs/lfs: lfs_inode.c lfs_vnops.c

Log Message:
print inode number in an assert I keep hitting and the adjacent one.
use PRIx64 for printing inode number elsewhere.


To generate a diff of this commit:
cvs rdiff -u -r1.148 -r1.149 src/sys/ufs/lfs/lfs_inode.c
cvs rdiff -u -r1.304 -r1.305 src/sys/ufs/lfs/lfs_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/ufs/lfs/lfs_inode.c
diff -u src/sys/ufs/lfs/lfs_inode.c:1.148 src/sys/ufs/lfs/lfs_inode.c:1.149
--- src/sys/ufs/lfs/lfs_inode.c:1.148	Mon Mar 13 13:45:53 2017
+++ src/sys/ufs/lfs/lfs_inode.c	Wed Mar 15 21:28:41 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_inode.c,v 1.148 2017/03/13 13:45:53 riastradh Exp $	*/
+/*	$NetBSD: lfs_inode.c,v 1.149 2017/03/15 21:28:41 maya Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.148 2017/03/13 13:45:53 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.149 2017/03/15 21:28:41 maya Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_quota.h"
@@ -149,7 +149,7 @@ lfs_update(struct vnode *vp, const struc
 	mutex_enter(vp->v_interlock);
 	while ((updflags & (UPDATE_WAIT|UPDATE_DIROP)) == UPDATE_WAIT &&
 	WRITEINPROG(vp)) {
-		DLOG((DLOG_SEG, "lfs_update: sleeping on ino %d"
+		DLOG((DLOG_SEG, "lfs_update: sleeping on ino %"PRIx64
 		  " (in progress)\n", ip->i_number));
 		cv_wait(>v_cv, vp->v_interlock);
 	}
@@ -168,7 +168,7 @@ lfs_update(struct vnode *vp, const struc
 		mutex_enter(_lock);
 		++fs->lfs_diropwait;
 		while (vp->v_uflag & VU_DIROP) {
-			DLOG((DLOG_DIROP, "lfs_update: sleeping on inode %d"
+			DLOG((DLOG_DIROP, "lfs_update: sleeping on inode %"PRIx64
 			  " (dirops)\n", ip->i_number));
 			DLOG((DLOG_DIROP, "lfs_update: vflags 0x%x, iflags"
 			  " 0x%x\n",
@@ -590,12 +590,12 @@ done:
 
 	KASSERTMSG((oip->i_size != 0 ||
 		lfs_dino_getblocks(fs, oip->i_din) == 0),
-	"truncate to 0 but %jd blks/%jd effblks",
-	lfs_dino_getblocks(fs, oip->i_din),
+	"ino %"PRIx64" truncate to 0 but %jd blks/%jd effblks",
+	oip->i_number, lfs_dino_getblocks(fs, oip->i_din),
 	oip->i_lfs_effnblks);
 	KASSERTMSG((oip->i_size != 0 || oip->i_lfs_effnblks == 0),
-	"truncate to 0 but %jd blks/%jd effblks",
-	lfs_dino_getblocks(fs, oip->i_din),
+	"ino %"PRIx64" truncate to 0 but %jd blks/%jd effblks",
+	oip->i_number, lfs_dino_getblocks(fs, oip->i_din),
 	oip->i_lfs_effnblks);
 
 	/*

Index: src/sys/ufs/lfs/lfs_vnops.c
diff -u src/sys/ufs/lfs/lfs_vnops.c:1.304 src/sys/ufs/lfs/lfs_vnops.c:1.305
--- src/sys/ufs/lfs/lfs_vnops.c:1.304	Wed Jul 13 16:26:26 2016
+++ src/sys/ufs/lfs/lfs_vnops.c	Wed Mar 15 21:28:41 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_vnops.c,v 1.304 2016/07/13 16:26:26 maya Exp $	*/
+/*	$NetBSD: lfs_vnops.c,v 1.305 2017/03/15 21:28:41 maya Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -125,7 +125,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.304 2016/07/13 16:26:26 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.305 2017/03/15 21:28:41 maya Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -539,7 +539,7 @@ lfs_inactive(void *v)
 	 */
 	if (ap->a_vp->v_uflag & VU_DIROP) {
 		struct inode *ip = VTOI(ap->a_vp);
-		printf("lfs_inactive: inactivating VU_DIROP? ino = %d\n", (int)ip->i_number);
+		printf("lfs_inactive: inactivating VU_DIROP? ino = %"PRIx64"\n", ip->i_number);
 	}
 #endif /* DIAGNOSTIC */
 
@@ -837,8 +837,7 @@ lfs_mknod(void *v)
 	 * Can this ever happen (barring hardware failure)?
 	 */
 	if ((error = VOP_FSYNC(*vpp, NOCRED, FSYNC_WAIT, 0, 0)) != 0) {
-		panic("lfs_mknod: couldn't fsync (ino %llu)",
-		  (unsigned long long)ino);
+		panic("lfs_mknod: couldn't fsync (ino %"PRIx64")", ino);
 		/* return (error); */
 	}
 
@@ -1520,14 +1519,14 @@ lfs_strategy(void *v)
 			if (sn == lfs_dtosn(fs, fs->lfs_cleanint[i]) &&
 			tbn >= fs->lfs_cleanint[i]) {
 DLOG((DLOG_CLEAN,
-  "lfs_strategy: ino %d lbn %" PRId64
+  "lfs_strategy: ino %"PRIx64" lbn %" PRId64
   " ind %d sn %d fsb %" PRIx64
   " given sn %d fsb %" PRIx64 "\n",
   ip->i_number, bp->b_lblkno, i,
   lfs_dtosn(fs, fs->lfs_cleanint[i]),
   fs->lfs_cleanint[i], sn, tbn));
 DLOG((DLOG_CLEAN,
-  "lfs_strategy: sleeping on ino %d lbn %"
+  "lfs_strategy: sleeping on ino %"PRIx64" lbn %"
   PRId64 "\n", ip->i_number, bp->b_lblkno));
 mutex_enter(_lock);
 if (LFS_SEGLOCK_HELD(fs) && fs->lfs_iocount) {



CVS commit: src/sys/ufs/lfs

2017-03-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Mar 13 14:24:20 UTC 2017

Modified Files:
src/sys/ufs/lfs: lfs_alloc.c lfs_bio.c lfs_segment.c lfs_syscalls.c
lfs_vfsops.c ulfs_bmap.c ulfs_vnops.c

Log Message:
#if DIAGNOSTIC panic ---> KASSERT

Replace some #if DEBUG by this too.  DEBUG is only for expensive
assertions; these are not.


To generate a diff of this commit:
cvs rdiff -u -r1.133 -r1.134 src/sys/ufs/lfs/lfs_alloc.c
cvs rdiff -u -r1.135 -r1.136 src/sys/ufs/lfs/lfs_bio.c
cvs rdiff -u -r1.263 -r1.264 src/sys/ufs/lfs/lfs_segment.c
cvs rdiff -u -r1.172 -r1.173 src/sys/ufs/lfs/lfs_syscalls.c
cvs rdiff -u -r1.352 -r1.353 src/sys/ufs/lfs/lfs_vfsops.c
cvs rdiff -u -r1.7 -r1.8 src/sys/ufs/lfs/ulfs_bmap.c
cvs rdiff -u -r1.44 -r1.45 src/sys/ufs/lfs/ulfs_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/ufs/lfs/lfs_alloc.c
diff -u src/sys/ufs/lfs/lfs_alloc.c:1.133 src/sys/ufs/lfs/lfs_alloc.c:1.134
--- src/sys/ufs/lfs/lfs_alloc.c:1.133	Sun Aug  7 05:09:12 2016
+++ src/sys/ufs/lfs/lfs_alloc.c	Mon Mar 13 14:24:20 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_alloc.c,v 1.133 2016/08/07 05:09:12 dholland Exp $	*/
+/*	$NetBSD: lfs_alloc.c,v 1.134 2017/03/13 14:24:20 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_alloc.c,v 1.133 2016/08/07 05:09:12 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_alloc.c,v 1.134 2017/03/13 14:24:20 riastradh Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_quota.h"
@@ -168,10 +168,8 @@ lfs_extend_ifile(struct lfs *fs, kauth_c
 	 */
 	LFS_GET_HEADFREE(fs, cip, cbp, );
 	LFS_PUT_HEADFREE(fs, cip, cbp, i);
-#ifdef DIAGNOSTIC
-	if (lfs_sb_getfreehd(fs) == LFS_UNUSED_INUM)
-		panic("inode 0 allocated [2]");
-#endif /* DIAGNOSTIC */
+	KASSERTMSG((lfs_sb_getfreehd(fs) != LFS_UNUSED_INUM),
+	"inode 0 allocated [2]");
 
 	/* inode number to stop at (XXX: why *x*max?) */
 	xmax = i + lfs_sb_getifpb(fs);
@@ -298,10 +296,8 @@ lfs_valloc(struct vnode *pvp, int mode, 
 			return error;
 		}
 	}
-#ifdef DIAGNOSTIC
-	if (lfs_sb_getfreehd(fs) == LFS_UNUSED_INUM)
-		panic("inode 0 allocated [3]");
-#endif /* DIAGNOSTIC */
+	KASSERTMSG((lfs_sb_getfreehd(fs) != LFS_UNUSED_INUM),
+	"inode 0 allocated [3]");
 
 	/* Set superblock modified bit */
 	mutex_enter(_lock);
@@ -667,12 +663,8 @@ lfs_vfree(struct vnode *vp, ino_t ino, i
 			}
 		}
 	}
-#ifdef DIAGNOSTIC
 	/* XXX: shouldn't this check be further up *before* we trash the fs? */
-	if (ino == LFS_UNUSED_INUM) {
-		panic("inode 0 freed");
-	}
-#endif /* DIAGNOSTIC */
+	KASSERTMSG((ino != LFS_UNUSED_INUM), "inode 0 freed");
 
 	/*
 	 * Update the segment summary for the segment where the on-disk
@@ -681,18 +673,12 @@ lfs_vfree(struct vnode *vp, ino_t ino, i
 	if (old_iaddr != LFS_UNUSED_DADDR) {
 		/* load it */
 		LFS_SEGENTRY(sup, fs, lfs_dtosn(fs, old_iaddr), bp);
-#ifdef DIAGNOSTIC
 		/* the number of bytes in the segment should not become < 0 */
-		if (sup->su_nbytes < DINOSIZE(fs)) {
-			printf("lfs_vfree: negative byte count"
-			   " (segment %" PRIu32 " short by %d)\n",
-			   lfs_dtosn(fs, old_iaddr),
-			   (int)DINOSIZE(fs) -
-sup->su_nbytes);
-			panic("lfs_vfree: negative byte count");
-			sup->su_nbytes = DINOSIZE(fs);
-		}
-#endif
+		KASSERTMSG((sup->su_nbytes >= DINOSIZE(fs)),
+		"lfs_vfree: negative byte count"
+		" (segment %" PRIu32 " short by %d)\n",
+		lfs_dtosn(fs, old_iaddr),
+		(int)DINOSIZE(fs) - sup->su_nbytes);
 		/* update the number of bytes in the segment */
 		sup->su_nbytes -= DINOSIZE(fs);
 		/* write the segment entry */

Index: src/sys/ufs/lfs/lfs_bio.c
diff -u src/sys/ufs/lfs/lfs_bio.c:1.135 src/sys/ufs/lfs/lfs_bio.c:1.136
--- src/sys/ufs/lfs/lfs_bio.c:1.135	Sat Oct  3 09:31:29 2015
+++ src/sys/ufs/lfs/lfs_bio.c	Mon Mar 13 14:24:20 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_bio.c,v 1.135 2015/10/03 09:31:29 hannken Exp $	*/
+/*	$NetBSD: lfs_bio.c,v 1.136 2017/03/13 14:24:20 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2008 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_bio.c,v 1.135 2015/10/03 09:31:29 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_bio.c,v 1.136 2017/03/13 14:24:20 riastradh Exp $");
 
 #include 
 #include 
@@ -315,11 +315,9 @@ lfs_bwrite(void *v)
 	} */ *ap = v;
 	struct buf *bp = ap->a_bp;
 
-#ifdef DIAGNOSTIC
-	if (VTOI(bp->b_vp)->i_lfs->lfs_ronly == 0 && (bp->b_flags & B_ASYNC)) {
-		panic("bawrite LFS buffer");
-	}
-#endif /* DIAGNOSTIC */
+	KASSERTMSG((VTOI(bp->b_vp)->i_lfs->lfs_ronly ||
+		!(bp->b_flags & B_ASYNC)),
+	"bawrite LFS buffer");
 	return lfs_bwrite_ext(bp, 0);
 }
 
@@ -385,10 +383,7 @@ lfs_availwait(struct lfs *fs, int fsb)
 #endif
 
 		lfs_wakeup_cleaner(fs);
-#ifdef DIAGNOSTIC
-		if 

CVS commit: src/sys/ufs/lfs

2017-03-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Mar 13 13:45:53 UTC 2017

Modified Files:
src/sys/ufs/lfs: lfs_inode.c

Log Message:
#if DIAGNOSTIC panic ---> KASSERTMSG


To generate a diff of this commit:
cvs rdiff -u -r1.147 -r1.148 src/sys/ufs/lfs/lfs_inode.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/ufs/lfs/lfs_inode.c
diff -u src/sys/ufs/lfs/lfs_inode.c:1.147 src/sys/ufs/lfs/lfs_inode.c:1.148
--- src/sys/ufs/lfs/lfs_inode.c:1.147	Tue Sep  1 06:13:09 2015
+++ src/sys/ufs/lfs/lfs_inode.c	Mon Mar 13 13:45:53 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_inode.c,v 1.147 2015/09/01 06:13:09 dholland Exp $	*/
+/*	$NetBSD: lfs_inode.c,v 1.148 2017/03/13 13:45:53 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.147 2015/09/01 06:13:09 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.148 2017/03/13 13:45:53 riastradh Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_quota.h"
@@ -243,10 +243,8 @@ lfs_truncate(struct vnode *ovp, off_t le
 	(oip->i_size < fs->um_maxsymlinklen ||
 	 (fs->um_maxsymlinklen == 0 &&
 	  lfs_dino_getblocks(fs, oip->i_din) == 0))) {
-#ifdef DIAGNOSTIC
-		if (length != 0)
-			panic("lfs_truncate: partial truncate of symlink");
-#endif
+		KASSERTMSG((length == 0),
+		"partial truncate of symlink: %jd", (intmax_t)length);
 		memset((char *)SHORTLINK(oip), 0, (u_int)oip->i_size);
 		oip->i_size = 0;
 		lfs_dino_setsize(fs, oip->i_din, 0);
@@ -589,15 +587,16 @@ done:
 	mutex_enter(_lock);
 	lfs_sb_addbfree(fs, blocksreleased);
 	mutex_exit(_lock);
-#ifdef DIAGNOSTIC
-	if (oip->i_size == 0 &&
-	(lfs_dino_getblocks(fs, oip->i_din) != 0 || oip->i_lfs_effnblks != 0)) {
-		printf("lfs_truncate: truncate to 0 but %jd blks/%jd effblks\n",
-		   (intmax_t)lfs_dino_getblocks(fs, oip->i_din),
-		   (intmax_t)oip->i_lfs_effnblks);
-		panic("lfs_truncate: persistent blocks");
-	}
-#endif
+
+	KASSERTMSG((oip->i_size != 0 ||
+		lfs_dino_getblocks(fs, oip->i_din) == 0),
+	"truncate to 0 but %jd blks/%jd effblks",
+	lfs_dino_getblocks(fs, oip->i_din),
+	oip->i_lfs_effnblks);
+	KASSERTMSG((oip->i_size != 0 || oip->i_lfs_effnblks == 0),
+	"truncate to 0 but %jd blks/%jd effblks",
+	lfs_dino_getblocks(fs, oip->i_din),
+	oip->i_lfs_effnblks);
 
 	/*
 	 * If we truncated to zero, take us off the paging queue.



CVS commit: src/sys/ufs/ffs

2017-03-10 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Fri Mar 10 22:43:03 UTC 2017

Modified Files:
src/sys/ufs/ffs: ffs_wapbl.c

Log Message:
sync any delayed writes when updating filesystem to log

Adresses PR kern/52056 by Martin Husemann, fix helped by Juergen Hannken, thanks


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/ufs/ffs/ffs_wapbl.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/ufs/ffs/ffs_wapbl.c
diff -u src/sys/ufs/ffs/ffs_wapbl.c:1.37 src/sys/ufs/ffs/ffs_wapbl.c:1.38
--- src/sys/ufs/ffs/ffs_wapbl.c:1.37	Thu Nov 10 22:19:23 2016
+++ src/sys/ufs/ffs/ffs_wapbl.c	Fri Mar 10 22:43:03 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_wapbl.c,v 1.37 2016/11/10 22:19:23 jdolecek Exp $	*/
+/*	$NetBSD: ffs_wapbl.c,v 1.38 2017/03/10 22:43:03 jdolecek Exp $	*/
 
 /*-
  * Copyright (c) 2003,2006,2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_wapbl.c,v 1.37 2016/11/10 22:19:23 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_wapbl.c,v 1.38 2017/03/10 22:43:03 jdolecek Exp $");
 
 #define WAPBL_INTERNAL
 
@@ -338,6 +338,13 @@ ffs_wapbl_start(struct mount *mp)
 return EINVAL;
 			}
 
+			/*
+			 * Make sure we don't carry over any delayed write
+			 * buffers when updating to log.
+			 */
+			if (mp->mnt_flag & MNT_UPDATE)
+ffs_sync(mp, MNT_WAIT, FSCRED);
+
 			error = wapbl_log_position(mp, fs, devvp, ,
 			, , );
 			if (error)



CVS commit: src/sys/ufs/ffs

2017-03-10 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Fri Mar 10 20:38:28 UTC 2017

Modified Files:
src/sys/ufs/ffs: ffs_vfsops.c

Log Message:
slightly rearrange the code for IMNT_WANTRDONLY + MNT_UPDATE case for
better readability, no functional change


To generate a diff of this commit:
cvs rdiff -u -r1.349 -r1.350 src/sys/ufs/ffs/ffs_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/ufs/ffs/ffs_vfsops.c
diff -u src/sys/ufs/ffs/ffs_vfsops.c:1.349 src/sys/ufs/ffs/ffs_vfsops.c:1.350
--- src/sys/ufs/ffs/ffs_vfsops.c:1.349	Mon Mar  6 10:12:00 2017
+++ src/sys/ufs/ffs/ffs_vfsops.c	Fri Mar 10 20:38:28 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_vfsops.c,v 1.349 2017/03/06 10:12:00 hannken Exp $	*/
+/*	$NetBSD: ffs_vfsops.c,v 1.350 2017/03/10 20:38:28 jdolecek Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.349 2017/03/06 10:12:00 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.350 2017/03/10 20:38:28 jdolecek Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -573,20 +573,23 @@ ffs_mount(struct mount *mp, const char *
 			if (mp->mnt_flag & MNT_FORCE)
 flags |= FORCECLOSE;
 			error = ffs_flushfiles(mp, flags, l);
-			if (error == 0)
-error = UFS_WAPBL_BEGIN(mp);
-			if (error == 0 &&
-			ffs_cgupdate(ump, MNT_WAIT) == 0 &&
+			if (error)
+return error;
+
+			error = UFS_WAPBL_BEGIN(mp);
+			if (error) {
+DPRINTF("wapbl %d", error);
+return error;
+			}
+
+			if (ffs_cgupdate(ump, MNT_WAIT) == 0 &&
 			fs->fs_clean & FS_WASCLEAN) {
 if (mp->mnt_flag & MNT_SOFTDEP)
 	fs->fs_flags &= ~FS_DOSOFTDEP;
 fs->fs_clean = FS_ISCLEAN;
 (void) ffs_sbupdate(ump, MNT_WAIT);
 			}
-			if (error) {
-DPRINTF("wapbl %d", error);
-return error;
-			}
+
 			UFS_WAPBL_END(mp);
 		}
 



CVS commit: src/sys/ufs/ffs

2017-03-06 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Mar  6 10:12:00 UTC 2017

Modified Files:
src/sys/ufs/ffs: ffs_vfsops.c

Log Message:
Adapt the test "enable WAPBL on rw mounts only" to the recent change of
the protocol to update a mounted file.

Should fix PR kern/52031 (FFS mount update doesn't play nice with WAPBL)


To generate a diff of this commit:
cvs rdiff -u -r1.348 -r1.349 src/sys/ufs/ffs/ffs_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/ufs/ffs/ffs_vfsops.c
diff -u src/sys/ufs/ffs/ffs_vfsops.c:1.348 src/sys/ufs/ffs/ffs_vfsops.c:1.349
--- src/sys/ufs/ffs/ffs_vfsops.c:1.348	Wed Mar  1 10:46:43 2017
+++ src/sys/ufs/ffs/ffs_vfsops.c	Mon Mar  6 10:12:00 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_vfsops.c,v 1.348 2017/03/01 10:46:43 hannken Exp $	*/
+/*	$NetBSD: ffs_vfsops.c,v 1.349 2017/03/06 10:12:00 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.348 2017/03/01 10:46:43 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.349 2017/03/06 10:12:00 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -518,7 +518,8 @@ ffs_mount(struct mount *mp, const char *
 
 #ifdef WAPBL
 	/* WAPBL can only be enabled on a r/w mount. */
-	if ((mp->mnt_flag & MNT_RDONLY) && !(mp->mnt_iflag & IMNT_WANTRDWR)) {
+	if (((mp->mnt_flag & MNT_RDONLY) && !(mp->mnt_iflag & IMNT_WANTRDWR)) ||
+	(mp->mnt_iflag & IMNT_WANTRDONLY)) {
 		mp->mnt_flag &= ~MNT_LOG;
 	}
 #else /* !WAPBL */



CVS commit: src/sys/ufs/ffs

2017-03-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Mar  2 00:43:40 UTC 2017

Modified Files:
src/sys/ufs/ffs: ffs_vnops.c

Log Message:
ifdef reduction


To generate a diff of this commit:
cvs rdiff -u -r1.127 -r1.128 src/sys/ufs/ffs/ffs_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/ufs/ffs/ffs_vnops.c
diff -u src/sys/ufs/ffs/ffs_vnops.c:1.127 src/sys/ufs/ffs/ffs_vnops.c:1.128
--- src/sys/ufs/ffs/ffs_vnops.c:1.127	Wed Mar  1 16:55:07 2017
+++ src/sys/ufs/ffs/ffs_vnops.c	Wed Mar  1 19:43:40 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_vnops.c,v 1.127 2017/03/01 21:55:07 hannken Exp $	*/
+/*	$NetBSD: ffs_vnops.c,v 1.128 2017/03/02 00:43:40 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_vnops.c,v 1.127 2017/03/01 21:55:07 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_vnops.c,v 1.128 2017/03/02 00:43:40 christos Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -283,9 +283,6 @@ ffs_spec_fsync(void *v)
 	} */ *ap = v;
 	int error, flags, uflags;
 	struct vnode *vp;
-#ifdef WAPBL
-	struct mount *mp;
-#endif /* WAPBL */
 
 	flags = ap->a_flags;
 	uflags = UPDATE_CLOSE | ((flags & FSYNC_WAIT) ? UPDATE_WAIT : 0);
@@ -296,7 +293,8 @@ ffs_spec_fsync(void *v)
 		goto out;
 
 #ifdef WAPBL
-	mp = vp->v_mount;
+	struct mount *mp = vp->v_mount;
+
 	if (mp && mp->mnt_wapbl) {
 		/*
 		 * Don't bother writing out metadata if the syncer is
@@ -462,6 +460,7 @@ ffs_full_fsync(struct vnode *vp, int fla
 
 #ifdef WAPBL
 	struct mount *mp = vp->v_mount;
+
 	if (mp && mp->mnt_wapbl) {
 
 		/*



CVS commit: src/sys/ufs/ffs

2017-03-01 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Mar  1 21:55:07 UTC 2017

Modified Files:
src/sys/ufs/ffs: ffs_vnops.c

Log Message:
Make compile again without "options WAPBL".

>From John D. Baker via current-users@, slightly modified by me.


To generate a diff of this commit:
cvs rdiff -u -r1.126 -r1.127 src/sys/ufs/ffs/ffs_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/ufs/ffs/ffs_vnops.c
diff -u src/sys/ufs/ffs/ffs_vnops.c:1.126 src/sys/ufs/ffs/ffs_vnops.c:1.127
--- src/sys/ufs/ffs/ffs_vnops.c:1.126	Wed Mar  1 10:42:45 2017
+++ src/sys/ufs/ffs/ffs_vnops.c	Wed Mar  1 21:55:07 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_vnops.c,v 1.126 2017/03/01 10:42:45 hannken Exp $	*/
+/*	$NetBSD: ffs_vnops.c,v 1.127 2017/03/01 21:55:07 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_vnops.c,v 1.126 2017/03/01 10:42:45 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_vnops.c,v 1.127 2017/03/01 21:55:07 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -283,18 +283,20 @@ ffs_spec_fsync(void *v)
 	} */ *ap = v;
 	int error, flags, uflags;
 	struct vnode *vp;
+#ifdef WAPBL
 	struct mount *mp;
+#endif /* WAPBL */
 
 	flags = ap->a_flags;
 	uflags = UPDATE_CLOSE | ((flags & FSYNC_WAIT) ? UPDATE_WAIT : 0);
 	vp = ap->a_vp;
-	mp = vp->v_mount;
 
 	error = spec_fsync(v);
 	if (error)
 		goto out;
 
 #ifdef WAPBL
+	mp = vp->v_mount;
 	if (mp && mp->mnt_wapbl) {
 		/*
 		 * Don't bother writing out metadata if the syncer is



CVS commit: src/sys/ufs/ffs

2017-03-01 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Mar  1 10:46:43 UTC 2017

Modified Files:
src/sys/ufs/ffs: ffs_vfsops.c

Log Message:
Bring back read-write to read-only mount update for ffs.


To generate a diff of this commit:
cvs rdiff -u -r1.347 -r1.348 src/sys/ufs/ffs/ffs_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/ufs/ffs/ffs_vfsops.c
diff -u src/sys/ufs/ffs/ffs_vfsops.c:1.347 src/sys/ufs/ffs/ffs_vfsops.c:1.348
--- src/sys/ufs/ffs/ffs_vfsops.c:1.347	Wed Mar  1 10:42:45 2017
+++ src/sys/ufs/ffs/ffs_vfsops.c	Wed Mar  1 10:46:43 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_vfsops.c,v 1.347 2017/03/01 10:42:45 hannken Exp $	*/
+/*	$NetBSD: ffs_vfsops.c,v 1.348 2017/03/01 10:46:43 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.347 2017/03/01 10:42:45 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.348 2017/03/01 10:46:43 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -564,7 +564,7 @@ ffs_mount(struct mount *mp, const char *
 
 		ump = VFSTOUFS(mp);
 		fs = ump->um_fs;
-		if (fs->fs_ronly == 0 && (mp->mnt_flag & MNT_RDONLY)) {
+		if (fs->fs_ronly == 0 && (mp->mnt_iflag & IMNT_WANTRDONLY)) {
 			/*
 			 * Changing from r/w to r/o
 			 */
@@ -599,7 +599,7 @@ ffs_mount(struct mount *mp, const char *
 		}
 #endif /* WAPBL */
 
-		if (fs->fs_ronly == 0 && (mp->mnt_flag & MNT_RDONLY)) {
+		if (fs->fs_ronly == 0 && (mp->mnt_iflag & IMNT_WANTRDONLY)) {
 			/*
 			 * Finish change from r/w to r/o
 			 */
@@ -1455,7 +1455,7 @@ ffs_mountfs(struct vnode *devvp, struct 
 	mp->mnt_fs_bshift = fs->fs_bshift;
 	mp->mnt_dev_bshift = DEV_BSHIFT;	/* XXX */
 	mp->mnt_flag |= MNT_LOCAL;
-	mp->mnt_iflag |= IMNT_MPSAFE;
+	mp->mnt_iflag |= IMNT_MPSAFE | IMNT_CAN_RWTORO;
 #ifdef FFS_EI
 	if (needswap)
 		ump->um_flags |= UFS_NEEDSWAP;



CVS commit: src/sys/ufs

2017-03-01 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Mar  1 10:42:46 UTC 2017

Modified Files:
src/sys/ufs/ffs: ffs_alloc.c ffs_snapshot.c ffs_vfsops.c ffs_vnops.c
src/sys/ufs/ufs: ufs_bmap.c ufs_inode.c ufs_quota2.c ufs_readwrite.c
ufs_vnops.c ufs_wapbl.c

Log Message:
Remove now redundant calls to fstrans_start()/fstrans_done().


To generate a diff of this commit:
cvs rdiff -u -r1.154 -r1.155 src/sys/ufs/ffs/ffs_alloc.c
cvs rdiff -u -r1.145 -r1.146 src/sys/ufs/ffs/ffs_snapshot.c
cvs rdiff -u -r1.346 -r1.347 src/sys/ufs/ffs/ffs_vfsops.c
cvs rdiff -u -r1.125 -r1.126 src/sys/ufs/ffs/ffs_vnops.c
cvs rdiff -u -r1.50 -r1.51 src/sys/ufs/ufs/ufs_bmap.c
cvs rdiff -u -r1.98 -r1.99 src/sys/ufs/ufs/ufs_inode.c
cvs rdiff -u -r1.41 -r1.42 src/sys/ufs/ufs/ufs_quota2.c
cvs rdiff -u -r1.120 -r1.121 src/sys/ufs/ufs/ufs_readwrite.c
cvs rdiff -u -r1.234 -r1.235 src/sys/ufs/ufs/ufs_vnops.c
cvs rdiff -u -r1.23 -r1.24 src/sys/ufs/ufs/ufs_wapbl.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/ufs/ffs/ffs_alloc.c
diff -u src/sys/ufs/ffs/ffs_alloc.c:1.154 src/sys/ufs/ffs/ffs_alloc.c:1.155
--- src/sys/ufs/ffs/ffs_alloc.c:1.154	Sun Oct 30 15:01:46 2016
+++ src/sys/ufs/ffs/ffs_alloc.c	Wed Mar  1 10:42:45 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_alloc.c,v 1.154 2016/10/30 15:01:46 christos Exp $	*/
+/*	$NetBSD: ffs_alloc.c,v 1.155 2017/03/01 10:42:45 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.154 2016/10/30 15:01:46 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.155 2017/03/01 10:42:45 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -82,7 +82,6 @@ __KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 

Index: src/sys/ufs/ffs/ffs_snapshot.c
diff -u src/sys/ufs/ffs/ffs_snapshot.c:1.145 src/sys/ufs/ffs/ffs_snapshot.c:1.146
--- src/sys/ufs/ffs/ffs_snapshot.c:1.145	Fri Feb 17 08:30:00 2017
+++ src/sys/ufs/ffs/ffs_snapshot.c	Wed Mar  1 10:42:45 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_snapshot.c,v 1.145 2017/02/17 08:30:00 hannken Exp $	*/
+/*	$NetBSD: ffs_snapshot.c,v 1.146 2017/03/01 10:42:45 hannken Exp $	*/
 
 /*
  * Copyright 2000 Marshall Kirk McKusick. All Rights Reserved.
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_snapshot.c,v 1.145 2017/02/17 08:30:00 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_snapshot.c,v 1.146 2017/03/01 10:42:45 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -2086,7 +2086,6 @@ ffs_snapshot_read(struct vnode *vp, stru
 	long size, xfersize, blkoffset;
 	int error;
 
-	fstrans_start(vp->v_mount, FSTRANS_SHARED);
 	mutex_enter(>si_snaplock);
 
 	if (ioflag & IO_ALTSEMANTICS)
@@ -2139,7 +2138,6 @@ ffs_snapshot_read(struct vnode *vp, stru
 		brelse(bp, BC_AGE);
 
 	mutex_exit(>si_snaplock);
-	fstrans_done(vp->v_mount);
 	return error;
 }
 

Index: src/sys/ufs/ffs/ffs_vfsops.c
diff -u src/sys/ufs/ffs/ffs_vfsops.c:1.346 src/sys/ufs/ffs/ffs_vfsops.c:1.347
--- src/sys/ufs/ffs/ffs_vfsops.c:1.346	Wed Feb 22 09:50:13 2017
+++ src/sys/ufs/ffs/ffs_vfsops.c	Wed Mar  1 10:42:45 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_vfsops.c,v 1.346 2017/02/22 09:50:13 hannken Exp $	*/
+/*	$NetBSD: ffs_vfsops.c,v 1.347 2017/03/01 10:42:45 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.346 2017/02/22 09:50:13 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.347 2017/03/01 10:42:45 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -92,7 +92,6 @@ __KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include 
@@ -1832,7 +1831,6 @@ ffs_statvfs(struct mount *mp, struct sta
 
 struct ffs_sync_ctx {
 	int waitfor;
-	bool is_suspending;
 };
 
 static bool
@@ -1869,9 +1867,6 @@ ffs_sync_selector(void *cl, struct vnode
 	UVM_OBJ_IS_CLEAN(>v_uobj
 		return false;
 
-	if (vp->v_type == VBLK && c->is_suspending)
-		return false;
-
 	return true;
 }
 
@@ -1890,7 +1885,6 @@ ffs_sync(struct mount *mp, int waitfor, 
 	struct fs *fs;
 	struct vnode_iterator *marker;
 	int error, allerror = 0;
-	bool is_suspending;
 	struct ffs_sync_ctx ctx;
 
 	fs = ump->um_fs;
@@ -1898,15 +1892,12 @@ ffs_sync(struct mount *mp, int waitfor, 
 		panic("%s: rofs mod, fs=%s", __func__, fs->fs_fsmnt);
 	}
 
-	fstrans_start(mp, FSTRANS_SHARED);
-	is_suspending = (fstrans_getstate(mp) == FSTRANS_SUSPENDING);
 	/*
 	 * Write back each (modified) inode.
 	 */
 	vfs_vnode_iterator_init(mp, );
 
 	ctx.waitfor = waitfor;
-	ctx.is_suspending = is_suspending;
 	while ((vp = vfs_vnode_iterator_next(marker, ffs_sync_selector, )))
 	{
 		error = vn_lock(vp,
@@ -1971,7 +1962,6 @@ ffs_sync(struct 

CVS commit: src/sys/ufs/ffs

2017-02-17 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Feb 17 08:26:41 UTC 2017

Modified Files:
src/sys/ufs/ffs: ffs_vfsops.c

Log Message:
Flush the log to disk when ffs_sync() gets called with MNT_WAIT.


To generate a diff of this commit:
cvs rdiff -u -r1.342 -r1.343 src/sys/ufs/ffs/ffs_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/ufs/ffs/ffs_vfsops.c
diff -u src/sys/ufs/ffs/ffs_vfsops.c:1.342 src/sys/ufs/ffs/ffs_vfsops.c:1.343
--- src/sys/ufs/ffs/ffs_vfsops.c:1.342	Tue Dec 27 10:54:38 2016
+++ src/sys/ufs/ffs/ffs_vfsops.c	Fri Feb 17 08:26:41 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_vfsops.c,v 1.342 2016/12/27 10:54:38 hannken Exp $	*/
+/*	$NetBSD: ffs_vfsops.c,v 1.343 2017/02/17 08:26:41 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.342 2016/12/27 10:54:38 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.343 2017/02/17 08:26:41 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -1973,7 +1973,7 @@ ffs_sync(struct mount *mp, int waitfor, 
 
 #ifdef WAPBL
 	if (mp->mnt_wapbl) {
-		error = wapbl_flush(mp->mnt_wapbl, 0);
+		error = wapbl_flush(mp->mnt_wapbl, (waitfor == MNT_WAIT));
 		if (error)
 			allerror = error;
 	}



CVS commit: src/sys/ufs/ffs

2017-02-08 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Thu Feb  9 04:37:35 UTC 2017

Modified Files:
src/sys/ufs/ffs: ffs_bswap.c ffs_extern.h

Log Message:
Sprinkle in a pinch of const, not too much, just enough
to add a little strength without affecting the overall balance...


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/ufs/ffs/ffs_bswap.c
cvs rdiff -u -r1.83 -r1.84 src/sys/ufs/ffs/ffs_extern.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/ufs/ffs/ffs_bswap.c
diff -u src/sys/ufs/ffs/ffs_bswap.c:1.39 src/sys/ufs/ffs/ffs_bswap.c:1.40
--- src/sys/ufs/ffs/ffs_bswap.c:1.39	Wed May 20 18:21:17 2015
+++ src/sys/ufs/ffs/ffs_bswap.c	Thu Feb  9 04:37:35 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_bswap.c,v 1.39 2015/05/20 18:21:17 riastradh Exp $	*/
+/*	$NetBSD: ffs_bswap.c,v 1.40 2017/02/09 04:37:35 kre Exp $	*/
 
 /*
  * Copyright (c) 1998 Manuel Bouyer.
@@ -30,7 +30,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_bswap.c,v 1.39 2015/05/20 18:21:17 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_bswap.c,v 1.40 2017/02/09 04:37:35 kre Exp $");
 
 #include 
 #if defined(_KERNEL)
@@ -52,17 +52,18 @@ __KERNEL_RCSID(0, "$NetBSD: ffs_bswap.c,
 #endif
 
 void
-ffs_sb_swap(struct fs *o, struct fs *n)
+ffs_sb_swap(const struct fs *o, struct fs *n)
 {
 	size_t i;
-	u_int32_t *o32, *n32;
+	const u_int32_t *o32;
+	u_int32_t *n32;
 
 	/*
 	 * In order to avoid a lot of lines, as the first N fields (52)
 	 * of the superblock up to fs_fmod are u_int32_t, we just loop
 	 * here to convert them.
 	 */
-	o32 = (u_int32_t *)o;
+	o32 = (const u_int32_t *)o;
 	n32 = (u_int32_t *)n;
 	for (i = 0; i < offsetof(struct fs, fs_fmod) / sizeof(u_int32_t); i++)
 		n32[i] = bswap32(o32[i]);
@@ -178,7 +179,7 @@ ffs_csum_swap(struct csum *o, struct csu
 }
 
 void
-ffs_csumtotal_swap(struct csum_total *o, struct csum_total *n)
+ffs_csumtotal_swap(const struct csum_total *o, struct csum_total *n)
 {
 	n->cs_ndir = bswap64(o->cs_ndir);
 	n->cs_nbfree = bswap64(o->cs_nbfree);

Index: src/sys/ufs/ffs/ffs_extern.h
diff -u src/sys/ufs/ffs/ffs_extern.h:1.83 src/sys/ufs/ffs/ffs_extern.h:1.84
--- src/sys/ufs/ffs/ffs_extern.h:1.83	Sat Oct  1 13:15:45 2016
+++ src/sys/ufs/ffs/ffs_extern.h	Thu Feb  9 04:37:35 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_extern.h,v 1.83 2016/10/01 13:15:45 jdolecek Exp $	*/
+/*	$NetBSD: ffs_extern.h,v 1.84 2017/02/09 04:37:35 kre Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -186,13 +186,13 @@ void	ffs_appleufs_set(struct appleufslab
 			 uint64_t);
 
 /* ffs_bswap.c */
-void	ffs_sb_swap(struct fs*, struct fs *);
+void	ffs_sb_swap(const struct fs *, struct fs *);
 void	ffs_dinode1_swap(struct ufs1_dinode *, struct ufs1_dinode *);
 void	ffs_dinode2_swap(struct ufs2_dinode *, struct ufs2_dinode *);
 struct csum;
 void	ffs_csum_swap(struct csum *, struct csum *, int);
 struct csum_total;
-void	ffs_csumtotal_swap(struct csum_total *, struct csum_total *);
+void	ffs_csumtotal_swap(const struct csum_total *, struct csum_total *);
 void	ffs_cg_swap(struct cg *, struct cg *, struct fs *);
 
 /* ffs_subr.c */



CVS commit: src/sys/ufs/ext2fs

2017-01-13 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Jan 13 18:04:36 UTC 2017

Modified Files:
src/sys/ufs/ext2fs: ext2fs_dinode.h

Log Message:
Fix unsigned


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/ufs/ext2fs/ext2fs_dinode.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/ufs/ext2fs/ext2fs_dinode.h
diff -u src/sys/ufs/ext2fs/ext2fs_dinode.h:1.36 src/sys/ufs/ext2fs/ext2fs_dinode.h:1.37
--- src/sys/ufs/ext2fs/ext2fs_dinode.h:1.36	Fri Aug 12 15:04:03 2016
+++ src/sys/ufs/ext2fs/ext2fs_dinode.h	Fri Jan 13 13:04:36 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_dinode.h,v 1.36 2016/08/12 19:04:03 jdolecek Exp $	*/
+/*	$NetBSD: ext2fs_dinode.h,v 1.37 2017/01/13 18:04:36 christos Exp $	*/
 
 /*
  * Copyright (c) 1982, 1989, 1993
@@ -205,7 +205,7 @@ struct ext2fs_dinode {
 #define EXT2_PROJINHERIT	0x2000 /* Children inherit project ID */
 
 /* Size of on-disk inode. */
-#define EXT2_REV0_DINODE_SIZE	128
+#define EXT2_REV0_DINODE_SIZE	128U
 #define EXT2_DINODE_SIZE(fs)	((fs)->e2fs.e2fs_rev > E2FS_REV0 ?	\
 (fs)->e2fs.e2fs_inode_size :	\
 EXT2_REV0_DINODE_SIZE)



CVS commit: src/sys/ufs/lfs

2017-01-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jan 12 18:40:02 UTC 2017

Modified Files:
src/sys/ufs/lfs: lfs_accessors.h

Log Message:
fix sign confusion


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/ufs/lfs/lfs_accessors.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/ufs/lfs/lfs_accessors.h
diff -u src/sys/ufs/lfs/lfs_accessors.h:1.46 src/sys/ufs/lfs/lfs_accessors.h:1.47
--- src/sys/ufs/lfs/lfs_accessors.h:1.46	Sun Jun 19 23:25:46 2016
+++ src/sys/ufs/lfs/lfs_accessors.h	Thu Jan 12 13:40:02 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_accessors.h,v 1.46 2016/06/20 03:25:46 dholland Exp $	*/
+/*	$NetBSD: lfs_accessors.h,v 1.47 2017/01/12 18:40:02 christos Exp $	*/
 
 /*  from NetBSD: lfs.h,v 1.165 2015/07/24 06:59:32 dholland Exp  */
 /*  from NetBSD: dinode.h,v 1.25 2016/01/22 23:06:10 dholland Exp  */
@@ -504,10 +504,10 @@ lfs_dino_getdb(STRUCT_LFS *fs, union lfs
 {
 	KASSERT(ix < ULFS_NDADDR);
 	if (fs->lfs_is64) {
-		return LFS_SWAP_uint64_t(fs, dip->u_64.di_db[ix]);
+		return LFS_SWAP_int64_t(fs, dip->u_64.di_db[ix]);
 	} else {
 		/* note: this must sign-extend or UNWRITTEN gets trashed */
-		return (int32_t)LFS_SWAP_uint32_t(fs, dip->u_32.di_db[ix]);
+		return (int32_t)LFS_SWAP_int32_t(fs, dip->u_32.di_db[ix]);
 	}
 }
 
@@ -516,10 +516,10 @@ lfs_dino_getib(STRUCT_LFS *fs, union lfs
 {
 	KASSERT(ix < ULFS_NIADDR);
 	if (fs->lfs_is64) {
-		return LFS_SWAP_uint64_t(fs, dip->u_64.di_ib[ix]);
+		return LFS_SWAP_int64_t(fs, dip->u_64.di_ib[ix]);
 	} else {
 		/* note: this must sign-extend or UNWRITTEN gets trashed */
-		return (int32_t)LFS_SWAP_uint32_t(fs, dip->u_32.di_ib[ix]);
+		return (int32_t)LFS_SWAP_int32_t(fs, dip->u_32.di_ib[ix]);
 	}
 }
 
@@ -528,7 +528,7 @@ lfs_dino_setdb(STRUCT_LFS *fs, union lfs
 {
 	KASSERT(ix < ULFS_NDADDR);
 	if (fs->lfs_is64) {
-		dip->u_64.di_db[ix] = LFS_SWAP_uint64_t(fs, val);
+		dip->u_64.di_db[ix] = LFS_SWAP_int64_t(fs, val);
 	} else {
 		dip->u_32.di_db[ix] = LFS_SWAP_uint32_t(fs, val);
 	}
@@ -539,7 +539,7 @@ lfs_dino_setib(STRUCT_LFS *fs, union lfs
 {
 	KASSERT(ix < ULFS_NIADDR);
 	if (fs->lfs_is64) {
-		dip->u_64.di_ib[ix] = LFS_SWAP_uint64_t(fs, val);
+		dip->u_64.di_ib[ix] = LFS_SWAP_int64_t(fs, val);
 	} else {
 		dip->u_32.di_ib[ix] = LFS_SWAP_uint32_t(fs, val);
 	}



CVS commit: src/sys/ufs/ufs

2017-01-04 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Jan  4 10:04:17 UTC 2017

Modified Files:
src/sys/ufs/ufs: ufs_inode.c

Log Message:
Change ufs_truncate_retry() to call UFS_TRUNCATE() at least once.
Even with "newsize == ip->i_size" it must set mtime etc.

Adresses PR kern/51762 "mtime not updated by open(O_TRUNC)"


To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.98 src/sys/ufs/ufs/ufs_inode.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/ufs/ufs/ufs_inode.c
diff -u src/sys/ufs/ufs/ufs_inode.c:1.97 src/sys/ufs/ufs/ufs_inode.c:1.98
--- src/sys/ufs/ufs/ufs_inode.c:1.97	Fri Oct 28 20:38:12 2016
+++ src/sys/ufs/ufs/ufs_inode.c	Wed Jan  4 10:04:17 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_inode.c,v 1.97 2016/10/28 20:38:12 jdolecek Exp $	*/
+/*	$NetBSD: ufs_inode.c,v 1.98 2017/01/04 10:04:17 hannken Exp $	*/
 
 /*
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_inode.c,v 1.97 2016/10/28 20:38:12 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_inode.c,v 1.98 2017/01/04 10:04:17 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -303,7 +303,7 @@ ufs_truncate_retry(struct vnode *vp, uin
 	/*
 	 * Truncate might temporarily fail, loop until done.
 	 */
-	while (ip->i_size != newsize) {
+	do {
 		error = UFS_WAPBL_BEGIN(mp);
 		if (error)
 			goto out;
@@ -313,7 +313,7 @@ ufs_truncate_retry(struct vnode *vp, uin
 
 		if (error != 0 && error != EAGAIN)
 			goto out;
-	}
+	} while (ip->i_size != newsize);
 
   out:
 	return error;



CVS commit: src/sys/ufs/ffs

2016-12-27 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Dec 27 10:54:38 UTC 2016

Modified Files:
src/sys/ufs/ffs: ffs_vfsops.c

Log Message:
Fix a bug introduced with Rev. 1.294:  use LK_NOWAIT when called with MNT_LAZY.


To generate a diff of this commit:
cvs rdiff -u -r1.341 -r1.342 src/sys/ufs/ffs/ffs_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/ufs/ffs/ffs_vfsops.c
diff -u src/sys/ufs/ffs/ffs_vfsops.c:1.341 src/sys/ufs/ffs/ffs_vfsops.c:1.342
--- src/sys/ufs/ffs/ffs_vfsops.c:1.341	Thu Oct 20 19:31:32 2016
+++ src/sys/ufs/ffs/ffs_vfsops.c	Tue Dec 27 10:54:38 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_vfsops.c,v 1.341 2016/10/20 19:31:32 jdolecek Exp $	*/
+/*	$NetBSD: ffs_vfsops.c,v 1.342 2016/12/27 10:54:38 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.341 2016/10/20 19:31:32 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.342 2016/12/27 10:54:38 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -1917,7 +1917,8 @@ ffs_sync(struct mount *mp, int waitfor, 
 	ctx.is_suspending = is_suspending;
 	while ((vp = vfs_vnode_iterator_next(marker, ffs_sync_selector, )))
 	{
-		error = vn_lock(vp, LK_EXCLUSIVE);
+		error = vn_lock(vp,
+		LK_EXCLUSIVE | (waitfor == MNT_LAZY ? LK_NOWAIT : 0));
 		if (error) {
 			vrele(vp);
 			continue;



CVS commit: src/sys/ufs/lfs

2016-11-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Nov 20 21:22:14 UTC 2016

Modified Files:
src/sys/ufs/lfs: ulfs_quota2.c

Log Message:
KASSERT(mutex_owner(...)) ---> KASSERT(mutex_owned(...))


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/ufs/lfs/ulfs_quota2.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/ufs/lfs/ulfs_quota2.c
diff -u src/sys/ufs/lfs/ulfs_quota2.c:1.28 src/sys/ufs/lfs/ulfs_quota2.c:1.29
--- src/sys/ufs/lfs/ulfs_quota2.c:1.28	Thu Jul  7 06:55:44 2016
+++ src/sys/ufs/lfs/ulfs_quota2.c	Sun Nov 20 21:22:14 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ulfs_quota2.c,v 1.28 2016/07/07 06:55:44 msaitoh Exp $	*/
+/*	$NetBSD: ulfs_quota2.c,v 1.29 2016/11/20 21:22:14 riastradh Exp $	*/
 /*  from NetBSD: ufs_quota2.c,v 1.40 2015/03/28 19:24:05 maxv Exp Exp  */
 /*  from NetBSD: ffs_quota2.c,v 1.5 2015/02/22 14:12:48 maxv Exp  */
 
@@ -29,7 +29,7 @@
   */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ulfs_quota2.c,v 1.28 2016/07/07 06:55:44 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ulfs_quota2.c,v 1.29 2016/11/20 21:22:14 riastradh Exp $");
 
 #include 
 #include 
@@ -205,7 +205,7 @@ quota2_walk_list(struct ulfsmount *ump, 
 	struct quota2_entry *q2e;
 	daddr_t lblkno, blkoff, olblkno = 0;
 
-	KASSERT(mutex_owner(_dqlock));
+	KASSERT(mutex_owned(_dqlock));
 
 	while (off != 0) {
 		lblkno = (off >> ump->um_mountp->mnt_fs_bshift);



CVS commit: src/sys/ufs/ufs

2016-11-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Nov 20 21:21:26 UTC 2016

Modified Files:
src/sys/ufs/ufs: ufs_quota2.c

Log Message:
KASSERT(mutex_owner(...)) ---> KASSERT(mutex_owned(...))

Fixes part of PR kern/47114.  Tested by code inspection.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/ufs/ufs/ufs_quota2.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/ufs/ufs/ufs_quota2.c
diff -u src/sys/ufs/ufs/ufs_quota2.c:1.40 src/sys/ufs/ufs/ufs_quota2.c:1.41
--- src/sys/ufs/ufs/ufs_quota2.c:1.40	Sat Mar 28 19:24:05 2015
+++ src/sys/ufs/ufs/ufs_quota2.c	Sun Nov 20 21:21:26 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: ufs_quota2.c,v 1.40 2015/03/28 19:24:05 maxv Exp $ */
+/* $NetBSD: ufs_quota2.c,v 1.41 2016/11/20 21:21:26 riastradh Exp $ */
 /*-
   * Copyright (c) 2010 Manuel Bouyer
   * All rights reserved.
@@ -26,7 +26,7 @@
   */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_quota2.c,v 1.40 2015/03/28 19:24:05 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_quota2.c,v 1.41 2016/11/20 21:21:26 riastradh Exp $");
 
 #include 
 #include 
@@ -200,7 +200,7 @@ quota2_walk_list(struct ufsmount *ump, s
 	struct quota2_entry *q2e;
 	daddr_t lblkno, blkoff, olblkno = 0;
 
-	KASSERT(mutex_owner());
+	KASSERT(mutex_owned());
 
 	while (off != 0) {
 		lblkno = (off >> ump->um_mountp->mnt_fs_bshift);



CVS commit: src/sys/ufs/ufs

2016-11-11 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Fri Nov 11 22:59:26 UTC 2016

Modified Files:
src/sys/ufs/ufs: ufs_wapbl.h

Log Message:
fix !WAPBL variant of UFS_WAPBL_REGISTER_DEALLOCATION()


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/ufs/ufs/ufs_wapbl.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/ufs/ufs/ufs_wapbl.h
diff -u src/sys/ufs/ufs/ufs_wapbl.h:1.13 src/sys/ufs/ufs/ufs_wapbl.h:1.14
--- src/sys/ufs/ufs/ufs_wapbl.h:1.13	Thu Nov 10 20:56:32 2016
+++ src/sys/ufs/ufs/ufs_wapbl.h	Fri Nov 11 22:59:26 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_wapbl.h,v 1.13 2016/11/10 20:56:32 jdolecek Exp $	*/
+/*	$NetBSD: ufs_wapbl.h,v 1.14 2016/11/11 22:59:26 jdolecek Exp $	*/
 
 /*-
  * Copyright (c) 2003,2006,2008 The NetBSD Foundation, Inc.
@@ -171,8 +171,8 @@ ufs_wapbl_end(struct mount *mp)
 #define	UFS_WAPBL_JUNLOCK_ASSERT(mp)
 #define	UFS_WAPBL_REGISTER_INODE(mp, ino, mode)		do { } while (0)
 #define	UFS_WAPBL_UNREGISTER_INODE(mp, ino, mode)	do { } while (0)
-#define	UFS_WAPBL_REGISTER_DEALLOCATION(mp, blk, len)		0
-#define	UFS_WAPBL_REGISTER_DEALLOCATION_FORCE(mp, blk, len)	0
+#define	UFS_WAPBL_REGISTER_DEALLOCATION(mp, blk, len, cookiep)		0
+#define	UFS_WAPBL_REGISTER_DEALLOCATION_FORCE(mp, blk, len)		0
 #define	UFS_WAPBL_UNREGISTER_DEALLOCATION(mp, cookie)	do { } while (0)
 #endif
 



CVS commit: src/sys/ufs/ffs

2016-11-11 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Nov 11 10:50:16 UTC 2016

Modified Files:
src/sys/ufs/ffs: ffs_inode.c

Log Message:
Fix a "slight tweak" from Rev. 1.121:  bap1/bap2 must be valid
before using BAP_ASSIGN().

Prevents NULL pointer dereference when "lastbn >= 0".


To generate a diff of this commit:
cvs rdiff -u -r1.122 -r1.123 src/sys/ufs/ffs/ffs_inode.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/ufs/ffs/ffs_inode.c
diff -u src/sys/ufs/ffs/ffs_inode.c:1.122 src/sys/ufs/ffs/ffs_inode.c:1.123
--- src/sys/ufs/ffs/ffs_inode.c:1.122	Thu Nov 10 20:56:32 2016
+++ src/sys/ufs/ffs/ffs_inode.c	Fri Nov 11 10:50:16 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_inode.c,v 1.122 2016/11/10 20:56:32 jdolecek Exp $	*/
+/*	$NetBSD: ffs_inode.c,v 1.123 2016/11/11 10:50:16 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_inode.c,v 1.122 2016/11/10 20:56:32 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_inode.c,v 1.123 2016/11/11 10:50:16 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -659,6 +659,10 @@ ffs_indirtrunc(struct inode *ip, daddr_t
 	 * This assumes the truncate process would not fail, contrary
 	 * to the wapbl case.
 	 */
+	if (ip->i_ump->um_fstype == UFS1)
+		bap1 = (int32_t *)bp->b_data;
+	else
+		bap2 = (int64_t *)bp->b_data;
 	if (lastbn >= 0 && !wapbl) {
 		copy = kmem_alloc(fs->fs_bsize, KM_SLEEP);
 		memcpy((void *)copy, bp->b_data, (u_int)fs->fs_bsize);
@@ -672,11 +676,6 @@ ffs_indirtrunc(struct inode *ip, daddr_t
 			bap1 = (int32_t *)copy;
 		else
 			bap2 = (int64_t *)copy;
-	} else {
-		if (ip->i_ump->um_fstype == UFS1)
-			bap1 = (int32_t *)bp->b_data;
-		else
-			bap2 = (int64_t *)bp->b_data;
 	}
 
 	/*



CVS commit: src/sys/ufs/ffs

2016-11-10 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Thu Nov 10 22:19:23 UTC 2016

Modified Files:
src/sys/ufs/ffs: ffs_wapbl.c

Log Message:
disable discard when log is enabled to preserve log consistency promise

PR kern/50725


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/ufs/ffs/ffs_wapbl.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/ufs/ffs/ffs_wapbl.c
diff -u src/sys/ufs/ffs/ffs_wapbl.c:1.36 src/sys/ufs/ffs/ffs_wapbl.c:1.37
--- src/sys/ufs/ffs/ffs_wapbl.c:1.36	Thu Nov 10 20:56:32 2016
+++ src/sys/ufs/ffs/ffs_wapbl.c	Thu Nov 10 22:19:23 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_wapbl.c,v 1.36 2016/11/10 20:56:32 jdolecek Exp $	*/
+/*	$NetBSD: ffs_wapbl.c,v 1.37 2016/11/10 22:19:23 jdolecek Exp $	*/
 
 /*-
  * Copyright (c) 2003,2006,2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_wapbl.c,v 1.36 2016/11/10 20:56:32 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_wapbl.c,v 1.37 2016/11/10 22:19:23 jdolecek Exp $");
 
 #define WAPBL_INTERNAL
 
@@ -371,6 +371,23 @@ ffs_wapbl_start(struct mount *mp)
 if (error)
 	goto out;
 			}
+
+			/*
+			 * XXX discard interferes with block deallocation
+			 * registration and hence log consistency
+			 */
+			if (mp->mnt_flag & MNT_DISCARD) {
+CLR(mp->mnt_flag, MNT_DISCARD);
+printf("%s: %s: disabling discard to preserve log consistency\n", __func__,
+fs->fs_fsmnt);
+
+if (ump->um_discarddata != NULL) {
+			ffs_discard_finish(ump->um_discarddata,
+	0);
+			ump->um_discarddata = NULL;
+}
+			}
+
 		} else if (fs->fs_flags & FS_DOWAPBL) {
 			fs->fs_fmod = 1;
 			fs->fs_flags &= ~FS_DOWAPBL;



CVS commit: src/sys/ufs/ffs

2016-11-10 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Thu Nov 10 19:10:05 UTC 2016

Modified Files:
src/sys/ufs/ffs: ffs_inode.c

Log Message:
ffs_indirtrunc(): for !wapbl, restore rev 1.117 behavior of writing the zeroed
(indirect) block before freeing the referenced blocks; it's necessary for
fsck to recover the filesystem, if system goes down during truncate

patch courtesy of hannken@ with only sligh tweaks


To generate a diff of this commit:
cvs rdiff -u -r1.120 -r1.121 src/sys/ufs/ffs/ffs_inode.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/ufs/ffs/ffs_inode.c
diff -u src/sys/ufs/ffs/ffs_inode.c:1.120 src/sys/ufs/ffs/ffs_inode.c:1.121
--- src/sys/ufs/ffs/ffs_inode.c:1.120	Mon Nov  7 21:14:23 2016
+++ src/sys/ufs/ffs/ffs_inode.c	Thu Nov 10 19:10:05 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_inode.c,v 1.120 2016/11/07 21:14:23 jdolecek Exp $	*/
+/*	$NetBSD: ffs_inode.c,v 1.121 2016/11/10 19:10:05 jdolecek Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_inode.c,v 1.120 2016/11/07 21:14:23 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_inode.c,v 1.121 2016/11/10 19:10:05 jdolecek Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -533,6 +533,8 @@ out:
 	 * blocks were deallocated creating a hole, but that is okay.
 	 */
 	if (error == EAGAIN) {
+		if (!allerror)
+			allerror = error;
 		length = osize;
 		uvm_vnp_setsize(ovp, length);
 	}
@@ -573,10 +575,12 @@ ffs_indirtrunc(struct inode *ip, daddr_t
 	int64_t *bap2 = NULL;
 	struct vnode *vp;
 	daddr_t nb, nlbn, last;
+	char *copy = NULL;
 	int64_t factor;
 	int64_t nblocks;
-	int error = 0;
+	int error = 0, allerror = 0;
 	const int needswap = UFS_FSNEEDSWAP(fs);
+	const int wapbl = (ip->i_ump->um_mountp->mnt_wapbl != NULL);
 
 #define RBAP(ip, i) (((ip)->i_ump->um_fstype == UFS1) ? \
 	ufs_rw32(bap1[i], needswap) : ufs_rw64(bap2[i], needswap))
@@ -602,7 +606,7 @@ ffs_indirtrunc(struct inode *ip, daddr_t
 	nblocks = btodb(fs->fs_bsize);
 	/*
 	 * Get buffer of block pointers, zero those entries corresponding
-	 * to blocks to be free'd, and update on disk copy.  Since
+	 * to blocks to be free'd, and update on disk copy first.  Since
 	 * double(triple) indirect before single(double) indirect, calls
 	 * to bmap on these blocks will fail.  However, we already have
 	 * the on disk address, so we have to set the b_blkno field
@@ -635,13 +639,35 @@ ffs_indirtrunc(struct inode *ip, daddr_t
 		return error;
 	}
 
-	if (ip->i_ump->um_fstype == UFS1)
-		bap1 = (int32_t *)bp->b_data;
-	else
-		bap2 = (int64_t *)bp->b_data;
+	/*
+	 * Clear reference to blocks to be removed on disk, before actually
+	 * reclaiming them, so that fsck is more likely to be able to recover
+	 * the filesystem if system goes down during the truncate process.
+	 * This assumes the truncate process would not fail, contrary
+	 * to the wapbl case.
+	 */
+	if (lastbn >= 0 && !wapbl) {
+		copy = kmem_alloc(fs->fs_bsize, KM_SLEEP);
+		memcpy((void *)copy, bp->b_data, (u_int)fs->fs_bsize);
+		for (i = last + 1; i < FFS_NINDIR(fs); i++)
+			BAP_ASSIGN(ip, i, 0);
+		error = bwrite(bp);
+		if (error)
+			allerror = error;
+
+		if (ip->i_ump->um_fstype == UFS1)
+			bap1 = (int32_t *)copy;
+		else
+			bap2 = (int64_t *)copy;
+	} else {
+		if (ip->i_ump->um_fstype == UFS1)
+			bap1 = (int32_t *)bp->b_data;
+		else
+			bap2 = (int64_t *)bp->b_data;
+	}
 
 	/*
-	 * Recursively free totally unused blocks, starting from first.
+	 * Recursively free totally unused blocks.
 	 */
 	for (i = FFS_NINDIR(fs) - 1, nlbn = lbn + 1 - i * factor; i > last;
 	i--, nlbn += factor) {
@@ -686,15 +712,22 @@ ffs_indirtrunc(struct inode *ip, daddr_t
 	}
 
 out:
-	if (lastbn < 0 && error == 0) {
+ 	if (error && !allerror)
+ 		allerror = error;
+
+ 	if (copy != NULL) {
+ 		kmem_free(copy, fs->fs_bsize);
+ 	} else if (lastbn < 0 && error == 0) {
 		/* all freed, release without writing back */
 		brelse(bp, BC_INVAL);
-	} else {
-		/* only partially freed, write the updated block */
-		(void) bwrite(bp);
+	} else if (wapbl) {
+ 		/* only partially freed, write the updated block */
+ 		error = bwrite(bp);
+ 		if (!allerror)
+ 			allerror = error;
 	}
 
-	return (error);
+	return (allerror);
 }
 
 void



CVS commit: src/sys/ufs/lfs

2016-11-08 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Wed Nov  9 05:44:42 UTC 2016

Modified Files:
src/sys/ufs/lfs: ulfs_extattr.c

Log Message:
Apply ufs_extattr.c 1.48:
Explain why the lock in here needs to be recursive. Related to PR 46997.

ufs_extattr 1.47 was also committed directly here, so this file is still
fully synced with it.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/ufs/lfs/ulfs_extattr.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/ufs/lfs/ulfs_extattr.c
diff -u src/sys/ufs/lfs/ulfs_extattr.c:1.13 src/sys/ufs/lfs/ulfs_extattr.c:1.14
--- src/sys/ufs/lfs/ulfs_extattr.c:1.13	Thu Jul  7 06:55:44 2016
+++ src/sys/ufs/lfs/ulfs_extattr.c	Wed Nov  9 05:44:42 2016
@@ -1,5 +1,5 @@
-/*	$NetBSD: ulfs_extattr.c,v 1.13 2016/07/07 06:55:44 msaitoh Exp $	*/
-/*  from NetBSD: ufs_extattr.c,v 1.46 2014/11/19 16:26:47 manu Exp  */
+/*	$NetBSD: ulfs_extattr.c,v 1.14 2016/11/09 05:44:42 dholland Exp $	*/
+/*  from NetBSD: ulfs_extattr.c,v 1.48 2016/11/09 05:08:35 dholland Exp  */
 
 /*-
  * Copyright (c) 1999-2002 Robert N. M. Watson
@@ -49,7 +49,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ulfs_extattr.c,v 1.13 2016/07/07 06:55:44 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ulfs_extattr.c,v 1.14 2016/11/09 05:44:42 dholland Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_lfs.h"
@@ -168,7 +168,13 @@ static void
 ulfs_extattr_uepm_lock(struct ulfsmount *ump)
 {
 
-	/* XXX Why does this need to be recursive? */
+	/*
+	 * XXX This needs to be recursive for the following reasons:
+	 *   - it is taken in ulfs_extattr_vnode_inactive
+	 *   - which is called from VOP_INACTIVE
+	 *   - which can be triggered by any vrele, vput, or vn_close
+	 *   - several of these can happen while it's held
+	 */
 	if (mutex_owned(>um_extattr.uepm_lock)) {
 		ump->um_extattr.uepm_lockcnt++;
 		return;



CVS commit: src/sys/ufs/ufs

2016-11-08 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Wed Nov  9 05:08:35 UTC 2016

Modified Files:
src/sys/ufs/ufs: ufs_extattr.c

Log Message:
Explain why the lock in here needs to be recursive. Related to PR 46997.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/ufs/ufs/ufs_extattr.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/ufs/ufs/ufs_extattr.c
diff -u src/sys/ufs/ufs/ufs_extattr.c:1.47 src/sys/ufs/ufs/ufs_extattr.c:1.48
--- src/sys/ufs/ufs/ufs_extattr.c:1.47	Thu Jul  7 06:55:44 2016
+++ src/sys/ufs/ufs/ufs_extattr.c	Wed Nov  9 05:08:35 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_extattr.c,v 1.47 2016/07/07 06:55:44 msaitoh Exp $	*/
+/*	$NetBSD: ufs_extattr.c,v 1.48 2016/11/09 05:08:35 dholland Exp $	*/
 
 /*-
  * Copyright (c) 1999-2002 Robert N. M. Watson
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_extattr.c,v 1.47 2016/07/07 06:55:44 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_extattr.c,v 1.48 2016/11/09 05:08:35 dholland Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ffs.h"
@@ -168,7 +168,13 @@ static void
 ufs_extattr_uepm_lock(struct ufsmount *ump)
 {
 
-	/* XXX Why does this need to be recursive? */
+	/*
+	 * XXX This needs to be recursive for the following reasons:
+	 *   - it is taken in ufs_extattr_vnode_inactive
+	 *   - which is called from VOP_INACTIVE
+	 *   - which can be triggered by any vrele, vput, or vn_close
+	 *   - several of these can happen while it's held
+	 */
 	if (mutex_owned(>um_extattr.uepm_lock)) {
 		ump->um_extattr.uepm_lockcnt++;
 		return;



CVS commit: src/sys/ufs/ufs

2016-11-08 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Wed Nov  9 04:12:55 UTC 2016

Modified Files:
src/sys/ufs/ufs: ufs_vnops.c

Log Message:
ufs_makeinode is declared file-static at the top of the file; mark it
at its definition too, for consistency and to avoid misleading casual
passersby.


To generate a diff of this commit:
cvs rdiff -u -r1.233 -r1.234 src/sys/ufs/ufs/ufs_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/ufs/ufs/ufs_vnops.c
diff -u src/sys/ufs/ufs/ufs_vnops.c:1.233 src/sys/ufs/ufs/ufs_vnops.c:1.234
--- src/sys/ufs/ufs/ufs_vnops.c:1.233	Fri Oct 28 20:38:12 2016
+++ src/sys/ufs/ufs/ufs_vnops.c	Wed Nov  9 04:12:55 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_vnops.c,v 1.233 2016/10/28 20:38:12 jdolecek Exp $	*/
+/*	$NetBSD: ufs_vnops.c,v 1.234 2016/11/09 04:12:55 dholland Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.233 2016/10/28 20:38:12 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.234 2016/11/09 04:12:55 dholland Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -1764,7 +1764,7 @@ ufs_vinit(struct mount *mntp, int (**spe
 /*
  * Allocate a new inode.
  */
-int
+static int
 ufs_makeinode(struct vattr *vap, struct vnode *dvp,
 	const struct ufs_lookup_results *ulr,
 	struct vnode **vpp, struct componentname *cnp)



CVS commit: src/sys/ufs/ffs

2016-11-07 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Mon Nov  7 21:14:23 UTC 2016

Modified Files:
src/sys/ufs/ffs: ffs_inode.c

Log Message:
fix broken test for partial truncate, introduced in rev 1.118

PR kern/51601 kern/51602


To generate a diff of this commit:
cvs rdiff -u -r1.119 -r1.120 src/sys/ufs/ffs/ffs_inode.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/ufs/ffs/ffs_inode.c
diff -u src/sys/ufs/ffs/ffs_inode.c:1.119 src/sys/ufs/ffs/ffs_inode.c:1.120
--- src/sys/ufs/ffs/ffs_inode.c:1.119	Mon Nov  7 21:05:38 2016
+++ src/sys/ufs/ffs/ffs_inode.c	Mon Nov  7 21:14:23 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_inode.c,v 1.119 2016/11/07 21:05:38 jdolecek Exp $	*/
+/*	$NetBSD: ffs_inode.c,v 1.120 2016/11/07 21:14:23 jdolecek Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_inode.c,v 1.119 2016/11/07 21:05:38 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_inode.c,v 1.120 2016/11/07 21:14:23 jdolecek Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -686,7 +686,7 @@ ffs_indirtrunc(struct inode *ip, daddr_t
 	}
 
 out:
-	if (RBAP(ip, 0) == 0) {
+	if (lastbn < 0 && error == 0) {
 		/* all freed, release without writing back */
 		brelse(bp, BC_INVAL);
 	} else {



CVS commit: src/sys/ufs/ffs

2016-11-07 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Mon Nov  7 21:05:38 UTC 2016

Modified Files:
src/sys/ufs/ffs: ffs_inode.c

Log Message:
reduce diff vs 1.117, no functional change


To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 src/sys/ufs/ffs/ffs_inode.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/ufs/ffs/ffs_inode.c
diff -u src/sys/ufs/ffs/ffs_inode.c:1.118 src/sys/ufs/ffs/ffs_inode.c:1.119
--- src/sys/ufs/ffs/ffs_inode.c:1.118	Fri Oct 28 20:38:12 2016
+++ src/sys/ufs/ffs/ffs_inode.c	Mon Nov  7 21:05:38 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_inode.c,v 1.118 2016/10/28 20:38:12 jdolecek Exp $	*/
+/*	$NetBSD: ffs_inode.c,v 1.119 2016/11/07 21:05:38 jdolecek Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_inode.c,v 1.118 2016/10/28 20:38:12 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_inode.c,v 1.119 2016/11/07 21:05:38 jdolecek Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -675,11 +675,11 @@ ffs_indirtrunc(struct inode *ip, daddr_t
 	 * Recursively free blocks on the now last partial indirect block.
 	 */
 	if (level > SINGLE && lastbn >= 0) {
-		nb = RBAP(ip, last);
+		last = lastbn % factor;
+		nb = RBAP(ip, i);
 		if (nb != 0) {
 			error = ffs_indirtrunc(ip, nlbn, FFS_FSBTODB(fs, nb),
-	   lastbn % factor, level - 1,
-	   countp);
+	   last, level - 1, countp);
 			if (error)
 goto out;
 		}



CVS commit: src/sys/ufs/ffs

2016-10-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Oct 30 15:01:46 UTC 2016

Modified Files:
src/sys/ufs/ffs: ffs_alloc.c

Log Message:
Tidy up panic messages, no functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.153 -r1.154 src/sys/ufs/ffs/ffs_alloc.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/ufs/ffs/ffs_alloc.c
diff -u src/sys/ufs/ffs/ffs_alloc.c:1.153 src/sys/ufs/ffs/ffs_alloc.c:1.154
--- src/sys/ufs/ffs/ffs_alloc.c:1.153	Fri Oct 28 16:38:12 2016
+++ src/sys/ufs/ffs/ffs_alloc.c	Sun Oct 30 11:01:46 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_alloc.c,v 1.153 2016/10/28 20:38:12 jdolecek Exp $	*/
+/*	$NetBSD: ffs_alloc.c,v 1.154 2016/10/30 15:01:46 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.153 2016/10/28 20:38:12 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.154 2016/10/30 15:01:46 christos Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -136,14 +136,13 @@ ffs_check_bad_allocation(const char *fun
 {
 	if ((u_int)size > fs->fs_bsize || ffs_fragoff(fs, size) != 0 ||
 	ffs_fragnum(fs, bno) + ffs_numfrags(fs, size) > fs->fs_frag) {
-		printf("dev = 0x%llx, bno = %" PRId64 " bsize = %d, "
-		"size = %ld, fs = %s\n",
+		panic("%s: bad size: dev = 0x%llx, bno = %" PRId64 
+		" bsize = %d, size = %ld, fs = %s", func,
 		(long long)dev, bno, fs->fs_bsize, size, fs->fs_fsmnt);
-		panic("%s: bad size", func);
 	}
 
 	if (bno >= fs->fs_size) {
-		printf("bad block %" PRId64 ", ino %llu\n", bno,
+		printf("%s: bad block %" PRId64 ", ino %llu\n", func, bno,
 		(unsigned long long)inum);
 		ffs_fserr(fs, NOCRED, "bad block");
 		return EINVAL;
@@ -229,14 +228,13 @@ ffs_alloc(struct inode *ip, daddr_t lbn,
 
 	*bnp = 0;
 #ifdef DIAGNOSTIC
+	if (cred == NOCRED)
+		panic("%s: missing credential", __func__);
 	if ((u_int)size > fs->fs_bsize || ffs_fragoff(fs, size) != 0) {
-		printf("dev = 0x%llx, bsize = %d, size = %d, fs = %s\n",
-		(unsigned long long)ip->i_dev, fs->fs_bsize, size,
-		fs->fs_fsmnt);
-		panic("ffs_alloc: bad size");
+		panic("%s: bad size: dev = 0x%llx, bsize = %d, size = %d, "
+		"fs = %s", __func__, (unsigned long long)ip->i_dev,
+		fs->fs_bsize, size, fs->fs_fsmnt);
 	}
-	if (cred == NOCRED)
-		panic("ffs_alloc: missing credential");
 #endif /* DIAGNOSTIC */
 	if (size == fs->fs_bsize && fs->fs_cstotal.cs_nbfree == 0)
 		goto nospace;
@@ -348,16 +346,15 @@ ffs_realloccg(struct inode *ip, daddr_t 
 #endif
 
 #ifdef DIAGNOSTIC
+	if (cred == NOCRED)
+		panic("%s: missing credential", __func__);
 	if ((u_int)osize > fs->fs_bsize || ffs_fragoff(fs, osize) != 0 ||
 	(u_int)nsize > fs->fs_bsize || ffs_fragoff(fs, nsize) != 0) {
-		printf(
-		"dev = 0x%llx, bsize = %d, osize = %d, nsize = %d, fs = %s\n",
+		panic("%s: bad size: dev = 0x%llx, bsize = %d, osize = %d, "
+		"nsize = %d, fs = %s", __func__,
 		(unsigned long long)ip->i_dev, fs->fs_bsize, osize, nsize,
 		fs->fs_fsmnt);
-		panic("ffs_realloccg: bad size");
 	}
-	if (cred == NOCRED)
-		panic("ffs_realloccg: missing credential");
 #endif /* DIAGNOSTIC */
 	if (freespace(fs, fs->fs_minfree) <= 0 &&
 	kauth_authorize_system(cred, KAUTH_SYSTEM_FS_RESERVEDSPACE, 0, NULL,
@@ -371,10 +368,10 @@ ffs_realloccg(struct inode *ip, daddr_t 
 		bprev = ufs_rw32(ip->i_ffs1_db[lbprev], UFS_FSNEEDSWAP(fs));
 
 	if (bprev == 0) {
-		printf("dev = 0x%llx, bsize = %d, bprev = %" PRId64 ", fs = %s\n",
+		panic("%s: bad bprev: dev = 0x%llx, bsize = %d, bprev = %"
+		PRId64 ", fs = %s", __func__,
 		(unsigned long long)ip->i_dev, fs->fs_bsize, bprev,
 		fs->fs_fsmnt);
-		panic("ffs_realloccg: bad bprev");
 	}
 	mutex_exit(>um_lock);
 
@@ -403,8 +400,11 @@ ffs_realloccg(struct inode *ip, daddr_t 
 		ip->i_flag |= IN_CHANGE | IN_UPDATE;
 
 		if (bpp != NULL) {
-			if (bp->b_blkno != FFS_FSBTODB(fs, bno))
-panic("bad blockno");
+			if (bp->b_blkno != FFS_FSBTODB(fs, bno)) {
+panic("%s: bad blockno %#llx != %#llx",
+__func__, (unsigned long long) bp->b_blkno,
+(unsigned long long)FFS_FSBTODB(fs, bno));
+			}
 			allocbuf(bp, nsize, 1);
 			memset((char *)bp->b_data + osize, 0, nsize - osize);
 			mutex_enter(bp->b_objlock);
@@ -471,9 +471,9 @@ ffs_realloccg(struct inode *ip, daddr_t 
 		fs->fs_optim = FS_OPTSPACE;
 		break;
 	default:
-		printf("dev = 0x%llx, optim = %d, fs = %s\n",
-		(unsigned long long)ip->i_dev, fs->fs_optim, fs->fs_fsmnt);
-		panic("ffs_realloccg: bad optim");
+		panic("%s: bad optim: dev = 0x%llx, optim = %d, fs = %s",
+		__func__, (unsigned long long)ip->i_dev, fs->fs_optim,
+		fs->fs_fsmnt);
 		/* NOTREACHED */
 	}
 	bno = ffs_hashalloc(ip, cg, bpref, request, nsize, 0, ffs_alloccg);
@@ -1324,18 +1324,16 @@ retry:
 		start = 0;
 		loc = skpc(0xff, len, [0]);

CVS commit: src/sys/ufs/ffs

2016-10-21 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Fri Oct 21 19:28:03 UTC 2016

Modified Files:
src/sys/ufs/ffs: ffs_snapshot.c

Log Message:
revert 1.141 - the second ffs_truncate() can't really fail

requested by hannken@


To generate a diff of this commit:
cvs rdiff -u -r1.141 -r1.142 src/sys/ufs/ffs/ffs_snapshot.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/ufs/ffs/ffs_snapshot.c
diff -u src/sys/ufs/ffs/ffs_snapshot.c:1.141 src/sys/ufs/ffs/ffs_snapshot.c:1.142
--- src/sys/ufs/ffs/ffs_snapshot.c:1.141	Thu Oct 20 20:17:46 2016
+++ src/sys/ufs/ffs/ffs_snapshot.c	Fri Oct 21 19:28:03 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_snapshot.c,v 1.141 2016/10/20 20:17:46 jdolecek Exp $	*/
+/*	$NetBSD: ffs_snapshot.c,v 1.142 2016/10/21 19:28:03 jdolecek Exp $	*/
 
 /*
  * Copyright 2000 Marshall Kirk McKusick. All Rights Reserved.
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_snapshot.c,v 1.141 2016/10/20 20:17:46 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_snapshot.c,v 1.142 2016/10/21 19:28:03 jdolecek Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -402,10 +402,6 @@ out:
 	}
 	if (error) {
 		if (UFS_WAPBL_BEGIN(mp) == 0) {
-			/*
-			 * This is okay to fail, we'll simply reuse the blocks
-			 * later.
-			 */
 			(void) ffs_truncate(vp, (off_t)0, 0, NOCRED);
 			UFS_WAPBL_END(mp);
 		}
@@ -441,13 +437,9 @@ snapshot_setup(struct mount *mp, struct 
 		return EACCES;
 
 	if (vp->v_size != 0) {
-		if (UFS_WAPBL_BEGIN(mp) == 0) {
-			/*
-			 * This is okay to fail, we'll simply reuse the blocks
-			 */
-			(void) ffs_truncate(vp, 0, 0, NOCRED);
-			UFS_WAPBL_END(mp);
-		}
+		error = ffs_truncate(vp, 0, 0, NOCRED);
+		if (error)
+			return error;
 	}
 
 	/* Change inode to snapshot type file. */
@@ -456,7 +448,6 @@ snapshot_setup(struct mount *mp, struct 
 		return error;
 #if defined(QUOTA) || defined(QUOTA2)
 	/* shapshot inodes are not accounted in quotas */
-	chkdq(ip, -DIP(ip, blocks), l->l_cred, 0);
 	chkiq(ip, -1, l->l_cred, 0);
 #endif
 	ip->i_flags |= (SF_SNAPSHOT | SF_SNAPINVAL);



CVS commit: src/sys/ufs/ffs

2016-10-20 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Thu Oct 20 20:17:46 UTC 2016

Modified Files:
src/sys/ufs/ffs: ffs_snapshot.c

Log Message:
allow also the snapshot_setup()'s call to ffs_truncate() fail, the code
should simply reuse the file blocks in that case; also make sure the
ffs_truncate() call is run within transaction if log is on


To generate a diff of this commit:
cvs rdiff -u -r1.140 -r1.141 src/sys/ufs/ffs/ffs_snapshot.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/ufs/ffs/ffs_snapshot.c
diff -u src/sys/ufs/ffs/ffs_snapshot.c:1.140 src/sys/ufs/ffs/ffs_snapshot.c:1.141
--- src/sys/ufs/ffs/ffs_snapshot.c:1.140	Sun Jun 28 10:04:32 2015
+++ src/sys/ufs/ffs/ffs_snapshot.c	Thu Oct 20 20:17:46 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_snapshot.c,v 1.140 2015/06/28 10:04:32 maxv Exp $	*/
+/*	$NetBSD: ffs_snapshot.c,v 1.141 2016/10/20 20:17:46 jdolecek Exp $	*/
 
 /*
  * Copyright 2000 Marshall Kirk McKusick. All Rights Reserved.
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_snapshot.c,v 1.140 2015/06/28 10:04:32 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_snapshot.c,v 1.141 2016/10/20 20:17:46 jdolecek Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -402,6 +402,10 @@ out:
 	}
 	if (error) {
 		if (UFS_WAPBL_BEGIN(mp) == 0) {
+			/*
+			 * This is okay to fail, we'll simply reuse the blocks
+			 * later.
+			 */
 			(void) ffs_truncate(vp, (off_t)0, 0, NOCRED);
 			UFS_WAPBL_END(mp);
 		}
@@ -437,9 +441,13 @@ snapshot_setup(struct mount *mp, struct 
 		return EACCES;
 
 	if (vp->v_size != 0) {
-		error = ffs_truncate(vp, 0, 0, NOCRED);
-		if (error)
-			return error;
+		if (UFS_WAPBL_BEGIN(mp) == 0) {
+			/*
+			 * This is okay to fail, we'll simply reuse the blocks
+			 */
+			(void) ffs_truncate(vp, 0, 0, NOCRED);
+			UFS_WAPBL_END(mp);
+		}
 	}
 
 	/* Change inode to snapshot type file. */
@@ -448,6 +456,7 @@ snapshot_setup(struct mount *mp, struct 
 		return error;
 #if defined(QUOTA) || defined(QUOTA2)
 	/* shapshot inodes are not accounted in quotas */
+	chkdq(ip, -DIP(ip, blocks), l->l_cred, 0);
 	chkiq(ip, -1, l->l_cred, 0);
 #endif
 	ip->i_flags |= (SF_SNAPSHOT | SF_SNAPINVAL);



CVS commit: src/sys/ufs/ffs

2016-10-20 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Thu Oct 20 19:31:32 UTC 2016

Modified Files:
src/sys/ufs/ffs: ffs_vfsops.c

Log Message:
add assertion to ensure ffs_cgupdate() is always called from
within a WAPBL transaction (if logging is on)


To generate a diff of this commit:
cvs rdiff -u -r1.340 -r1.341 src/sys/ufs/ffs/ffs_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/ufs/ffs/ffs_vfsops.c
diff -u src/sys/ufs/ffs/ffs_vfsops.c:1.340 src/sys/ufs/ffs/ffs_vfsops.c:1.341
--- src/sys/ufs/ffs/ffs_vfsops.c:1.340	Thu Jul 28 08:24:58 2016
+++ src/sys/ufs/ffs/ffs_vfsops.c	Thu Oct 20 19:31:32 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_vfsops.c,v 1.340 2016/07/28 08:24:58 martin Exp $	*/
+/*	$NetBSD: ffs_vfsops.c,v 1.341 2016/10/20 19:31:32 jdolecek Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.340 2016/07/28 08:24:58 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.341 2016/10/20 19:31:32 jdolecek Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -2351,6 +2351,8 @@ ffs_cgupdate(struct ufsmount *mp, int wa
 	void *space;
 	int i, size, error = 0, allerror = 0;
 
+	UFS_WAPBL_JLOCK_ASSERT(mp);
+
 	allerror = ffs_sbupdate(mp, waitfor);
 	blks = howmany(fs->fs_cssize, fs->fs_fsize);
 	space = fs->fs_csp;



CVS commit: src/sys/ufs/lfs

2016-10-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Oct  4 16:46:20 UTC 2016

Modified Files:
src/sys/ufs/lfs: lfs_pages.c

Log Message:
Grr, the optimizer on mips64 can't handle this... Use MIN_PAGE_SIZE.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/ufs/lfs/lfs_pages.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/ufs/lfs/lfs_pages.c
diff -u src/sys/ufs/lfs/lfs_pages.c:1.8 src/sys/ufs/lfs/lfs_pages.c:1.9
--- src/sys/ufs/lfs/lfs_pages.c:1.8	Thu Jul 21 14:10:47 2016
+++ src/sys/ufs/lfs/lfs_pages.c	Tue Oct  4 12:46:20 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_pages.c,v 1.8 2016/07/21 18:10:47 christos Exp $	*/
+/*	$NetBSD: lfs_pages.c,v 1.9 2016/10/04 16:46:20 christos Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_pages.c,v 1.8 2016/07/21 18:10:47 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_pages.c,v 1.9 2016/10/04 16:46:20 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -244,8 +244,7 @@ check_dirty(struct lfs *fs, struct vnode
 {
 	int by_list;
 	struct vm_page *curpg = NULL; /* XXX: gcc */
-	struct vm_page *pgs[MAXBSIZE /
-	(__builtin_constant_p(PAGE_SIZE) ? PAGE_SIZE : 1024)], *pg;
+	struct vm_page *pgs[MAXBSIZE / MIN_PAGE_SIZE], *pg;
 	off_t soff = 0; /* XXX: gcc */
 	voff_t off;
 	int i;



CVS commit: src/sys/ufs/ffs

2016-10-02 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Oct  2 19:02:57 UTC 2016

Modified Files:
src/sys/ufs/ffs: ffs_wapbl.c

Log Message:
use __func__ and print the filesystem we are printing the message for.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/ufs/ffs/ffs_wapbl.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/ufs/ffs/ffs_wapbl.c
diff -u src/sys/ufs/ffs/ffs_wapbl.c:1.34 src/sys/ufs/ffs/ffs_wapbl.c:1.35
--- src/sys/ufs/ffs/ffs_wapbl.c:1.34	Sat Oct  1 09:15:45 2016
+++ src/sys/ufs/ffs/ffs_wapbl.c	Sun Oct  2 15:02:57 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_wapbl.c,v 1.34 2016/10/01 13:15:45 jdolecek Exp $	*/
+/*	$NetBSD: ffs_wapbl.c,v 1.35 2016/10/02 19:02:57 christos Exp $	*/
 
 /*-
  * Copyright (c) 2003,2006,2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_wapbl.c,v 1.34 2016/10/01 13:15:45 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_wapbl.c,v 1.35 2016/10/02 19:02:57 christos Exp $");
 
 #define WAPBL_INTERNAL
 
@@ -126,16 +126,17 @@ ffs_wapbl_replay_finish(struct mount *mp
 		struct inode *ip;
 		error = VFS_VGET(mp, wr->wr_inodes[i].wr_inumber, );
 		if (error) {
-			printf("ffs_wapbl_replay_finish: "
-			"unable to cleanup inode %" PRIu32 "\n",
+			printf("%s: %s: unable to cleanup inode %" PRIu32 "\n",
+			__func__, VFSTOUFS(mp)->um_fs->fs_fsmnt,
 			wr->wr_inodes[i].wr_inumber);
 			continue;
 		}
 		ip = VTOI(vp);
 		KDASSERT(wr->wr_inodes[i].wr_inumber == ip->i_number);
 #ifdef WAPBL_DEBUG
-		printf("ffs_wapbl_replay_finish: "
-		"cleaning inode %" PRIu64 " size=%" PRIu64 " mode=%o nlink=%d\n",
+		printf("%s%s: %s: cleaning inode %" PRIu64 " size=%" PRIu64
+		" mode=%o nlink=%d\n",
+		__func__, VFSTOUFS(mp)->um_fs->fs_fsmnt,
 		ip->i_number, ip->i_size, ip->i_mode, ip->i_nlink);
 #endif
 		KASSERT(ip->i_nlink == 0);
@@ -149,8 +150,9 @@ ffs_wapbl_replay_finish(struct mount *mp
 		if (ip->i_mode == 0) {
 			error = UFS_WAPBL_BEGIN(mp);
 			if (error) {
-printf("ffs_wapbl_replay_finish: "
+printf("%s: %s: "
 "unable to cleanup inode %" PRIu32 "\n",
+__func__, VFSTOUFS(mp)->um_fs->fs_fsmnt,
 wr->wr_inodes[i].wr_inumber);
 			} else {
 ffs_vfree(vp, ip->i_number,
@@ -177,7 +179,7 @@ ffs_wapbl_sync_metadata(struct mount *mp
 	UFS_WAPBL_JLOCK_ASSERT(mp);
 
 #ifdef WAPBL_DEBUG_INODES
-	ufs_wapbl_verify_inodes(mp, "ffs_wapbl_sync_metadata");
+	ufs_wapbl_verify_inodes(mp, __func__);
 #endif
 
 	for (wd = fdealloc; wd != NULL; wd = SIMPLEQ_NEXT(wd, wd_entries)) {
@@ -254,16 +256,16 @@ wapbl_remove_log(struct mount *mp)
 			goto done;
 		error = VFS_VGET(mp, log_ino, );
 		if (error != 0) {
-			printf("ffs_wapbl: vget failed %d\n",
-			error);
+			printf("%s: %s: vget failed %d\n", __func__,
+			fs->fs_fsmnt, error);
 			/* clear out log info on error */
 			goto done;
 		}
 		ip = VTOI(vp);
 		KASSERT(log_ino == ip->i_number);
 		if ((ip->i_flags & SF_LOG) == 0) {
-			printf("ffs_wapbl: try to clear non-log inode "
-			"%" PRId64 "\n", log_ino);
+			printf("%s: %s: try to clear non-log inode "
+			"%" PRId64 "\n", __func__, fs->fs_fsmnt, log_ino);
 			vput(vp);
 			/* clear out log info on error */
 			goto done;
@@ -284,8 +286,8 @@ wapbl_remove_log(struct mount *mp)
 		break;
 
 	default:
-		printf("ffs_wapbl: unknown journal type %d\n",
-		fs->fs_journal_location);
+		printf("%s: %s: unknown journal type %d\n", __func__,
+		fs->fs_fsmnt, fs->fs_journal_location);
 		break;
 	}
 
@@ -329,8 +331,8 @@ ffs_wapbl_start(struct mount *mp)
 
 			/* WAPBL needs UFS2 format super block */
 			if (ffs_superblock_layout(fs) < 2) {
-printf("%s fs superblock in old format, "
-   "not journaling\n",
+printf("%s: %s: fs superblock in old format, "
+   "not journaling\n", __func__,
    VFSTOUFS(mp)->um_fs->fs_fsmnt);
 mp->mnt_flag &= ~MNT_LOG;
 return EINVAL;
@@ -351,7 +353,8 @@ ffs_wapbl_start(struct mount *mp)
 			mp->mnt_wapbl_op = _ops;
 
 #ifdef WAPBL_DEBUG
-			printf("%s: enabling logging\n", fs->fs_fsmnt);
+			printf("%s: %s: enabling logging\n", __func__,
+			fs->fs_fsmnt);
 #endif
 
 			if ((fs->fs_flags & FS_DOWAPBL) == 0) {
@@ -440,7 +443,7 @@ ffs_wapbl_stop(struct mount *mp, int for
 		mp->mnt_wapbl = NULL;
 
 #ifdef WAPBL_DEBUG
-		printf("%s: disabled logging\n", fs->fs_fsmnt);
+		printf("%s: %s: disabled logging\n", __func__, fs->fs_fsmnt);
 #endif
 	}
 
@@ -533,8 +536,8 @@ wapbl_log_position(struct mount *mp, str
 			return 0;
 
 		default:
-			printf("ffs_wapbl: unknown journal type %d\n",
-			fs->fs_journal_location);
+			printf("%s: %s: unknown journal type %d\n", __func__,
+			fs->fs_fsmnt, fs->fs_journal_location);
 			return EINVAL;
 		}
 	}
@@ -687,14 +690,14 @@ wapbl_allocate_log_file(struct mount *mp
 		logsize = fs->fs_journallocs[UFS_WAPBL_INFS_COUNT];
 
 	if 

CVS commit: src/sys/ufs/ffs

2016-10-01 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sat Oct  1 13:06:20 UTC 2016

Modified Files:
src/sys/ufs/ffs: ffs_wapbl.c

Log Message:
wapbl_remove_log(): add missing break; harmless, fallthrough just printed
extra debug message


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/ufs/ffs/ffs_wapbl.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/ufs/ffs/ffs_wapbl.c
diff -u src/sys/ufs/ffs/ffs_wapbl.c:1.32 src/sys/ufs/ffs/ffs_wapbl.c:1.33
--- src/sys/ufs/ffs/ffs_wapbl.c:1.32	Sat Sep 24 21:00:54 2016
+++ src/sys/ufs/ffs/ffs_wapbl.c	Sat Oct  1 13:06:20 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_wapbl.c,v 1.32 2016/09/24 21:00:54 jdolecek Exp $	*/
+/*	$NetBSD: ffs_wapbl.c,v 1.33 2016/10/01 13:06:20 jdolecek Exp $	*/
 
 /*-
  * Copyright (c) 2003,2006,2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_wapbl.c,v 1.32 2016/09/24 21:00:54 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_wapbl.c,v 1.33 2016/10/01 13:06:20 jdolecek Exp $");
 
 #define WAPBL_INTERNAL
 
@@ -277,6 +277,7 @@ wapbl_remove_log(struct mount *mp)
 		ip->i_nlink = 0;
 		DIP_ASSIGN(ip, nlink, 0);
 		vput(vp);
+		break;
 
 	case UFS_WAPBL_JOURNALLOC_END_PARTITION:
 		DPRINTF("end-of-partition log\n");



CVS commit: src/sys/ufs/ffs

2016-09-25 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sun Sep 25 17:14:59 UTC 2016

Modified Files:
src/sys/ufs/ffs: ffs_alloc.c

Log Message:
adjust ffs_realloccg() so that the logic about allocating full
contiguous block for future fragment expansion doesn't need to
UFS_WAPBL_REGISTER_DEALLOCATION() or ffs_blkfree(); the free blocks
are now immediatelly available for use by the expanding file in further i/o

primary driver is safe removal of the deallocation registration and
hence failure point, but this also fixes degenerate case for wapbl,
and similar also for discard - if the file would be actually expanded
before wapbl commit, or before discard queue would be processed,
the filesystem would not yet see the contiguous free blocks, and
would be forced to allocate another fragment elsewhere


To generate a diff of this commit:
cvs rdiff -u -r1.151 -r1.152 src/sys/ufs/ffs/ffs_alloc.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/ufs/ffs/ffs_alloc.c
diff -u src/sys/ufs/ffs/ffs_alloc.c:1.151 src/sys/ufs/ffs/ffs_alloc.c:1.152
--- src/sys/ufs/ffs/ffs_alloc.c:1.151	Wed Aug 12 14:52:35 2015
+++ src/sys/ufs/ffs/ffs_alloc.c	Sun Sep 25 17:14:59 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_alloc.c,v 1.151 2015/08/12 14:52:35 riastradh Exp $	*/
+/*	$NetBSD: ffs_alloc.c,v 1.152 2016/09/25 17:14:59 jdolecek Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.151 2015/08/12 14:52:35 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.152 2016/09/25 17:14:59 jdolecek Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -107,14 +107,14 @@ __KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,
 #include 
 #endif
 
-static daddr_t ffs_alloccg(struct inode *, int, daddr_t, int, int);
-static daddr_t ffs_alloccgblk(struct inode *, struct buf *, daddr_t, int);
+static daddr_t ffs_alloccg(struct inode *, int, daddr_t, int, int, int);
+static daddr_t ffs_alloccgblk(struct inode *, struct buf *, daddr_t, int, int);
 static ino_t ffs_dirpref(struct inode *);
 static daddr_t ffs_fragextend(struct inode *, int, daddr_t, int, int);
 static void ffs_fserr(struct fs *, kauth_cred_t, const char *);
-static daddr_t ffs_hashalloc(struct inode *, int, daddr_t, int, int,
-daddr_t (*)(struct inode *, int, daddr_t, int, int));
-static daddr_t ffs_nodealloccg(struct inode *, int, daddr_t, int, int);
+static daddr_t ffs_hashalloc(struct inode *, int, daddr_t, int, int, int,
+daddr_t (*)(struct inode *, int, daddr_t, int, int, int));
+static daddr_t ffs_nodealloccg(struct inode *, int, daddr_t, int, int, int);
 static int32_t ffs_mapsearch(struct fs *, struct cg *,
   daddr_t, int);
 static void ffs_blkfree_common(struct ufsmount *, struct fs *, dev_t, struct buf *,
@@ -174,8 +174,8 @@ ffs_check_bad_allocation(const char *fun
  * => releases um_lock before returning
  */
 int
-ffs_alloc(struct inode *ip, daddr_t lbn, daddr_t bpref, int size, int flags,
-kauth_cred_t cred, daddr_t *bnp)
+ffs_alloc(struct inode *ip, daddr_t lbn, daddr_t bpref, int size,
+int flags, kauth_cred_t cred, daddr_t *bnp)
 {
 	struct ufsmount *ump;
 	struct fs *fs;
@@ -257,7 +257,7 @@ ffs_alloc(struct inode *ip, daddr_t lbn,
 		cg = ino_to_cg(fs, ip->i_number);
 	else
 		cg = dtog(fs, bpref);
-	bno = ffs_hashalloc(ip, cg, bpref, size, flags, ffs_alloccg);
+	bno = ffs_hashalloc(ip, cg, bpref, size, 0, flags, ffs_alloccg);
 	if (bno > 0) {
 		DIP_ADD(ip, blocks, btodb(size));
 		ip->i_flag |= IN_CHANGE | IN_UPDATE;
@@ -476,7 +476,7 @@ ffs_realloccg(struct inode *ip, daddr_t 
 		panic("ffs_realloccg: bad optim");
 		/* NOTREACHED */
 	}
-	bno = ffs_hashalloc(ip, cg, bpref, request, 0, ffs_alloccg);
+	bno = ffs_hashalloc(ip, cg, bpref, request, nsize, 0, ffs_alloccg);
 	if (bno > 0) {
 		if ((ip->i_ump->um_mountp->mnt_wapbl) &&
 		(ITOV(ip)->v_type != VREG)) {
@@ -487,18 +487,6 @@ ffs_realloccg(struct inode *ip, daddr_t 
 			ffs_blkfree(fs, ip->i_devvp, bprev, (long)osize,
 			ip->i_number);
 		}
-		if (nsize < request) {
-			if ((ip->i_ump->um_mountp->mnt_wapbl) &&
-			(ITOV(ip)->v_type != VREG)) {
-UFS_WAPBL_REGISTER_DEALLOCATION(
-ip->i_ump->um_mountp,
-FFS_FSBTODB(fs, (bno + ffs_numfrags(fs, nsize))),
-request - nsize);
-			} else
-ffs_blkfree(fs, ip->i_devvp,
-bno + ffs_numfrags(fs, nsize),
-(long)(request - nsize), ip->i_number);
-		}
 		DIP_ADD(ip, blocks, btodb(nsize - osize));
 		ip->i_flag |= IN_CHANGE | IN_UPDATE;
 		if (bpp != NULL) {
@@ -595,7 +583,7 @@ ffs_valloc(struct vnode *pvp, int mode, 
 		if (fs->fs_contigdirs[cg] > 0)
 			fs->fs_contigdirs[cg]--;
 	}
-	ino = (ino_t)ffs_hashalloc(pip, cg, ipref, mode, 0, ffs_nodealloccg);
+	ino = (ino_t)ffs_hashalloc(pip, cg, ipref, mode, 0, 0, ffs_nodealloccg);
 	if (ino == 0)
 		goto noinodes;
 	

CVS commit: src/sys/ufs/ffs

2016-09-25 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sun Sep 25 11:45:39 UTC 2016

Modified Files:
src/sys/ufs/ffs: ffs_balloc.c

Log Message:
fix typo in #ifdef notyet part


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sys/ufs/ffs/ffs_balloc.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/ufs/ffs/ffs_balloc.c
diff -u src/sys/ufs/ffs/ffs_balloc.c:1.61 src/sys/ufs/ffs/ffs_balloc.c:1.62
--- src/sys/ufs/ffs/ffs_balloc.c:1.61	Sat Mar 28 19:24:04 2015
+++ src/sys/ufs/ffs/ffs_balloc.c	Sun Sep 25 11:45:39 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_balloc.c,v 1.61 2015/03/28 19:24:04 maxv Exp $	*/
+/*	$NetBSD: ffs_balloc.c,v 1.62 2016/09/25 11:45:39 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 2002 Networks Associates Technology, Inc.
@@ -41,7 +41,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_balloc.c,v 1.61 2015/03/28 19:24:04 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_balloc.c,v 1.62 2016/09/25 11:45:39 jdolecek Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_quota.h"
@@ -636,7 +636,7 @@ ffs_balloc_ufs2(struct vnode *vp, off_t 
 			if (error)
 return (error);
 			error = ffs_getblk(vp, -1 - lbn, FFS_FSBTODB(fs, newb),
-			nsize, (flags & BA_CLRBUF) != 0, );
+			nsize, (flags & B_CLRBUF) != 0, );
 			if (error)
 return error;
 			bp->b_xflags |= BX_ALTDATA;



CVS commit: src/sys/ufs/ffs

2016-09-24 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sat Sep 24 21:00:54 UTC 2016

Modified Files:
src/sys/ufs/ffs: ffs_wapbl.c

Log Message:
fix swapped KASSERT()


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/ufs/ffs/ffs_wapbl.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/ufs/ffs/ffs_wapbl.c
diff -u src/sys/ufs/ffs/ffs_wapbl.c:1.31 src/sys/ufs/ffs/ffs_wapbl.c:1.32
--- src/sys/ufs/ffs/ffs_wapbl.c:1.31	Sat Sep 24 20:59:51 2016
+++ src/sys/ufs/ffs/ffs_wapbl.c	Sat Sep 24 21:00:54 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_wapbl.c,v 1.31 2016/09/24 20:59:51 jdolecek Exp $	*/
+/*	$NetBSD: ffs_wapbl.c,v 1.32 2016/09/24 21:00:54 jdolecek Exp $	*/
 
 /*-
  * Copyright (c) 2003,2006,2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_wapbl.c,v 1.31 2016/09/24 20:59:51 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_wapbl.c,v 1.32 2016/09/24 21:00:54 jdolecek Exp $");
 
 #define WAPBL_INTERNAL
 
@@ -193,7 +193,7 @@ ffs_wapbl_sync_metadata(struct mount *mp
 		fs->fs_fmod = 0;
 		fs->fs_time = time_second;
 		error = ffs_cgupdate(ump, 0);
-		KASSERT(error != 0);
+		KASSERT(error == 0);
 	}
 }
 



CVS commit: src/sys/ufs/ffs

2016-09-24 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sat Sep 24 20:59:51 UTC 2016

Modified Files:
src/sys/ufs/ffs: ffs_wapbl.c

Log Message:
i/o optimization for wapbl flush - only sync superblock and cgs when
they were actually changed


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/ufs/ffs/ffs_wapbl.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/ufs/ffs/ffs_wapbl.c
diff -u src/sys/ufs/ffs/ffs_wapbl.c:1.30 src/sys/ufs/ffs/ffs_wapbl.c:1.31
--- src/sys/ufs/ffs/ffs_wapbl.c:1.30	Sat Mar 28 19:24:04 2015
+++ src/sys/ufs/ffs/ffs_wapbl.c	Sat Sep 24 20:59:51 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_wapbl.c,v 1.30 2015/03/28 19:24:04 maxv Exp $	*/
+/*	$NetBSD: ffs_wapbl.c,v 1.31 2016/09/24 20:59:51 jdolecek Exp $	*/
 
 /*-
  * Copyright (c) 2003,2006,2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_wapbl.c,v 1.30 2015/03/28 19:24:04 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_wapbl.c,v 1.31 2016/09/24 20:59:51 jdolecek Exp $");
 
 #define WAPBL_INTERNAL
 
@@ -174,6 +174,8 @@ ffs_wapbl_sync_metadata(struct mount *mp
 	struct fs *fs = ump->um_fs;
 	int i, error __diagused;
 
+	UFS_WAPBL_JLOCK_ASSERT(mp);
+
 #ifdef WAPBL_DEBUG_INODES
 	ufs_wapbl_verify_inodes(mp, "ffs_wapbl_sync_metadata");
 #endif
@@ -187,10 +189,12 @@ ffs_wapbl_sync_metadata(struct mount *mp
 		FFS_DBTOFSB(fs, deallocblks[i]), dealloclens[i], -1);
 	}
 
-	fs->fs_fmod = 0;
-	fs->fs_time = time_second;
-	error = ffs_cgupdate(ump, 0);
-	KASSERT(error == 0);
+	if (fs->fs_fmod != 0) {
+		fs->fs_fmod = 0;
+		fs->fs_time = time_second;
+		error = ffs_cgupdate(ump, 0);
+		KASSERT(error != 0);
+	}
 }
 
 void



CVS commit: src/sys/ufs/ext2fs

2016-08-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Aug 25 07:18:35 UTC 2016

Modified Files:
src/sys/ufs/ext2fs: ext2fs_vfsops.c

Log Message:
put back second strlcpy; pointed out by dholland.


To generate a diff of this commit:
cvs rdiff -u -r1.203 -r1.204 src/sys/ufs/ext2fs/ext2fs_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/ufs/ext2fs/ext2fs_vfsops.c
diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.203 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.204
--- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.203	Tue Aug 23 02:24:30 2016
+++ src/sys/ufs/ext2fs/ext2fs_vfsops.c	Thu Aug 25 03:18:35 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_vfsops.c,v 1.203 2016/08/23 06:24:30 christos Exp $	*/
+/*	$NetBSD: ext2fs_vfsops.c,v 1.204 2016/08/25 07:18:35 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1994
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.203 2016/08/23 06:24:30 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.204 2016/08/25 07:18:35 christos Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -245,6 +245,9 @@ ext2fs_sb_setmountinfo(struct m_ext2fs *
 	(void)strlcpy(fs->e2fs_fsmnt, mp->mnt_stat.f_mntonname,
 sizeof(fs->e2fs_fsmnt));
 	if (fs->e2fs_ronly == 0 && fs->e2fs.e2fs_rev > E2FS_REV0) {
+		(void)strlcpy(fs->e2fs.e2fs_fsmnt, mp->mnt_stat.f_mntonname,
+		sizeof(fs->e2fs.e2fs_fsmnt));
+
 		fs->e2fs.e2fs_mtime = time_second;
 		fs->e2fs.e2fs_mnt_count++;
 



CVS commit: src/sys/ufs/ext2fs

2016-08-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Aug 23 06:40:54 UTC 2016

Modified Files:
src/sys/ufs/ext2fs: ext2fs_xattr.c

Log Message:
CID 1371648: off by one in index checking
KNF.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/ufs/ext2fs/ext2fs_xattr.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/ufs/ext2fs/ext2fs_xattr.c
diff -u src/sys/ufs/ext2fs/ext2fs_xattr.c:1.3 src/sys/ufs/ext2fs/ext2fs_xattr.c:1.4
--- src/sys/ufs/ext2fs/ext2fs_xattr.c:1.3	Sun Aug 14 07:40:31 2016
+++ src/sys/ufs/ext2fs/ext2fs_xattr.c	Tue Aug 23 02:40:54 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_xattr.c,v 1.3 2016/08/14 11:40:31 jdolecek Exp $	*/
+/*	$NetBSD: ext2fs_xattr.c,v 1.4 2016/08/23 06:40:54 christos Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_xattr.c,v 1.3 2016/08/14 11:40:31 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_xattr.c,v 1.4 2016/08/23 06:40:54 christos Exp $");
 
 #include 
 #include 
@@ -68,7 +68,9 @@ static const char * const xattr_prefix_i
 };
 
 static int
-ext2fs_find_xattr(struct ext2fs_xattr_entry *e, uint8_t *start, uint8_t *end, int attrnamespace, struct uio *uio, size_t *size, uint8_t name_index, const char *name)
+ext2fs_find_xattr(struct ext2fs_xattr_entry *e, uint8_t *start, uint8_t *end,
+int attrnamespace, struct uio *uio, size_t *size, uint8_t name_index,
+const char *name)
 {
 	uint8_t *value;
 	int error;
@@ -83,8 +85,10 @@ ext2fs_find_xattr(struct ext2fs_xattr_en
 		 * Only EXT2FS_XATTR_PREFIX_USER is USER, anything else
 		 * is considered SYSTEM.
 		 */
-		if ((attrnamespace == EXTATTR_NAMESPACE_USER && e->e_name_index != EXT2FS_XATTR_PREFIX_USER) ||
-		(attrnamespace == EXTATTR_NAMESPACE_SYSTEM && e->e_name_index == EXT2FS_XATTR_PREFIX_USER)) {
+		if ((attrnamespace == EXTATTR_NAMESPACE_USER
+		&& e->e_name_index != EXT2FS_XATTR_PREFIX_USER) ||
+		(attrnamespace == EXTATTR_NAMESPACE_SYSTEM
+		&& e->e_name_index == EXT2FS_XATTR_PREFIX_USER)) {
 			continue;
 		}
 
@@ -94,8 +98,8 @@ ext2fs_find_xattr(struct ext2fs_xattr_en
 			continue;
 
 		value_offs = fs2h32(e->e_value_offs);
-		value_len  = fs2h32(e->e_value_size);
-		value  = [value_offs];
+		value_len = fs2h32(e->e_value_size);
+		value = [value_offs];
 
 		/* make sure the value offset are sane */
 		if ([value_len] > end)
@@ -103,8 +107,8 @@ ext2fs_find_xattr(struct ext2fs_xattr_en
 
 		if (uio != NULL) {
 			/*
-			 * Figure out maximum to transfer -- use buffer size and
-			 * local data limit.
+			 * Figure out maximum to transfer -- use buffer size
+			 * and local data limit.
 			 */
 			len = MIN(uio->uio_resid, value_len);
 			old_len = uio->uio_resid;
@@ -131,24 +135,27 @@ ext2fs_find_xattr(struct ext2fs_xattr_en
 }
 
 static int
-ext2fs_get_inode_xattr(struct inode *ip, int attrnamespace, struct uio *uio, size_t *size, uint8_t name_index, const char *name)
+ext2fs_get_inode_xattr(struct inode *ip, int attrnamespace, struct uio *uio,
+size_t *size, uint8_t name_index, const char *name)
 {
 	struct ext2fs_dinode *di = ip->i_din.e2fs_din;
 	struct ext2fs_xattr_ibody_header *h;
 	uint8_t *start, *end;
 
 	start = &((uint8_t *)di)[EXT2_REV0_DINODE_SIZE + di->e2di_extra_isize];
-	h = (struct ext2fs_xattr_ibody_header *)start;
-	end   = &((uint8_t *)di)[EXT2_DINODE_SIZE(ip->i_e2fs)];
+	h = (struct ext2fs_xattr_ibody_header *)start;
+	end = &((uint8_t *)di)[EXT2_DINODE_SIZE(ip->i_e2fs)];
 
 	if (end <= start || fs2h32(h->h_magic) != EXT2FS_XATTR_MAGIC)
 		return ENODATA;
 
-	return ext2fs_find_xattr(EXT2FS_XATTR_IFIRST(h), start, end, attrnamespace, uio, size, name_index, name);
+	return ext2fs_find_xattr(EXT2FS_XATTR_IFIRST(h), start, end,
+	attrnamespace, uio, size, name_index, name);
 }
 
 static int
-ext2fs_get_block_xattr(struct inode *ip, int attrnamespace, struct uio *uio, size_t *size, uint8_t name_index, const char *name)
+ext2fs_get_block_xattr(struct inode *ip, int attrnamespace, struct uio *uio,
+size_t *size, uint8_t name_index, const char *name)
 {
 	struct ext2fs_dinode *di = ip->i_din.e2fs_din;
 	uint8_t *start, *end;
@@ -165,7 +172,8 @@ ext2fs_get_block_xattr(struct inode *ip,
 	if (xblk == 0)
 		return 0;
 
-	error = bread(ip->i_devvp, fsbtodb(ip->i_e2fs, xblk), (int)ip->i_e2fs->e2fs_bsize, 0, );
+	error = bread(ip->i_devvp, fsbtodb(ip->i_e2fs, xblk),
+	(int)ip->i_e2fs->e2fs_bsize, 0, );
 	if (error)
 		goto out;
 
@@ -176,9 +184,10 @@ ext2fs_get_block_xattr(struct inode *ip,
 	if (end <= start || fs2h32(h->h_magic) != EXT2FS_XATTR_MAGIC)
 		goto out;
 
-	error = ext2fs_find_xattr(EXT2FS_XATTR_BFIRST(h), start, end, attrnamespace, uio, size, name_index, name);
+	error = ext2fs_find_xattr(EXT2FS_XATTR_BFIRST(h), start, end,
+	attrnamespace, uio, size, name_index, name);
 
-out:
+out:
 	if (bp)
 		brelse(bp, 0);
 

CVS commit: src/sys/ufs/ext2fs

2016-08-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Aug 23 06:40:25 UTC 2016

Modified Files:
src/sys/ufs/ext2fs: ext2fs_lookup.c

Log Message:
KNF, no functional change


To generate a diff of this commit:
cvs rdiff -u -r1.87 -r1.88 src/sys/ufs/ext2fs/ext2fs_lookup.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/ufs/ext2fs/ext2fs_lookup.c
diff -u src/sys/ufs/ext2fs/ext2fs_lookup.c:1.87 src/sys/ufs/ext2fs/ext2fs_lookup.c:1.88
--- src/sys/ufs/ext2fs/ext2fs_lookup.c:1.87	Thu Aug 18 20:05:43 2016
+++ src/sys/ufs/ext2fs/ext2fs_lookup.c	Tue Aug 23 02:40:25 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_lookup.c,v 1.87 2016/08/19 00:05:43 jdolecek Exp $	*/
+/*	$NetBSD: ext2fs_lookup.c,v 1.88 2016/08/23 06:40:25 christos Exp $	*/
 
 /*
  * Modified for NetBSD 1.2E
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_lookup.c,v 1.87 2016/08/19 00:05:43 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_lookup.c,v 1.88 2016/08/23 06:40:25 christos Exp $");
 
 #include 
 #include 
@@ -305,8 +305,6 @@ ext2fs_lookup(void *v)
 	int dirblksiz = ump->um_dirblksiz;
 	ino_t foundino;
 	struct ufs_lookup_results *results;
-	doff_t i_offset;		/* cached i_offset value */
-	struct ext2fs_searchslot ss;
 
 	flags = cnp->cn_flags;
 
@@ -386,7 +384,6 @@ ext2fs_lookup(void *v)
 	prevoff = results->ulr_offset;
 	endsearch = roundup(ext2fs_size(dp), dirblksiz);
 	enduseful = 0;
-
 	/*
 	 * Try to lookup dir entry using htree directory index.
 	 *
@@ -394,6 +391,8 @@ ext2fs_lookup(void *v)
 	 * we will fall back to linear search.
 	 */
 	if (!ext2fs_is_dot_entry(cnp) && ext2fs_htree_has_idx(dp)) {
+		doff_t i_offset;		/* cached i_offset value */
+		struct ext2fs_searchslot ss;
 		numdirpasses = 1;
 		entryoffsetinblock = 0;
 		
@@ -402,8 +401,7 @@ ext2fs_lookup(void *v)
 		, , );
 		switch (htree_lookup_ret) {
 		case 0:
-			ep = (struct ext2fs_direct*)((char *)bp->b_data +
-			(i_offset & bmask));
+			ep = (void *)((char *)bp->b_data + (i_offset & bmask));
 			foundino = ep->e2d_ino;
 			goto found;
 		case ENOENT:
@@ -428,8 +426,8 @@ searchloop:
 		if ((results->ulr_offset & bmask) == 0) {
 			if (bp != NULL)
 brelse(bp, 0);
-			error = ext2fs_blkatoff(vdp, (off_t)results->ulr_offset, NULL,
-			);
+			error = ext2fs_blkatoff(vdp, (off_t)results->ulr_offset,
+			NULL, );
 			if (error != 0)
 return error;
 			entryoffsetinblock = 0;



CVS commit: src/sys/ufs/ext2fs

2016-08-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Aug 23 06:24:30 UTC 2016

Modified Files:
src/sys/ufs/ext2fs: ext2fs_vfsops.c

Log Message:
CID 1371644: use strlcpy, remove dup copy.


To generate a diff of this commit:
cvs rdiff -u -r1.202 -r1.203 src/sys/ufs/ext2fs/ext2fs_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/ufs/ext2fs/ext2fs_vfsops.c
diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.202 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.203
--- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.202	Sat Aug 20 17:22:25 2016
+++ src/sys/ufs/ext2fs/ext2fs_vfsops.c	Tue Aug 23 02:24:30 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_vfsops.c,v 1.202 2016/08/20 21:22:25 jdolecek Exp $	*/
+/*	$NetBSD: ext2fs_vfsops.c,v 1.203 2016/08/23 06:24:30 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1994
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.202 2016/08/20 21:22:25 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.203 2016/08/23 06:24:30 christos Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -242,12 +242,9 @@ ext2fs_done(void)
 static void
 ext2fs_sb_setmountinfo(struct m_ext2fs *fs, struct mount *mp)
 {
-	(void)strncpy(fs->e2fs_fsmnt, mp->mnt_stat.f_mntonname,
+	(void)strlcpy(fs->e2fs_fsmnt, mp->mnt_stat.f_mntonname,
 sizeof(fs->e2fs_fsmnt));
 	if (fs->e2fs_ronly == 0 && fs->e2fs.e2fs_rev > E2FS_REV0) {
-		(void)strncpy(fs->e2fs.e2fs_fsmnt, mp->mnt_stat.f_mntonname,
-sizeof(fs->e2fs.e2fs_fsmnt));
-
 		fs->e2fs.e2fs_mtime = time_second;
 		fs->e2fs.e2fs_mnt_count++;
 



CVS commit: src/sys/ufs/ext2fs

2016-08-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Aug 23 06:23:27 UTC 2016

Modified Files:
src/sys/ufs/ext2fs: ext2fs_htree.c

Log Message:
CID 1371645: remove dead code


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/ufs/ext2fs/ext2fs_htree.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/ufs/ext2fs/ext2fs_htree.c
diff -u src/sys/ufs/ext2fs/ext2fs_htree.c:1.8 src/sys/ufs/ext2fs/ext2fs_htree.c:1.9
--- src/sys/ufs/ext2fs/ext2fs_htree.c:1.8	Sat Aug 20 15:45:20 2016
+++ src/sys/ufs/ext2fs/ext2fs_htree.c	Tue Aug 23 02:23:26 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_htree.c,v 1.8 2016/08/20 19:45:20 jdolecek Exp $	*/
+/*	$NetBSD: ext2fs_htree.c,v 1.9 2016/08/23 06:23:26 christos Exp $	*/
 
 /*-
  * Copyright (c) 2010, 2012 Zheng Liu 
@@ -29,7 +29,7 @@
  * $FreeBSD: head/sys/fs/ext2fs/ext2fs_htree.c 294653 2016-01-24 02:41:49Z pfg $
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_htree.c,v 1.8 2016/08/20 19:45:20 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_htree.c,v 1.9 2016/08/23 06:23:26 christos Exp $");
 
 #include 
 #include 
@@ -451,8 +451,6 @@ ext2fs_htree_create_index(struct vnode *
 		bdwrite(bp);
 	
 	dp->i_flag |= IN_CHANGE | IN_UPDATE;
-	if (error)
-		goto out;
 
 	/*
 	 * Write directory block 1.



CVS commit: src/sys/ufs/ext2fs

2016-08-20 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sat Aug 20 21:22:25 UTC 2016

Modified Files:
src/sys/ufs/ext2fs: ext2fs_vfsops.c

Log Message:
fix code which sets REV1 e2fs_fsmnt, set also mount time and mount count


To generate a diff of this commit:
cvs rdiff -u -r1.201 -r1.202 src/sys/ufs/ext2fs/ext2fs_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/ufs/ext2fs/ext2fs_vfsops.c
diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.201 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.202
--- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.201	Sat Aug 20 20:05:28 2016
+++ src/sys/ufs/ext2fs/ext2fs_vfsops.c	Sat Aug 20 21:22:25 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_vfsops.c,v 1.201 2016/08/20 20:05:28 jdolecek Exp $	*/
+/*	$NetBSD: ext2fs_vfsops.c,v 1.202 2016/08/20 21:22:25 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1994
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.201 2016/08/20 20:05:28 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.202 2016/08/20 21:22:25 jdolecek Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -239,6 +239,22 @@ ext2fs_done(void)
 	pool_destroy(_inode_pool);
 }
 
+static void
+ext2fs_sb_setmountinfo(struct m_ext2fs *fs, struct mount *mp)
+{
+	(void)strncpy(fs->e2fs_fsmnt, mp->mnt_stat.f_mntonname,
+sizeof(fs->e2fs_fsmnt));
+	if (fs->e2fs_ronly == 0 && fs->e2fs.e2fs_rev > E2FS_REV0) {
+		(void)strncpy(fs->e2fs.e2fs_fsmnt, mp->mnt_stat.f_mntonname,
+sizeof(fs->e2fs.e2fs_fsmnt));
+
+		fs->e2fs.e2fs_mtime = time_second;
+		fs->e2fs.e2fs_mnt_count++;
+
+		fs->e2fs_fmod = 1;
+	}
+}
+
 /*
  * Called by main() when ext2fs is going to be mounted as root.
  *
@@ -270,14 +286,7 @@ ext2fs_mountroot(void)
 	mountlist_append(mp);
 	ump = VFSTOUFS(mp);
 	fs = ump->um_e2fs;
-	memset(fs->e2fs_fsmnt, 0, sizeof(fs->e2fs_fsmnt));
-	(void) copystr(mp->mnt_stat.f_mntonname, fs->e2fs_fsmnt,
-	sizeof(fs->e2fs_fsmnt) - 1, 0);
-	if (fs->e2fs.e2fs_rev > E2FS_REV0) {
-		memset(fs->e2fs.e2fs_fsmnt, 0, sizeof(fs->e2fs.e2fs_fsmnt));
-		(void) copystr(mp->mnt_stat.f_mntonname, fs->e2fs.e2fs_fsmnt,
-		sizeof(fs->e2fs.e2fs_fsmnt) - 1, 0);
-	}
+	ext2fs_sb_setmountinfo(fs, mp);
 	(void)ext2fs_statvfs(mp, >mnt_stat);
 	vfs_unbusy(mp, false, NULL);
 	setrootfstime((time_t)fs->e2fs.e2fs_wtime);
@@ -297,7 +306,6 @@ ext2fs_mount(struct mount *mp, const cha
 	struct ufs_args *args = data;
 	struct ufsmount *ump = NULL;
 	struct m_ext2fs *fs;
-	size_t size;
 	int error = 0, flags, update;
 	mode_t accessmode;
 
@@ -467,15 +475,9 @@ ext2fs_mount(struct mount *mp, const cha
 
 	error = set_statvfs_info(path, UIO_USERSPACE, args->fspec,
 	UIO_USERSPACE, mp->mnt_op->vfs_name, mp, l);
-	(void) copystr(mp->mnt_stat.f_mntonname, fs->e2fs_fsmnt,
-	sizeof(fs->e2fs_fsmnt) - 1, );
-	memset(fs->e2fs_fsmnt + size, 0, sizeof(fs->e2fs_fsmnt) - size);
-	if (fs->e2fs.e2fs_rev > E2FS_REV0) {
-		(void) copystr(mp->mnt_stat.f_mntonname, fs->e2fs.e2fs_fsmnt,
-		sizeof(fs->e2fs.e2fs_fsmnt) - 1, );
-		memset(fs->e2fs.e2fs_fsmnt, 0,
-		sizeof(fs->e2fs.e2fs_fsmnt) - size);
-	}
+	if (error == 0)
+		ext2fs_sb_setmountinfo(fs, mp);
+
 	if (fs->e2fs_fmod != 0) {	/* XXX */
 		fs->e2fs_fmod = 0;
 		if (fs->e2fs.e2fs_state == 0)



CVS commit: src/sys/ufs/ext2fs

2016-08-20 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sat Aug 20 20:05:28 UTC 2016

Modified Files:
src/sys/ufs/ext2fs: ext2fs_vfsops.c

Log Message:
adjust ext2fs_loadvnode_content() to do the sanity checking before allocating
memory, and avoid reallocaing memory on vnode reload


To generate a diff of this commit:
cvs rdiff -u -r1.200 -r1.201 src/sys/ufs/ext2fs/ext2fs_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/ufs/ext2fs/ext2fs_vfsops.c
diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.200 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.201
--- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.200	Sat Aug 20 19:47:44 2016
+++ src/sys/ufs/ext2fs/ext2fs_vfsops.c	Sat Aug 20 20:05:28 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_vfsops.c,v 1.200 2016/08/20 19:47:44 jdolecek Exp $	*/
+/*	$NetBSD: ext2fs_vfsops.c,v 1.201 2016/08/20 20:05:28 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1994
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.200 2016/08/20 19:47:44 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.201 2016/08/20 20:05:28 jdolecek Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -493,22 +493,19 @@ fail:
 }
 
 /*
- *
+ * Sanity check the disk vnode content, and copy it over to inode structure.
  */
 static int
 ext2fs_loadvnode_content(struct m_ext2fs *fs, ino_t ino, struct buf *bp, struct inode *ip)
 {
 	struct ext2fs_dinode *din;
-	void *cp;
 	int error = 0;
 
-	cp = (char *)bp->b_data + (ino_to_fsbo(fs, ino) * EXT2_DINODE_SIZE(fs));
-	din = kmem_alloc(EXT2_DINODE_SIZE(fs), KM_SLEEP);
-	e2fs_iload((struct ext2fs_dinode *)cp, din, EXT2_DINODE_SIZE(fs));
+	din = (struct ext2fs_dinode *)((char *)bp->b_data + (ino_to_fsbo(fs, ino) * EXT2_DINODE_SIZE(fs)));
 
-	/* sanity checks */
+	/* sanity checks - inode data NOT byteswapped at this point */
 	if (EXT2_DINODE_FITS(din, e2di_extra_isize, EXT2_DINODE_SIZE(fs))
-	&& (EXT2_DINODE_SIZE(fs) - EXT2_REV0_DINODE_SIZE) < din->e2di_extra_isize)
+	&& (EXT2_DINODE_SIZE(fs) - EXT2_REV0_DINODE_SIZE) < fs2h16(din->e2di_extra_isize))
 	{
 		printf("ext2fs: inode %"PRIu64" bad extra_isize %u",
 			ino, din->e2di_extra_isize);
@@ -516,16 +513,15 @@ ext2fs_loadvnode_content(struct m_ext2fs
 		goto bad;
 	}
 
-	/* replace old dinode; assumes new dinode size is same as old one */
-	if (ip->i_din.e2fs_din)
-		kmem_free(ip->i_din.e2fs_din, EXT2_DINODE_SIZE(fs));
-	ip->i_din.e2fs_din = din;
+	/* everything allright, proceed with copy */
+	if (ip->i_din.e2fs_din == NULL)
+		ip->i_din.e2fs_din = kmem_alloc(EXT2_DINODE_SIZE(fs), KM_SLEEP);
+
+	e2fs_iload(din, ip->i_din.e2fs_din, EXT2_DINODE_SIZE(fs));
 
 	ext2fs_set_inode_guid(ip);
-	return error;
 
 bad:
-	kmem_free(din, EXT2_DINODE_SIZE(fs));
 	return error;
 }
 



CVS commit: src/sys/ufs/ext2fs

2016-08-20 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sat Aug 20 19:53:43 UTC 2016

Modified Files:
src/sys/ufs/ext2fs: ext2fs_alloc.c

Log Message:
modify the comment to note code needs to brele() to have a shot on actually
working


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/ufs/ext2fs/ext2fs_alloc.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/ufs/ext2fs/ext2fs_alloc.c
diff -u src/sys/ufs/ext2fs/ext2fs_alloc.c:1.50 src/sys/ufs/ext2fs/ext2fs_alloc.c:1.51
--- src/sys/ufs/ext2fs/ext2fs_alloc.c:1.50	Sat Aug 20 19:51:50 2016
+++ src/sys/ufs/ext2fs/ext2fs_alloc.c	Sat Aug 20 19:53:43 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_alloc.c,v 1.50 2016/08/20 19:51:50 jdolecek Exp $	*/
+/*	$NetBSD: ext2fs_alloc.c,v 1.51 2016/08/20 19:53:43 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_alloc.c,v 1.50 2016/08/20 19:51:50 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_alloc.c,v 1.51 2016/08/20 19:53:43 jdolecek Exp $");
 
 #include 
 #include 
@@ -418,7 +418,10 @@ ext2fs_alloccg(struct inode *ip, int cg,
 
 	bno = ext2fs_mapsearch(fs, bbp, bpref);
 #if 0
-	/* XXX jdolecek mapsearch actually never fails, it panics instead */
+	/*
+	 * XXX jdolecek mapsearch actually never fails, it panics instead.
+	 * If re-enabling, make sure to brele() before returning.
+	 */
 	if (bno < 0)
 		return 0;
 #endif



CVS commit: src/sys/ufs/ext2fs

2016-08-20 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sat Aug 20 19:51:50 UTC 2016

Modified Files:
src/sys/ufs/ext2fs: ext2fs_alloc.c

Log Message:
#if 0 the check for ext2fs_mapsearch() failure (similar what was done
for ffs counterpart), it actually never fails, it panics instead


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/ufs/ext2fs/ext2fs_alloc.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/ufs/ext2fs/ext2fs_alloc.c
diff -u src/sys/ufs/ext2fs/ext2fs_alloc.c:1.49 src/sys/ufs/ext2fs/ext2fs_alloc.c:1.50
--- src/sys/ufs/ext2fs/ext2fs_alloc.c:1.49	Sat Aug 20 19:47:44 2016
+++ src/sys/ufs/ext2fs/ext2fs_alloc.c	Sat Aug 20 19:51:50 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_alloc.c,v 1.49 2016/08/20 19:47:44 jdolecek Exp $	*/
+/*	$NetBSD: ext2fs_alloc.c,v 1.50 2016/08/20 19:51:50 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_alloc.c,v 1.49 2016/08/20 19:47:44 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_alloc.c,v 1.50 2016/08/20 19:51:50 jdolecek Exp $");
 
 #include 
 #include 
@@ -417,8 +417,11 @@ ext2fs_alloccg(struct inode *ip, int cg,
 	}
 
 	bno = ext2fs_mapsearch(fs, bbp, bpref);
+#if 0
+	/* XXX jdolecek mapsearch actually never fails, it panics instead */
 	if (bno < 0)
 		return 0;
+#endif
 gotit:
 #ifdef DIAGNOSTIC
 	if (isset(bbp, (daddr_t)bno)) {



CVS commit: src/sys/ufs/ext2fs

2016-08-20 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sat Aug 20 19:47:44 UTC 2016

Modified Files:
src/sys/ufs/ext2fs: ext2fs.h ext2fs_alloc.c ext2fs_bswap.c
ext2fs_extern.h ext2fs_vfsops.c

Log Message:
add support for GDT_CSUM AKA uninit_bg feature


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/ufs/ext2fs/ext2fs.h
cvs rdiff -u -r1.48 -r1.49 src/sys/ufs/ext2fs/ext2fs_alloc.c
cvs rdiff -u -r1.23 -r1.24 src/sys/ufs/ext2fs/ext2fs_bswap.c
cvs rdiff -u -r1.54 -r1.55 src/sys/ufs/ext2fs/ext2fs_extern.h
cvs rdiff -u -r1.199 -r1.200 src/sys/ufs/ext2fs/ext2fs_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/ufs/ext2fs/ext2fs.h
diff -u src/sys/ufs/ext2fs/ext2fs.h:1.47 src/sys/ufs/ext2fs/ext2fs.h:1.48
--- src/sys/ufs/ext2fs/ext2fs.h:1.47	Mon Aug 15 18:46:11 2016
+++ src/sys/ufs/ext2fs/ext2fs.h	Sat Aug 20 19:47:44 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs.h,v 1.47 2016/08/15 18:46:11 jdolecek Exp $	*/
+/*	$NetBSD: ext2fs.h,v 1.48 2016/08/20 19:47:44 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -249,10 +249,10 @@ struct m_ext2fs {
 	int64_t e2fs_qbmask;	/* ~fs_bmask - for use with quad size */
 	int32_t	e2fs_fsbtodb;	/* fsbtodb and dbtofsb shift constant */
 	int32_t	e2fs_ncg;	/* number of cylinder groups */
-	int32_t	e2fs_ngdb;	/* number of group descriptor block */
+	int32_t	e2fs_ngdb;	/* number of group descriptor blocks */
 	int32_t	e2fs_ipb;	/* number of inodes per block */
-	int32_t	e2fs_itpg;	/* number of inode table per group */
-	struct	ext2_gd *e2fs_gd; /* group descripors */
+	int32_t	e2fs_itpg;	/* number of inode table blocks per group */
+	struct	ext2_gd *e2fs_gd; /* group descriptors (data not byteswapped) */
 };
 
 
@@ -366,7 +366,8 @@ struct m_ext2fs {
 	 | EXT2F_ROCOMPAT_LARGEFILE \
 	 | EXT2F_ROCOMPAT_HUGE_FILE \
 	 | EXT2F_ROCOMPAT_EXTRA_ISIZE \
-	 | EXT2F_ROCOMPAT_DIR_NLINK)
+	 | EXT2F_ROCOMPAT_DIR_NLINK \
+	 | EXT2F_ROCOMPAT_GDT_CSUM)
 #define EXT2F_INCOMPAT_SUPP		(EXT2F_INCOMPAT_FTYPE \
 	 | EXT2F_INCOMPAT_EXTENTS \
 	 | EXT2F_INCOMPAT_FLEX_BG)
@@ -415,15 +416,35 @@ struct m_ext2fs {
 struct ext2_gd {
 	uint32_t ext2bgd_b_bitmap;	/* blocks bitmap block */
 	uint32_t ext2bgd_i_bitmap;	/* inodes bitmap block */
-	uint32_t ext2bgd_i_tables;	/* inodes table block  */
+	uint32_t ext2bgd_i_tables;	/* first inodes table block */
 	uint16_t ext2bgd_nbfree;	/* number of free blocks */
 	uint16_t ext2bgd_nifree;	/* number of free inodes */
 	uint16_t ext2bgd_ndirs;		/* number of directories */
-	uint16_t reserved;
-	uint32_t reserved2[3];
+
+	/*
+	 * Following only valid when either GDT_CSUM (AKA uninit_bg) 
+	 * or METADATA_CKSUM feature is on
+	 */
+	uint16_t ext2bgd_flags;		/* ext4 bg flags (INODE_UNINIT, ...)*/
+	uint32_t ext2bgd_exclude_bitmap_lo;	/* snapshot exclude bitmap */
+	uint16_t ext2bgd_block_bitmap_csum_lo;	/* Low block bitmap checksum */
+	uint16_t ext2bgd_inode_bitmap_csum_lo;	/* Low inode bitmap checksum */
+	uint16_t ext2bgd_itable_unused_lo;	/* Low unused inode offset */
+	uint16_t ext2bgd_checksum;		/* Group desc checksum */
+
+	/*
+	 * XXX disk32 Further fields only exist if 64BIT feature is on
+	 * and superblock desc_size > 32, not supported for now.
+	 */
 };
 
+#define E2FS_BG_INODE_UNINIT	0x0001	/* Inode bitmap not used/initialized */
+#define E2FS_BG_BLOCK_UNINIT	0x0002	/* Block bitmap not used/initialized */
+#define E2FS_BG_INODE_ZEROED	0x0004	/* On-disk inode table initialized */
 
+#define E2FS_HAS_GD_CSUM(fs) \
+	EXT2F_HAS_ROCOMPAT_FEATURE(fs, EXT2F_ROCOMPAT_GDT_CSUM|EXT2F_ROCOMPAT_METADATA_CKSUM) != 0
+	
 /*
  * If the EXT2F_ROCOMPAT_SPARSESUPER flag is set, the cylinder group has a
  * copy of the super and cylinder group descriptors blocks only if it's
@@ -457,13 +478,10 @@ cg_has_sb(int i)
 #	define fs2h16(x) (x)
 #	define fs2h32(x) (x)
 #	define fs2h64(x) (x)
-#	define e2fs_sbload(old, new) memcpy((new), (old), SBSIZE);
-#	define e2fs_cgload(old, new, size) memcpy((new), (old), (size));
-#	define e2fs_sbsave(old, new) memcpy((new), (old), SBSIZE);
-#	define e2fs_cgsave(old, new, size) memcpy((new), (old), (size));
+#	define e2fs_sbload(old, new) memcpy((new), (old), SBSIZE)
+#	define e2fs_sbsave(old, new) memcpy((new), (old), SBSIZE)
 #else
 void e2fs_sb_bswap(struct ext2fs *, struct ext2fs *);
-void e2fs_cg_bswap(struct ext2_gd *, struct ext2_gd *, int);
 #	define h2fs16(x) bswap16(x)
 #	define h2fs32(x) bswap32(x)
 #	define h2fs64(x) bswap64(x)
@@ -471,11 +489,13 @@ void e2fs_cg_bswap(struct ext2_gd *, str
 #	define fs2h32(x) bswap32(x)
 #	define fs2h64(x) bswap64(x)
 #	define e2fs_sbload(old, new) e2fs_sb_bswap((old), (new))
-#	define e2fs_cgload(old, new, size) e2fs_cg_bswap((old), (new), (size));
 #	define e2fs_sbsave(old, new) e2fs_sb_bswap((old), (new))
-#	define e2fs_cgsave(old, new, size) e2fs_cg_bswap((old), (new), (size));
 #endif
 
+/* Group descriptors 

CVS commit: src/sys/ufs/ext2fs

2016-08-20 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sat Aug 20 19:45:20 UTC 2016

Modified Files:
src/sys/ufs/ext2fs: ext2fs_htree.c

Log Message:
whitespace fix


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/ufs/ext2fs/ext2fs_htree.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/ufs/ext2fs/ext2fs_htree.c
diff -u src/sys/ufs/ext2fs/ext2fs_htree.c:1.7 src/sys/ufs/ext2fs/ext2fs_htree.c:1.8
--- src/sys/ufs/ext2fs/ext2fs_htree.c:1.7	Fri Aug 19 00:05:43 2016
+++ src/sys/ufs/ext2fs/ext2fs_htree.c	Sat Aug 20 19:45:20 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_htree.c,v 1.7 2016/08/19 00:05:43 jdolecek Exp $	*/
+/*	$NetBSD: ext2fs_htree.c,v 1.8 2016/08/20 19:45:20 jdolecek Exp $	*/
 
 /*-
  * Copyright (c) 2010, 2012 Zheng Liu 
@@ -29,7 +29,7 @@
  * $FreeBSD: head/sys/fs/ext2fs/ext2fs_htree.c 294653 2016-01-24 02:41:49Z pfg $
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_htree.c,v 1.7 2016/08/19 00:05:43 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_htree.c,v 1.8 2016/08/20 19:45:20 jdolecek Exp $");
 
 #include 
 #include 
@@ -306,7 +306,7 @@ ext2fs_htree_split_dirblock(char *block1
 	 * Sort directory entry descriptors by name hash value.
 	 */
 	kheapsort(sort_info, entry_cnt, sizeof(struct ext2fs_htree_sort_entry),
-	ext2fs_htree_cmp_sort_entry,);
+	ext2fs_htree_cmp_sort_entry, );
 
 	/*
 	 * Count the number of entries to move to directory block 2.



CVS commit: src/sys/ufs/ext2fs

2016-08-18 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Fri Aug 19 00:05:43 UTC 2016

Modified Files:
src/sys/ufs/ext2fs: ext2fs_extern.h ext2fs_htree.c ext2fs_lookup.c

Log Message:
fix bug introduced in rev 1.82 of ext2fs_lookup.c, when ext2fs_add_entry()
was introduced splitting code from ext2fs_direnter() - code used
incorrect new entry size, leading to incomplete entry copy or buffer
overflow; fixed by passing the right size from ext2fs_direnter()


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sys/ufs/ext2fs/ext2fs_extern.h
cvs rdiff -u -r1.6 -r1.7 src/sys/ufs/ext2fs/ext2fs_htree.c
cvs rdiff -u -r1.86 -r1.87 src/sys/ufs/ext2fs/ext2fs_lookup.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/ufs/ext2fs/ext2fs_extern.h
diff -u src/sys/ufs/ext2fs/ext2fs_extern.h:1.53 src/sys/ufs/ext2fs/ext2fs_extern.h:1.54
--- src/sys/ufs/ext2fs/ext2fs_extern.h:1.53	Mon Aug 15 18:29:34 2016
+++ src/sys/ufs/ext2fs/ext2fs_extern.h	Fri Aug 19 00:05:43 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_extern.h,v 1.53 2016/08/15 18:29:34 jdolecek Exp $	*/
+/*	$NetBSD: ext2fs_extern.h,v 1.54 2016/08/19 00:05:43 jdolecek Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -134,7 +134,7 @@ int ext2fs_dirrewrite(struct inode *, co
 			   struct inode *, struct componentname *);
 int ext2fs_dirempty(struct inode *, ino_t, kauth_cred_t);
 int ext2fs_add_entry(struct vnode *, struct ext2fs_direct *,
-const struct ufs_lookup_results *); 
+const struct ufs_lookup_results *, size_t); 
 
 /* ext2fs_subr.c */
 int ext2fs_blkatoff(struct vnode *, off_t, char **, struct buf **);
@@ -190,7 +190,7 @@ int ext2fs_htree_lookup(struct inode *, 
 int ext2fs_htree_create_index(struct vnode *, struct componentname *,
 struct ext2fs_direct *);
 int ext2fs_htree_add_entry(struct vnode *, struct ext2fs_direct *,
-struct componentname *);
+struct componentname *, size_t);
 
 __END_DECLS
 

Index: src/sys/ufs/ext2fs/ext2fs_htree.c
diff -u src/sys/ufs/ext2fs/ext2fs_htree.c:1.6 src/sys/ufs/ext2fs/ext2fs_htree.c:1.7
--- src/sys/ufs/ext2fs/ext2fs_htree.c:1.6	Sun Aug 14 11:42:50 2016
+++ src/sys/ufs/ext2fs/ext2fs_htree.c	Fri Aug 19 00:05:43 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_htree.c,v 1.6 2016/08/14 11:42:50 jdolecek Exp $	*/
+/*	$NetBSD: ext2fs_htree.c,v 1.7 2016/08/19 00:05:43 jdolecek Exp $	*/
 
 /*-
  * Copyright (c) 2010, 2012 Zheng Liu 
@@ -29,7 +29,7 @@
  * $FreeBSD: head/sys/fs/ext2fs/ext2fs_htree.c 294653 2016-01-24 02:41:49Z pfg $
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_htree.c,v 1.6 2016/08/14 11:42:50 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_htree.c,v 1.7 2016/08/19 00:05:43 jdolecek Exp $");
 
 #include 
 #include 
@@ -480,7 +480,7 @@ out1:
  */
 int
 ext2fs_htree_add_entry(struct vnode *dvp, struct ext2fs_direct *entry,
-struct componentname *cnp)
+struct componentname *cnp, size_t newentrysize)
 {
 	struct ext2fs_htree_entry *entries, *leaf_node;
 	struct ext2fs_htree_lookup_info info;
@@ -507,7 +507,8 @@ ext2fs_htree_add_entry(struct vnode *dvp
 	blksize = m_fs->e2fs_bsize;
 
 	if (ip->i_crap.ulr_count != 0) 
-		return ext2fs_add_entry(dvp, entry, &(ip->i_crap));
+		return ext2fs_add_entry(dvp, entry, &(ip->i_crap), newentrysize);
+
 	/* Target directory block is full, split it */
 	memset(, 0, sizeof(info));
 	error = ext2fs_htree_find_leaf(ip, entry->e2d_name, entry->e2d_namlen,

Index: src/sys/ufs/ext2fs/ext2fs_lookup.c
diff -u src/sys/ufs/ext2fs/ext2fs_lookup.c:1.86 src/sys/ufs/ext2fs/ext2fs_lookup.c:1.87
--- src/sys/ufs/ext2fs/ext2fs_lookup.c:1.86	Sun Aug 14 11:46:05 2016
+++ src/sys/ufs/ext2fs/ext2fs_lookup.c	Fri Aug 19 00:05:43 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_lookup.c,v 1.86 2016/08/14 11:46:05 jdolecek Exp $	*/
+/*	$NetBSD: ext2fs_lookup.c,v 1.87 2016/08/19 00:05:43 jdolecek Exp $	*/
 
 /*
  * Modified for NetBSD 1.2E
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_lookup.c,v 1.86 2016/08/14 11:46:05 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_lookup.c,v 1.87 2016/08/19 00:05:43 jdolecek Exp $");
 
 #include 
 #include 
@@ -839,10 +839,8 @@ ext2fs_dirbadentry(struct vnode *dp, str
 
 	if (reclen < EXT2FS_DIRSIZ(1)) /* e2d_namlen = 1 */
 		error_msg = "rec_len is smaller than minimal";
-#if 0
 	else if (reclen % 4 != 0)
 		error_msg = "rec_len % 4 != 0";
-#endif
 	else if (namlen > EXT2FS_MAXNAMLEN)
 		error_msg = "namlen > EXT2FS_MAXNAMLEN";
 	else if (reclen < EXT2FS_DIRSIZ(namlen))
@@ -880,9 +878,10 @@ ext2fs_direnter(struct inode *ip, struct
 	struct ext2fs_direct newdir;
 	struct iovec aiov;
 	struct uio auio;
-	int error, newentrysize;
+	int error;
 	struct ufsmount *ump = VFSTOUFS(dvp->v_mount);
 	int dirblksiz = ump->um_dirblksiz;
+	size_t newentrysize;
 
 	dp = VTOI(dvp);
 
@@ -895,11 +894,11 @@ ext2fs_direnter(struct inode *ip, struct
 	}
 	memcpy(newdir.e2d_name, cnp->cn_nameptr, 

CVS commit: src/sys/ufs/ext2fs

2016-08-15 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Mon Aug 15 18:46:11 UTC 2016

Modified Files:
src/sys/ufs/ext2fs: ext2fs.h

Log Message:
EXT2F_INCOMPAT_FLEX_BG feature actually doesn't require any explicit
code changes, all magic is done by setting the block offsets appropriately
in group descriptors by newfs; add it to the list of supported INCOMPAT flags


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/ufs/ext2fs/ext2fs.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/ufs/ext2fs/ext2fs.h
diff -u src/sys/ufs/ext2fs/ext2fs.h:1.46 src/sys/ufs/ext2fs/ext2fs.h:1.47
--- src/sys/ufs/ext2fs/ext2fs.h:1.46	Mon Aug 15 18:38:10 2016
+++ src/sys/ufs/ext2fs/ext2fs.h	Mon Aug 15 18:46:11 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs.h,v 1.46 2016/08/15 18:38:10 jdolecek Exp $	*/
+/*	$NetBSD: ext2fs.h,v 1.47 2016/08/15 18:46:11 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -368,7 +368,8 @@ struct m_ext2fs {
 	 | EXT2F_ROCOMPAT_EXTRA_ISIZE \
 	 | EXT2F_ROCOMPAT_DIR_NLINK)
 #define EXT2F_INCOMPAT_SUPP		(EXT2F_INCOMPAT_FTYPE \
-	 | EXT2F_INCOMPAT_EXTENTS)
+	 | EXT2F_INCOMPAT_EXTENTS \
+	 | EXT2F_INCOMPAT_FLEX_BG)
 
 /*
  * Feature set definitions



CVS commit: src/sys/ufs/ext2fs

2016-08-15 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Mon Aug 15 18:38:10 UTC 2016

Modified Files:
src/sys/ufs/ext2fs: ext2fs.h ext2fs_rename.c ext2fs_vnops.c

Log Message:
bump link limit to 65000 for files, and add support for 
EXT2F_ROCOMPAT_DIR_NLINK to make link count unlimited for directories


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/ufs/ext2fs/ext2fs.h
cvs rdiff -u -r1.10 -r1.11 src/sys/ufs/ext2fs/ext2fs_rename.c
cvs rdiff -u -r1.124 -r1.125 src/sys/ufs/ext2fs/ext2fs_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/ufs/ext2fs/ext2fs.h
diff -u src/sys/ufs/ext2fs/ext2fs.h:1.45 src/sys/ufs/ext2fs/ext2fs.h:1.46
--- src/sys/ufs/ext2fs/ext2fs.h:1.45	Sun Aug 14 11:42:50 2016
+++ src/sys/ufs/ext2fs/ext2fs.h	Mon Aug 15 18:38:10 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs.h,v 1.45 2016/08/14 11:42:50 jdolecek Exp $	*/
+/*	$NetBSD: ext2fs.h,v 1.46 2016/08/15 18:38:10 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -128,6 +128,13 @@
 #define MINFREE		5
 
 /*
+ * This is maximum amount of links allowed for files. For directories,
+ * going over this means setting DIR_NLINK feature.
+ */
+#define EXT2FS_LINK_MAX		65000
+#define EXT2FS_LINK_INF		1		/* link count unknown */
+
+/*
  * Super block for an ext2fs file system.
  */
 struct ext2fs {
@@ -358,7 +365,8 @@ struct m_ext2fs {
 #define EXT2F_ROCOMPAT_SUPP		(EXT2F_ROCOMPAT_SPARSESUPER \
 	 | EXT2F_ROCOMPAT_LARGEFILE \
 	 | EXT2F_ROCOMPAT_HUGE_FILE \
-	 | EXT2F_ROCOMPAT_EXTRA_ISIZE)
+	 | EXT2F_ROCOMPAT_EXTRA_ISIZE \
+	 | EXT2F_ROCOMPAT_DIR_NLINK)
 #define EXT2F_INCOMPAT_SUPP		(EXT2F_INCOMPAT_FTYPE \
 	 | EXT2F_INCOMPAT_EXTENTS)
 

Index: src/sys/ufs/ext2fs/ext2fs_rename.c
diff -u src/sys/ufs/ext2fs/ext2fs_rename.c:1.10 src/sys/ufs/ext2fs/ext2fs_rename.c:1.11
--- src/sys/ufs/ext2fs/ext2fs_rename.c:1.10	Sat Aug 13 07:40:10 2016
+++ src/sys/ufs/ext2fs/ext2fs_rename.c	Mon Aug 15 18:38:10 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_rename.c,v 1.10 2016/08/13 07:40:10 christos Exp $	*/
+/*	$NetBSD: ext2fs_rename.c,v 1.11 2016/08/15 18:38:10 jdolecek Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_rename.c,v 1.10 2016/08/13 07:40:10 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_rename.c,v 1.11 2016/08/15 18:38:10 jdolecek Exp $");
 
 #include 
 #include 
@@ -307,7 +307,7 @@ ext2fs_gro_rename(struct mount *mp, kaut
 	 * We shall need to temporarily bump the link count, so make
 	 * sure there is room to do so.
 	 */
-	if ((nlink_t)VTOI(fvp)->i_e2fs_nlink >= LINK_MAX)
+	if ((nlink_t)VTOI(fvp)->i_e2fs_nlink >= EXT2FS_LINK_MAX)
 		return EMLINK;
 
 	directory_p = (fvp->v_type == VDIR);
@@ -330,7 +330,7 @@ ext2fs_gro_rename(struct mount *mp, kaut
 	 *may be wrong, but correctable.
 	 */
 
-	KASSERT((nlink_t)VTOI(fvp)->i_e2fs_nlink < LINK_MAX);
+	KASSERT((nlink_t)VTOI(fvp)->i_e2fs_nlink < EXT2FS_LINK_MAX);
 	VTOI(fvp)->i_e2fs_nlink++;
 	VTOI(fvp)->i_flag |= IN_CHANGE;
 	error = ext2fs_update(fvp, NULL, NULL, UPDATE_WAIT);
@@ -352,11 +352,11 @@ ext2fs_gro_rename(struct mount *mp, kaut
 		 * parent we don't fool with the link count.
 		 */
 		if (directory_p && reparent_p) {
-			if ((nlink_t)VTOI(tdvp)->i_e2fs_nlink >= LINK_MAX) {
+			if ((nlink_t)VTOI(tdvp)->i_e2fs_nlink >= EXT2FS_LINK_MAX) {
 error = EMLINK;
 goto whymustithurtsomuch;
 			}
-			KASSERT((nlink_t)VTOI(tdvp)->i_e2fs_nlink < LINK_MAX);
+			KASSERT((nlink_t)VTOI(tdvp)->i_e2fs_nlink < EXT2FS_LINK_MAX);
 			VTOI(tdvp)->i_e2fs_nlink++;
 			VTOI(tdvp)->i_flag |= IN_CHANGE;
 			error = ext2fs_update(tdvp, NULL, NULL, UPDATE_WAIT);

Index: src/sys/ufs/ext2fs/ext2fs_vnops.c
diff -u src/sys/ufs/ext2fs/ext2fs_vnops.c:1.124 src/sys/ufs/ext2fs/ext2fs_vnops.c:1.125
--- src/sys/ufs/ext2fs/ext2fs_vnops.c:1.124	Mon Aug 15 18:29:34 2016
+++ src/sys/ufs/ext2fs/ext2fs_vnops.c	Mon Aug 15 18:38:10 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_vnops.c,v 1.124 2016/08/15 18:29:34 jdolecek Exp $	*/
+/*	$NetBSD: ext2fs_vnops.c,v 1.125 2016/08/15 18:38:10 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -65,7 +65,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.124 2016/08/15 18:29:34 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.125 2016/08/15 18:38:10 jdolecek Exp $");
 
 #include 
 #include 
@@ -626,7 +626,7 @@ ext2fs_link(void *v)
 		goto out2;
 	}
 	ip = VTOI(vp);
-	if ((nlink_t)ip->i_e2fs_nlink >= LINK_MAX) {
+	if ((nlink_t)ip->i_e2fs_nlink >= EXT2FS_LINK_MAX) {
 		VOP_ABORTOP(dvp, cnp);
 		error = EMLINK;
 		goto out1;
@@ -677,11 +677,6 @@ ext2fs_mkdir(void *v)
 	ulr = (dvp)->i_crap;
 	UFS_CHECK_CRAPCOUNTER(VTOI(dvp));
 
-	if ((nlink_t)dp->i_e2fs_nlink >= LINK_MAX) {
-		error = EMLINK;
-		goto out;
-	}
-
 	/*
 	 * Acquire the inode, but don't sync/direnter it just yet
 	 */
@@ -700,7 

CVS commit: src/sys/ufs/ext2fs

2016-08-15 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Mon Aug 15 18:29:34 UTC 2016

Modified Files:
src/sys/ufs/ext2fs: ext2fs_bswap.c ext2fs_extern.h ext2fs_vnops.c

Log Message:
adjust ext2fs_makeinode() so that the direnter is optional, use the function 
(with the direnter off) in ext2fs_mkdir() instead of the code copy; adjust 
ext2fs_makeinode() to initialize extra_isize and set creation time, if 
supported by the filesystem


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/ufs/ext2fs/ext2fs_bswap.c
cvs rdiff -u -r1.52 -r1.53 src/sys/ufs/ext2fs/ext2fs_extern.h
cvs rdiff -u -r1.123 -r1.124 src/sys/ufs/ext2fs/ext2fs_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/ufs/ext2fs/ext2fs_bswap.c
diff -u src/sys/ufs/ext2fs/ext2fs_bswap.c:1.22 src/sys/ufs/ext2fs/ext2fs_bswap.c:1.23
--- src/sys/ufs/ext2fs/ext2fs_bswap.c:1.22	Thu Aug  4 17:43:48 2016
+++ src/sys/ufs/ext2fs/ext2fs_bswap.c	Mon Aug 15 18:29:34 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_bswap.c,v 1.22 2016/08/04 17:43:48 jdolecek Exp $	*/
+/*	$NetBSD: ext2fs_bswap.c,v 1.23 2016/08/15 18:29:34 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1997 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_bswap.c,v 1.22 2016/08/04 17:43:48 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_bswap.c,v 1.23 2016/08/15 18:29:34 jdolecek Exp $");
 
 #include 
 #include 
@@ -79,6 +79,7 @@ e2fs_sb_bswap(struct ext2fs *old, struct
 	new->e2fs_features_rocompat =	bswap32(old->e2fs_features_rocompat);
 	new->e2fs_algo		=	bswap32(old->e2fs_algo);
 	new->e2fs_reserved_ngdb	=	bswap16(old->e2fs_reserved_ngdb);
+	new->e4fs_want_extra_isize =	bswap16(old->e4fs_want_extra_isize);
 }
 
 void

Index: src/sys/ufs/ext2fs/ext2fs_extern.h
diff -u src/sys/ufs/ext2fs/ext2fs_extern.h:1.52 src/sys/ufs/ext2fs/ext2fs_extern.h:1.53
--- src/sys/ufs/ext2fs/ext2fs_extern.h:1.52	Tue Aug  9 21:08:02 2016
+++ src/sys/ufs/ext2fs/ext2fs_extern.h	Mon Aug 15 18:29:34 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_extern.h,v 1.52 2016/08/09 21:08:02 kre Exp $	*/
+/*	$NetBSD: ext2fs_extern.h,v 1.53 2016/08/15 18:29:34 jdolecek Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -176,7 +176,7 @@ int ext2fs_fsync(void *);
 int ext2fs_vinit(struct mount *, int (**specops)(void *),
 		  int (**fifoops)(void *), struct vnode **);
 int ext2fs_makeinode(int, struct vnode *, struct vnode **,
-			  struct componentname *cnp);
+			  struct componentname *cnp, int);
 int ext2fs_reclaim(void *);
 
 /* ext2fs_hash.c */

Index: src/sys/ufs/ext2fs/ext2fs_vnops.c
diff -u src/sys/ufs/ext2fs/ext2fs_vnops.c:1.123 src/sys/ufs/ext2fs/ext2fs_vnops.c:1.124
--- src/sys/ufs/ext2fs/ext2fs_vnops.c:1.123	Sun Aug 14 11:44:54 2016
+++ src/sys/ufs/ext2fs/ext2fs_vnops.c	Mon Aug 15 18:29:34 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_vnops.c,v 1.123 2016/08/14 11:44:54 jdolecek Exp $	*/
+/*	$NetBSD: ext2fs_vnops.c,v 1.124 2016/08/15 18:29:34 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -65,7 +65,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.123 2016/08/14 11:44:54 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.124 2016/08/15 18:29:34 jdolecek Exp $");
 
 #include 
 #include 
@@ -136,7 +136,7 @@ ext2fs_create(void *v)
 
 	error =
 	ext2fs_makeinode(MAKEIMODE(ap->a_vap->va_type, ap->a_vap->va_mode),
-			 ap->a_dvp, ap->a_vpp, ap->a_cnp);
+			 ap->a_dvp, ap->a_vpp, ap->a_cnp, 1);
 
 	if (error)
 		return error;
@@ -166,7 +166,7 @@ ext2fs_mknod(void *v)
 	ino_t		ino;
 
 	if ((error = ext2fs_makeinode(MAKEIMODE(vap->va_type, vap->va_mode),
-		ap->a_dvp, vpp, ap->a_cnp)) != 0)
+		ap->a_dvp, vpp, ap->a_cnp, 1)) != 0)
 		return error;
 	VN_KNOTE(ap->a_dvp, NOTE_WRITE);
 	ip = VTOI(*vpp);
@@ -666,12 +666,11 @@ ext2fs_mkdir(void *v)
 		struct vattr *a_vap;
 	} */ *ap = v;
 	struct vnode		*dvp = ap->a_dvp;
-	struct vattr		*vap = ap->a_vap;
 	struct componentname	*cnp = ap->a_cnp;
 	struct inode		*ip, *dp = VTOI(dvp);
 	struct vnode		*tvp;
 	struct ext2fs_dirtemplate dirtemplate;
-	int			error, dmode;
+	int			error;
 	struct ufs_lookup_results *ulr;
 
 	/* XXX should handle this material another way */
@@ -682,30 +681,17 @@ ext2fs_mkdir(void *v)
 		error = EMLINK;
 		goto out;
 	}
-	dmode = vap->va_mode & ACCESSPERMS;
-	dmode |= IFDIR;
+
 	/*
-	 * Must simulate part of ext2fs_makeinode here to acquire the inode,
-	 * but not have it entered in the parent directory. The entry is
-	 * made later after writing "." and ".." entries.
+	 * Acquire the inode, but don't sync/direnter it just yet
 	 */
-	if ((error = ext2fs_valloc(dvp, dmode, cnp->cn_cred, )) != 0)
+	error = ext2fs_makeinode(IFDIR | ap->a_vap->va_mode, ap->a_dvp,
+			  , ap->a_cnp, 0);
+	if (error)
 		goto out;
+
+	/* the link count is going to be 2 when all is done */
 	ip = VTOI(tvp);
-	ip->i_uid = 

CVS commit: src/sys/ufs/ext2fs

2016-08-14 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sun Aug 14 11:46:06 UTC 2016

Modified Files:
src/sys/ufs/ext2fs: ext2fs_lookup.c

Log Message:
when converting on-disk direntry, only use the on-disk filetype if the feature 
flag is present


To generate a diff of this commit:
cvs rdiff -u -r1.85 -r1.86 src/sys/ufs/ext2fs/ext2fs_lookup.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/ufs/ext2fs/ext2fs_lookup.c
diff -u src/sys/ufs/ext2fs/ext2fs_lookup.c:1.85 src/sys/ufs/ext2fs/ext2fs_lookup.c:1.86
--- src/sys/ufs/ext2fs/ext2fs_lookup.c:1.85	Sun Aug 14 11:44:54 2016
+++ src/sys/ufs/ext2fs/ext2fs_lookup.c	Sun Aug 14 11:46:05 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_lookup.c,v 1.85 2016/08/14 11:44:54 jdolecek Exp $	*/
+/*	$NetBSD: ext2fs_lookup.c,v 1.86 2016/08/14 11:46:05 jdolecek Exp $	*/
 
 /*
  * Modified for NetBSD 1.2E
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_lookup.c,v 1.85 2016/08/14 11:44:54 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_lookup.c,v 1.86 2016/08/14 11:46:05 jdolecek Exp $");
 
 #include 
 #include 
@@ -76,7 +76,8 @@ __KERNEL_RCSID(0, "$NetBSD: ext2fs_looku
 
 extern	int dirchk;
 
-static void	ext2fs_dirconv2ffs(struct ext2fs_direct *e2dir,
+static void	ext2fs_dirconv2ffs(struct m_ext2fs *fs,
+	  struct ext2fs_direct *e2dir,
 	  struct dirent *ffsdir);
 static int	ext2fs_dirbadentry(struct vnode *dp,
 	  struct ext2fs_direct *de,
@@ -93,13 +94,16 @@ static int	ext2fs_dirbadentry(struct vno
  * have worked w/o changes (except for the difference in DIRBLKSIZ)
  */
 static void
-ext2fs_dirconv2ffs(struct ext2fs_direct *e2dir, struct dirent *ffsdir)
+ext2fs_dirconv2ffs(struct m_ext2fs *fs, struct ext2fs_direct *e2dir, struct dirent *ffsdir)
 {
 	memset(ffsdir, 0, sizeof(struct dirent));
 	ffsdir->d_fileno = fs2h32(e2dir->e2d_ino);
 	ffsdir->d_namlen = e2dir->e2d_namlen;
 
-	ffsdir->d_type = ext2dt2dt(e2dir->e2d_type);
+	if (EXT2F_HAS_INCOMPAT_FEATURE(fs, EXT2F_INCOMPAT_FTYPE))
+		ffsdir->d_type = ext2dt2dt(e2dir->e2d_type);
+	else
+		ffsdir->d_type = DT_UNKNOWN;
 
 #ifdef DIAGNOSTIC
 #if MAXNAMLEN < E2FS_MAXNAMLEN
@@ -199,7 +203,7 @@ ext2fs_readdir(void *v)
 error = EIO;
 break;
 			}
-			ext2fs_dirconv2ffs(dp, dstd);
+			ext2fs_dirconv2ffs(fs, dp, dstd);
 			if(dstd->d_reclen > uio->uio_resid) {
 break;
 			}



CVS commit: src/sys/ufs/ext2fs

2016-08-14 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sun Aug 14 11:44:54 UTC 2016

Modified Files:
src/sys/ufs/ext2fs: ext2fs_inode.c ext2fs_lookup.c ext2fs_vfsops.c
ext2fs_vnops.c

Log Message:
switch code to use the EXT2_HAS_{COMPAT|ROCOMPAT|INCOMPAT}_FEATURE() macros 
instead of open coding the checks


To generate a diff of this commit:
cvs rdiff -u -r1.85 -r1.86 src/sys/ufs/ext2fs/ext2fs_inode.c
cvs rdiff -u -r1.84 -r1.85 src/sys/ufs/ext2fs/ext2fs_lookup.c
cvs rdiff -u -r1.198 -r1.199 src/sys/ufs/ext2fs/ext2fs_vfsops.c
cvs rdiff -u -r1.122 -r1.123 src/sys/ufs/ext2fs/ext2fs_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/ufs/ext2fs/ext2fs_inode.c
diff -u src/sys/ufs/ext2fs/ext2fs_inode.c:1.85 src/sys/ufs/ext2fs/ext2fs_inode.c:1.86
--- src/sys/ufs/ext2fs/ext2fs_inode.c:1.85	Sat Aug 13 07:40:10 2016
+++ src/sys/ufs/ext2fs/ext2fs_inode.c	Sun Aug 14 11:44:54 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_inode.c,v 1.85 2016/08/13 07:40:10 christos Exp $	*/
+/*	$NetBSD: ext2fs_inode.c,v 1.86 2016/08/14 11:44:54 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_inode.c,v 1.85 2016/08/13 07:40:10 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_inode.c,v 1.86 2016/08/14 11:44:54 jdolecek Exp $");
 
 #include 
 #include 
@@ -121,8 +121,8 @@ ext2fs_setsize(struct inode *ip, uint64_
 /* Linux automagically upgrades to REV1 here! */
 return EFBIG;
 			}
-			if (!(fs->e2fs.e2fs_features_rocompat
-			& EXT2F_ROCOMPAT_LARGEFILE)) {
+			if (!EXT2F_HAS_ROCOMPAT_FEATURE(fs,
+			EXT2F_ROCOMPAT_LARGEFILE)) {
 fs->e2fs.e2fs_features_rocompat |=
 EXT2F_ROCOMPAT_LARGEFILE;
 fs->e2fs_fmod = 1;
@@ -142,7 +142,7 @@ ext2fs_nblock(struct inode *ip)
 	uint64_t nblock = ip->i_e2fs_nblock;
 	struct m_ext2fs * const fs = ip->i_e2fs;
 
-	if (fs->e2fs.e2fs_features_rocompat & EXT2F_ROCOMPAT_HUGE_FILE) {
+	if (EXT2F_HAS_ROCOMPAT_FEATURE(fs, EXT2F_ROCOMPAT_HUGE_FILE)) {
 		nblock |= (uint64_t)ip->i_e2fs_nblock_high << 32;
 
 		if ((ip->i_e2fs_flags & EXT2_HUGE_FILE)) {
@@ -164,7 +164,7 @@ ext2fs_setnblock(struct inode *ip, uint6
 		return 0;
 	}
 
-	if (!ISSET(fs->e2fs.e2fs_features_rocompat, EXT2F_ROCOMPAT_HUGE_FILE)) 
+	if (!EXT2F_HAS_ROCOMPAT_FEATURE(fs, EXT2F_ROCOMPAT_HUGE_FILE)) 
 		return EFBIG;
 
 	if (nblock <= 0xULL) {

Index: src/sys/ufs/ext2fs/ext2fs_lookup.c
diff -u src/sys/ufs/ext2fs/ext2fs_lookup.c:1.84 src/sys/ufs/ext2fs/ext2fs_lookup.c:1.85
--- src/sys/ufs/ext2fs/ext2fs_lookup.c:1.84	Sat Aug 13 07:40:10 2016
+++ src/sys/ufs/ext2fs/ext2fs_lookup.c	Sun Aug 14 11:44:54 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_lookup.c,v 1.84 2016/08/13 07:40:10 christos Exp $	*/
+/*	$NetBSD: ext2fs_lookup.c,v 1.85 2016/08/14 11:44:54 jdolecek Exp $	*/
 
 /*
  * Modified for NetBSD 1.2E
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_lookup.c,v 1.84 2016/08/13 07:40:10 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_lookup.c,v 1.85 2016/08/14 11:44:54 jdolecek Exp $");
 
 #include 
 #include 
@@ -884,8 +884,7 @@ ext2fs_direnter(struct inode *ip, struct
 
 	newdir.e2d_ino = h2fs32(ip->i_number);
 	newdir.e2d_namlen = cnp->cn_namelen;
-	if (ip->i_e2fs->e2fs.e2fs_rev > E2FS_REV0 &&
-	(ip->i_e2fs->e2fs.e2fs_features_incompat & EXT2F_INCOMPAT_FTYPE)) {
+	if (EXT2F_HAS_INCOMPAT_FEATURE(ip->i_e2fs, EXT2F_INCOMPAT_FTYPE)) {
 		newdir.e2d_type = inot2ext2dt(IFTODT(ip->i_e2fs_mode));
 	} else {
 		newdir.e2d_type = 0;
@@ -1099,8 +1098,7 @@ ext2fs_dirrewrite(struct inode *dp, cons
 	if (error != 0)
 		return error;
 	ep->e2d_ino = h2fs32(ip->i_number);
-	if (ip->i_e2fs->e2fs.e2fs_rev > E2FS_REV0 &&
-	(ip->i_e2fs->e2fs.e2fs_features_incompat & EXT2F_INCOMPAT_FTYPE)) {
+	if (EXT2F_HAS_INCOMPAT_FEATURE(dp->i_e2fs, EXT2F_INCOMPAT_FTYPE)) {
 		ep->e2d_type = inot2ext2dt(IFTODT(ip->i_e2fs_mode));
 	} else {
 		ep->e2d_type = 0;

Index: src/sys/ufs/ext2fs/ext2fs_vfsops.c
diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.198 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.199
--- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.198	Sat Aug 13 07:40:10 2016
+++ src/sys/ufs/ext2fs/ext2fs_vfsops.c	Sun Aug 14 11:44:54 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_vfsops.c,v 1.198 2016/08/13 07:40:10 christos Exp $	*/
+/*	$NetBSD: ext2fs_vfsops.c,v 1.199 2016/08/14 11:44:54 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1994
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.198 2016/08/13 07:40:10 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.199 2016/08/14 11:44:54 jdolecek Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -834,8 +834,7 @@ ext2fs_statvfs(struct mount *mp, struct 
 	fs->e2fs_itpg;
 	overhead = fs->e2fs.e2fs_first_dblock +
 	fs->e2fs_ncg * overhead_per_group;
-	if (fs->e2fs.e2fs_rev > 

CVS commit: src/sys/ufs/ext2fs

2016-08-14 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sun Aug 14 11:42:50 UTC 2016

Modified Files:
src/sys/ufs/ext2fs: ext2fs.h ext2fs_htree.c

Log Message:
switch ext2fs_htree_has_idx() over to EXT2F_HAS_COMPAT_FEATURE() and remove 
EXT2F_HAS_COMPAT_FEATURE() - this also fixes it for BE machines, as 
EXT2F_HAS_COMPAT_FEATURE() did extra byte swap; also remove XXX comment about 
IN_E3INDEX


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/ufs/ext2fs/ext2fs.h
cvs rdiff -u -r1.5 -r1.6 src/sys/ufs/ext2fs/ext2fs_htree.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/ufs/ext2fs/ext2fs.h
diff -u src/sys/ufs/ext2fs/ext2fs.h:1.44 src/sys/ufs/ext2fs/ext2fs.h:1.45
--- src/sys/ufs/ext2fs/ext2fs.h:1.44	Sun Aug 14 11:40:31 2016
+++ src/sys/ufs/ext2fs/ext2fs.h	Sun Aug 14 11:42:50 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs.h,v 1.44 2016/08/14 11:40:31 jdolecek Exp $	*/
+/*	$NetBSD: ext2fs.h,v 1.45 2016/08/14 11:42:50 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -365,8 +365,6 @@ struct m_ext2fs {
 /*
  * Feature set definitions
  */
-#define EXT2_HAS_COMPAT_FEATURE(sb, mask) \
-((sb)->e2fs.e2fs_features_compat & htole32(mask))
 #define EXT2F_HAS_COMPAT_FEATURE(fs, feature) \
 	((fs)->e2fs.e2fs_rev >= E2FS_REV1 && \
 	((fs)->e2fs.e2fs_features_compat & (feature)) != 0)

Index: src/sys/ufs/ext2fs/ext2fs_htree.c
diff -u src/sys/ufs/ext2fs/ext2fs_htree.c:1.5 src/sys/ufs/ext2fs/ext2fs_htree.c:1.6
--- src/sys/ufs/ext2fs/ext2fs_htree.c:1.5	Sat Aug 13 07:40:10 2016
+++ src/sys/ufs/ext2fs/ext2fs_htree.c	Sun Aug 14 11:42:50 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_htree.c,v 1.5 2016/08/13 07:40:10 christos Exp $	*/
+/*	$NetBSD: ext2fs_htree.c,v 1.6 2016/08/14 11:42:50 jdolecek Exp $	*/
 
 /*-
  * Copyright (c) 2010, 2012 Zheng Liu 
@@ -29,7 +29,7 @@
  * $FreeBSD: head/sys/fs/ext2fs/ext2fs_htree.c 294653 2016-01-24 02:41:49Z pfg $
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_htree.c,v 1.5 2016/08/13 07:40:10 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_htree.c,v 1.6 2016/08/14 11:42:50 jdolecek Exp $");
 
 #include 
 #include 
@@ -65,8 +65,7 @@ static int ext2fs_htree_find_leaf(struct
 int
 ext2fs_htree_has_idx(struct inode *ip)
 {
-	/* XXX ip->i_flags should have got checked here for IN_E3INDEX */
-	return EXT2_HAS_COMPAT_FEATURE(ip->i_e2fs, EXT2F_COMPAT_DIRHASHINDEX)
+	return EXT2F_HAS_COMPAT_FEATURE(ip->i_e2fs, EXT2F_COMPAT_DIRHASHINDEX)
 	&& (ip->i_din.e2fs_din->e2di_flags & EXT2_INDEX);
 }
 



CVS commit: src/sys/ufs/ext2fs

2016-08-14 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sun Aug 14 11:40:31 UTC 2016

Modified Files:
src/sys/ufs/ext2fs: ext2fs.h ext2fs_xattr.c

Log Message:
add EXT2F_HAS_ROCOMPAT_FEATURE() macro, and change the current 
EXT2F_HAS_{COMPAT|INCOMPAT}_FEATURE() to take fs as first parameter


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/ufs/ext2fs/ext2fs.h
cvs rdiff -u -r1.2 -r1.3 src/sys/ufs/ext2fs/ext2fs_xattr.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/ufs/ext2fs/ext2fs.h
diff -u src/sys/ufs/ext2fs/ext2fs.h:1.43 src/sys/ufs/ext2fs/ext2fs.h:1.44
--- src/sys/ufs/ext2fs/ext2fs.h:1.43	Fri Aug 12 20:26:15 2016
+++ src/sys/ufs/ext2fs/ext2fs.h	Sun Aug 14 11:40:31 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs.h,v 1.43 2016/08/12 20:26:15 macallan Exp $	*/
+/*	$NetBSD: ext2fs.h,v 1.44 2016/08/14 11:40:31 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -341,14 +341,6 @@ struct m_ext2fs {
 	"\02INCOMPAT_FTYPE" \
 	"\01INCOMPAT_COMP"
 
-#define EXT2F_HAS_COMPAT_FEATURE(ip, feature) \
-	((ip)->i_e2fs->e2fs.e2fs_rev >= E2FS_REV1 && \
-	((ip)->i_e2fs->e2fs.e2fs_features_compat & (feature)) != 0)
-
-#define EXT2F_HAS_INCOMPAT_FEATURE(ip, feature) \
-	((ip)->i_e2fs->e2fs.e2fs_rev >= E2FS_REV1 && \
-	((ip)->i_e2fs->e2fs.e2fs_features_incompat & (feature)) != 0)
-
 /*
  * Features supported in this implementation
  *
@@ -375,6 +367,18 @@ struct m_ext2fs {
  */
 #define EXT2_HAS_COMPAT_FEATURE(sb, mask) \
 ((sb)->e2fs.e2fs_features_compat & htole32(mask))
+#define EXT2F_HAS_COMPAT_FEATURE(fs, feature) \
+	((fs)->e2fs.e2fs_rev >= E2FS_REV1 && \
+	((fs)->e2fs.e2fs_features_compat & (feature)) != 0)
+
+#define EXT2F_HAS_ROCOMPAT_FEATURE(fs, feature) \
+	((fs)->e2fs.e2fs_rev >= E2FS_REV1 && \
+	((fs)->e2fs.e2fs_features_rocompat & (feature)) != 0)
+
+#define EXT2F_HAS_INCOMPAT_FEATURE(fs, feature) \
+	((fs)->e2fs.e2fs_rev >= E2FS_REV1 && \
+	((fs)->e2fs.e2fs_features_incompat & (feature)) != 0)
+
 
 /*
  * Definitions of behavior on errors

Index: src/sys/ufs/ext2fs/ext2fs_xattr.c
diff -u src/sys/ufs/ext2fs/ext2fs_xattr.c:1.2 src/sys/ufs/ext2fs/ext2fs_xattr.c:1.3
--- src/sys/ufs/ext2fs/ext2fs_xattr.c:1.2	Sat Aug 13 07:40:10 2016
+++ src/sys/ufs/ext2fs/ext2fs_xattr.c	Sun Aug 14 11:40:31 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_xattr.c,v 1.2 2016/08/13 07:40:10 christos Exp $	*/
+/*	$NetBSD: ext2fs_xattr.c,v 1.3 2016/08/14 11:40:31 jdolecek Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_xattr.c,v 1.2 2016/08/13 07:40:10 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_xattr.c,v 1.3 2016/08/14 11:40:31 jdolecek Exp $");
 
 #include 
 #include 
@@ -158,7 +158,7 @@ ext2fs_get_block_xattr(struct inode *ip,
 	daddr_t xblk;
 
 	xblk = di->e2di_facl;
-	if (EXT2F_HAS_INCOMPAT_FEATURE(ip, EXT2F_INCOMPAT_64BIT))
+	if (EXT2F_HAS_INCOMPAT_FEATURE(ip->i_e2fs, EXT2F_INCOMPAT_64BIT))
 		xblk |= (((daddr_t)di->e2di_facl_high) << 32);
 
 	/* don't do anything if no attr block was allocated */
@@ -348,7 +348,7 @@ ext2fs_list_block_xattr(struct inode *ip
 	daddr_t xblk;
 
 	xblk = di->e2di_facl;
-	if (EXT2F_HAS_INCOMPAT_FEATURE(ip, EXT2F_INCOMPAT_64BIT))
+	if (EXT2F_HAS_INCOMPAT_FEATURE(ip->i_e2fs, EXT2F_INCOMPAT_64BIT))
 		xblk |= (((daddr_t)di->e2di_facl_high) << 32);
 
 	/* don't do anything if no attr block was allocated */
@@ -390,7 +390,7 @@ ext2fs_listextattr(void *v)
 	const char *prefix;
 	size_t listsize = 0;
 
-	if (!EXT2F_HAS_COMPAT_FEATURE(ip, EXT2F_COMPAT_EXTATTR)) {
+	if (!EXT2F_HAS_COMPAT_FEATURE(ip->i_e2fs, EXT2F_COMPAT_EXTATTR)) {
 		/* no EA on the filesystem */
 		goto out;
 	}



CVS commit: src/sys/ufs/ufs

2016-08-14 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sun Aug 14 11:31:41 UTC 2016

Modified Files:
src/sys/ufs/ufs: inode.h

Log Message:
again remove IN_E4EXTENTS; it's not used anywhere any more, and it's better to 
keep fs-specific flags out of generic headers anyway


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/sys/ufs/ufs/inode.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/ufs/ufs/inode.h
diff -u src/sys/ufs/ufs/inode.h:1.74 src/sys/ufs/ufs/inode.h:1.75
--- src/sys/ufs/ufs/inode.h:1.74	Thu Aug  4 17:47:47 2016
+++ src/sys/ufs/ufs/inode.h	Sun Aug 14 11:31:41 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: inode.h,v 1.74 2016/08/04 17:47:47 jdolecek Exp $	*/
+/*	$NetBSD: inode.h,v 1.75 2016/08/14 11:31:41 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1982, 1989, 1993
@@ -226,7 +226,6 @@ struct inode {
 /*	   unused   0x1000 */	/* was LFS-only IN_PAGING */
 #define	IN_MODIFY	0x2000		/* Modification time update request. */
 /*	   unused	0x4000 */	/* was LFS-only IN_CDIROP */
-#define	IN_E4EXTENTS0x8000		/* ext4 extents */
 
 #if defined(_KERNEL)
 



CVS commit: src/sys/ufs/ext2fs

2016-08-14 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sun Aug 14 11:26:35 UTC 2016

Modified Files:
src/sys/ufs/ext2fs: ext2fs_bmap.c

Log Message:
whitespace cleanup


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/ufs/ext2fs/ext2fs_bmap.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/ufs/ext2fs/ext2fs_bmap.c
diff -u src/sys/ufs/ext2fs/ext2fs_bmap.c:1.29 src/sys/ufs/ext2fs/ext2fs_bmap.c:1.30
--- src/sys/ufs/ext2fs/ext2fs_bmap.c:1.29	Sun Aug 14 11:25:36 2016
+++ src/sys/ufs/ext2fs/ext2fs_bmap.c	Sun Aug 14 11:26:35 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_bmap.c,v 1.29 2016/08/14 11:25:36 jdolecek Exp $	*/
+/*	$NetBSD: ext2fs_bmap.c,v 1.30 2016/08/14 11:26:35 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993
@@ -65,7 +65,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_bmap.c,v 1.29 2016/08/14 11:25:36 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_bmap.c,v 1.30 2016/08/14 11:26:35 jdolecek Exp $");
 
 #include 
 #include 
@@ -106,6 +106,7 @@ ext2fs_bmap(void *v)
 		daddr_t *a_bnp;
 		int *a_runp;
 	} */ *ap = v;
+
 	/*
 	 * Check for underlying vnode requests and ensure that logical
 	 * to physical mapping is requested.
@@ -114,16 +115,13 @@ ext2fs_bmap(void *v)
 		*ap->a_vpp = VTOI(ap->a_vp)->i_devvp;
 	if (ap->a_bnp == NULL)
 		return 0;
-	
-	
+
 	if (VTOI(ap->a_vp)->i_din.e2fs_din->e2di_flags & EXT2_EXTENTS)
 		return ext4_bmapext(ap->a_vp, ap->a_bn, ap->a_bnp,
 		ap->a_runp, NULL);
 	else
 		return ext2fs_bmaparray(ap->a_vp, ap->a_bn, ap->a_bnp, NULL,
 		NULL, ap->a_runp);
-	
-		
 }
 
 /*



CVS commit: src/sys/ufs/ext2fs

2016-08-14 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Sun Aug 14 11:25:36 UTC 2016

Modified Files:
src/sys/ufs/ext2fs: ext2fs_bmap.c

Log Message:
check correct inode extents flag - IN_E4EXTENTS is defined as 0x8000, correct 
flag EXT2_EXTENTS is 0x8


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/ufs/ext2fs/ext2fs_bmap.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/ufs/ext2fs/ext2fs_bmap.c
diff -u src/sys/ufs/ext2fs/ext2fs_bmap.c:1.28 src/sys/ufs/ext2fs/ext2fs_bmap.c:1.29
--- src/sys/ufs/ext2fs/ext2fs_bmap.c:1.28	Sat Aug 13 07:40:10 2016
+++ src/sys/ufs/ext2fs/ext2fs_bmap.c	Sun Aug 14 11:25:36 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_bmap.c,v 1.28 2016/08/13 07:40:10 christos Exp $	*/
+/*	$NetBSD: ext2fs_bmap.c,v 1.29 2016/08/14 11:25:36 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993
@@ -65,7 +65,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_bmap.c,v 1.28 2016/08/13 07:40:10 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_bmap.c,v 1.29 2016/08/14 11:25:36 jdolecek Exp $");
 
 #include 
 #include 
@@ -116,7 +116,7 @@ ext2fs_bmap(void *v)
 		return 0;
 	
 	
-	if (VTOI(ap->a_vp)->i_din.e2fs_din->e2di_flags & IN_E4EXTENTS)
+	if (VTOI(ap->a_vp)->i_din.e2fs_din->e2di_flags & EXT2_EXTENTS)
 		return ext4_bmapext(ap->a_vp, ap->a_bn, ap->a_bnp,
 		ap->a_runp, NULL);
 	else



CVS commit: src/sys/ufs/ext2fs

2016-08-13 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Aug 13 07:40:10 UTC 2016

Modified Files:
src/sys/ufs/ext2fs: ext2fs_alloc.c ext2fs_balloc.c ext2fs_bmap.c
ext2fs_extents.c ext2fs_hash.c ext2fs_htree.c ext2fs_inode.c
ext2fs_lookup.c ext2fs_readwrite.c ext2fs_rename.c ext2fs_subr.c
ext2fs_vfsops.c ext2fs_vnops.c ext2fs_xattr.c

Log Message:
KNF, no functional changes...


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/ufs/ext2fs/ext2fs_alloc.c
cvs rdiff -u -r1.40 -r1.41 src/sys/ufs/ext2fs/ext2fs_balloc.c
cvs rdiff -u -r1.27 -r1.28 src/sys/ufs/ext2fs/ext2fs_bmap.c
cvs rdiff -u -r1.2 -r1.3 src/sys/ufs/ext2fs/ext2fs_extents.c
cvs rdiff -u -r1.1 -r1.2 src/sys/ufs/ext2fs/ext2fs_hash.c \
src/sys/ufs/ext2fs/ext2fs_xattr.c
cvs rdiff -u -r1.4 -r1.5 src/sys/ufs/ext2fs/ext2fs_htree.c
cvs rdiff -u -r1.84 -r1.85 src/sys/ufs/ext2fs/ext2fs_inode.c
cvs rdiff -u -r1.83 -r1.84 src/sys/ufs/ext2fs/ext2fs_lookup.c
cvs rdiff -u -r1.74 -r1.75 src/sys/ufs/ext2fs/ext2fs_readwrite.c
cvs rdiff -u -r1.9 -r1.10 src/sys/ufs/ext2fs/ext2fs_rename.c
cvs rdiff -u -r1.32 -r1.33 src/sys/ufs/ext2fs/ext2fs_subr.c
cvs rdiff -u -r1.197 -r1.198 src/sys/ufs/ext2fs/ext2fs_vfsops.c
cvs rdiff -u -r1.121 -r1.122 src/sys/ufs/ext2fs/ext2fs_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/ufs/ext2fs/ext2fs_alloc.c
diff -u src/sys/ufs/ext2fs/ext2fs_alloc.c:1.47 src/sys/ufs/ext2fs/ext2fs_alloc.c:1.48
--- src/sys/ufs/ext2fs/ext2fs_alloc.c:1.47	Wed Aug  3 17:53:02 2016
+++ src/sys/ufs/ext2fs/ext2fs_alloc.c	Sat Aug 13 03:40:10 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_alloc.c,v 1.47 2016/08/03 21:53:02 jdolecek Exp $	*/
+/*	$NetBSD: ext2fs_alloc.c,v 1.48 2016/08/13 07:40:10 christos Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_alloc.c,v 1.47 2016/08/03 21:53:02 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_alloc.c,v 1.48 2016/08/13 07:40:10 christos Exp $");
 
 #include 
 #include 
@@ -138,12 +138,12 @@ ext2fs_alloc(struct inode *ip, daddr_t l
 		ext2fs_setnblock(ip, ext2fs_nblock(ip) + btodb(fs->e2fs_bsize));
 		ip->i_flag |= IN_CHANGE | IN_UPDATE;
 		*bnp = bno;
-		return (0);
+		return 0;
 	}
 nospace:
 	ext2fs_fserr(fs, kauth_cred_geteuid(cred), "file system full");
 	uprintf("\n%s: write failed, file system is full\n", fs->e2fs_fsmnt);
-	return (ENOSPC);
+	return ENOSPC;
 }
 
 /*
@@ -188,7 +188,7 @@ ext2fs_valloc(struct vnode *pvp, int mod
 	error = VFS_VGET(pvp->v_mount, ino, vpp);
 	if (error) {
 		ext2fs_vfree(pvp, ino, mode);
-		return (error);
+		return error;
 	}
 	ip = VTOI(*vpp);
 	if (ip->i_e2fs_mode && ip->i_e2fs_nlink != 0) {
@@ -206,11 +206,11 @@ ext2fs_valloc(struct vnode *pvp, int mod
 	if (++ext2gennumber < time_second)
 		ext2gennumber = time_second;
 	ip->i_e2fs_gen = ext2gennumber;
-	return (0);
+	return 0;
 noinodes:
 	ext2fs_fserr(fs, kauth_cred_geteuid(cred), "out of inodes");
 	uprintf("\n%s: create/symlink failed, no inodes free\n", fs->e2fs_fsmnt);
-	return (ENOSPC);
+	return ENOSPC;
 }
 
 /*
@@ -307,7 +307,7 @@ ext2fs_hashalloc(struct inode *ip, int c
 	 */
 	result = (*allocator)(ip, cg, pref, size);
 	if (result)
-		return (result);
+		return result;
 	/*
 	 * 2: quadratic rehash
 	 */
@@ -317,7 +317,7 @@ ext2fs_hashalloc(struct inode *ip, int c
 			cg -= fs->e2fs_ncg;
 		result = (*allocator)(ip, cg, 0, size);
 		if (result)
-			return (result);
+			return result;
 	}
 	/*
 	 * 3: brute force search
@@ -328,12 +328,12 @@ ext2fs_hashalloc(struct inode *ip, int c
 	for (i = 2; i < fs->e2fs_ncg; i++) {
 		result = (*allocator)(ip, cg, 0, size);
 		if (result)
-			return (result);
+			return result;
 		cg++;
 		if (cg == fs->e2fs_ncg)
 			cg = 0;
 	}
-	return (0);
+	return 0;
 }
 
 /*
@@ -354,12 +354,12 @@ ext2fs_alloccg(struct inode *ip, int cg,
 
 	fs = ip->i_e2fs;
 	if (fs->e2fs_gd[cg].ext2bgd_nbfree == 0)
-		return (0);
+		return 0;
 	error = bread(ip->i_devvp, EXT2_FSBTODB(fs,
 		fs->e2fs_gd[cg].ext2bgd_b_bitmap),
 		(int)fs->e2fs_bsize, B_MODIFY, );
 	if (error) {
-		return (0);
+		return 0;
 	}
 	bbp = (char *)bp->b_data;
 
@@ -401,7 +401,7 @@ ext2fs_alloccg(struct inode *ip, int cg,
 
 	bno = ext2fs_mapsearch(fs, bbp, bpref);
 	if (bno < 0)
-		return (0);
+		return 0;
 gotit:
 #ifdef DIAGNOSTIC
 	if (isset(bbp, (daddr_t)bno)) {
@@ -415,7 +415,7 @@ gotit:
 	fs->e2fs_gd[cg].ext2bgd_nbfree--;
 	fs->e2fs_fmod = 1;
 	bdwrite(bp);
-	return (cg * fs->e2fs.e2fs_fpg + fs->e2fs.e2fs_first_dblock + bno);
+	return cg * fs->e2fs.e2fs_fpg + fs->e2fs.e2fs_first_dblock + bno;
 }
 
 /*
@@ -440,12 +440,12 @@ ext2fs_nodealloccg(struct inode *ip, int
 		ipref = 0;
 	fs = ip->i_e2fs;
 	if (fs->e2fs_gd[cg].ext2bgd_nifree == 0)
-		return (0);
+		return 0;
 	error = bread(ip->i_devvp, EXT2_FSBTODB(fs,
 		fs->e2fs_gd[cg].ext2bgd_i_bitmap),
 		(int)fs->e2fs_bsize, 

CVS commit: src/sys/ufs/ext2fs

2016-08-13 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Aug 13 07:25:29 UTC 2016

Modified Files:
src/sys/ufs/ext2fs: ext2fs_lookup.c

Log Message:
sync with hrishi's git


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/sys/ufs/ext2fs/ext2fs_lookup.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/ufs/ext2fs/ext2fs_lookup.c
diff -u src/sys/ufs/ext2fs/ext2fs_lookup.c:1.82 src/sys/ufs/ext2fs/ext2fs_lookup.c:1.83
--- src/sys/ufs/ext2fs/ext2fs_lookup.c:1.82	Tue Aug  9 16:18:08 2016
+++ src/sys/ufs/ext2fs/ext2fs_lookup.c	Sat Aug 13 03:25:29 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_lookup.c,v 1.82 2016/08/09 20:18:08 christos Exp $	*/
+/*	$NetBSD: ext2fs_lookup.c,v 1.83 2016/08/13 07:25:29 christos Exp $	*/
 
 /*
  * Modified for NetBSD 1.2E
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_lookup.c,v 1.82 2016/08/09 20:18:08 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_lookup.c,v 1.83 2016/08/13 07:25:29 christos Exp $");
 
 #include 
 #include 
@@ -389,7 +389,7 @@ ext2fs_lookup(void *v)
 	 * If we got an error or we want to find '.' or '..' entry,
 	 * we will fall back to linear search.
 	 */
-	if (ext2fs_htree_has_idx(dp) && ext2fs_is_dot_entry(cnp)) {
+	if (!ext2fs_is_dot_entry(cnp) && ext2fs_htree_has_idx(dp)) {
 		numdirpasses = 1;
 		entryoffsetinblock = 0;
 		
@@ -707,6 +707,37 @@ found:
 	cache_enter(vdp, *vpp, cnp->cn_nameptr, cnp->cn_namelen, cnp->cn_flags);
 	return 0;
 }
+static void
+ext2fs_accumulatespace (struct ext2fs_searchslot *ssp, struct ext2fs_direct *ep,
+doff_t *offp) 
+{
+	int size = ep->e2d_reclen;
+
+	if (ep->e2d_ino != 0)
+		size -= EXT2_DIR_REC_LEN(ep->e2d_namlen);
+
+	if (size <= 0)
+		return;
+
+	if (size >= ssp->slotneeded) {
+		ssp->slotstatus = FOUND;
+		ssp->slotoffset = *offp;
+		ssp->slotsize = ep->e2d_reclen;
+		return;
+	}
+
+	if (ssp->slotstatus != NONE)
+		return;
+
+	ssp->slotfreespace += size;
+	if (ssp->slotoffset == -1)
+		ssp->slotoffset = *offp;
+
+	if (ssp->slotfreespace >= ssp->slotneeded) {
+		ssp->slotstatus = COMPACT;
+		ssp->slotsize = *offp + ep->e2d_reclen - ssp->slotoffset;
+	}
+}
 
 int
 ext2fs_search_dirblock(struct inode *ip, void *data, int *foundp,
@@ -746,26 +777,8 @@ ext2fs_search_dirblock(struct inode *ip,
 		 * in the current block so that we can determine if
 		 * compaction is viable.
 		 */
-		if (ssp->slotstatus != FOUND) {
-			int size = ep->e2d_reclen;
-
-			if (ep->e2d_ino != 0)
-size -= EXT2_DIR_REC_LEN(ep->e2d_namlen);
-			if (size >= ssp->slotneeded) {
-ssp->slotstatus = FOUND;
-ssp->slotoffset = *offp;
-ssp->slotsize = ep->e2d_reclen;
-			} else if (size > 0 && ssp->slotstatus == NONE) {
-ssp->slotfreespace += size;
-if (ssp->slotoffset == -1)
-	ssp->slotoffset = *offp;
-if (ssp->slotfreespace >= ssp->slotneeded) {
-	ssp->slotstatus = COMPACT;
-	ssp->slotsize = *offp + ep->e2d_reclen -
-	ssp->slotoffset;
-}
-			}
-		}
+		if (ssp->slotstatus != FOUND)
+			ext2fs_accumulatespace(ssp, ep, offp);
 
 		/*
 		 * Check for a name match.



CVS commit: src/sys/ufs/ext2fs

2016-08-12 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Aug 12 20:30:15 UTC 2016

Modified Files:
src/sys/ufs/ext2fs: ext2fs_xattr.h

Log Message:
cast pointers to uintptr_t before comparing them, also ()s
now this at least compiles


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/ufs/ext2fs/ext2fs_xattr.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/ufs/ext2fs/ext2fs_xattr.h
diff -u src/sys/ufs/ext2fs/ext2fs_xattr.h:1.1 src/sys/ufs/ext2fs/ext2fs_xattr.h:1.2
--- src/sys/ufs/ext2fs/ext2fs_xattr.h:1.1	Fri Aug 12 19:04:03 2016
+++ src/sys/ufs/ext2fs/ext2fs_xattr.h	Fri Aug 12 20:30:15 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_xattr.h,v 1.1 2016/08/12 19:04:03 jdolecek Exp $	*/
+/*	$NetBSD: ext2fs_xattr.h,v 1.2 2016/08/12 20:30:15 macallan Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
 #define _UFS_EXT2FS_EXT2FS_XATTR_H_
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_xattr.h,v 1.1 2016/08/12 19:04:03 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_xattr.h,v 1.2 2016/08/12 20:30:15 macallan Exp $");
 
 #ifdef _KERNEL
 
@@ -79,7 +79,7 @@ struct ext2fs_xattr_entry {
  * doesn't overflow past end.
  */
 #define EXT2FS_XATTR_IS_LAST_ENTRY(entry, end) \
-	*((uint32_t *)(entry)) == 0 || EXT2FS_XATTR_NEXT(entry) > end
+	(*((uint32_t *)(entry)) == 0 || (uintptr_t)EXT2FS_XATTR_NEXT(entry) > (uintptr_t)end)
 
 /*
  * Each ext2fs_xattr_entry starts on next 4-byte boundary, pad if necessary.



CVS commit: src/sys/ufs/ext2fs

2016-08-12 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Aug 12 20:26:15 UTC 2016

Modified Files:
src/sys/ufs/ext2fs: ext2fs.h

Log Message:
sprinkle ()s in macros with comparisons, shuts up compiler warnings


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/ufs/ext2fs/ext2fs.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/ufs/ext2fs/ext2fs.h
diff -u src/sys/ufs/ext2fs/ext2fs.h:1.42 src/sys/ufs/ext2fs/ext2fs.h:1.43
--- src/sys/ufs/ext2fs/ext2fs.h:1.42	Fri Aug 12 19:04:03 2016
+++ src/sys/ufs/ext2fs/ext2fs.h	Fri Aug 12 20:26:15 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs.h,v 1.42 2016/08/12 19:04:03 jdolecek Exp $	*/
+/*	$NetBSD: ext2fs.h,v 1.43 2016/08/12 20:26:15 macallan Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -342,12 +342,12 @@ struct m_ext2fs {
 	"\01INCOMPAT_COMP"
 
 #define EXT2F_HAS_COMPAT_FEATURE(ip, feature) \
-	(ip)->i_e2fs->e2fs.e2fs_rev >= E2FS_REV1 && \
-	((ip)->i_e2fs->e2fs.e2fs_features_compat & (feature)) != 0
+	((ip)->i_e2fs->e2fs.e2fs_rev >= E2FS_REV1 && \
+	((ip)->i_e2fs->e2fs.e2fs_features_compat & (feature)) != 0)
 
 #define EXT2F_HAS_INCOMPAT_FEATURE(ip, feature) \
-	(ip)->i_e2fs->e2fs.e2fs_rev >= E2FS_REV1 && \
-	((ip)->i_e2fs->e2fs.e2fs_features_incompat & (feature)) != 0
+	((ip)->i_e2fs->e2fs.e2fs_rev >= E2FS_REV1 && \
+	((ip)->i_e2fs->e2fs.e2fs_features_incompat & (feature)) != 0)
 
 /*
  * Features supported in this implementation



CVS commit: src/sys/ufs

2016-08-12 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Fri Aug 12 19:04:03 UTC 2016

Modified Files:
src/sys/ufs: files.ufs
src/sys/ufs/ext2fs: ext2fs.h ext2fs_dinode.h ext2fs_vnops.c
Added Files:
src/sys/ufs/ext2fs: ext2fs_xattr.c ext2fs_xattr.h

Log Message:
add support for extended attributes in ext2fs for ext3/ext4; read-only for now


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/ufs/files.ufs
cvs rdiff -u -r1.41 -r1.42 src/sys/ufs/ext2fs/ext2fs.h
cvs rdiff -u -r1.35 -r1.36 src/sys/ufs/ext2fs/ext2fs_dinode.h
cvs rdiff -u -r1.120 -r1.121 src/sys/ufs/ext2fs/ext2fs_vnops.c
cvs rdiff -u -r0 -r1.1 src/sys/ufs/ext2fs/ext2fs_xattr.c \
src/sys/ufs/ext2fs/ext2fs_xattr.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/ufs/files.ufs
diff -u src/sys/ufs/files.ufs:1.42 src/sys/ufs/files.ufs:1.43
--- src/sys/ufs/files.ufs:1.42	Fri Jun 24 17:21:56 2016
+++ src/sys/ufs/files.ufs	Fri Aug 12 19:04:03 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: files.ufs,v 1.42 2016/06/24 17:21:56 christos Exp $
+#	$NetBSD: files.ufs,v 1.43 2016/08/12 19:04:03 jdolecek Exp $
 
 deffs	FFS
 deffs	EXT2FS
@@ -28,6 +28,7 @@ file	ufs/ext2fs/ext2fs_rename.c	ext2fs
 file	ufs/ext2fs/ext2fs_subr.c	ext2fs
 file	ufs/ext2fs/ext2fs_vfsops.c	ext2fs
 file	ufs/ext2fs/ext2fs_vnops.c	ext2fs
+file	ufs/ext2fs/ext2fs_xattr.c	ext2fs
 
 define	chfs: vfs, ffs
 file	ufs/chfs/ebh.c			chfs

Index: src/sys/ufs/ext2fs/ext2fs.h
diff -u src/sys/ufs/ext2fs/ext2fs.h:1.41 src/sys/ufs/ext2fs/ext2fs.h:1.42
--- src/sys/ufs/ext2fs/ext2fs.h:1.41	Fri Aug  5 21:22:06 2016
+++ src/sys/ufs/ext2fs/ext2fs.h	Fri Aug 12 19:04:03 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs.h,v 1.41 2016/08/05 21:22:06 jdolecek Exp $	*/
+/*	$NetBSD: ext2fs.h,v 1.42 2016/08/12 19:04:03 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -341,6 +341,14 @@ struct m_ext2fs {
 	"\02INCOMPAT_FTYPE" \
 	"\01INCOMPAT_COMP"
 
+#define EXT2F_HAS_COMPAT_FEATURE(ip, feature) \
+	(ip)->i_e2fs->e2fs.e2fs_rev >= E2FS_REV1 && \
+	((ip)->i_e2fs->e2fs.e2fs_features_compat & (feature)) != 0
+
+#define EXT2F_HAS_INCOMPAT_FEATURE(ip, feature) \
+	(ip)->i_e2fs->e2fs.e2fs_rev >= E2FS_REV1 && \
+	((ip)->i_e2fs->e2fs.e2fs_features_incompat & (feature)) != 0
+
 /*
  * Features supported in this implementation
  *

Index: src/sys/ufs/ext2fs/ext2fs_dinode.h
diff -u src/sys/ufs/ext2fs/ext2fs_dinode.h:1.35 src/sys/ufs/ext2fs/ext2fs_dinode.h:1.36
--- src/sys/ufs/ext2fs/ext2fs_dinode.h:1.35	Sat Aug  6 09:29:28 2016
+++ src/sys/ufs/ext2fs/ext2fs_dinode.h	Fri Aug 12 19:04:03 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_dinode.h,v 1.35 2016/08/06 09:29:28 jdolecek Exp $	*/
+/*	$NetBSD: ext2fs_dinode.h,v 1.36 2016/08/12 19:04:03 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1982, 1989, 1993
@@ -123,11 +123,11 @@ struct ext2fs_dinode {
 	uint32_t	e2di_blocks[EXT2FS_NDADDR+EXT2FS_NIADDR];
 	/* 40: disk blocks */
 	uint32_t	e2di_gen;	/* 100: generation number */
-	uint32_t	e2di_facl;	/* 104: file ACL (not implemented) (ext3) */
+	uint32_t	e2di_facl;	/* 104: file ACL (ext3) */
 	uint32_t	e2di_size_high;	/* 108: Size (in bytes) high */
 	uint32_t	e2di_obso_faddr;/* 112: obsolete fragment address (ext2) */
 	uint16_t	e2di_nblock_high; /* 116: Blocks count bits 47:32 (ext4) */
-	uint16_t	e2di_facl_high; /* 118: file ACL bits 47:32 (ext4) */
+	uint16_t	e2di_facl_high; /* 118: file ACL bits 47:32 (ext4/64bit) */
 	uint16_t	e2di_uid_high;	/* 120: Owner UID top 16 bits (ext4) */
 	uint16_t	e2di_gid_high;	/* 122: Owner GID top 16 bits (ext4) */
 	uint16_t 	e2di_checksum_low;  /* 124: crc LE (not implemented) (ext4) */

Index: src/sys/ufs/ext2fs/ext2fs_vnops.c
diff -u src/sys/ufs/ext2fs/ext2fs_vnops.c:1.120 src/sys/ufs/ext2fs/ext2fs_vnops.c:1.121
--- src/sys/ufs/ext2fs/ext2fs_vnops.c:1.120	Fri Aug  5 20:15:41 2016
+++ src/sys/ufs/ext2fs/ext2fs_vnops.c	Fri Aug 12 19:04:03 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_vnops.c,v 1.120 2016/08/05 20:15:41 jdolecek Exp $	*/
+/*	$NetBSD: ext2fs_vnops.c,v 1.121 2016/08/12 19:04:03 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -65,7 +65,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.120 2016/08/05 20:15:41 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.121 2016/08/12 19:04:03 jdolecek Exp $");
 
 #include 
 #include 
@@ -94,6 +94,7 @@ __KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops
 #include 
 #include 
 #include 
+#include 
 
 extern int prtactive;
 
@@ -1182,6 +1183,10 @@ const struct vnodeopv_entry_desc ext2fs_
 	{ _bwrite_desc, vn_bwrite },		/* bwrite */
 	{ _getpages_desc, genfs_getpages },		/* getpages */
 	{ _putpages_desc, genfs_putpages },		/* putpages */
+	{ _getextattr_desc, ext2fs_getextattr },	/* getextattr */
+	{ _setextattr_desc, ext2fs_setextattr },	/* setextattr */
+	{ _listextattr_desc, ext2fs_listextattr },	/* listextattr */
+	{ _deleteextattr_desc, ext2fs_deleteextattr },/* 

<    1   2   3   4   5   6   7   8   >