CVS commit: src/sys/ufs/lfs

2021-07-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Jul 25 06:10:01 UTC 2021

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

Log Message:
#include  for COHERENCY_UNIT (and KNF)


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/ufs/lfs/ulfs_quota1_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/ulfs_quota1_subr.c
diff -u src/sys/ufs/lfs/ulfs_quota1_subr.c:1.3 src/sys/ufs/lfs/ulfs_quota1_subr.c:1.4
--- src/sys/ufs/lfs/ulfs_quota1_subr.c:1.3	Thu Jun  6 00:49:28 2013
+++ src/sys/ufs/lfs/ulfs_quota1_subr.c	Sun Jul 25 06:10:01 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ulfs_quota1_subr.c,v 1.3 2013/06/06 00:49:28 dholland Exp $	*/
+/*	$NetBSD: ulfs_quota1_subr.c,v 1.4 2021/07/25 06:10:01 skrll Exp $	*/
 /*  from NetBSD: quota1_subr.c,v 1.7 2012/01/29 06:23:20 dholland Exp  */
 
 /*-
@@ -28,12 +28,12 @@
   */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ulfs_quota1_subr.c,v 1.3 2013/06/06 00:49:28 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ulfs_quota1_subr.c,v 1.4 2021/07/25 06:10:01 skrll Exp $");
 
+#include 
 #include 
-#include 
-
 #include 
+
 #include 
 
 static uint64_t



CVS commit: src/sys/ufs/lfs

2020-09-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Sep  7 02:28:12 UTC 2020

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

Log Message:
Suppress -Waddress-of-packed-member just for lfs_accessors.h.

We can remove -Wno-error=address-of-packed-member from various
makefiles now.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 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.49 src/sys/ufs/lfs/lfs_accessors.h:1.50
--- src/sys/ufs/lfs/lfs_accessors.h:1.49	Sat Mar 21 06:11:05 2020
+++ src/sys/ufs/lfs/lfs_accessors.h	Mon Sep  7 02:28:12 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_accessors.h,v 1.49 2020/03/21 06:11:05 riastradh Exp $	*/
+/*	$NetBSD: lfs_accessors.h,v 1.50 2020/09/07 02:28:12 riastradh 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  */
@@ -218,6 +218,31 @@
 
 
 /*
+ * Suppress spurious warnings -- we use
+ *
+ *	type *foo = >member;
+ *
+ * in macros to verify that obj->member has the right type.  When the
+ * object is a packed structure with misaligned members, this causes
+ * some compiles to squeal that taking the address might lead to
+ * undefined behaviour later on -- which is helpful in general, not
+ * relevant in this case, because we don't do anything with foo
+ * afterward; we only declare it to get a type check and then we
+ * discard it.
+ */
+#ifdef __GNUC__
+#if defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Waddress-of-packed-member"
+#elif __GNUC_PREREQ__(9,0)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Waddress-of-packed-member"
+#endif
+#endif
+
+
+
+/*
  * directories
  */
 
@@ -1508,5 +1533,16 @@ lfs_blocks_sub(STRUCT_LFS *fs, union lfs
 #define LFS_NRESERVE(F) (lfs_btofsb((F), (2 * ULFS_NIADDR + 3) << lfs_sb_getbshift(F)))
 
 
+/*
+ * Suppress spurious clang warnings
+ */
+#ifdef __GNUC__
+#if defined(__clang__)
+#pragma clang diagnostic pop
+#elif __GNUC_PREREQ__(9,0)
+#pragma GCC diagnostic pop
+#endif
+#endif
+
 
 #endif /* _UFS_LFS_LFS_ACCESSORS_H_ */



CVS commit: src/sys/ufs/lfs

2020-08-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Aug 13 17:26:43 UTC 2020

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

Log Message:
Skip unlinked inodes.

They no longer matter on disk so we don't need to write anything out
for them.


To generate a diff of this commit:
cvs rdiff -u -r1.286 -r1.287 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.286 src/sys/ufs/lfs/lfs_segment.c:1.287
--- src/sys/ufs/lfs/lfs_segment.c:1.286	Sun Feb 23 15:46:42 2020
+++ src/sys/ufs/lfs/lfs_segment.c	Thu Aug 13 17:26:43 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_segment.c,v 1.286 2020/02/23 15:46:42 ad Exp $	*/
+/*	$NetBSD: lfs_segment.c,v 1.287 2020/08/13 17:26:43 riastradh 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.286 2020/02/23 15:46:42 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_segment.c,v 1.287 2020/08/13 17:26:43 riastradh Exp $");
 
 #ifdef DEBUG
 # define vndebug(vp, str) do {		\
@@ -487,7 +487,7 @@ lfs_writevnodes_selector(void *cl, struc
 	KASSERT(mutex_owned(vp->v_interlock));
 
 	ip = VTOI(vp);
-	if (ip == NULL || vp->v_type == VNON)
+	if (ip == NULL || vp->v_type == VNON || ip->i_nlink <= 0)
 		return false;
 	if ((op == VN_DIROP && !(vp->v_uflag & VU_DIROP)) ||
 	(op != VN_DIROP && op != VN_CLEAN && (vp->v_uflag & VU_DIROP))) {



CVS commit: src/sys/ufs/lfs

2020-08-03 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Aug  4 03:00:47 UTC 2020

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

Log Message:
Mark lfs vnodes with VV_LOCKSWORK, same as ffs.


To generate a diff of this commit:
cvs rdiff -u -r1.378 -r1.379 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_vfsops.c
diff -u src/sys/ufs/lfs/lfs_vfsops.c:1.378 src/sys/ufs/lfs/lfs_vfsops.c:1.379
--- src/sys/ufs/lfs/lfs_vfsops.c:1.378	Sat Apr  4 20:49:31 2020
+++ src/sys/ufs/lfs/lfs_vfsops.c	Tue Aug  4 03:00:47 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_vfsops.c,v 1.378 2020/04/04 20:49:31 ad Exp $	*/
+/*	$NetBSD: lfs_vfsops.c,v 1.379 2020/08/04 03:00:47 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007, 2007
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.378 2020/04/04 20:49:31 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.379 2020/08/04 03:00:47 riastradh Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_lfs.h"
@@ -1592,6 +1592,7 @@ lfs_init_vnode(struct ulfsmount *ump, in
 
 	vp->v_tag = VT_LFS;
 	vp->v_op = lfs_vnodeop_p;
+	vp->v_vflag |= VV_LOCKSWORK;
 	vp->v_data = ip;
 }
 



CVS commit: src/sys/ufs/lfs

2020-03-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Mar 28 01:08:43 UTC 2020

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

Log Message:
Comment out some of the CTASSERTS for lint until I fix lint.


To generate a diff of this commit:
cvs rdiff -u -r1.207 -r1.208 src/sys/ufs/lfs/lfs.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.207 src/sys/ufs/lfs/lfs.h:1.208
--- src/sys/ufs/lfs/lfs.h:1.207	Sat Mar 21 02:11:05 2020
+++ src/sys/ufs/lfs/lfs.h	Fri Mar 27 21:08:42 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs.h,v 1.207 2020/03/21 06:11:05 riastradh Exp $	*/
+/*	$NetBSD: lfs.h,v 1.208 2020/03/28 01:08:42 christos 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  */
@@ -370,7 +370,9 @@ union lfs_dirheader {
 	struct lfs_dirheader32 u_32;
 };
 __CTASSERT(__alignof(union lfs_dirheader) == __alignof(struct lfs_dirheader64));
+#ifndef __lint__
 __CTASSERT(__alignof(union lfs_dirheader) == __alignof(struct lfs_dirheader32));
+#endif
 
 typedef union lfs_dirheader LFS_DIRHEADER;
 
@@ -583,7 +585,9 @@ typedef union finfo {
 	struct finfo32 u_32;
 } FINFO;
 __CTASSERT(__alignof(union finfo) == __alignof(struct finfo64));
+#ifndef __lint__
 __CTASSERT(__alignof(union finfo) == __alignof(struct finfo32));
+#endif
 
 /*
  * inode info (part of the segment summary)
@@ -608,7 +612,9 @@ typedef union iinfo {
 	struct iinfo32 u_32;
 } IINFO;
 __CTASSERT(__alignof(union iinfo) == __alignof(struct iinfo64));
+#ifndef __lint__
 __CTASSERT(__alignof(union iinfo) == __alignof(struct iinfo32));
+#endif
 
 /*
  * Index file inode entries.
@@ -663,8 +669,10 @@ typedef union ifile {
 	struct ifile_v1 u_v1;
 } IFILE;
 __CTASSERT(__alignof(union ifile) == __alignof(struct ifile64));
+#ifndef __lint__
 __CTASSERT(__alignof(union ifile) == __alignof(struct ifile32));
 __CTASSERT(__alignof(union ifile) == __alignof(struct ifile_v1));
+#endif
 
 /*
  * Cleaner information structure.  This resides in the ifile and is used
@@ -702,8 +710,10 @@ typedef union _cleanerinfo {
 	CLEANERINFO32 u_32;
 	CLEANERINFO64 u_64;
 } CLEANERINFO;
+#ifndef __lint__
 __CTASSERT(__alignof(union _cleanerinfo) == __alignof(struct _cleanerinfo32));
 __CTASSERT(__alignof(union _cleanerinfo) == __alignof(struct _cleanerinfo64));
+#endif
 
 /*
  * On-disk segment summary information
@@ -781,7 +791,9 @@ union segsum {
 };
 __CTASSERT(__alignof(union segsum) == __alignof(struct segsum64));
 __CTASSERT(__alignof(union segsum) == __alignof(struct segsum32));
+#ifndef __lint__
 __CTASSERT(__alignof(union segsum) == __alignof(struct segsum_v1));
+#endif
 
 /*
  * On-disk super block.



CVS commit: src/sys/ufs/lfs

2020-03-21 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Mar 21 06:11:05 UTC 2020

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

Log Message:
Avoid misaligned access to lfs64 on-disk records in memory.

lfs64 directory entries are only 32-bit aligned in order to conserve
space in directory blocks, and we had a hack to stuff a 64-bit inode
in them.  This replaces the hack by __aligned(4) __packed, and goes
further:

1. It's not clear that all the other lfs64 data structures are 64-bit
   aligned on disk to begin with.  We can go through these later and
   upgrade them from

struct foo64 {
...
} __aligned(4) __packed;

union foo {
struct foo64 f64;
...
};

   to

struct foo64 {
...
};

union foo {
struct foo64 f64 __aligned(8);
...
} __aligned(4) __packed;

   if we really want to take advantage of 64-bit memory accesses.

   However, the __aligned(4) __packed must remain on the union
   because:

2. We access even the lfs32 data structures via a union that has
   lfs64 members, and it turns out that compilers will assume access
   through a union with 64-bit aligned members implies the whole
   union has 64-bit alignment, even if we're only accessing a 32-bit
   aligned member.


To generate a diff of this commit:
cvs rdiff -u -r1.206 -r1.207 src/sys/ufs/lfs/lfs.h
cvs rdiff -u -r1.48 -r1.49 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.h
diff -u src/sys/ufs/lfs/lfs.h:1.206 src/sys/ufs/lfs/lfs.h:1.207
--- src/sys/ufs/lfs/lfs.h:1.206	Sat Mar 21 06:09:33 2020
+++ src/sys/ufs/lfs/lfs.h	Sat Mar 21 06:11:05 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs.h,v 1.206 2020/03/21 06:09:33 riastradh Exp $	*/
+/*	$NetBSD: lfs.h,v 1.207 2020/03/21 06:11:05 riastradh 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  */
@@ -358,18 +358,19 @@ struct lfs_dirheader32 {
 __CTASSERT(sizeof(struct lfs_dirheader32) == 8);
 
 struct lfs_dirheader64 {
-	uint32_t dh_inoA;		/* inode number of entry */
-	uint32_t dh_inoB;		/* inode number of entry */
+	uint64_t dh_ino;		/* inode number of entry */
 	uint16_t dh_reclen;		/* length of this record */
 	uint8_t  dh_type; 		/* file type, see below */
 	uint8_t  dh_namlen;		/* length of string in d_name */
-};
+} __aligned(4) __packed;
 __CTASSERT(sizeof(struct lfs_dirheader64) == 12);
 
 union lfs_dirheader {
 	struct lfs_dirheader64 u_64;
 	struct lfs_dirheader32 u_32;
 };
+__CTASSERT(__alignof(union lfs_dirheader) == __alignof(struct lfs_dirheader64));
+__CTASSERT(__alignof(union lfs_dirheader) == __alignof(struct lfs_dirheader32));
 
 typedef union lfs_dirheader LFS_DIRHEADER;
 
@@ -481,6 +482,8 @@ union lfs_dinode {
 	struct lfs64_dinode u_64;
 	struct lfs32_dinode u_32;
 };
+__CTASSERT(__alignof(union lfs_dinode) == __alignof(struct lfs64_dinode));
+__CTASSERT(__alignof(union lfs_dinode) == __alignof(struct lfs32_dinode));
 
 /*
  * The di_db fields may be overlaid with other information for
@@ -563,7 +566,7 @@ struct finfo64 {
 	uint64_t fi_ino;		/* inode number */
 	uint32_t fi_lastlength;		/* length of last block in array */
 	uint32_t fi_pad;		/* unused */
-};
+} __aligned(4) __packed;
 __CTASSERT(sizeof(struct finfo64) == 24);
 
 typedef struct finfo32 FINFO32;
@@ -579,6 +582,8 @@ typedef union finfo {
 	struct finfo64 u_64;
 	struct finfo32 u_32;
 } FINFO;
+__CTASSERT(__alignof(union finfo) == __alignof(struct finfo64));
+__CTASSERT(__alignof(union finfo) == __alignof(struct finfo32));
 
 /*
  * inode info (part of the segment summary)
@@ -590,7 +595,7 @@ typedef union finfo {
 
 typedef struct iinfo64 {
 	uint64_t ii_block;		/* block number */
-} IINFO64;
+} __aligned(4) __packed IINFO64;
 __CTASSERT(sizeof(struct iinfo64) == 8);
 
 typedef struct iinfo32 {
@@ -602,6 +607,8 @@ typedef union iinfo {
 	struct iinfo64 u_64;
 	struct iinfo32 u_32;
 } IINFO;
+__CTASSERT(__alignof(union iinfo) == __alignof(struct iinfo64));
+__CTASSERT(__alignof(union iinfo) == __alignof(struct iinfo32));
 
 /*
  * Index file inode entries.
@@ -620,7 +627,7 @@ struct ifile64 {
 	uint64_t if_atime_sec;		/* Last access time, seconds */
 	int64_t	  if_daddr;		/* inode disk address */
 	uint64_t if_nextfree;		/* next-unallocated inode */
-};
+} __aligned(4) __packed;
 __CTASSERT(sizeof(struct ifile64) == 32);
 
 typedef struct ifile32 IFILE32;
@@ -655,6 +662,9 @@ typedef union ifile {
 	struct ifile32 u_32;
 	struct ifile_v1 u_v1;
 } IFILE;
+__CTASSERT(__alignof(union ifile) == __alignof(struct ifile64));
+__CTASSERT(__alignof(union ifile) == __alignof(struct ifile32));
+__CTASSERT(__alignof(union ifile) == __alignof(struct ifile_v1));
 
 /*
  * Cleaner information structure.  This resides in 

CVS commit: src/sys/ufs/lfs

2020-03-21 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Mar 21 06:09:34 UTC 2020

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

Log Message:
CTASSERT lfs on-disk structure sizes.


To generate a diff of this commit:
cvs rdiff -u -r1.205 -r1.206 src/sys/ufs/lfs/lfs.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.205 src/sys/ufs/lfs/lfs.h:1.206
--- src/sys/ufs/lfs/lfs.h:1.205	Sun Feb 23 08:49:34 2020
+++ src/sys/ufs/lfs/lfs.h	Sat Mar 21 06:09:33 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs.h,v 1.205 2020/02/23 08:49:34 riastradh Exp $	*/
+/*	$NetBSD: lfs.h,v 1.206 2020/03/21 06:09:33 riastradh 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  */
@@ -355,6 +355,7 @@ struct lfs_dirheader32 {
 	uint8_t  dh_type; 		/* file type, see below */
 	uint8_t  dh_namlen;		/* length of string in d_name */
 };
+__CTASSERT(sizeof(struct lfs_dirheader32) == 8);
 
 struct lfs_dirheader64 {
 	uint32_t dh_inoA;		/* inode number of entry */
@@ -363,6 +364,7 @@ struct lfs_dirheader64 {
 	uint8_t  dh_type; 		/* file type, see below */
 	uint8_t  dh_namlen;		/* length of string in d_name */
 };
+__CTASSERT(sizeof(struct lfs_dirheader64) == 12);
 
 union lfs_dirheader {
 	struct lfs_dirheader64 u_64;
@@ -381,6 +383,7 @@ struct lfs_dirtemplate32 {
 	struct lfs_dirheader32	dotdot_header;
 	char			dotdot_name[4];	/* ditto */
 };
+__CTASSERT(sizeof(struct lfs_dirtemplate32) == 2*(8 + 4));
 
 struct lfs_dirtemplate64 {
 	struct lfs_dirheader64	dot_header;
@@ -388,6 +391,7 @@ struct lfs_dirtemplate64 {
 	struct lfs_dirheader64	dotdot_header;
 	char			dotdot_name[4];	/* ditto */
 };
+__CTASSERT(sizeof(struct lfs_dirtemplate64) == 2*(12 + 4));
 
 union lfs_dirtemplate {
 	struct lfs_dirtemplate64 u_64;
@@ -408,6 +412,7 @@ struct lfs_odirtemplate {
 	uint16_t	dotdot_namlen;
 	char		dotdot_name[4];	/* ditto */
 };
+__CTASSERT(sizeof(struct lfs_odirtemplate) == 2*(8 + 4));
 #endif
 
 /*
@@ -441,6 +446,7 @@ struct lfs32_dinode {
 	uint32_t	di_gid;		/* 116: File group. */
 	uint64_t	di_modrev;	/* 120: i_modrev for NFSv4 */
 };
+__CTASSERT(sizeof(struct lfs32_dinode) == 128);
 
 struct lfs64_dinode {
 	uint16_t	di_mode;	/*   0: IFMT, permissions; see below. */
@@ -469,6 +475,7 @@ struct lfs64_dinode {
 	uint64_t	di_inumber;	/* 240: Inode number */
 	uint64_t	di_spare[1];	/* 248: Reserved; currently unused */
 };
+__CTASSERT(sizeof(struct lfs64_dinode) == 256);
 
 union lfs_dinode {
 	struct lfs64_dinode u_64;
@@ -529,6 +536,7 @@ struct segusage {
 	uint32_t su_flags;		/* 12: segment flags */
 	uint64_t su_lastmod;		/* 16: last modified timestamp */
 };
+__CTASSERT(sizeof(struct segusage) == 24);
 
 typedef struct segusage_v1 SEGUSE_V1;
 struct segusage_v1 {
@@ -538,6 +546,7 @@ struct segusage_v1 {
 	uint16_t su_ninos;		/* 10: number of inode blocks in seg */
 	uint32_t su_flags;		/* 12: segment flags  */
 };
+__CTASSERT(sizeof(struct segusage_v1) == 16);
 
 /*
  * On-disk file information.  One per file with data blocks in the segment.
@@ -555,6 +564,7 @@ struct finfo64 {
 	uint32_t fi_lastlength;		/* length of last block in array */
 	uint32_t fi_pad;		/* unused */
 };
+__CTASSERT(sizeof(struct finfo64) == 24);
 
 typedef struct finfo32 FINFO32;
 struct finfo32 {
@@ -563,6 +573,7 @@ struct finfo32 {
 	uint32_t fi_ino;		/* inode number */
 	uint32_t fi_lastlength;		/* length of last block in array */
 };
+__CTASSERT(sizeof(struct finfo32) == 16);
 
 typedef union finfo {
 	struct finfo64 u_64;
@@ -580,10 +591,12 @@ typedef union finfo {
 typedef struct iinfo64 {
 	uint64_t ii_block;		/* block number */
 } IINFO64;
+__CTASSERT(sizeof(struct iinfo64) == 8);
 
 typedef struct iinfo32 {
 	uint32_t ii_block;		/* block number */
 } IINFO32;
+__CTASSERT(sizeof(struct iinfo32) == 4);
 
 typedef union iinfo {
 	struct iinfo64 u_64;
@@ -608,6 +621,7 @@ struct ifile64 {
 	int64_t	  if_daddr;		/* inode disk address */
 	uint64_t if_nextfree;		/* next-unallocated inode */
 };
+__CTASSERT(sizeof(struct ifile64) == 32);
 
 typedef struct ifile32 IFILE32;
 struct ifile32 {
@@ -617,6 +631,7 @@ struct ifile32 {
 	uint32_t if_atime_sec;		/* Last access time, seconds */
 	uint32_t if_atime_nsec;		/* and nanoseconds */
 };
+__CTASSERT(sizeof(struct ifile32) == 20);
 
 typedef struct ifile_v1 IFILE_V1;
 struct ifile_v1 {
@@ -628,6 +643,7 @@ struct ifile_v1 {
 	struct timespec if_atime;	/* Last access time */
 #endif
 };
+__CTASSERT(sizeof(struct ifile_v1) == 12);
 
 /*
  * Note: struct ifile_v1 is often handled by accessing the first three
@@ -657,6 +673,7 @@ typedef struct _cleanerinfo32 {
 	uint32_t free_tail;		/* 20: tail of the inode free list */
 	uint32_t flags;			/* 24: status word from the kernel */
 } CLEANERINFO32;
+__CTASSERT(sizeof(struct _cleanerinfo32) == 28);
 
 typedef struct _cleanerinfo64 {
 	uint32_t 

CVS commit: src/sys/ufs/lfs

2020-03-14 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Sat Mar 14 15:35:35 UTC 2020

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

Log Message:
OR into bp->b_cflags; don't overwrite.


To generate a diff of this commit:
cvs rdiff -u -r1.146 -r1.147 src/sys/ufs/lfs/lfs_bio.c
cvs rdiff -u -r1.374 -r1.375 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.146 src/sys/ufs/lfs/lfs_bio.c:1.147
--- src/sys/ufs/lfs/lfs_bio.c:1.146	Sun Feb 23 08:39:28 2020
+++ src/sys/ufs/lfs/lfs_bio.c	Sat Mar 14 15:35:35 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_bio.c,v 1.146 2020/02/23 08:39:28 riastradh Exp $	*/
+/*	$NetBSD: lfs_bio.c,v 1.147 2020/03/14 15:35:35 ad 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.146 2020/02/23 08:39:28 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_bio.c,v 1.147 2020/03/14 15:35:35 ad Exp $");
 
 #include 
 #include 
@@ -735,7 +735,7 @@ lfs_newbuf(struct lfs *fs, struct vnode 
 	bp->b_error = 0;
 	bp->b_resid = 0;
 	bp->b_iodone = lfs_free_aiodone;
-	bp->b_cflags = BC_BUSY | BC_NOCACHE;
+	bp->b_cflags |= BC_BUSY | BC_NOCACHE;
 	bp->b_private = fs;
 
 	mutex_enter(_lock);

Index: src/sys/ufs/lfs/lfs_vfsops.c
diff -u src/sys/ufs/lfs/lfs_vfsops.c:1.374 src/sys/ufs/lfs/lfs_vfsops.c:1.375
--- src/sys/ufs/lfs/lfs_vfsops.c:1.374	Sun Feb 23 15:46:42 2020
+++ src/sys/ufs/lfs/lfs_vfsops.c	Sat Mar 14 15:35:35 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_vfsops.c,v 1.374 2020/02/23 15:46:42 ad Exp $	*/
+/*	$NetBSD: lfs_vfsops.c,v 1.375 2020/03/14 15:35:35 ad Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007, 2007
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.374 2020/02/23 15:46:42 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.375 2020/03/14 15:35:35 ad Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_lfs.h"
@@ -2127,7 +2127,7 @@ lfs_gop_write(struct vnode *vp, struct v
 	mbp->b_bufsize = npages << PAGE_SHIFT;
 	mbp->b_data = (void *)kva;
 	mbp->b_resid = mbp->b_bcount = bytes;
-	mbp->b_cflags = BC_BUSY|BC_AGE;
+	mbp->b_cflags |= BC_BUSY|BC_AGE;
 	mbp->b_iodone = uvm_aio_aiodone;
 
 	bp = NULL;



CVS commit: src/sys/ufs/lfs

2020-02-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Feb 23 15:23:08 UTC 2020

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

Log Message:
Fix missing  by removing the evcnts instead.

Just wanted to confirm that a race might happen, and indeed it did.
These serve little diagnostic value otherwise.


To generate a diff of this commit:
cvs rdiff -u -r1.101 -r1.102 src/sys/ufs/lfs/lfs_subr.c
cvs rdiff -u -r1.329 -r1.330 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_subr.c
diff -u src/sys/ufs/lfs/lfs_subr.c:1.101 src/sys/ufs/lfs/lfs_subr.c:1.102
--- src/sys/ufs/lfs/lfs_subr.c:1.101	Sun Feb 23 15:09:55 2020
+++ src/sys/ufs/lfs/lfs_subr.c	Sun Feb 23 15:23:08 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_subr.c,v 1.101 2020/02/23 15:09:55 ad Exp $	*/
+/*	$NetBSD: lfs_subr.c,v 1.102 2020/02/23 15:23:08 riastradh 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.101 2020/02/23 15:09:55 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_subr.c,v 1.102 2020/02/23 15:23:08 riastradh Exp $");
 
 #include 
 #include 
@@ -337,10 +337,6 @@ lfs_seglock(struct lfs *fs, unsigned lon
 
 static void lfs_unmark_dirop(struct lfs *);
 
-static struct evcnt lfs_dchain_marker_pass_dirop =
-EVCNT_INITIALIZER(EVCNT_TYPE_MISC, NULL, "lfs", "dchain marker pass dirop");
-EVCNT_ATTACH_STATIC(lfs_dchain_marker_pass_dirop);
-
 static void
 lfs_unmark_dirop(struct lfs *fs)
 {
@@ -371,10 +367,8 @@ lfs_unmark_dirop(struct lfs *fs)
 		TAILQ_REMOVE(>lfs_dchainhd, marker, i_lfs_dchain);
 		TAILQ_INSERT_AFTER(>lfs_dchainhd, ip, marker,
 		i_lfs_dchain);
-		if (ip->i_state & IN_MARKER) {
-			lfs_dchain_marker_pass_dirop.ev_count++;
+		if (ip->i_state & IN_MARKER)
 			continue;
-		}
 		vp = ITOV(ip);
 		if ((ip->i_state & (IN_ADIROP | IN_CDIROP)) == IN_CDIROP) {
 			--lfs_dirvcount;

Index: src/sys/ufs/lfs/lfs_vnops.c
diff -u src/sys/ufs/lfs/lfs_vnops.c:1.329 src/sys/ufs/lfs/lfs_vnops.c:1.330
--- src/sys/ufs/lfs/lfs_vnops.c:1.329	Sun Feb 23 08:40:19 2020
+++ src/sys/ufs/lfs/lfs_vnops.c	Sun Feb 23 15:23:08 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_vnops.c,v 1.329 2020/02/23 08:40:19 riastradh Exp $	*/
+/*	$NetBSD: lfs_vnops.c,v 1.330 2020/02/23 15:23:08 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.329 2020/02/23 08:40:19 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.330 2020/02/23 15:23:08 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -1595,10 +1595,6 @@ lfs_strategy(void *v)
 	return VOP_STRATEGY(vp, bp);
 }
 
-static struct evcnt lfs_dchain_marker_pass_flush =
-EVCNT_INITIALIZER(EVCNT_TYPE_MISC, NULL, "lfs", "dchain marker pass flush");
-EVCNT_ATTACH_STATIC(lfs_dchain_marker_pass_flush);
-
 /*
  * Inline lfs_segwrite/lfs_writevnodes, but just for dirops.
  * Technically this is a checkpoint (the on-disk state is valid)
@@ -1662,10 +1658,8 @@ lfs_flush_dirops(struct lfs *fs)
 		TAILQ_REMOVE(>lfs_dchainhd, marker, i_lfs_dchain);
 		TAILQ_INSERT_AFTER(>lfs_dchainhd, ip, marker,
 		i_lfs_dchain);
-		if (ip->i_state & IN_MARKER) {
-			lfs_dchain_marker_pass_flush.ev_count++;
+		if (ip->i_state & IN_MARKER)
 			continue;
-		}
 		vp = ITOV(ip);
 
 		/*



CVS commit: src/sys/ufs/lfs

2020-02-23 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Sun Feb 23 15:09:55 UTC 2020

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

Log Message:
Fix !DIAGNOSTIC compile


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 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.100 src/sys/ufs/lfs/lfs_subr.c:1.101
--- src/sys/ufs/lfs/lfs_subr.c:1.100	Sun Feb 23 08:42:53 2020
+++ src/sys/ufs/lfs/lfs_subr.c	Sun Feb 23 15:09:55 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_subr.c,v 1.100 2020/02/23 08:42:53 riastradh Exp $	*/
+/*	$NetBSD: lfs_subr.c,v 1.101 2020/02/23 15:09:55 ad 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.100 2020/02/23 08:42:53 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_subr.c,v 1.101 2020/02/23 15:09:55 ad Exp $");
 
 #include 
 #include 
@@ -574,7 +574,7 @@ lfs_segunlock(struct lfs *fs)
 void
 lfs_writer_enter(struct lfs *fs, const char *wmesg)
 {
-	int error;
+	int error __diagused;
 
 	ASSERT_NO_SEGLOCK(fs);
 	mutex_enter(_lock);



CVS commit: src/sys/ufs/lfs

2020-02-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Feb 23 08:49:46 UTC 2020

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

Log Message:
Dust off the orphan detection code and try to make it work.


To generate a diff of this commit:
cvs rdiff -u -r1.140 -r1.141 src/sys/ufs/lfs/lfs_alloc.c
cvs rdiff -u -r1.117 -r1.118 src/sys/ufs/lfs/lfs_extern.h
cvs rdiff -u -r1.372 -r1.373 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_alloc.c
diff -u src/sys/ufs/lfs/lfs_alloc.c:1.140 src/sys/ufs/lfs/lfs_alloc.c:1.141
--- src/sys/ufs/lfs/lfs_alloc.c:1.140	Sun Feb 23 08:49:34 2020
+++ src/sys/ufs/lfs/lfs_alloc.c	Sun Feb 23 08:49:46 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_alloc.c,v 1.140 2020/02/23 08:49:34 riastradh Exp $	*/
+/*	$NetBSD: lfs_alloc.c,v 1.141 2020/02/23 08:49:46 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.140 2020/02/23 08:49:34 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_alloc.c,v 1.141 2020/02/23 08:49:46 riastradh Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_quota.h"
@@ -705,16 +705,16 @@ lfs_vfree(struct vnode *vp, ino_t ino, i
  * Takes the segmenet lock.
  */
 void
-lfs_order_freelist(struct lfs *fs)
+lfs_order_freelist(struct lfs *fs, ino_t **orphanp, size_t *norphanp)
 {
 	CLEANERINFO *cip;
 	IFILE *ifp = NULL;
 	struct buf *bp;
 	ino_t ino, firstino, lastino, maxino;
-#ifdef notyet
-	struct vnode *vp;
-#endif
-	
+	ino_t *orphan = NULL;
+	size_t norphan = 0;
+	size_t norphan_alloc = 0;
+
 	ASSERT_NO_SEGLOCK(fs);
 	lfs_seglock(fs, SEGM_PROT);
 
@@ -745,7 +745,6 @@ lfs_order_freelist(struct lfs *fs)
 		if (ino == LFS_UNUSED_INUM || ino == LFS_IFILE_INUM)
 			continue;
 
-#ifdef notyet
 		/*
 		 * Address orphaned files.
 		 *
@@ -757,40 +756,26 @@ lfs_order_freelist(struct lfs *fs)
 		 * but presumably it doesn't work... not sure what
 		 * happens to such files currently. -- dholland 20160806
 		 */
-		if (lfs_if_getnextfree(fs, ifp) == LFS_ORPHAN_NEXTFREE(fs) &&
-		VFS_VGET(fs->lfs_ivnode->v_mount, ino, LK_EXCLUSIVE, )
-		 == 0) {
-			unsigned segno;
-
-			/* get the segment the inode in on disk  */
-			segno = lfs_dtosn(fs, lfs_if_getdaddr(fs, ifp));
-
-			/* truncate the inode */
-			lfs_truncate(vp, 0, 0, NOCRED);
-			vput(vp);
-
-			/* load the segment summary */
-			LFS_SEGENTRY(sup, fs, segno, bp);
-			/* update the number of bytes in the segment */
-			KASSERT(sup->su_nbytes >= DINOSIZE(fs));
-			sup->su_nbytes -= DINOSIZE(fs);
-			/* write the segment summary */
-			LFS_WRITESEGENTRY(sup, fs, segno, bp);
-
-			/* Drop the on-disk address */
-			lfs_if_setdaddr(fs, ifp, LFS_UNUSED_DADDR);
-			/* write the ifile entry */
-			LFS_BWRITE_LOG(bp);
-
-			/*
-			 * and reload it (XXX: why? I guess
-			 * LFS_BWRITE_LOG drops it...)
-			 */
-			LFS_IENTRY(ifp, fs, ino, bp);
-
-			/* Fall through to next if block */
+		if (lfs_if_getnextfree(fs, ifp) == LFS_ORPHAN_NEXTFREE(fs)) {
+			if (orphan == NULL) {
+norphan_alloc = 32; /* XXX pulled from arse */
+orphan = kmem_zalloc(sizeof(orphan[0]) *
+norphan_alloc, KM_SLEEP);
+			} else if (norphan == norphan_alloc) {
+ino_t *orphan_new;
+if (norphan_alloc >= 4096)
+	norphan_alloc += 4096;
+else
+	norphan_alloc *= 2;
+orphan_new = kmem_zalloc(sizeof(orphan[0]) *
+norphan_alloc, KM_SLEEP);
+memcpy(orphan_new, orphan, sizeof(orphan[0]) *
+norphan);
+kmem_free(orphan, sizeof(orphan[0]) * norphan);
+orphan = orphan_new;
+			}
+			orphan[norphan++] = ino;
 		}
-#endif
 
 		if (lfs_if_getdaddr(fs, ifp) == LFS_UNUSED_DADDR) {
 
@@ -837,6 +822,22 @@ lfs_order_freelist(struct lfs *fs)
 
 	/* done */
 	lfs_segunlock(fs);
+
+	/*
+	 * Shrink the array of orphans so we don't have to carry around
+	 * the allocation size.
+	 */
+	if (norphan < norphan_alloc) {
+		ino_t *orphan_new = kmem_alloc(sizeof(orphan[0]) * norphan,
+		KM_SLEEP);
+		memcpy(orphan_new, orphan, sizeof(orphan[0]) * norphan);
+		kmem_free(orphan, sizeof(orphan[0]) * norphan_alloc);
+		orphan = orphan_new;
+		norphan_alloc = norphan;
+	}
+
+	*orphanp = orphan;
+	*norphanp = norphan;
 }
 
 /*
@@ -855,3 +856,82 @@ lfs_orphan(struct lfs *fs, ino_t ino)
 	lfs_if_setnextfree(fs, ifp, LFS_ORPHAN_NEXTFREE(fs));
 	LFS_BWRITE_LOG(bp);
 }
+
+/*
+ * Free orphans discovered during mount.  This is a separate stage
+ * because it requires fs->lfs_suflags to be set up, which is not done
+ * by the time we run lfs_order_freelist.  It's possible that we could
+ * run lfs_order_freelist later (i.e., set up fs->lfs_suflags sooner)
+ * but that requires more thought than I can put into this at the
+ * moment.
+ */
+void
+lfs_free_orphans(struct lfs *fs, ino_t *orphan, size_t norphan)
+{
+	size_t i;
+
+	

CVS commit: src/sys/ufs/lfs

2020-02-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Feb 23 08:49:34 UTC 2020

Modified Files:
src/sys/ufs/lfs: lfs.h lfs_alloc.c

Log Message:
Teach LFS_ORPHAN_NEXTFREE about lfs64.


To generate a diff of this commit:
cvs rdiff -u -r1.204 -r1.205 src/sys/ufs/lfs/lfs.h
cvs rdiff -u -r1.139 -r1.140 src/sys/ufs/lfs/lfs_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/lfs/lfs.h
diff -u src/sys/ufs/lfs/lfs.h:1.204 src/sys/ufs/lfs/lfs.h:1.205
--- src/sys/ufs/lfs/lfs.h:1.204	Thu Jan 10 06:31:04 2019
+++ src/sys/ufs/lfs/lfs.h	Sun Feb 23 08:49:34 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs.h,v 1.204 2019/01/10 06:31:04 martin Exp $	*/
+/*	$NetBSD: lfs.h,v 1.205 2020/02/23 08:49:34 riastradh 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  */
@@ -596,8 +596,9 @@ typedef union iinfo {
 
 /* magic value for daddrs */
 #define	LFS_UNUSED_DADDR	0	/* out-of-band daddr */
-/* magic value for if_nextfree */
-#define LFS_ORPHAN_NEXTFREE	(~(uint32_t)0) /* indicate orphaned file */
+/* magic value for if_nextfree -- indicate orphaned file */
+#define LFS_ORPHAN_NEXTFREE(fs) \
+	((fs)->lfs_is64 ? ~(uint64_t)0 : ~(uint32_t)0)
 
 typedef struct ifile64 IFILE64;
 struct ifile64 {

Index: src/sys/ufs/lfs/lfs_alloc.c
diff -u src/sys/ufs/lfs/lfs_alloc.c:1.139 src/sys/ufs/lfs/lfs_alloc.c:1.140
--- src/sys/ufs/lfs/lfs_alloc.c:1.139	Sat Feb 22 00:32:08 2020
+++ src/sys/ufs/lfs/lfs_alloc.c	Sun Feb 23 08:49:34 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_alloc.c,v 1.139 2020/02/22 00:32:08 kamil Exp $	*/
+/*	$NetBSD: lfs_alloc.c,v 1.140 2020/02/23 08:49:34 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.139 2020/02/22 00:32:08 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_alloc.c,v 1.140 2020/02/23 08:49:34 riastradh Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_quota.h"
@@ -757,7 +757,7 @@ lfs_order_freelist(struct lfs *fs)
 		 * but presumably it doesn't work... not sure what
 		 * happens to such files currently. -- dholland 20160806
 		 */
-		if (lfs_if_getnextfree(fs, ifp) == LFS_ORPHAN_NEXTFREE &&
+		if (lfs_if_getnextfree(fs, ifp) == LFS_ORPHAN_NEXTFREE(fs) &&
 		VFS_VGET(fs->lfs_ivnode->v_mount, ino, LK_EXCLUSIVE, )
 		 == 0) {
 			unsigned segno;
@@ -852,6 +852,6 @@ lfs_orphan(struct lfs *fs, ino_t ino)
 	struct buf *bp;
 
 	LFS_IENTRY(ifp, fs, ino, bp);
-	lfs_if_setnextfree(fs, ifp, LFS_ORPHAN_NEXTFREE);
+	lfs_if_setnextfree(fs, ifp, LFS_ORPHAN_NEXTFREE(fs));
 	LFS_BWRITE_LOG(bp);
 }



CVS commit: src/sys/ufs/lfs

2020-02-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Feb 23 08:42:53 UTC 2020

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

Log Message:
lfs_writer_enter can't fail; keep it simple and don't pretend it can.

Assert that mtsleep can't fail either -- it doesn't catch signals and
there's no timeout.


To generate a diff of this commit:
cvs rdiff -u -r1.116 -r1.117 src/sys/ufs/lfs/lfs_extern.h
cvs rdiff -u -r1.99 -r1.100 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_extern.h
diff -u src/sys/ufs/lfs/lfs_extern.h:1.116 src/sys/ufs/lfs/lfs_extern.h:1.117
--- src/sys/ufs/lfs/lfs_extern.h:1.116	Sun Feb 23 08:40:37 2020
+++ src/sys/ufs/lfs/lfs_extern.h	Sun Feb 23 08:42:53 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_extern.h,v 1.116 2020/02/23 08:40:37 riastradh Exp $	*/
+/*	$NetBSD: lfs_extern.h,v 1.117 2020/02/23 08:42:53 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -210,7 +210,7 @@ void lfs_free(struct lfs *, void *, int)
 int lfs_seglock(struct lfs *, unsigned long);
 void lfs_segunlock(struct lfs *);
 void lfs_segunlock_relock(struct lfs *);
-int lfs_writer_enter(struct lfs *, const char *);
+void lfs_writer_enter(struct lfs *, const char *);
 int lfs_writer_tryenter(struct lfs *);
 void lfs_writer_leave(struct lfs *);
 void lfs_wakeup_cleaner(struct lfs *);

Index: src/sys/ufs/lfs/lfs_subr.c
diff -u src/sys/ufs/lfs/lfs_subr.c:1.99 src/sys/ufs/lfs/lfs_subr.c:1.100
--- src/sys/ufs/lfs/lfs_subr.c:1.99	Sun Feb 23 08:40:37 2020
+++ src/sys/ufs/lfs/lfs_subr.c	Sun Feb 23 08:42:53 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_subr.c,v 1.99 2020/02/23 08:40:37 riastradh Exp $	*/
+/*	$NetBSD: lfs_subr.c,v 1.100 2020/02/23 08:42:53 riastradh 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.99 2020/02/23 08:40:37 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_subr.c,v 1.100 2020/02/23 08:42:53 riastradh Exp $");
 
 #include 
 #include 
@@ -561,6 +561,7 @@ lfs_segunlock(struct lfs *fs)
 			lfs_unmark_dirop(fs);
 	} else {
 		--fs->lfs_seglock;
+		KASSERT(fs->lfs_seglock != 0);
 		mutex_exit(_lock);
 	}
 }
@@ -570,10 +571,10 @@ lfs_segunlock(struct lfs *fs)
  *
  * No simple_locks are held when we enter and none are held when we return.
  */
-int
+void
 lfs_writer_enter(struct lfs *fs, const char *wmesg)
 {
-	int error = 0;
+	int error;
 
 	ASSERT_NO_SEGLOCK(fs);
 	mutex_enter(_lock);
@@ -585,15 +586,11 @@ lfs_writer_enter(struct lfs *fs, const c
 		++fs->lfs_diropwait;
 		error = mtsleep(>lfs_writer, PRIBIO+1, wmesg, 0,
 _lock);
+		KASSERT(error == 0);
 		--fs->lfs_diropwait;
 	}
 
-	if (error)
-		fs->lfs_writer--;
-
 	mutex_exit(_lock);
-
-	return error;
 }
 
 int



CVS commit: src/sys/ufs/lfs

2020-02-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Feb 23 08:41:08 UTC 2020

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

Log Message:
Call lfs_orphan in lfs_rename while we're still in the dirop.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/ufs/lfs/lfs_rename.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/ufs/lfs/lfs_rename.c
diff -u src/sys/ufs/lfs/lfs_rename.c:1.22 src/sys/ufs/lfs/lfs_rename.c:1.23
--- src/sys/ufs/lfs/lfs_rename.c:1.22	Sat Jun 10 05:29:36 2017
+++ src/sys/ufs/lfs/lfs_rename.c	Sun Feb 23 08:41:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_rename.c,v 1.22 2017/06/10 05:29:36 maya Exp $	*/
+/*	$NetBSD: lfs_rename.c,v 1.23 2020/02/23 08:41:07 riastradh Exp $	*/
 /*  from NetBSD: ufs_rename.c,v 1.12 2015/03/27 17:27:56 riastradh Exp  */
 
 /*-
@@ -89,7 +89,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_rename.c,v 1.22 2017/06/10 05:29:36 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_rename.c,v 1.23 2020/02/23 08:41:07 riastradh Exp $");
 
 #include 
 #include 
@@ -1061,6 +1061,9 @@ lfs_gro_rename(struct mount *mp, kauth_c
 	fdvp, fcnp, fde, fvp,
 	tdvp, tcnp, tde, tvp);
 
+	if (tvp && VTOI(tvp)->i_nlink == 0)
+		lfs_orphan(VTOI(tvp)->i_lfs, VTOI(tvp)->i_number);
+
 	UNMARK_VNODE(fdvp);
 	UNMARK_VNODE(fvp);
 	UNMARK_VNODE(tdvp);



CVS commit: src/sys/ufs/lfs

2020-02-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Feb 23 08:40:59 UTC 2020

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

Log Message:
In lfs_update, hold lfs_writer around lfs_vflush.

Otherwise, we might do

lfs_vflush
-> lfs_seglock
-> lfs_segwait(SEGM_CKP)
   -> lfs_writer_enter

which is the reverse of the lfs_writer -> lfs_seglock ordering.


To generate a diff of this commit:
cvs rdiff -u -r1.157 -r1.158 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.157 src/sys/ufs/lfs/lfs_inode.c:1.158
--- src/sys/ufs/lfs/lfs_inode.c:1.157	Sat Jun 10 05:29:36 2017
+++ src/sys/ufs/lfs/lfs_inode.c	Sun Feb 23 08:40:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_inode.c,v 1.157 2017/06/10 05:29:36 maya Exp $	*/
+/*	$NetBSD: lfs_inode.c,v 1.158 2020/02/23 08:40:58 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.157 2017/06/10 05:29:36 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.158 2020/02/23 08:40:58 riastradh Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_quota.h"
@@ -133,6 +133,7 @@ lfs_update(struct vnode *vp, const struc
 	struct inode *ip;
 	struct lfs *fs = VFSTOULFS(vp->v_mount)->um_lfs;
 	int flags;
+	int error;
 
 	ASSERT_NO_SEGLOCK(fs);
 	if (vp->v_mount->mnt_flag & MNT_RDONLY)
@@ -175,7 +176,7 @@ lfs_update(struct vnode *vp, const struc
 			  vp->v_iflag | vp->v_vflag | vp->v_uflag,
 			  ip->i_state));
 			if (fs->lfs_dirops == 0)
-lfs_flush_fs(fs, SEGM_SYNC);
+break;
 			else
 mtsleep(>lfs_writer, PRIBIO+1, "lfs_fsync",
 	0, _lock);
@@ -183,8 +184,18 @@ lfs_update(struct vnode *vp, const struc
 			twice? */
 		}
 		--fs->lfs_diropwait;
+		fs->lfs_writer++;
+		if (vp->v_uflag & VU_DIROP) {
+			KASSERT(fs->lfs_dirops == 0);
+			lfs_flush_fs(fs, SEGM_SYNC);
+		}
+		mutex_exit(_lock);
+		error = lfs_vflush(vp);
+		mutex_enter(_lock);
+		if (--fs->lfs_writer == 0)
+			cv_broadcast(>lfs_diropscv);
 		mutex_exit(_lock);
-		return lfs_vflush(vp);
+		return error;
 	}
 	return 0;
 }



CVS commit: src/sys/ufs/lfs

2020-02-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Feb 23 08:40:49 UTC 2020

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

Log Message:
Initialize/destroy lfs_allclean_wakeup in modcmd, not lfs_mountfs.

Fixes reloading lfs.kmod.


To generate a diff of this commit:
cvs rdiff -u -r1.371 -r1.372 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_vfsops.c
diff -u src/sys/ufs/lfs/lfs_vfsops.c:1.371 src/sys/ufs/lfs/lfs_vfsops.c:1.372
--- src/sys/ufs/lfs/lfs_vfsops.c:1.371	Sun Feb 23 08:39:18 2020
+++ src/sys/ufs/lfs/lfs_vfsops.c	Sun Feb 23 08:40:49 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_vfsops.c,v 1.371 2020/02/23 08:39:18 riastradh Exp $	*/
+/*	$NetBSD: lfs_vfsops.c,v 1.372 2020/02/23 08:40:49 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007, 2007
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.371 2020/02/23 08:39:18 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.372 2020/02/23 08:40:49 riastradh Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_lfs.h"
@@ -356,6 +356,7 @@ lfs_modcmd(modcmd_t cmd, void *arg)
 			break;
 		}
 		lfs_sysctl_setup(_sysctl_log);
+		cv_init(_allclean_wakeup, "segment");
 		break;
 	case MODULE_CMD_FINI:
 		error = vfs_detach(_vfsops);
@@ -363,6 +364,7 @@ lfs_modcmd(modcmd_t cmd, void *arg)
 			break;
 		syscall_disestablish(NULL, lfs_syscalls);
 		sysctl_teardown(_sysctl_log);
+		cv_destroy(_allclean_wakeup);
 		break;
 	default:
 		error = ENOTTY;
@@ -857,7 +859,6 @@ lfs_checkmagic(struct lfs *fs)
 int
 lfs_mountfs(struct vnode *devvp, struct mount *mp, struct lwp *l)
 {
-	static bool lfs_mounted_once = false;
 	struct lfs *primarysb, *altsb, *thesb;
 	struct buf *primarybuf, *altbuf;
 	struct lfs *fs;
@@ -1091,12 +1092,6 @@ lfs_mountfs(struct vnode *devvp, struct 
 	cv_init(>lfs_stopcv, "lfsstop");
 	cv_init(>lfs_nextsegsleep, "segment");
 
-	/* Initialize values for all LFS mounts */
-	if (!lfs_mounted_once) {
-		cv_init(_allclean_wakeup, "segment");
-		lfs_mounted_once = true;
-	}
-
 	/* Set the file system readonly/modify bits. */
 	fs->lfs_ronly = ronly;
 	if (ronly == 0)



CVS commit: src/sys/ufs/lfs

2020-02-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Feb 23 08:40:08 UTC 2020

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

Log Message:
Change some cheap KDASSERT into KASSERT.


To generate a diff of this commit:
cvs rdiff -u -r1.283 -r1.284 src/sys/ufs/lfs/lfs_segment.c
cvs rdiff -u -r1.327 -r1.328 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_segment.c
diff -u src/sys/ufs/lfs/lfs_segment.c:1.283 src/sys/ufs/lfs/lfs_segment.c:1.284
--- src/sys/ufs/lfs/lfs_segment.c:1.283	Sat Feb 22 22:20:47 2020
+++ src/sys/ufs/lfs/lfs_segment.c	Sun Feb 23 08:40:08 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_segment.c,v 1.283 2020/02/22 22:20:47 ad Exp $	*/
+/*	$NetBSD: lfs_segment.c,v 1.284 2020/02/23 08:40:08 riastradh 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.283 2020/02/22 22:20:47 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_segment.c,v 1.284 2020/02/23 08:40:08 riastradh Exp $");
 
 #ifdef DEBUG
 # define vndebug(vp, str) do {		\
@@ -396,7 +396,7 @@ lfs_vflush(struct vnode *vp)
 	 * still not done with this vnode.
 	 * XXX we can do better than this.
 	 */
-	KDASSERT(ip->i_number != LFS_IFILE_INUM);
+	KASSERT(ip->i_number != LFS_IFILE_INUM);
 	lfs_writeinode(fs, sp, ip);
 	mutex_enter(_lock);
 	LFS_SET_UINO(ip, IN_MODIFIED);

Index: src/sys/ufs/lfs/lfs_vnops.c
diff -u src/sys/ufs/lfs/lfs_vnops.c:1.327 src/sys/ufs/lfs/lfs_vnops.c:1.328
--- src/sys/ufs/lfs/lfs_vnops.c:1.327	Sun Feb 23 08:39:39 2020
+++ src/sys/ufs/lfs/lfs_vnops.c	Sun Feb 23 08:40:08 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_vnops.c,v 1.327 2020/02/23 08:39:39 riastradh Exp $	*/
+/*	$NetBSD: lfs_vnops.c,v 1.328 2020/02/23 08:40:08 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.327 2020/02/23 08:39:39 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.328 2020/02/23 08:40:08 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -1707,7 +1707,7 @@ lfs_flush_dirops(struct lfs *fs)
 break;
 			}
 		}
-		KDASSERT(ip->i_number != LFS_IFILE_INUM);
+		KASSERT(ip->i_number != LFS_IFILE_INUM);
 		error = lfs_writeinode(fs, sp, ip);
 		mutex_enter(_lock);
 		if (error && (sp->seg_flags & SEGM_SINGLE)) {
@@ -1829,7 +1829,7 @@ lfs_flush_pchain(struct lfs *fs)
 			LFS_SET_UINO(ip, IN_MODIFIED);
 			mutex_exit(_lock);
 		}
-		KDASSERT(ip->i_number != LFS_IFILE_INUM);
+		KASSERT(ip->i_number != LFS_IFILE_INUM);
 		error2 = lfs_writeinode(fs, sp, ip);
 
 		VOP_UNLOCK(vp);



CVS commit: src/sys/ufs/lfs

2020-02-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Feb 23 08:40:19 UTC 2020

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

Log Message:
Take a reference and fix assertions in lfs_flush_dirops.

Fixes panic:

KASSERT((ip->i_state & IN_ADIROP) == 0) at lfs_vnops.c:1670
lfs_flush_dirops
lfs_check
lfs_setattr
VOP_SETATTR
change_mode
sys_fchmod
syscall

This assertion -- and the assertion that vp->v_uflag has VU_DIROP set
-- is valid only until we release lfs_lock, because we may race with
lfs_unmark_dirop which will remove the nodes and change the flags.

Further, vp itself is valid only as long as it is referenced, which it
is as long as it's on the dchain, but lfs_unmark_dirop drops the
dchain's reference.


To generate a diff of this commit:
cvs rdiff -u -r1.328 -r1.329 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.328 src/sys/ufs/lfs/lfs_vnops.c:1.329
--- src/sys/ufs/lfs/lfs_vnops.c:1.328	Sun Feb 23 08:40:08 2020
+++ src/sys/ufs/lfs/lfs_vnops.c	Sun Feb 23 08:40:19 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_vnops.c,v 1.328 2020/02/23 08:40:08 riastradh Exp $	*/
+/*	$NetBSD: lfs_vnops.c,v 1.329 2020/02/23 08:40:19 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.328 2020/02/23 08:40:08 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.329 2020/02/23 08:40:19 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -1623,7 +1623,6 @@ lfs_flush_dirops(struct lfs *fs)
 		return EROFS;
 
 	mutex_enter(_lock);
-	KASSERT(fs->lfs_writer);
 	if (TAILQ_FIRST(>lfs_dchainhd) == NULL) {
 		mutex_exit(_lock);
 		return 0;
@@ -1667,13 +1666,33 @@ lfs_flush_dirops(struct lfs *fs)
 			lfs_dchain_marker_pass_flush.ev_count++;
 			continue;
 		}
-		mutex_exit(_lock);
 		vp = ITOV(ip);
-		mutex_enter(vp->v_interlock);
 
+		/*
+		 * Prevent the vnode from going away if it's just been
+		 * put out in the segment and lfs_unmark_dirop is about
+		 * to release it.  While it is on the list it is always
+		 * referenced, so it cannot be reclaimed until we
+		 * release it.
+		 */
+		vref(vp);
+
+		/*
+		 * Since we hold lfs_writer, the node can't be in an
+		 * active dirop.  Since it's on the list and we hold a
+		 * reference to it, it can't be reclaimed now.
+		 */
 		KASSERT((ip->i_state & IN_ADIROP) == 0);
 		KASSERT(vp->v_uflag & VU_DIROP);
-		KASSERT(vdead_check(vp, VDEAD_NOWAIT) == 0);
+
+		/*
+		 * After we release lfs_lock, if we were in the middle
+		 * of writing a segment, lfs_unmark_dirop may end up
+		 * clearing VU_DIROP, and we have no way to stop it.
+		 * That should be OK -- we'll just have less to do
+		 * here.
+		 */
+		mutex_exit(_lock);
 
 		/*
 		 * All writes to directories come from dirops; all
@@ -1683,15 +1702,6 @@ lfs_flush_dirops(struct lfs *fs)
 		 * directory blocks inodes and file inodes.  So we don't
 		 * really need to lock.
 		 */
-		if (vdead_check(vp, VDEAD_NOWAIT) != 0) {
-			mutex_exit(vp->v_interlock);
-			mutex_enter(_lock);
-			continue;
-		}
-		mutex_exit(vp->v_interlock);
-		/* XXX see below
-		 * waslocked = VOP_ISLOCKED(vp);
-		 */
 		if (vp->v_type != VREG &&
 		((ip->i_state & IN_ALLMOD) || !VPISEMPTY(vp))) {
 			error = lfs_writefile(fs, sp, vp);
@@ -1702,6 +1712,7 @@ lfs_flush_dirops(struct lfs *fs)
 				mutex_exit(_lock);
 			}
 			if (error && (sp->seg_flags & SEGM_SINGLE)) {
+vrele(vp);
 mutex_enter(_lock);
 error = EAGAIN;
 break;
@@ -1709,8 +1720,9 @@ lfs_flush_dirops(struct lfs *fs)
 		}
 		KASSERT(ip->i_number != LFS_IFILE_INUM);
 		error = lfs_writeinode(fs, sp, ip);
-		mutex_enter(_lock);
 		if (error && (sp->seg_flags & SEGM_SINGLE)) {
+			vrele(vp);
+			mutex_enter(_lock);
 			error = EAGAIN;
 			break;
 		}
@@ -1723,7 +1735,12 @@ lfs_flush_dirops(struct lfs *fs)
 		 * write them.
 		 */
 		/* XXX only for non-directories? --KS */
+		mutex_enter(_lock);
 		LFS_SET_UINO(ip, IN_MODIFIED);
+		mutex_exit(_lock);
+
+		vrele(vp);
+		mutex_enter(_lock);
 	}
 	TAILQ_REMOVE(>lfs_dchainhd, marker, i_lfs_dchain);
 	mutex_exit(_lock);



CVS commit: src/sys/ufs/lfs

2020-02-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Feb 23 08:40:28 UTC 2020

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

Log Message:
Don't lfs_writer_enter while holding v_interlock.

There's no need to lfs_writer_enter at all here, as far as I can see.
lfs_flush_fs will do it for us.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 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.20 src/sys/ufs/lfs/lfs_pages.c:1.21
--- src/sys/ufs/lfs/lfs_pages.c:1.20	Wed Jan 15 17:55:44 2020
+++ src/sys/ufs/lfs/lfs_pages.c	Sun Feb 23 08:40:27 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_pages.c,v 1.20 2020/01/15 17:55:44 ad Exp $	*/
+/*	$NetBSD: lfs_pages.c,v 1.21 2020/02/23 08:40:27 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2019 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_pages.c,v 1.20 2020/01/15 17:55:44 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_pages.c,v 1.21 2020/02/23 08:40:27 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -671,29 +671,30 @@ retry:
 	(vp->v_uflag & VU_DIROP)) {
 		DLOG((DLOG_PAGE, "lfs_putpages: flushing VU_DIROP\n"));
 
- 		lfs_writer_enter(fs, "ppdirop");
+		/*
+		 * NB: lfs_flush_fs can recursively call lfs_putpages,
+		 * but it won't reach this branch because it passes
+		 * PGO_LOCKED.
+		 */
 
-		/* Note if we hold the vnode locked */
-		if (VOP_ISLOCKED(vp) == LK_EXCLUSIVE)
-		{
-		DLOG((DLOG_PAGE, "lfs_putpages: dirop inode already locked\n"));
-		} else {
-		DLOG((DLOG_PAGE, "lfs_putpages: dirop inode not locked\n"));
-		}
 		mutex_exit(vp->v_interlock);
-
 		mutex_enter(_lock);
 		lfs_flush_fs(fs, sync ? SEGM_SYNC : 0);
 		mutex_exit(_lock);
-
 		mutex_enter(vp->v_interlock);
-		lfs_writer_leave(fs);
 
 		/*
 		 * The flush will have cleaned out this vnode as well,
 		 *  no need to do more to it.
 		 *  XXX then why are we falling through and continuing?
 		 */
+
+		/*
+		 * XXX State may have changed while we dropped the
+		 * lock; start over just in case.  The above comment
+		 * suggests this should maybe instead be goto out.
+		 */
+		goto retry;
 	}
 
 	/*



CVS commit: src/sys/ufs/lfs

2020-02-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Feb 23 08:40:37 UTC 2020

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

Log Message:
Break deadlock in PR kern/52301.

The lock order is lfs_writer -> lfs_seglock.  The problem in 52301 is
that lfs_segwrite violates this lock order by sometimes doing
lfs_seglock -> lfs_writer, either (a) when doing a checkpoint or (b),
opportunistically, when there are no dirops pending.  Both cases can
deadlock, because dirops sometimes take the seglock (lfs_truncate,
lfs_valloc, lfs_vfree):

(a) There may be dirops pending, and they may be waiting for the
seglock, so we can't wait for them to complete while holding the
seglock.

(b) The test for fs->lfs_dirops == 0 happens unlocked, and the state
may change by the time lfs_writer_enter acquires lfs_lock.

To resolve this in each case:

(a) Do lfs_writer_enter before lfs_seglock, since we will need it
unconditionally anyway.  The worst performance impact of this should
be that some dirops get delayed a little bit.

(b) Create a new lfs_writer_tryenter to use at this point so that the
test for fs->lfs_dirops == 0 and the acquisition of lfs_writer happen
atomically under lfs_lock.


To generate a diff of this commit:
cvs rdiff -u -r1.115 -r1.116 src/sys/ufs/lfs/lfs_extern.h
cvs rdiff -u -r1.284 -r1.285 src/sys/ufs/lfs/lfs_segment.c
cvs rdiff -u -r1.98 -r1.99 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_extern.h
diff -u src/sys/ufs/lfs/lfs_extern.h:1.115 src/sys/ufs/lfs/lfs_extern.h:1.116
--- src/sys/ufs/lfs/lfs_extern.h:1.115	Tue Feb 18 20:23:17 2020
+++ src/sys/ufs/lfs/lfs_extern.h	Sun Feb 23 08:40:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_extern.h,v 1.115 2020/02/18 20:23:17 chs Exp $	*/
+/*	$NetBSD: lfs_extern.h,v 1.116 2020/02/23 08:40:37 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -211,6 +211,7 @@ int lfs_seglock(struct lfs *, unsigned l
 void lfs_segunlock(struct lfs *);
 void lfs_segunlock_relock(struct lfs *);
 int lfs_writer_enter(struct lfs *, const char *);
+int lfs_writer_tryenter(struct lfs *);
 void lfs_writer_leave(struct lfs *);
 void lfs_wakeup_cleaner(struct lfs *);
 

Index: src/sys/ufs/lfs/lfs_segment.c
diff -u src/sys/ufs/lfs/lfs_segment.c:1.284 src/sys/ufs/lfs/lfs_segment.c:1.285
--- src/sys/ufs/lfs/lfs_segment.c:1.284	Sun Feb 23 08:40:08 2020
+++ src/sys/ufs/lfs/lfs_segment.c	Sun Feb 23 08:40:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_segment.c,v 1.284 2020/02/23 08:40:08 riastradh Exp $	*/
+/*	$NetBSD: lfs_segment.c,v 1.285 2020/02/23 08:40:37 riastradh 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.284 2020/02/23 08:40:08 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_segment.c,v 1.285 2020/02/23 08:40:37 riastradh Exp $");
 
 #ifdef DEBUG
 # define vndebug(vp, str) do {		\
@@ -621,6 +621,15 @@ lfs_segwrite(struct mount *mp, int flags
 	 */
 	do_ckp = LFS_SHOULD_CHECKPOINT(fs, flags);
 
+	/*
+	 * If we know we're gonna need the writer lock, take it now to
+	 * preserve the lock order lfs_writer -> lfs_seglock.
+	 */
+	if (do_ckp) {
+		lfs_writer_enter(fs, "ckpwriter");
+		writer_set = 1;
+	}
+
 	/* We can't do a partial write and checkpoint at the same time. */
 	if (do_ckp)
 		flags &= ~SEGM_SINGLE;
@@ -650,11 +659,10 @@ lfs_segwrite(struct mount *mp, int flags
 break;
 			}
 
-			if (do_ckp || fs->lfs_dirops == 0) {
-if (!writer_set) {
-	lfs_writer_enter(fs, "lfs writer");
-	writer_set = 1;
-}
+			if (do_ckp ||
+			(writer_set = lfs_writer_tryenter(fs)) != 0) {
+KASSERT(writer_set);
+KASSERT(fs->lfs_writer);
 error = lfs_writevnodes(fs, mp, sp, VN_DIROP);
 if (um_error == 0)
 	um_error = error;

Index: src/sys/ufs/lfs/lfs_subr.c
diff -u src/sys/ufs/lfs/lfs_subr.c:1.98 src/sys/ufs/lfs/lfs_subr.c:1.99
--- src/sys/ufs/lfs/lfs_subr.c:1.98	Sun Feb 23 08:38:58 2020
+++ src/sys/ufs/lfs/lfs_subr.c	Sun Feb 23 08:40:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_subr.c,v 1.98 2020/02/23 08:38:58 riastradh Exp $	*/
+/*	$NetBSD: lfs_subr.c,v 1.99 2020/02/23 08:40:37 riastradh 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.98 2020/02/23 08:38:58 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_subr.c,v 1.99 2020/02/23 08:40:37 riastradh Exp $");
 
 #include 
 #include 
@@ -575,7 +575,7 @@ lfs_writer_enter(struct lfs *fs, const c
 {
 	int error = 0;
 
-	ASSERT_MAYBE_SEGLOCK(fs);
+	ASSERT_NO_SEGLOCK(fs);
 	mutex_enter(_lock);
 
 	/* disallow dirops during flush */
@@ -596,6 +596,21 @@ lfs_writer_enter(struct lfs *fs, const c
 	return error;
 }
 
+int

CVS commit: src/sys/ufs/lfs

2020-02-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Feb 23 08:39:19 UTC 2020

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

Log Message:
Teach lfs to transition ro<->rw.


To generate a diff of this commit:
cvs rdiff -u -r1.370 -r1.371 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_vfsops.c
diff -u src/sys/ufs/lfs/lfs_vfsops.c:1.370 src/sys/ufs/lfs/lfs_vfsops.c:1.371
--- src/sys/ufs/lfs/lfs_vfsops.c:1.370	Tue Feb 18 20:23:17 2020
+++ src/sys/ufs/lfs/lfs_vfsops.c	Sun Feb 23 08:39:18 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_vfsops.c,v 1.370 2020/02/18 20:23:17 chs Exp $	*/
+/*	$NetBSD: lfs_vfsops.c,v 1.371 2020/02/23 08:39:18 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007, 2007
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.370 2020/02/18 20:23:17 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.371 2020/02/23 08:39:18 riastradh Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_lfs.h"
@@ -120,6 +120,7 @@ MODULE(MODULE_CLASS_VFS, lfs, NULL);
 
 static int lfs_gop_write(struct vnode *, struct vm_page **, int, int);
 static int lfs_mountfs(struct vnode *, struct mount *, struct lwp *);
+static int lfs_flushfiles(struct mount *, int);
 
 static struct sysctllog *lfs_sysctl_log;
 
@@ -755,23 +756,18 @@ lfs_mount(struct mount *mp, const char *
 		ump = VFSTOULFS(mp);
 		fs = ump->um_lfs;
 
-		if (fs->lfs_ronly == 0 && (mp->mnt_flag & MNT_RDONLY)) {
+		if (!fs->lfs_ronly && (mp->mnt_iflag & IMNT_WANTRDONLY)) {
 			/*
 			 * Changing from read/write to read-only.
-			 * XXX: shouldn't we sync here? or does vfs do that?
 			 */
-#ifdef LFS_QUOTA2
-			/* XXX: quotas should remain on when readonly */
-			if (fs->lfs_use_quota2) {
-error = lfsquota2_umount(mp, 0);
-if (error) {
-	return error;
-}
-			}
-#endif
-		}
-
-		if (fs->lfs_ronly && (mp->mnt_iflag & IMNT_WANTRDWR)) {
+			int flags = WRITECLOSE;
+			if (mp->mnt_flag & MNT_FORCE)
+flags |= FORCECLOSE;
+			error = lfs_flushfiles(mp, flags);
+			if (error)
+return error;
+			fs->lfs_ronly = 1;
+		} else if (fs->lfs_ronly && (mp->mnt_iflag & IMNT_WANTRDWR)) {
 			/*
 			 * Changing from read-only to read/write.
 			 * Note in the superblocks that we're writing.
@@ -805,8 +801,9 @@ lfs_mount(struct mount *mp, const char *
 lfs_writesuper(fs, lfs_sb_getsboff(fs, 1));
 			}
 		}
+
 		if (args->fspec == NULL)
-			return EINVAL;
+			return 0;
 	}
 
 	error = set_statvfs_info(path, UIO_USERSPACE, args->fspec,
@@ -1137,6 +1134,7 @@ lfs_mountfs(struct vnode *devvp, struct 
 	mp->mnt_stat.f_iosize = lfs_sb_getbsize(fs);
 	mp->mnt_flag |= MNT_LOCAL;
 	mp->mnt_fs_bshift = lfs_sb_getbshift(fs);
+	mp->mnt_iflag |= IMNT_CAN_RWTORO;
 	if (fs->um_maxsymlinklen > 0)
 		mp->mnt_iflag |= IMNT_DTYPE;
 	else
@@ -1328,22 +1326,72 @@ out:
 int
 lfs_unmount(struct mount *mp, int mntflags)
 {
-	struct lwp *l = curlwp;
 	struct ulfsmount *ump;
 	struct lfs *fs;
-	int error, flags, ronly;
-	vnode_t *vp;
+	int error, ronly;
+
+	ump = VFSTOULFS(mp);
+	fs = ump->um_lfs;
 
-	flags = 0;
-	if (mntflags & MNT_FORCE)
-		flags |= FORCECLOSE;
+	error = lfs_flushfiles(mp, mntflags & MNT_FORCE ? FORCECLOSE : 0);
+	if (error)
+		return error;
+
+	/* Finish with the Ifile, now that we're done with it */
+	vgone(fs->lfs_ivnode);
+
+	ronly = !fs->lfs_ronly;
+	if (fs->lfs_devvp->v_type != VBAD)
+		spec_node_setmountedfs(fs->lfs_devvp, NULL);
+	vn_lock(fs->lfs_devvp, LK_EXCLUSIVE | LK_RETRY);
+	error = VOP_CLOSE(fs->lfs_devvp,
+	ronly ? FREAD : FREAD|FWRITE, NOCRED);
+	vput(fs->lfs_devvp);
+
+	/* Complain about page leakage */
+	if (fs->lfs_pages > 0)
+		printf("lfs_unmount: still claim %d pages (%d in subsystem)\n",
+			fs->lfs_pages, lfs_subsys_pages);
+
+	/* Free per-mount data structures */
+	free(fs->lfs_ino_bitmap, M_SEGMENT);
+	free(fs->lfs_suflags[0], M_SEGMENT);
+	free(fs->lfs_suflags[1], M_SEGMENT);
+	free(fs->lfs_suflags, M_SEGMENT);
+	lfs_free_resblks(fs);
+	cv_destroy(>lfs_sleeperscv);
+	cv_destroy(>lfs_diropscv);
+	cv_destroy(>lfs_stopcv);
+	cv_destroy(>lfs_nextsegsleep);
+
+	rw_destroy(>lfs_fraglock);
+	rw_destroy(>lfs_iflock);
+
+	kmem_free(fs, sizeof(struct lfs));
+	kmem_free(ump, sizeof(*ump));
+
+	mp->mnt_data = NULL;
+	mp->mnt_flag &= ~MNT_LOCAL;
+	return (error);
+}
+
+static int
+lfs_flushfiles(struct mount *mp, int flags)
+{
+	struct lwp *l = curlwp;
+	struct ulfsmount *ump;
+	struct lfs *fs;
+	struct vnode *vp;
+	int error;
 
 	ump = VFSTOULFS(mp);
 	fs = ump->um_lfs;
 
 	/* Two checkpoints */
-	lfs_segwrite(mp, SEGM_CKP | SEGM_SYNC);
-	lfs_segwrite(mp, SEGM_CKP | SEGM_SYNC);
+	if (!fs->lfs_ronly) {
+		lfs_segwrite(mp, SEGM_CKP | SEGM_SYNC);
+		lfs_segwrite(mp, SEGM_CKP | SEGM_SYNC);
+	}
 
 	/* wake up the cleaner so it can die */
 	/* XXX: shouldn't this be *after* the error cases below? */
@@ -1383,51 +1431,18 @@ 

CVS commit: src/sys/ufs/lfs

2020-02-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Feb 23 08:39:48 UTC 2020

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

Log Message:
Serialize access to the splay tree with lfs_lock.


To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 src/sys/ufs/lfs/lfs_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/lfs/lfs_balloc.c
diff -u src/sys/ufs/lfs/lfs_balloc.c:1.94 src/sys/ufs/lfs/lfs_balloc.c:1.95
--- src/sys/ufs/lfs/lfs_balloc.c:1.94	Sat Jun 10 05:29:36 2017
+++ src/sys/ufs/lfs/lfs_balloc.c	Sun Feb 23 08:39:48 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_balloc.c,v 1.94 2017/06/10 05:29:36 maya Exp $	*/
+/*	$NetBSD: lfs_balloc.c,v 1.95 2020/02/23 08:39:48 riastradh 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.94 2017/06/10 05:29:36 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_balloc.c,v 1.95 2020/02/23 08:39:48 riastradh Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_quota.h"
@@ -660,9 +660,10 @@ lfs_register_block(struct vnode *vp, dad
 static void
 lfs_do_deregister(struct lfs *fs, struct inode *ip, struct lbnentry *lbp)
 {
+
+	KASSERT(mutex_owned(_lock));
 	ASSERT_MAYBE_SEGLOCK(fs);
 
-	mutex_enter(_lock);
 	--ip->i_lfs_nbtree;
 	SPLAY_REMOVE(lfs_splay, >i_lfs_lbtree, lbp);
 	if (fs->lfs_favail > lfs_btofsb(fs, (1 << lfs_sb_getbshift(fs
@@ -671,9 +672,12 @@ lfs_do_deregister(struct lfs *fs, struct
 	if (locked_fakequeue_count > 0)
 		--locked_fakequeue_count;
 	lfs_subsys_pages -= lfs_sb_getbsize(fs) >> PAGE_SHIFT;
-	mutex_exit(_lock);
 
+	mutex_exit(_lock);
 	pool_put(_lbnentry_pool, lbp);
+	mutex_enter(_lock);
+
+	KASSERT(mutex_owned(_lock));
 }
 
 void
@@ -690,19 +694,18 @@ lfs_deregister_block(struct vnode *vp, d
 	if (lbn < 0 || vp->v_type != VREG || ip->i_number == LFS_IFILE_INUM)
 		return;
 
+	mutex_enter(_lock);
 	fs = ip->i_lfs;
 	tmp.lbn = lbn;
-	lbp = SPLAY_FIND(lfs_splay, >i_lfs_lbtree, );
-	if (lbp == NULL)
-		return;
-
-	lfs_do_deregister(fs, ip, lbp);
+	if ((lbp = SPLAY_FIND(lfs_splay, >i_lfs_lbtree, )) != NULL)
+		lfs_do_deregister(fs, ip, lbp);
+	mutex_exit(_lock);
 }
 
 void
 lfs_deregister_all(struct vnode *vp)
 {
-	struct lbnentry *lbp, *nlbp;
+	struct lbnentry *lbp;
 	struct lfs_splay *hd;
 	struct lfs *fs;
 	struct inode *ip;
@@ -711,8 +714,8 @@ lfs_deregister_all(struct vnode *vp)
 	fs = ip->i_lfs;
 	hd = >i_lfs_lbtree;
 
-	for (lbp = SPLAY_MIN(lfs_splay, hd); lbp != NULL; lbp = nlbp) {
-		nlbp = SPLAY_NEXT(lfs_splay, hd, lbp);
+	mutex_enter(_lock);
+	while ((lbp = SPLAY_MIN(lfs_splay, hd)) != NULL)
 		lfs_do_deregister(fs, ip, lbp);
-	}
+	mutex_exit(_lock);
 }



CVS commit: src/sys/ufs/lfs

2020-02-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Feb 23 08:39:28 UTC 2020

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

Log Message:
Prevent new dirops while we issue lfs_flush_dirops.

lfs_flush_dirops assumes (by KASSERT((ip->i_state & IN_ADIROP) == 0))
that vnodes on the dchain will not become involved in active dirops
even while holding no other locks (lfs_lock, v_interlock), so we must
set lfs_writer here.  All other callers already set lfs_writer.

We set fs->lfs_writer++ without explicitly doing lfs_writer_enter
because

(a) we already waited for the dirops to drain, and
(b) we hold lfs_lock and cannot drop it before setting lfs_writer.


To generate a diff of this commit:
cvs rdiff -u -r1.145 -r1.146 src/sys/ufs/lfs/lfs_bio.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.145 src/sys/ufs/lfs/lfs_bio.c:1.146
--- src/sys/ufs/lfs/lfs_bio.c:1.145	Tue Feb 18 20:23:17 2020
+++ src/sys/ufs/lfs/lfs_bio.c	Sun Feb 23 08:39:28 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_bio.c,v 1.145 2020/02/18 20:23:17 chs Exp $	*/
+/*	$NetBSD: lfs_bio.c,v 1.146 2020/02/23 08:39:28 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.145 2020/02/18 20:23:17 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_bio.c,v 1.146 2020/02/23 08:39:28 riastradh Exp $");
 
 #include 
 #include 
@@ -653,9 +653,14 @@ lfs_check(struct vnode *vp, daddr_t blkn
 	/* If there are too many pending dirops, we have to flush them. */
 	if (fs->lfs_dirvcount > LFS_MAX_FSDIROP(fs) ||
 	lfs_dirvcount > LFS_MAX_DIROP || fs->lfs_diropwait > 0) {
+		KASSERT(fs->lfs_dirops == 0);
+		fs->lfs_writer++;
 		mutex_exit(_lock);
 		lfs_flush_dirops(fs);
 		mutex_enter(_lock);
+		if (--fs->lfs_writer == 0)
+			cv_broadcast(>lfs_diropscv);
+		KASSERT(fs->lfs_dirops == 0);
 	} else if (locked_queue_count + INOCOUNT(fs) > LFS_MAX_BUFS ||
 	locked_queue_bytes + INOBYTES(fs) > LFS_MAX_BYTES ||
 	lfs_subsys_pages > LFS_MAX_PAGES ||



CVS commit: src/sys/ufs/lfs

2020-02-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Feb 23 08:39:39 UTC 2020

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

Log Message:
Assert lfs_writer where I think we can now prove it.


To generate a diff of this commit:
cvs rdiff -u -r1.326 -r1.327 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.326 src/sys/ufs/lfs/lfs_vnops.c:1.327
--- src/sys/ufs/lfs/lfs_vnops.c:1.326	Sun Feb 23 08:38:58 2020
+++ src/sys/ufs/lfs/lfs_vnops.c	Sun Feb 23 08:39:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_vnops.c,v 1.326 2020/02/23 08:38:58 riastradh Exp $	*/
+/*	$NetBSD: lfs_vnops.c,v 1.327 2020/02/23 08:39:39 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.326 2020/02/23 08:38:58 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.327 2020/02/23 08:39:39 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -1616,12 +1616,14 @@ lfs_flush_dirops(struct lfs *fs)
 	int error = 0;
 
 	ASSERT_MAYBE_SEGLOCK(fs);
-	KASSERT(fs->lfs_nadirop == 0);
+	KASSERT(fs->lfs_nadirop == 0); /* stable during lfs_writer */
+	KASSERT(fs->lfs_dirops == 0);  /* stable during lfs_writer */
 
 	if (fs->lfs_ronly)
 		return EROFS;
 
 	mutex_enter(_lock);
+	KASSERT(fs->lfs_writer);
 	if (TAILQ_FIRST(>lfs_dchainhd) == NULL) {
 		mutex_exit(_lock);
 		return 0;
@@ -1655,6 +1657,7 @@ lfs_flush_dirops(struct lfs *fs)
 	 *
 	 */
 	mutex_enter(_lock);
+	KASSERT(fs->lfs_writer);
 	TAILQ_INSERT_HEAD(>lfs_dchainhd, marker, i_lfs_dchain);
 	while ((ip = TAILQ_NEXT(marker, i_lfs_dchain)) != NULL) {
 		TAILQ_REMOVE(>lfs_dchainhd, marker, i_lfs_dchain);
@@ -1755,6 +1758,7 @@ lfs_flush_pchain(struct lfs *fs)
 	int error, error2;
 
 	ASSERT_NO_SEGLOCK(fs);
+	KASSERT(fs->lfs_writer);
 
 	if (fs->lfs_ronly)
 		return EROFS;



CVS commit: src/sys/ufs/lfs

2020-02-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Feb 23 08:39:09 UTC 2020

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

Log Message:
Just use VOP_BWRITE for lfs_bwrite_log.

Hope this doesn't cause trouble with vfs_suspend.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/ufs/lfs/lfs_debug.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_debug.c
diff -u src/sys/ufs/lfs/lfs_debug.c:1.54 src/sys/ufs/lfs/lfs_debug.c:1.55
--- src/sys/ufs/lfs/lfs_debug.c:1.54	Tue Sep  1 06:12:04 2015
+++ src/sys/ufs/lfs/lfs_debug.c	Sun Feb 23 08:39:09 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_debug.c,v 1.54 2015/09/01 06:12:04 dholland Exp $	*/
+/*	$NetBSD: lfs_debug.c,v 1.55 2020/02/23 08:39:09 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_debug.c,v 1.54 2015/09/01 06:12:04 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_debug.c,v 1.55 2020/02/23 08:39:09 riastradh Exp $");
 
 #ifdef DEBUG
 
@@ -84,16 +84,12 @@ struct lfs_log_entry lfs_log[LFS_LOGLENG
 int
 lfs_bwrite_log(struct buf *bp, const char *file, int line)
 {
-	struct vop_bwrite_args a;
-
-	a.a_desc = VDESC(vop_bwrite);
-	a.a_bp = bp;
 
 	if (!(bp->b_flags & B_GATHERED) && !(bp->b_oflags & BO_DELWRI)) {
 		LFS_ENTER_LOG("write", file, line, bp->b_lblkno, bp->b_flags,
 			curproc->p_pid);
 	}
-	return (VCALL(bp->b_vp, VOFFSET(vop_bwrite), ));
+	return VOP_BWRITE(bp->b_vp, bp);
 }
 
 void



CVS commit: src/sys/ufs/lfs

2020-02-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Feb 23 08:38:58 UTC 2020

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

Log Message:
Use a marker node to iterate lfs_dchainhd / i_lfs_dchain.

I believe elements can be removed while the lock is dropped,
including the next node we're hanging on to.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/ufs/lfs/lfs_inode.h
cvs rdiff -u -r1.97 -r1.98 src/sys/ufs/lfs/lfs_subr.c
cvs rdiff -u -r1.325 -r1.326 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.h
diff -u src/sys/ufs/lfs/lfs_inode.h:1.24 src/sys/ufs/lfs/lfs_inode.h:1.25
--- src/sys/ufs/lfs/lfs_inode.h:1.24	Tue Feb 18 20:23:17 2020
+++ src/sys/ufs/lfs/lfs_inode.h	Sun Feb 23 08:38:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_inode.h,v 1.24 2020/02/18 20:23:17 chs Exp $	*/
+/*	$NetBSD: lfs_inode.h,v 1.25 2020/02/23 08:38:58 riastradh 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  */
 
@@ -123,6 +123,7 @@ struct inode {
 /* 	   unused	0x0400 */	/* was FFS-only IN_SPACECOUNTED */
 #define	IN_PAGING   0x1000		/* LFS: file is on paging queue */
 #define IN_CDIROP   0x4000  /* LFS: dirop completed pending i/o */
+#define	IN_MARKER	0x0001	/* LFS: marker inode for iteration */
 
 /* 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)

Index: src/sys/ufs/lfs/lfs_subr.c
diff -u src/sys/ufs/lfs/lfs_subr.c:1.97 src/sys/ufs/lfs/lfs_subr.c:1.98
--- src/sys/ufs/lfs/lfs_subr.c:1.97	Wed Jul 26 16:42:37 2017
+++ src/sys/ufs/lfs/lfs_subr.c	Sun Feb 23 08:38:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_subr.c,v 1.97 2017/07/26 16:42:37 maya Exp $	*/
+/*	$NetBSD: lfs_subr.c,v 1.98 2020/02/23 08:38:58 riastradh 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.97 2017/07/26 16:42:37 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_subr.c,v 1.98 2020/02/23 08:38:58 riastradh Exp $");
 
 #include 
 #include 
@@ -337,10 +337,14 @@ lfs_seglock(struct lfs *fs, unsigned lon
 
 static void lfs_unmark_dirop(struct lfs *);
 
+static struct evcnt lfs_dchain_marker_pass_dirop =
+EVCNT_INITIALIZER(EVCNT_TYPE_MISC, NULL, "lfs", "dchain marker pass dirop");
+EVCNT_ATTACH_STATIC(lfs_dchain_marker_pass_dirop);
+
 static void
 lfs_unmark_dirop(struct lfs *fs)
 {
-	struct inode *ip, *nip;
+	struct inode *ip, *marker;
 	struct vnode *vp;
 	int doit;
 
@@ -349,13 +353,28 @@ lfs_unmark_dirop(struct lfs *fs)
 	doit = !(fs->lfs_flags & LFS_UNDIROP);
 	if (doit)
 		fs->lfs_flags |= LFS_UNDIROP;
-	if (!doit) {
-		mutex_exit(_lock);
+	mutex_exit(_lock);
+
+	if (!doit)
 		return;
-	}
 
-	for (ip = TAILQ_FIRST(>lfs_dchainhd); ip != NULL; ip = nip) {
-		nip = TAILQ_NEXT(ip, i_lfs_dchain);
+	marker = pool_get(_inode_pool, PR_WAITOK);
+	KASSERT(fs != NULL);
+	memset(marker, 0, sizeof(*marker));
+	marker->inode_ext.lfs = pool_get(_inoext_pool, PR_WAITOK);
+	memset(marker->inode_ext.lfs, 0, sizeof(*marker->inode_ext.lfs));
+	marker->i_state |= IN_MARKER;
+
+	mutex_enter(_lock);
+	TAILQ_INSERT_HEAD(>lfs_dchainhd, marker, i_lfs_dchain);
+	while ((ip = TAILQ_NEXT(marker, i_lfs_dchain)) != NULL) {
+		TAILQ_REMOVE(>lfs_dchainhd, marker, i_lfs_dchain);
+		TAILQ_INSERT_AFTER(>lfs_dchainhd, ip, marker,
+		i_lfs_dchain);
+		if (ip->i_state & IN_MARKER) {
+			lfs_dchain_marker_pass_dirop.ev_count++;
+			continue;
+		}
 		vp = ITOV(ip);
 		if ((ip->i_state & (IN_ADIROP | IN_CDIROP)) == IN_CDIROP) {
 			--lfs_dirvcount;
@@ -371,10 +390,13 @@ lfs_unmark_dirop(struct lfs *fs)
 			ip->i_state &= ~IN_CDIROP;
 		}
 	}
-
+	TAILQ_REMOVE(>lfs_dchainhd, marker, i_lfs_dchain);
 	fs->lfs_flags &= ~LFS_UNDIROP;
 	wakeup(>lfs_flags);
 	mutex_exit(_lock);
+
+	pool_put(_inoext_pool, marker->inode_ext.lfs);
+	pool_put(_inode_pool, marker);
 }
 
 static void

Index: src/sys/ufs/lfs/lfs_vnops.c
diff -u src/sys/ufs/lfs/lfs_vnops.c:1.325 src/sys/ufs/lfs/lfs_vnops.c:1.326
--- src/sys/ufs/lfs/lfs_vnops.c:1.325	Wed Sep 18 17:59:15 2019
+++ src/sys/ufs/lfs/lfs_vnops.c	Sun Feb 23 08:38:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_vnops.c,v 1.325 2019/09/18 17:59:15 christos Exp $	*/
+/*	$NetBSD: lfs_vnops.c,v 1.326 2020/02/23 08:38:58 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.325 2019/09/18 17:59:15 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.326 2020/02/23 08:38:58 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -1595,6 +1595,10 @@ lfs_strategy(void *v)
 	return VOP_STRATEGY(vp, bp);
 }

CVS commit: src/sys/ufs/lfs

2020-02-22 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Sat Feb 22 22:20:47 UTC 2020

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

Log Message:
Make LFS/rump play nice with aiodoned removal.

PR kern/55004 (Hundreds of file system tests now fail on real hardware)


To generate a diff of this commit:
cvs rdiff -u -r1.282 -r1.283 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.282 src/sys/ufs/lfs/lfs_segment.c:1.283
--- src/sys/ufs/lfs/lfs_segment.c:1.282	Tue Feb 18 20:23:17 2020
+++ src/sys/ufs/lfs/lfs_segment.c	Sat Feb 22 22:20:47 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_segment.c,v 1.282 2020/02/18 20:23:17 chs Exp $	*/
+/*	$NetBSD: lfs_segment.c,v 1.283 2020/02/22 22:20:47 ad 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.282 2020/02/18 20:23:17 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_segment.c,v 1.283 2020/02/22 22:20:47 ad Exp $");
 
 #ifdef DEBUG
 # define vndebug(vp, str) do {		\
@@ -2513,7 +2513,7 @@ lfs_free_aiodone(struct buf *bp)
 	fs = bp->b_private;
 	ASSERT_NO_SEGLOCK(fs);
 	lfs_freebuf(fs, bp);
-	KERNEL_UNLOCK_LAST(curlwp);
+	KERNEL_UNLOCK_ONE(curlwp);
 }
 
 static void
@@ -2531,7 +2531,7 @@ lfs_super_aiodone(struct buf *bp)
 	wakeup(>lfs_sbactive);
 	mutex_exit(_lock);
 	lfs_freebuf(fs, bp);
-	KERNEL_UNLOCK_LAST(curlwp);
+	KERNEL_UNLOCK_ONE(curlwp);
 }
 
 static void
@@ -2664,7 +2664,7 @@ lfs_cluster_aiodone(struct buf *bp)
 		wakeup(>lfs_iocount);
 	mutex_exit(_lock);
 
-	KERNEL_UNLOCK_LAST(curlwp);
+	KERNEL_UNLOCK_ONE(curlwp);
 
 	pool_put(>lfs_bpppool, cl->bpp);
 	cl->bpp = NULL;



CVS commit: src/sys/ufs/lfs

2020-02-21 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat Feb 22 00:32:09 UTC 2020

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

Log Message:
Avoid undefined behavior in *_BITMAP_FREE() macros

left shift of 1 by 31 places cannot be represented in type 'int'


To generate a diff of this commit:
cvs rdiff -u -r1.138 -r1.139 src/sys/ufs/lfs/lfs_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/lfs/lfs_alloc.c
diff -u src/sys/ufs/lfs/lfs_alloc.c:1.138 src/sys/ufs/lfs/lfs_alloc.c:1.139
--- src/sys/ufs/lfs/lfs_alloc.c:1.138	Fri Jan 17 20:08:10 2020
+++ src/sys/ufs/lfs/lfs_alloc.c	Sat Feb 22 00:32:08 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_alloc.c,v 1.138 2020/01/17 20:08:10 ad Exp $	*/
+/*	$NetBSD: lfs_alloc.c,v 1.139 2020/02/22 00:32:08 kamil 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.138 2020/01/17 20:08:10 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_alloc.c,v 1.139 2020/02/22 00:32:08 kamil Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_quota.h"
@@ -95,16 +95,16 @@ __KERNEL_RCSID(0, "$NetBSD: lfs_alloc.c,
 #define SET_BITMAP_FREE(F, I) do { \
 	DLOG((DLOG_ALLOC, "lfs: ino %d wrd %d bit %d set\n", (int)(I), 	\
 	 (int)((I) >> BMSHIFT), (int)((I) & BMMASK)));		\
-	(F)->lfs_ino_bitmap[(I) >> BMSHIFT] |= (1 << ((I) & BMMASK));	\
+	(F)->lfs_ino_bitmap[(I) >> BMSHIFT] |= (1U << ((I) & BMMASK));	\
 } while (0)
 #define CLR_BITMAP_FREE(F, I) do { \
 	DLOG((DLOG_ALLOC, "lfs: ino %d wrd %d bit %d clr\n", (int)(I), 	\
 	 (int)((I) >> BMSHIFT), (int)((I) & BMMASK)));		\
-	(F)->lfs_ino_bitmap[(I) >> BMSHIFT] &= ~(1 << ((I) & BMMASK));	\
+	(F)->lfs_ino_bitmap[(I) >> BMSHIFT] &= ~(1U << ((I) & BMMASK));	\
 } while(0)
 
 #define ISSET_BITMAP_FREE(F, I) \
-	((F)->lfs_ino_bitmap[(I) >> BMSHIFT] & (1 << ((I) & BMMASK)))
+	((F)->lfs_ino_bitmap[(I) >> BMSHIFT] & (1U << ((I) & BMMASK)))
 
 /*
  * Add a new block to the Ifile, to accommodate future file creations.



CVS commit: src/sys/ufs/lfs

2019-12-20 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Fri Dec 20 20:54:48 UTC 2019

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

Log Message:
Fix lfs_putpages() for bsize < nbpg.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 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.17 src/sys/ufs/lfs/lfs_pages.c:1.18
--- src/sys/ufs/lfs/lfs_pages.c:1.17	Sun Dec 15 21:11:35 2019
+++ src/sys/ufs/lfs/lfs_pages.c	Fri Dec 20 20:54:48 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_pages.c,v 1.17 2019/12/15 21:11:35 ad Exp $	*/
+/*	$NetBSD: lfs_pages.c,v 1.18 2019/12/20 20:54:48 ad Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2019 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_pages.c,v 1.17 2019/12/15 21:11:35 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_pages.c,v 1.18 2019/12/20 20:54:48 ad Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -310,7 +310,8 @@ check_dirty(struct lfs *fs, struct vnode
   (pg->flags & PG_CLEAN) == 0);
 			dirty += tdirty;
 		}
-		if (nonexistent >= pages_per_block) {
+		if ((pages_per_block > 0 && nonexistent >= pages_per_block) ||
+		(pages_per_block == 0 && nonexistent > 0)) {
 			soff += MAX(PAGE_SIZE, lfs_sb_getbsize(fs));
 			continue;
 		}
@@ -755,9 +756,6 @@ retry:
 		KASSERT(mutex_owned(vp->v_interlock));
 		if (check_dirty(fs, vp, startoffset, endoffset, blkeof,
 ap->a_flags, 0, ) < 0) {
-			mutex_exit(vp->v_interlock);
-			/* XXX why? --ks */
-			mutex_enter(vp->v_interlock);
 			write_and_wait(fs, vp, busypg, seglocked, NULL);
 			if (!seglocked) {
 mutex_exit(vp->v_interlock);



CVS commit: src/sys/ufs/lfs

2019-12-08 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Sun Dec  8 19:24:26 UTC 2019

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

Log Message:
Avoid thundering herd: cv_broadcast(>b_busy) -> cv_signal(>b_busy)


To generate a diff of this commit:
cvs rdiff -u -r1.278 -r1.279 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.278 src/sys/ufs/lfs/lfs_segment.c:1.279
--- src/sys/ufs/lfs/lfs_segment.c:1.278	Mon Sep  3 16:29:37 2018
+++ src/sys/ufs/lfs/lfs_segment.c	Sun Dec  8 19:24:26 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_segment.c,v 1.278 2018/09/03 16:29:37 riastradh Exp $	*/
+/*	$NetBSD: lfs_segment.c,v 1.279 2019/12/08 19:24:26 ad 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.278 2018/09/03 16:29:37 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_segment.c,v 1.279 2019/12/08 19:24:26 ad Exp $");
 
 #ifdef DEBUG
 # define vndebug(vp, str) do {		\
@@ -2197,7 +2197,7 @@ lfs_writeseg(struct lfs *fs, struct segm
 		if (unbusybp != NULL) {
 			unbusybp->b_cflags &= ~BC_BUSY;
 			if (unbusybp->b_cflags & BC_WANTED)
-cv_broadcast(>b_busy);
+cv_signal(>b_busy);
 		}
 	}
 	mutex_exit(_lock);



CVS commit: src/sys/ufs/lfs

2019-01-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Jan 10 06:31:04 UTC 2019

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

Log Message:
Update comment (overlooked in r1.179).
>From Jos� Luis Rodr�guez Garc�a in PR kern/53849.


To generate a diff of this commit:
cvs rdiff -u -r1.203 -r1.204 src/sys/ufs/lfs/lfs.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.203 src/sys/ufs/lfs/lfs.h:1.204
--- src/sys/ufs/lfs/lfs.h:1.203	Wed Jul 26 16:42:37 2017
+++ src/sys/ufs/lfs/lfs.h	Thu Jan 10 06:31:04 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs.h,v 1.203 2017/07/26 16:42:37 maya Exp $	*/
+/*	$NetBSD: lfs.h,v 1.204 2019/01/10 06:31:04 martin 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  */
@@ -467,7 +467,7 @@ struct lfs64_dinode {
 	int64_t		di_ib[ULFS_NIADDR]; /* 208: Indirect disk blocks. */
 	uint64_t	di_modrev;	/* 232: i_modrev for NFSv4 */
 	uint64_t	di_inumber;	/* 240: Inode number */
-	uint64_t	di_spare[1];	/* 244: Reserved; currently unused */
+	uint64_t	di_spare[1];	/* 248: Reserved; currently unused */
 };
 
 union lfs_dinode {



CVS commit: src/sys/ufs/lfs

2018-08-11 Thread Zafer Aydogan
Module Name:src
Committed By:   zafer
Date:   Sat Aug 11 20:16:21 UTC 2018

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

Log Message:
In lfs_mkdir fix wrong return path in case of EMLINK which causes a panic. 
Also, check earlier before setting up dirop.


To generate a diff of this commit:
cvs rdiff -u -r1.321 -r1.322 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.321 src/sys/ufs/lfs/lfs_vnops.c:1.322
--- src/sys/ufs/lfs/lfs_vnops.c:1.321	Sun Aug 20 05:37:03 2017
+++ src/sys/ufs/lfs/lfs_vnops.c	Sat Aug 11 20:16:21 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_vnops.c,v 1.321 2017/08/20 05:37:03 maya Exp $	*/
+/*	$NetBSD: lfs_vnops.c,v 1.322 2018/08/11 20:16:21 zafer 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.321 2017/08/20 05:37:03 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.322 2018/08/11 20:16:21 zafer Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -959,6 +959,11 @@ lfs_mkdir(void *v)
 	if (fs->lfs_ronly) {
 		return EROFS;
 	}
+
+	if ((nlink_t)dp->i_nlink >= LINK_MAX) {
+		return EMLINK;
+	}
+
 	dirblksiz = fs->um_dirblksiz;
 	/* XXX dholland 20150911 I believe this to be true, but... */
 	//KASSERT(dirblksiz == LFS_DIRBLKSIZ);
@@ -967,11 +972,6 @@ lfs_mkdir(void *v)
 	if (error)
 		return error;
 
-	if ((nlink_t)dp->i_nlink >= LINK_MAX) {
-		error = EMLINK;
-		goto out;
-	}
-
 	/*
 	 * Must simulate part of lfs_makeinode here to acquire the inode,
 	 * but not have it entered in the parent directory. The entry is



CVS commit: src/sys/ufs/lfs

2018-06-09 Thread Zafer Aydogan
Module Name:src
Committed By:   zafer
Date:   Sat Jun  9 18:48:31 UTC 2018

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

Log Message:
Add missing b_cflags and b_oflags.
Ok dholland@
Addresses PR kern/42342 by Yoshihiro Nakajima


To generate a diff of this commit:
cvs rdiff -u -r1.141 -r1.142 src/sys/ufs/lfs/lfs_bio.c
cvs rdiff -u -r1.276 -r1.277 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_bio.c
diff -u src/sys/ufs/lfs/lfs_bio.c:1.141 src/sys/ufs/lfs/lfs_bio.c:1.142
--- src/sys/ufs/lfs/lfs_bio.c:1.141	Sat Jun 10 05:29:36 2017
+++ src/sys/ufs/lfs/lfs_bio.c	Sat Jun  9 18:48:31 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_bio.c,v 1.141 2017/06/10 05:29:36 maya Exp $	*/
+/*	$NetBSD: lfs_bio.c,v 1.142 2018/06/09 18:48:31 zafer 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.141 2017/06/10 05:29:36 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_bio.c,v 1.142 2018/06/09 18:48:31 zafer Exp $");
 
 #include 
 #include 
@@ -420,8 +420,7 @@ lfs_bwrite_ext(struct buf *bp, int flags
 	ASSERT_MAYBE_SEGLOCK(fs);
 	KASSERT(bp->b_cflags & BC_BUSY);
 	KASSERT(flags & BW_CLEAN || !LFS_IS_MALLOC_BUF(bp));
-	KASSERT(((bp->b_oflags | bp->b_flags) & (BO_DELWRI|B_LOCKED))
-	!= BO_DELWRI);
+	KASSERT((bp->b_flags & B_LOCKED) || !(bp->b_oflags & BO_DELWRI));
 
 	/*
 	 * Don't write *any* blocks if we're mounted read-only, or

Index: src/sys/ufs/lfs/lfs_segment.c
diff -u src/sys/ufs/lfs/lfs_segment.c:1.276 src/sys/ufs/lfs/lfs_segment.c:1.277
--- src/sys/ufs/lfs/lfs_segment.c:1.276	Wed Jun  6 01:49:09 2018
+++ src/sys/ufs/lfs/lfs_segment.c	Sat Jun  9 18:48:31 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_segment.c,v 1.276 2018/06/06 01:49:09 maya Exp $	*/
+/*	$NetBSD: lfs_segment.c,v 1.277 2018/06/09 18:48:31 zafer 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.276 2018/06/06 01:49:09 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_segment.c,v 1.277 2018/06/09 18:48:31 zafer Exp $");
 
 #ifdef DEBUG
 # define vndebug(vp, str) do {		\
@@ -1408,13 +1408,13 @@ loop:
 			continue;
 		}
 #ifdef DIAGNOSTIC
-# ifdef LFS_USE_B_INVAL
-		if ((bp->b_flags & BC_INVAL) != 0 && bp->b_iodone == NULL) {
+# ifdef LFS_USE_BC_INVAL
+		if ((bp->b_cflags & BC_INVAL) != 0 && bp->b_iodone == NULL) {
 			DLOG((DLOG_SEG, "lfs_gather: lbn %" PRId64
 			  " is BC_INVAL\n", bp->b_lblkno));
 			VOP_PRINT(bp->b_vp);
 		}
-# endif /* LFS_USE_B_INVAL */
+# endif /* LFS_USE_BC_INVAL */
 		if (!(bp->b_oflags & BO_DELWRI))
 			panic("lfs_gather: bp not BO_DELWRI");
 		if (!(bp->b_flags & B_LOCKED)) {
@@ -2106,7 +2106,7 @@ lfs_writeseg(struct lfs *fs, struct segm
 	LFS_WRITESEGENTRY(sup, fs, sp->seg_number, bp); /* Ifile */
 
 	/*
-	 * Mark blocks B_BUSY, to prevent then from being changed between
+	 * Mark blocks BC_BUSY, to prevent then from being changed between
 	 * the checksum computation and the actual write.
 	 *
 	 * If we are cleaning, check indirect blocks for UNWRITTEN, and if
@@ -2217,7 +2217,7 @@ lfs_writeseg(struct lfs *fs, struct segm
 		/* Loop through gop_write cluster blocks */
 		for (byteoffset = 0; byteoffset < (*bpp)->b_bcount;
 		 byteoffset += lfs_sb_getbsize(fs)) {
-#ifdef LFS_USE_B_INVAL
+#ifdef LFS_USE_BC_INVAL
 			if (((*bpp)->b_cflags & BC_INVAL) != 0 &&
 			(*bpp)->b_iodone != NULL) {
 if (copyin((void *)(*bpp)->b_saveaddr +
@@ -2228,7 +2228,7 @@ lfs_writeseg(struct lfs *fs, struct segm
 		(*bpp)->b_lblkno);
 }
 			} else
-#endif /* LFS_USE_B_INVAL */
+#endif /* LFS_USE_BC_INVAL */
 			{
 sum = lfs_cksum_part((char *)
 (*bpp)->b_data + byteoffset, el_size, sum);
@@ -2320,9 +2320,9 @@ lfs_writeseg(struct lfs *fs, struct segm
 			bp->b_bcount, bp->b_blkno,
 			sp->seg_number);
 
-#ifdef LFS_USE_B_INVAL
+#ifdef LFS_USE_BC_INVAL
 			/*
-			 * Fake buffers from the cleaner are marked as B_INVAL.
+			 * Fake buffers from the cleaner are marked as BC_INVAL.
 			 * We need to copy the data from user space rather than
 			 * from the buffer indicated.
 			 * XXX == what do I do on an error?
@@ -2333,7 +2333,7 @@ lfs_writeseg(struct lfs *fs, struct segm
 	panic("lfs_writeseg: "
 	"copyin failed [2]");
 			} else
-#endif /* LFS_USE_B_INVAL */
+#endif /* LFS_USE_BC_INVAL */
 			if (cl->flags & LFS_CL_MALLOC) {
 /* copy data into our cluster. */
 memcpy(p, bp->b_data, bp->b_bcount);
@@ -2590,8 +2590,7 @@ lfs_cluster_aiodone(struct buf *bp)
 			tbp->b_flags |= B_ASYNC; /* for biodone */
 		}
 
-		if (((tbp->b_flags | tbp->b_oflags) &
-		(B_LOCKED | BO_DELWRI)) == B_LOCKED)
+		if ((tbp->b_flags & B_LOCKED) && !(tbp->b_oflags & BO_DELWRI))
 			LFS_UNLOCK_BUF(tbp);
 
 		if 

CVS commit: src/sys/ufs/lfs

2017-08-19 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Sun Aug 20 05:37:03 UTC 2017

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

Log Message:
Fix typo in comment


To generate a diff of this commit:
cvs rdiff -u -r1.320 -r1.321 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.320 src/sys/ufs/lfs/lfs_vnops.c:1.321
--- src/sys/ufs/lfs/lfs_vnops.c:1.320	Sat Aug 19 12:01:08 2017
+++ src/sys/ufs/lfs/lfs_vnops.c	Sun Aug 20 05:37:03 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_vnops.c,v 1.320 2017/08/19 12:01:08 maya Exp $	*/
+/*	$NetBSD: lfs_vnops.c,v 1.321 2017/08/20 05:37:03 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.320 2017/08/19 12:01:08 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.321 2017/08/20 05:37:03 maya Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -473,7 +473,7 @@ lfs_fsync(void *v)
 	}
 
 	/*
-	 * If a vnode is bring cleaned, flush it out before we try to
+	 * If a vnode is being cleaned, flush it out before we try to
 	 * reuse it.  This prevents the cleaner from writing files twice
 	 * in the same partial segment, causing an accounting underflow.
 	 */



CVS commit: src/sys/ufs/lfs

2017-08-19 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Sun Aug 20 00:03:12 UTC 2017

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

Log Message:
XXX question our double-flushing of dirops


To generate a diff of this commit:
cvs rdiff -u -r1.274 -r1.275 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.274 src/sys/ufs/lfs/lfs_segment.c:1.275
--- src/sys/ufs/lfs/lfs_segment.c:1.274	Wed Jul 26 16:42:37 2017
+++ src/sys/ufs/lfs/lfs_segment.c	Sun Aug 20 00:03:12 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_segment.c,v 1.274 2017/07/26 16:42:37 maya Exp $	*/
+/*	$NetBSD: lfs_segment.c,v 1.275 2017/08/20 00:03:12 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.274 2017/07/26 16:42:37 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_segment.c,v 1.275 2017/08/20 00:03:12 maya Exp $");
 
 #ifdef DEBUG
 # define vndebug(vp, str) do {		\
@@ -661,7 +661,11 @@ lfs_segwrite(struct mount *mp, int flags
 error = lfs_writevnodes(fs, mp, sp, VN_DIROP);
 if (um_error == 0)
 	um_error = error;
-/* In case writevnodes errored out */
+/*
+ * In case writevnodes errored out
+ * XXX why are we always doing this and not
+ * just on error?
+ */
 lfs_flush_dirops(fs);
 ssp = (SEGSUM *)(sp->segsum);
 lfs_ss_setflags(fs, ssp,



CVS commit: src/sys/ufs/lfs

2017-08-19 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Sat Aug 19 14:22:49 UTC 2017

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

Log Message:
Ask some question about the code in a XXX comment


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 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.14 src/sys/ufs/lfs/lfs_pages.c:1.15
--- src/sys/ufs/lfs/lfs_pages.c:1.14	Sat Jun 10 05:29:36 2017
+++ src/sys/ufs/lfs/lfs_pages.c	Sat Aug 19 14:22:49 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_pages.c,v 1.14 2017/06/10 05:29:36 maya Exp $	*/
+/*	$NetBSD: lfs_pages.c,v 1.15 2017/08/19 14:22:49 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.14 2017/06/10 05:29:36 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_pages.c,v 1.15 2017/08/19 14:22:49 maya Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -728,8 +728,11 @@ retry:
 		mutex_enter(vp->v_interlock);
 		lfs_writer_leave(fs);
 
-		/* The flush will have cleaned out this vnode as well,
-		   no need to do more to it. */
+		/*
+		 * The flush will have cleaned out this vnode as well,
+		 *  no need to do more to it.
+		 *  XXX then why are we falling through and continuing?
+		 */
 	}
 
 	/*



CVS commit: src/sys/ufs/lfs

2017-08-19 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Sat Aug 19 12:01:08 UTC 2017

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

Log Message:
Not much point doing anything after a panic call


To generate a diff of this commit:
cvs rdiff -u -r1.319 -r1.320 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.319 src/sys/ufs/lfs/lfs_vnops.c:1.320
--- src/sys/ufs/lfs/lfs_vnops.c:1.319	Sat Aug 19 11:27:42 2017
+++ src/sys/ufs/lfs/lfs_vnops.c	Sat Aug 19 12:01:08 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_vnops.c,v 1.319 2017/08/19 11:27:42 maya Exp $	*/
+/*	$NetBSD: lfs_vnops.c,v 1.320 2017/08/19 12:01:08 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.319 2017/08/19 11:27:42 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.320 2017/08/19 12:01:08 maya Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -1451,11 +1451,8 @@ lfs_reclaim(void *v)
 		ip->i_state &= ~IN_PAGING;
 		TAILQ_REMOVE(>lfs_pchainhd, ip, i_lfs_pchain);
 	}
-	if (vp->v_uflag & VU_DIROP) {
+	if (vp->v_uflag & VU_DIROP)
 		panic("reclaimed vnode is VU_DIROP");
-		vp->v_uflag &= ~VU_DIROP;
-		TAILQ_REMOVE(>lfs_dchainhd, ip, i_lfs_dchain);
-	}
 	mutex_exit(_lock);
 
 	pool_put(_dinode_pool, ip->i_din);



CVS commit: src/sys/ufs/lfs

2017-08-19 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Sat Aug 19 11:27:42 UTC 2017

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

Log Message:
Consistently use {,UN}MARK_VNODE macros rather than function calls.


To generate a diff of this commit:
cvs rdiff -u -r1.136 -r1.137 src/sys/ufs/lfs/lfs_alloc.c
cvs rdiff -u -r1.318 -r1.319 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_alloc.c
diff -u src/sys/ufs/lfs/lfs_alloc.c:1.136 src/sys/ufs/lfs/lfs_alloc.c:1.137
--- src/sys/ufs/lfs/lfs_alloc.c:1.136	Sat Jun 10 05:29:36 2017
+++ src/sys/ufs/lfs/lfs_alloc.c	Sat Aug 19 11:27:42 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_alloc.c,v 1.136 2017/06/10 05:29:36 maya Exp $	*/
+/*	$NetBSD: lfs_alloc.c,v 1.137 2017/08/19 11:27:42 maya 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.136 2017/06/10 05:29:36 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_alloc.c,v 1.137 2017/08/19 11:27:42 maya Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_quota.h"
@@ -510,7 +510,7 @@ lfs_vfree(struct vnode *vp, ino_t ino, i
 	 * not updated together in one function? (and why do both exist,
 	 * anyway?)
 	 */
-	lfs_unmark_vnode(vp);
+	UNMARK_VNODE(vp);
 
 	mutex_enter(_lock);
 	if (vp->v_uflag & VU_DIROP) {

Index: src/sys/ufs/lfs/lfs_vnops.c
diff -u src/sys/ufs/lfs/lfs_vnops.c:1.318 src/sys/ufs/lfs/lfs_vnops.c:1.319
--- src/sys/ufs/lfs/lfs_vnops.c:1.318	Wed Jul 26 16:42:37 2017
+++ src/sys/ufs/lfs/lfs_vnops.c	Sat Aug 19 11:27:42 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_vnops.c,v 1.318 2017/07/26 16:42:37 maya Exp $	*/
+/*	$NetBSD: lfs_vnops.c,v 1.319 2017/08/19 11:27:42 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.318 2017/07/26 16:42:37 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.319 2017/08/19 11:27:42 maya Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -374,7 +374,7 @@ lfs_makeinode(struct vattr *vap, struct 
 		vrele(tvp);
 		return error;
 	}
-	lfs_mark_vnode(tvp);
+	MARK_VNODE(tvp);
 	*vpp = tvp;
 	ip = VTOI(tvp);
 	ip->i_state |= IN_ACCESS | IN_CHANGE | IN_UPDATE;
@@ -419,7 +419,7 @@ lfs_makeinode(struct vattr *vap, struct 
 	DIP_ASSIGN(ip, nlink, 0);
 	ip->i_state |= IN_CHANGE;
 	/* If IN_ADIROP, account for it */
-	lfs_unmark_vnode(tvp);
+	UNMARK_VNODE(tvp);
 	vput(tvp);
 	return (error);
 }
@@ -526,7 +526,7 @@ lfs_inactive(void *v)
 
 	KASSERT(VOP_ISLOCKED(ap->a_vp) == LK_EXCLUSIVE);
 
-	lfs_unmark_vnode(ap->a_vp);
+	UNMARK_VNODE(ap->a_vp);
 
 	/*
 	 * The Ifile is only ever inactivated on unmount.
@@ -989,7 +989,7 @@ lfs_mkdir(void *v)
 	}
 
 	tvp = *ap->a_vpp;
-	lfs_mark_vnode(tvp);
+	MARK_VNODE(tvp);
 	ip = VTOI(tvp);
 	ip->i_state |= IN_ACCESS | IN_CHANGE | IN_UPDATE;
 	ip->i_nlink = 2;
@@ -1064,7 +1064,7 @@ lfs_mkdir(void *v)
 		DIP_ASSIGN(ip, nlink, 0);
 		ip->i_state |= IN_CHANGE;
 		/* If IN_ADIROP, account for it */
-		lfs_unmark_vnode(tvp);
+		UNMARK_VNODE(tvp);
 		vput(tvp);
 	}
 



CVS commit: src/sys/ufs/lfs

2017-08-04 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Fri Aug  4 07:27:42 UTC 2017

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

Log Message:
fix buffer overflow/KASSERT when cookies are supplied
lfs no longer uses the ffs-style struct direct, use the correct minimum
size

from dholland
XXX more wrong


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 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/ulfs_vnops.c
diff -u src/sys/ufs/lfs/ulfs_vnops.c:1.49 src/sys/ufs/lfs/ulfs_vnops.c:1.50
--- src/sys/ufs/lfs/ulfs_vnops.c:1.49	Sat Jun 10 05:29:36 2017
+++ src/sys/ufs/lfs/ulfs_vnops.c	Fri Aug  4 07:27:42 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ulfs_vnops.c,v 1.49 2017/06/10 05:29:36 maya Exp $	*/
+/*	$NetBSD: ulfs_vnops.c,v 1.50 2017/08/04 07:27:42 maya Exp $	*/
 /*  from NetBSD: ufs_vnops.c,v 1.232 2016/05/19 18:32:03 riastradh Exp  */
 
 /*-
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ulfs_vnops.c,v 1.49 2017/06/10 05:29:36 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ulfs_vnops.c,v 1.50 2017/08/04 07:27:42 maya Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_lfs.h"
@@ -826,7 +826,7 @@ ulfs_readdir(void *v)
 
 	off = uio->uio_offset;
 	if (ap->a_cookies) {
-		ccount = rcount / _DIRENT_RECLEN(ndp, 1);
+		ccount = rcount / LFS_DIRECTSIZ(fs, 1);
 		ccp = *(ap->a_cookies) = malloc(ccount * sizeof(*ccp),
 		M_TEMP, M_WAITOK);
 	} else {



CVS commit: src/sys/ufs/lfs

2017-07-26 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Wed Jul 26 16:42:37 UTC 2017

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

Log Message:
change lfs_nextsegsleep and lfs_allclean_wakeup to use condvar

XXX had to use lfs_lock in lfs_segwait, removed kernel_lock, is this
appropriate?


To generate a diff of this commit:
cvs rdiff -u -r1.202 -r1.203 src/sys/ufs/lfs/lfs.h
cvs rdiff -u -r1.112 -r1.113 src/sys/ufs/lfs/lfs_extern.h
cvs rdiff -u -r1.273 -r1.274 src/sys/ufs/lfs/lfs_segment.c
cvs rdiff -u -r1.96 -r1.97 src/sys/ufs/lfs/lfs_subr.c
cvs rdiff -u -r1.174 -r1.175 src/sys/ufs/lfs/lfs_syscalls.c
cvs rdiff -u -r1.359 -r1.360 src/sys/ufs/lfs/lfs_vfsops.c
cvs rdiff -u -r1.317 -r1.318 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.202 src/sys/ufs/lfs/lfs.h:1.203
--- src/sys/ufs/lfs/lfs.h:1.202	Mon Jun  5 01:01:42 2017
+++ src/sys/ufs/lfs/lfs.h	Wed Jul 26 16:42:37 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs.h,v 1.202 2017/06/05 01:01:42 maya Exp $	*/
+/*	$NetBSD: lfs.h,v 1.203 2017/07/26 16:42:37 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  */
@@ -1047,7 +1047,7 @@ struct lfs {
 	/* XXX: should be replaced with a condvar */
 	int lfs_availsleep;
 	/* This one replaces _nextseg... all ditto */
-	int lfs_nextsegsleep;
+	kcondvar_t lfs_nextsegsleep;
 
 	/* Cleaner lwp, set on first bmapv syscall. */
 	struct lwp *lfs_cleaner_thread;

Index: src/sys/ufs/lfs/lfs_extern.h
diff -u src/sys/ufs/lfs/lfs_extern.h:1.112 src/sys/ufs/lfs/lfs_extern.h:1.113
--- src/sys/ufs/lfs/lfs_extern.h:1.112	Thu Jun  8 01:23:01 2017
+++ src/sys/ufs/lfs/lfs_extern.h	Wed Jul 26 16:42:37 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_extern.h,v 1.112 2017/06/08 01:23:01 chs Exp $	*/
+/*	$NetBSD: lfs_extern.h,v 1.113 2017/07/26 16:42:37 maya Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -109,7 +109,7 @@ __BEGIN_DECLS
 
 #if defined(_KERNEL)
 
-extern int lfs_allclean_wakeup;
+extern kcondvar_t lfs_allclean_wakeup;
 extern struct pool lfs_inode_pool;		/* memory pool for inodes */
 extern struct pool lfs_dinode_pool;		/* memory pool for dinodes */
 extern struct pool lfs_inoext_pool;	/* memory pool for inode extension */

Index: src/sys/ufs/lfs/lfs_segment.c
diff -u src/sys/ufs/lfs/lfs_segment.c:1.273 src/sys/ufs/lfs/lfs_segment.c:1.274
--- src/sys/ufs/lfs/lfs_segment.c:1.273	Wed Jul 26 15:07:27 2017
+++ src/sys/ufs/lfs/lfs_segment.c	Wed Jul 26 16:42:37 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_segment.c,v 1.273 2017/07/26 15:07:27 maya Exp $	*/
+/*	$NetBSD: lfs_segment.c,v 1.274 2017/07/26 16:42:37 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.273 2017/07/26 15:07:27 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_segment.c,v 1.274 2017/07/26 16:42:37 maya Exp $");
 
 #ifdef DEBUG
 # define vndebug(vp, str) do {		\
@@ -145,7 +145,7 @@ int	 lfs_writevnodes(struct lfs *fs, str
 static void lfs_shellsort(struct lfs *, struct buf **, union lfs_blocks *,
 			  int, int);
 
-int	lfs_allclean_wakeup;		/* Cleaner wakeup address. */
+kcondvar_t	lfs_allclean_wakeup;	/* Cleaner wakeup address. */
 int	lfs_writeindir = 1;		/* whether to flush indir on non-ckp */
 int	lfs_clean_vnhead = 0;		/* Allow freeing to head of vn list */
 int	lfs_dirvcount = 0;		/* # active dirops */

Index: src/sys/ufs/lfs/lfs_subr.c
diff -u src/sys/ufs/lfs/lfs_subr.c:1.96 src/sys/ufs/lfs/lfs_subr.c:1.97
--- src/sys/ufs/lfs/lfs_subr.c:1.96	Wed Jul 26 14:38:59 2017
+++ src/sys/ufs/lfs/lfs_subr.c	Wed Jul 26 16:42:37 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_subr.c,v 1.96 2017/07/26 14:38:59 maya Exp $	*/
+/*	$NetBSD: lfs_subr.c,v 1.97 2017/07/26 16:42:37 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.96 2017/07/26 14:38:59 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_subr.c,v 1.97 2017/07/26 16:42:37 maya Exp $");
 
 #include 
 #include 
@@ -649,6 +649,6 @@ lfs_wakeup_cleaner(struct lfs *fs)
 	if (fs->lfs_nowrap > 0)
 		return;
 
-	wakeup(>lfs_nextsegsleep);
-	wakeup(_allclean_wakeup);
+	cv_broadcast(>lfs_nextsegsleep);
+	cv_broadcast(_allclean_wakeup);
 }

Index: src/sys/ufs/lfs/lfs_syscalls.c
diff -u src/sys/ufs/lfs/lfs_syscalls.c:1.174 src/sys/ufs/lfs/lfs_syscalls.c:1.175
--- src/sys/ufs/lfs/lfs_syscalls.c:1.174	Mon Apr 17 08:32:01 2017
+++ src/sys/ufs/lfs/lfs_syscalls.c	Wed Jul 26 16:42:37 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_syscalls.c,v 1.174 2017/04/17 08:32:01 hannken Exp $	*/
+/*	$NetBSD: lfs_syscalls.c,v 1.175 

CVS commit: src/sys/ufs/lfs

2017-07-26 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Wed Jul 26 15:07:27 UTC 2017

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

Log Message:
Revert r1.272 fix to PR kern/52301, the performance hit is making things
unusable.


To generate a diff of this commit:
cvs rdiff -u -r1.272 -r1.273 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.272 src/sys/ufs/lfs/lfs_segment.c:1.273
--- src/sys/ufs/lfs/lfs_segment.c:1.272	Thu Jun 15 14:37:30 2017
+++ src/sys/ufs/lfs/lfs_segment.c	Wed Jul 26 15:07:27 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_segment.c,v 1.272 2017/06/15 14:37:30 maya Exp $	*/
+/*	$NetBSD: lfs_segment.c,v 1.273 2017/07/26 15:07:27 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.272 2017/06/15 14:37:30 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_segment.c,v 1.273 2017/07/26 15:07:27 maya Exp $");
 
 #ifdef DEBUG
 # define vndebug(vp, str) do {		\
@@ -603,6 +603,7 @@ lfs_segwrite(struct mount *mp, int flags
 	SEGUSE *segusep;
 	int do_ckp, did_ckp, error;
 	unsigned n, segleft, maxseg, sn, i, curseg;
+	int writer_set = 0;
 	int dirty;
 	int redo;
 	SEGSUM *ssp;
@@ -627,8 +628,6 @@ lfs_segwrite(struct mount *mp, int flags
 	if (do_ckp)
 		flags &= ~SEGM_SINGLE;
 
-	lfs_writer_enter(fs, "lfs segwrite");
-
 	lfs_seglock(fs, flags | (do_ckp ? SEGM_CKP : 0));
 	sp = fs->lfs_sp;
 	if (sp->seg_flags & (SEGM_CLEAN | SEGM_CKP))
@@ -654,7 +653,11 @@ lfs_segwrite(struct mount *mp, int flags
 break;
 			}
 
-			if (do_ckp) {
+			if (do_ckp || fs->lfs_dirops == 0) {
+if (!writer_set) {
+	lfs_writer_enter(fs, "lfs writer");
+	writer_set = 1;
+}
 error = lfs_writevnodes(fs, mp, sp, VN_DIROP);
 if (um_error == 0)
 	um_error = error;
@@ -803,7 +806,8 @@ lfs_segwrite(struct mount *mp, int flags
 
 	/* Note Ifile no longer needs to be written */
 	fs->lfs_doifile = 0;
-	lfs_writer_leave(fs);
+	if (writer_set)
+		lfs_writer_leave(fs);
 
 	/*
 	 * If we didn't write the Ifile, we didn't really do anything.



CVS commit: src/sys/ufs/lfs

2017-07-26 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Wed Jul 26 14:39:00 UTC 2017

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

Log Message:
Deduplicate sanity check that seglock is held on segunlock


To generate a diff of this commit:
cvs rdiff -u -r1.95 -r1.96 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.95 src/sys/ufs/lfs/lfs_subr.c:1.96
--- src/sys/ufs/lfs/lfs_subr.c:1.95	Mon Jun 19 12:09:37 2017
+++ src/sys/ufs/lfs/lfs_subr.c	Wed Jul 26 14:38:59 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_subr.c,v 1.95 2017/06/19 12:09:37 maya Exp $	*/
+/*	$NetBSD: lfs_subr.c,v 1.96 2017/07/26 14:38:59 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.95 2017/06/19 12:09:37 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_subr.c,v 1.96 2017/07/26 14:38:59 maya Exp $");
 
 #include 
 #include 
@@ -430,7 +430,10 @@ lfs_segunlock(struct lfs *fs)
 	sp = fs->lfs_sp;
 
 	mutex_enter(_lock);
-	KASSERT(LFS_SEGLOCK_HELD(fs));
+
+	if (!LFS_SEGLOCK_HELD(fs))
+		panic("lfs seglock not held");
+
 	if (fs->lfs_seglock == 1) {
 		if ((sp->seg_flags & (SEGM_PROT | SEGM_CLEAN)) == 0)
 			do_unmark_dirop = 1;
@@ -534,9 +537,6 @@ lfs_segunlock(struct lfs *fs)
 		rw_exit(>lfs_fraglock);
 		if (do_unmark_dirop)
 			lfs_unmark_dirop(fs);
-	} else if (fs->lfs_seglock == 0) {
-		mutex_exit(_lock);
-		panic ("Seglock not held");
 	} else {
 		--fs->lfs_seglock;
 		mutex_exit(_lock);



CVS commit: src/sys/ufs/lfs

2017-06-19 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Mon Jun 19 12:09:37 UTC 2017

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

Log Message:
Ifdef out KDASSERT which fires on my machine.


To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 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.94 src/sys/ufs/lfs/lfs_subr.c:1.95
--- src/sys/ufs/lfs/lfs_subr.c:1.94	Sat Jun 10 05:29:36 2017
+++ src/sys/ufs/lfs/lfs_subr.c	Mon Jun 19 12:09:37 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_subr.c,v 1.94 2017/06/10 05:29:36 maya Exp $	*/
+/*	$NetBSD: lfs_subr.c,v 1.95 2017/06/19 12:09:37 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.94 2017/06/10 05:29:36 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_subr.c,v 1.95 2017/06/19 12:09:37 maya Exp $");
 
 #include 
 #include 
@@ -261,10 +261,12 @@ lfs_free(struct lfs *fs, void *p, int ty
 		}
 	}
 
+#ifdef notyet /* XXX this assert fires */
 	for (int i = 0; i < LFS_N_TOTAL; i++) {
 		KDASSERTMSG(fs->lfs_resblk[i].p == p,
 		"lfs_free: inconsistent reserved block");
 	}
+#endif
 
 	mutex_exit(_lock);
 



CVS commit: src/sys/ufs/lfs

2017-06-15 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Thu Jun 15 14:37:31 UTC 2017

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

Log Message:
It isn't safe to drain dirops with seglock held, it'll deadlock if there
are any dirops. drain before grabbing seglock.

lfs_dirops == 0 is always true (as we already drained dirops), so omit
that part of the comparison.

Fixes a lot of LFS deadlocks. PR kern/52301

Many thanks to dholland for help analyzing coredumps


To generate a diff of this commit:
cvs rdiff -u -r1.271 -r1.272 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.271 src/sys/ufs/lfs/lfs_segment.c:1.272
--- src/sys/ufs/lfs/lfs_segment.c:1.271	Mon Jun 12 15:02:32 2017
+++ src/sys/ufs/lfs/lfs_segment.c	Thu Jun 15 14:37:30 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_segment.c,v 1.271 2017/06/12 15:02:32 maya Exp $	*/
+/*	$NetBSD: lfs_segment.c,v 1.272 2017/06/15 14:37:30 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.271 2017/06/12 15:02:32 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_segment.c,v 1.272 2017/06/15 14:37:30 maya Exp $");
 
 #ifdef DEBUG
 # define vndebug(vp, str) do {		\
@@ -603,7 +603,6 @@ lfs_segwrite(struct mount *mp, int flags
 	SEGUSE *segusep;
 	int do_ckp, did_ckp, error;
 	unsigned n, segleft, maxseg, sn, i, curseg;
-	int writer_set = 0;
 	int dirty;
 	int redo;
 	SEGSUM *ssp;
@@ -628,6 +627,8 @@ lfs_segwrite(struct mount *mp, int flags
 	if (do_ckp)
 		flags &= ~SEGM_SINGLE;
 
+	lfs_writer_enter(fs, "lfs segwrite");
+
 	lfs_seglock(fs, flags | (do_ckp ? SEGM_CKP : 0));
 	sp = fs->lfs_sp;
 	if (sp->seg_flags & (SEGM_CLEAN | SEGM_CKP))
@@ -653,11 +654,7 @@ lfs_segwrite(struct mount *mp, int flags
 break;
 			}
 
-			if (do_ckp || fs->lfs_dirops == 0) {
-if (!writer_set) {
-	lfs_writer_enter(fs, "lfs writer");
-	writer_set = 1;
-}
+			if (do_ckp) {
 error = lfs_writevnodes(fs, mp, sp, VN_DIROP);
 if (um_error == 0)
 	um_error = error;
@@ -806,8 +803,7 @@ lfs_segwrite(struct mount *mp, int flags
 
 	/* Note Ifile no longer needs to be written */
 	fs->lfs_doifile = 0;
-	if (writer_set)
-		lfs_writer_leave(fs);
+	lfs_writer_leave(fs);
 
 	/*
 	 * If we didn't write the Ifile, we didn't really do anything.



CVS commit: src/sys/ufs/lfs

2017-06-12 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Mon Jun 12 15:02:32 UTC 2017

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

Log Message:
Use continue to denote the no-op loop to match netbsd style
newline for extra clarity.


To generate a diff of this commit:
cvs rdiff -u -r1.270 -r1.271 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.270 src/sys/ufs/lfs/lfs_segment.c:1.271
--- src/sys/ufs/lfs/lfs_segment.c:1.270	Sat Jun 10 05:29:36 2017
+++ src/sys/ufs/lfs/lfs_segment.c	Mon Jun 12 15:02:32 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_segment.c,v 1.270 2017/06/10 05:29:36 maya Exp $	*/
+/*	$NetBSD: lfs_segment.c,v 1.271 2017/06/12 15:02:32 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.270 2017/06/10 05:29:36 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_segment.c,v 1.271 2017/06/12 15:02:32 maya Exp $");
 
 #ifdef DEBUG
 # define vndebug(vp, str) do {		\
@@ -1381,7 +1381,8 @@ loop:
 	for (bp = LIST_FIRST(>v_dirtyblkhd);
 	 bp && LIST_NEXT(bp, b_vnbufs) != NULL;
 	 bp = LIST_NEXT(bp, b_vnbufs))
-		/* nothing */;
+		continue;
+
 	for (; bp && bp != BEG_OF_LIST; bp = nbp) {
 		nbp = BACK_BUF(bp);
 #else /* LFS_NO_BACKBUF_HACK */



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/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/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/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/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/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/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/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/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/lfs

2016-08-06 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sun Aug  7 05:09:12 UTC 2016

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

Log Message:
Remove unused 


To generate a diff of this commit:
cvs rdiff -u -r1.132 -r1.133 src/sys/ufs/lfs/lfs_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/lfs/lfs_alloc.c
diff -u src/sys/ufs/lfs/lfs_alloc.c:1.132 src/sys/ufs/lfs/lfs_alloc.c:1.133
--- src/sys/ufs/lfs/lfs_alloc.c:1.132	Sun Aug  7 00:12:48 2016
+++ src/sys/ufs/lfs/lfs_alloc.c	Sun Aug  7 05:09:12 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_alloc.c,v 1.132 2016/08/07 00:12:48 dholland Exp $	*/
+/*	$NetBSD: lfs_alloc.c,v 1.133 2016/08/07 05:09:12 dholland 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.132 2016/08/07 00:12:48 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_alloc.c,v 1.133 2016/08/07 05:09:12 dholland Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_quota.h"
@@ -77,7 +77,6 @@ __KERNEL_RCSID(0, "$NetBSD: lfs_alloc.c,
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include 



CVS commit: src/sys/ufs/lfs

2016-08-06 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sun Aug  7 02:42:32 UTC 2016

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

Log Message:
Fix stupid thinko.


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/sys/ufs/lfs/lfs_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/lfs/lfs_balloc.c
diff -u src/sys/ufs/lfs/lfs_balloc.c:1.90 src/sys/ufs/lfs/lfs_balloc.c:1.91
--- src/sys/ufs/lfs/lfs_balloc.c:1.90	Sun Aug  7 02:31:03 2016
+++ src/sys/ufs/lfs/lfs_balloc.c	Sun Aug  7 02:42:32 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_balloc.c,v 1.90 2016/08/07 02:31:03 dholland Exp $	*/
+/*	$NetBSD: lfs_balloc.c,v 1.91 2016/08/07 02:42:32 dholland 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.90 2016/08/07 02:31:03 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_balloc.c,v 1.91 2016/08/07 02:42:32 dholland Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_quota.h"
@@ -502,15 +502,15 @@ lfs_fragextend(struct vnode *vp, int osi
 	/* (XXX: except it's not clear what purpose it serves) */
 	extern long locked_queue_bytes;
 
+	ip = VTOI(vp);
+	fs = ip->i_lfs;
+
 	/*
 	 * XXX: is there some reason we know more about the seglock
 	 * state here than at the top of lfs_balloc?
 	 */
 	ASSERT_NO_SEGLOCK(fs);
 
-	ip = VTOI(vp);
-	fs = ip->i_lfs;
-
 	/* number of frags we're adding */
 	frags = (long)lfs_numfrags(fs, nsize - osize);
 



CVS commit: src/sys/ufs/lfs

2016-08-06 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sun Aug  7 02:31:03 UTC 2016

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

Log Message:
comments


To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.90 src/sys/ufs/lfs/lfs_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/lfs/lfs_balloc.c
diff -u src/sys/ufs/lfs/lfs_balloc.c:1.89 src/sys/ufs/lfs/lfs_balloc.c:1.90
--- src/sys/ufs/lfs/lfs_balloc.c:1.89	Sun Aug  7 00:25:22 2016
+++ src/sys/ufs/lfs/lfs_balloc.c	Sun Aug  7 02:31:03 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_balloc.c,v 1.89 2016/08/07 00:25:22 dholland Exp $	*/
+/*	$NetBSD: lfs_balloc.c,v 1.90 2016/08/07 02:31:03 dholland 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.89 2016/08/07 00:25:22 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_balloc.c,v 1.90 2016/08/07 02:31:03 dholland Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_quota.h"
@@ -97,17 +97,23 @@ static int lfs_fragextend(struct vnode *
 u_int64_t locked_fakequeue_count;
 
 /*
- * Allocate a block, and to inode and filesystem block accounting for it
- * and for any indirect blocks the may need to be created in order for
- * this block to be created.
- *
- * Blocks which have never been accounted for (i.e., which "do not exist")
- * have disk address 0, which is translated by ulfs_bmap to the special value
- * UNASSIGNED == -1, as in the historical ULFS.
- *
- * Blocks which have been accounted for but which have not yet been written
- * to disk are given the new special disk address UNWRITTEN == -2, so that
- * they can be differentiated from completely new blocks.
+ * Allocate a block, and do inode and filesystem block accounting for
+ * it and for any indirect blocks that may need to be created in order
+ * to handle this block.
+ *
+ * Blocks which have never been accounted for (i.e., which "do not
+ * exist") have disk address 0, which is translated by ulfs_bmap to
+ * the special value UNASSIGNED == -1, as in historical FFS-related
+ * code.
+ *
+ * Blocks which have been accounted for but which have not yet been
+ * written to disk are given the new special disk address UNWRITTEN ==
+ * -2, so that they can be differentiated from completely new blocks.
+ *
+ * Note: it seems that bpp is passed as NULL for blocks that are file
+ * pages that will be handled by UVM and not the buffer cache.
+ *
+ * XXX: locking?
  */
 /* VOP_BWRITE ULFS_NIADDR+2 times */
 int
@@ -126,12 +132,27 @@ lfs_balloc(struct vnode *vp, off_t start
 
 	ip = VTOI(vp);
 	fs = ip->i_lfs;
+
+	/* Declare to humans that we might have the seglock here */
+	ASSERT_MAYBE_SEGLOCK(fs);
+
+
+	/* offset within block */
 	offset = lfs_blkoff(fs, startoffset);
+
+	/* This is usually but not always exactly the block size */
 	KASSERT(iosize <= lfs_sb_getbsize(fs));
+
+	/* block number (within file) */
 	lbn = lfs_lblkno(fs, startoffset);
+
+	/*
+	 * This checks for whether pending stuff needs to be flushed
+	 * out and potentially waits. It's been disabled since UBC
+	 * support was added to LFS in 2003. -- dholland 20160806
+	 */
 	/* (void)lfs_check(vp, lbn, 0); */
 
-	ASSERT_MAYBE_SEGLOCK(fs);
 
 	/*
 	 * Three cases: it's a block beyond the end of file, it's a block in
@@ -152,19 +173,29 @@ lfs_balloc(struct vnode *vp, off_t start
 	if (bpp)
 		*bpp = NULL;
 
-	/* Check for block beyond end of file and fragment extension needed. */
+	/* Last block number in file */
 	lastblock = lfs_lblkno(fs, ip->i_size);
+
 	if (lastblock < ULFS_NDADDR && lastblock < lbn) {
+		/*
+		 * The file is small enough to have fragments, and we're
+		 * allocating past EOF.
+		 *
+		 * If the last block was a fragment we need to rewrite it
+		 * as a full block.
+		 */
 		osize = lfs_blksize(fs, ip, lastblock);
 		if (osize < lfs_sb_getbsize(fs) && osize > 0) {
 			if ((error = lfs_fragextend(vp, osize, lfs_sb_getbsize(fs),
 		lastblock,
 		(bpp ?  : NULL), cred)))
 return (error);
+			/* Update the file size with what we just did (only) */
 			ip->i_size = (lastblock + 1) * lfs_sb_getbsize(fs);
 			lfs_dino_setsize(fs, ip->i_din, ip->i_size);
 			uvm_vnp_setsize(vp, ip->i_size);
 			ip->i_flag |= IN_CHANGE | IN_UPDATE;
+			/* if we got a buffer for this, write it out now */
 			if (bpp)
 (void) VOP_BWRITE(bp->b_vp, bp);
 		}
@@ -192,12 +223,24 @@ lfs_balloc(struct vnode *vp, off_t start
 if (flags & B_CLRBUF)
 	clrbuf(bp);
 			}
+
+			/*
+			 * Update the effective block count (this count
+			 * includes blocks that don't have an on-disk
+			 * presence or location yet)
+			 */
 			ip->i_lfs_effnblks += frags;
+
+			/* account for the space we're taking */
 			mutex_enter(_lock);
 			lfs_sb_subbfree(fs, frags);
 			mutex_exit(_lock);
+
+			/* update the inode */
 			lfs_dino_setdb(fs, ip->i_din, lbn, 

CVS commit: src/sys/ufs/lfs

2016-08-06 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sun Aug  7 00:25:22 UTC 2016

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

Log Message:
use static properly


To generate a diff of this commit:
cvs rdiff -u -r1.88 -r1.89 src/sys/ufs/lfs/lfs_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/lfs/lfs_balloc.c
diff -u src/sys/ufs/lfs/lfs_balloc.c:1.88 src/sys/ufs/lfs/lfs_balloc.c:1.89
--- src/sys/ufs/lfs/lfs_balloc.c:1.88	Sat Oct 10 22:33:31 2015
+++ src/sys/ufs/lfs/lfs_balloc.c	Sun Aug  7 00:25:22 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_balloc.c,v 1.88 2015/10/10 22:33:31 dholland Exp $	*/
+/*	$NetBSD: lfs_balloc.c,v 1.89 2016/08/07 00:25:22 dholland 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.88 2015/10/10 22:33:31 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_balloc.c,v 1.89 2016/08/07 00:25:22 dholland Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_quota.h"
@@ -91,7 +91,8 @@ __KERNEL_RCSID(0, "$NetBSD: lfs_balloc.c
 
 #include 
 
-int lfs_fragextend(struct vnode *, int, int, daddr_t, struct buf **, kauth_cred_t);
+static int lfs_fragextend(struct vnode *, int, int, daddr_t, struct buf **,
+			  kauth_cred_t);
 
 u_int64_t locked_fakequeue_count;
 
@@ -365,9 +366,9 @@ lfs_balloc(struct vnode *vp, off_t start
 }
 
 /* VOP_BWRITE 1 time */
-int
-lfs_fragextend(struct vnode *vp, int osize, int nsize, daddr_t lbn, struct buf **bpp,
-kauth_cred_t cred)
+static int
+lfs_fragextend(struct vnode *vp, int osize, int nsize, daddr_t lbn,
+struct buf **bpp, kauth_cred_t cred)
 {
 	struct inode *ip;
 	struct lfs *fs;



CVS commit: src/sys/ufs/lfs

2016-07-21 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jul 21 18:10:47 UTC 2016

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

Log Message:
Don't do variable stack allocations for systems with non-const PAGE_SIZE;
instead assume that the smallest pagesize is 1024.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 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.7 src/sys/ufs/lfs/lfs_pages.c:1.8
--- src/sys/ufs/lfs/lfs_pages.c:1.7	Wed Aug 12 14:26:27 2015
+++ src/sys/ufs/lfs/lfs_pages.c	Thu Jul 21 14:10:47 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_pages.c,v 1.7 2015/08/12 18:26:27 dholland Exp $	*/
+/*	$NetBSD: lfs_pages.c,v 1.8 2016/07/21 18:10:47 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.7 2015/08/12 18:26:27 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_pages.c,v 1.8 2016/07/21 18:10:47 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -244,7 +244,8 @@ check_dirty(struct lfs *fs, struct vnode
 {
 	int by_list;
 	struct vm_page *curpg = NULL; /* XXX: gcc */
-	struct vm_page *pgs[MAXBSIZE / PAGE_SIZE], *pg;
+	struct vm_page *pgs[MAXBSIZE /
+	(__builtin_constant_p(PAGE_SIZE) ? PAGE_SIZE : 1024)], *pg;
 	off_t soff = 0; /* XXX: gcc */
 	voff_t off;
 	int i;



CVS commit: src/sys/ufs/lfs

2016-06-21 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Tue Jun 21 06:14:40 UTC 2016

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

Log Message:
Revert version 1.19 (make ufid_ino in struct ulfs_ufid 64-bit) -- via
a twisty maze of marginal if not illegal type punning it breaks the
cleaner.

This will need to be done over, but it requires substantially more
mechanism and compat ioctls. Booo.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/ufs/lfs/ulfs_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/ulfs_inode.h
diff -u src/sys/ufs/lfs/ulfs_inode.h:1.21 src/sys/ufs/lfs/ulfs_inode.h:1.22
--- src/sys/ufs/lfs/ulfs_inode.h:1.21	Mon Jun 20 03:29:52 2016
+++ src/sys/ufs/lfs/ulfs_inode.h	Tue Jun 21 06:14:40 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ulfs_inode.h,v 1.21 2016/06/20 03:29:52 dholland Exp $	*/
+/*	$NetBSD: ulfs_inode.h,v 1.22 2016/06/21 06:14:40 dholland Exp $	*/
 /*  from NetBSD: inode.h,v 1.72 2016/06/03 15:36:03 christos Exp  */
 
 /*
@@ -146,8 +146,8 @@ typedef struct lfs_res_blk {
 struct ulfs_ufid {
 	uint16_t ufid_len;	/* Length of structure. */
 	uint16_t ufid_pad;	/* Force 32-bit alignment. */
+	uint32_t ufid_ino;	/* File number (ino). XXX should be 64 */
 	int32_t	  ufid_gen;	/* Generation number. */
-	uint64_t ufid_ino;	/* File number (ino). */
 };
 /* Filehandle structure for exported LFSes */
 struct lfid {



CVS commit: src/sys/ufs/lfs

2016-06-19 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Jun 20 03:55:34 UTC 2016

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

Log Message:
In lfs_mknod, don't release dvp until done with it. This was exposed a
while back when I removed a sketchy preprocessor macro scheme, but I'd
left it the way it was at the time and marked it for later. Now I
guess it's later.

Also don't randomly use both dvp and ap->a_dvp; they're the same, so
pick one and stick to it.


To generate a diff of this commit:
cvs rdiff -u -r1.302 -r1.303 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.302 src/sys/ufs/lfs/lfs_vnops.c:1.303
--- src/sys/ufs/lfs/lfs_vnops.c:1.302	Mon Jun 20 03:36:09 2016
+++ src/sys/ufs/lfs/lfs_vnops.c	Mon Jun 20 03:55:34 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_vnops.c,v 1.302 2016/06/20 03:36:09 dholland Exp $	*/
+/*	$NetBSD: lfs_vnops.c,v 1.303 2016/06/20 03:55:34 dholland 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.302 2016/06/20 03:36:09 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.303 2016/06/20 03:55:34 dholland Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -806,22 +806,17 @@ lfs_mknod(void *v)
 	if (error)
 		return error;
 
-	fstrans_start(ap->a_dvp->v_mount, FSTRANS_SHARED);
+	fstrans_start(dvp->v_mount, FSTRANS_SHARED);
 	error = lfs_makeinode(vap, dvp, ulr, vpp, ap->a_cnp);
 
 	/* Either way we're done with the dirop at this point */
 	UNMARK_VNODE(dvp);
 	UNMARK_VNODE(*vpp);
 	lfs_unset_dirop(fs, dvp, "mknod");
-	/*
-	 * XXX this is where this used to be (though inside some evil
-	 * macros) but it clearly should be moved further down.
-	 * - dholland 20140515
-	 */
-	vrele(dvp);
 
 	if (error) {
-		fstrans_done(ap->a_dvp->v_mount);
+		fstrans_done(dvp->v_mount);
+		vrele(dvp);
 		*vpp = NULL;
 		return (error);
 	}
@@ -845,7 +840,8 @@ lfs_mknod(void *v)
 		/* return (error); */
 	}
 
-	fstrans_done(ap->a_dvp->v_mount);
+	fstrans_done(dvp->v_mount);
+	vrele(dvp);
 	KASSERT(error == 0);
 	VOP_UNLOCK(*vpp);
 	return (0);



CVS commit: src/sys/ufs/lfs

2016-06-19 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Jun 20 03:36:09 UTC 2016

Modified Files:
src/sys/ufs/lfs: lfs_rename.c lfs_vnops.c ulfs_extern.h ulfs_inode.c
ulfs_readwrite.c ulfs_vnops.c ulfsmount.h

Log Message:
One more batch of already-synced ufs changes:

ufs_extern.h 1.79 is equivalent to ulfs_extern.h 1.14
ufsmount.h 1.43 is (roughly) equivalent to lfs_extern.h 1.102
ufs_inode.c 1.94 does not apply to lfs
ufs_inode.c 1.95 does not apply to lfs either
ufs_readwrite.c 1.108 is equivalent to ulfs_readwrite.c 1.8
ufs_readwrite.c 1.109 is equivalent to ulfs_readwrite.c 1.9
ufs_readwrite.c 1.110 is equivalent to ulfs_readwrite.c 1.10
ufs_readwrite.c 1.111 does not apply to lfs
ufs_readwrite.c 1.112 is equivalent to ulfs_readwrite.c 1.11
ufs_readwrite.c 1.113 is equivalent to ulfs_readwrite.c 1.13
ufs_readwrite.c 1.114 is equivalent to ulfs_readwrite.c 1.14
ufs_readwrite.c 1.115 is equivalent to ulfs_readwrite.c 1.15
ufs_readwrite.c 1.116-1.118 does not apply to lfs
ufs_readwrite.c 1.119-1.120 are equivalent to ulfs_readwrite.c 1.16
ufs_rename.c 1.12 is equivalent to lfs_rename.c 1.8
ufs_vnops.c 1.226 is equivalent to ulfs_vnops.c 1.22 and lfs_vnops.c 1.270
ufs_vnops.c 1.227 is equivalent to ulfs_vnops.c 1.23
ufs_vnops.c 1.228-1.229 are equivalent to ulfs_vnops.c 1.24
ufs_vnops.c 1.230 is equivalent to ulfs_vnops.c 1.25 and lfs_vnops.c 1.271
ufs_vnops.c 1.231 originated in lfs
ufs_vnops.c 1.232 does not apply to lfs


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/ufs/lfs/lfs_rename.c
cvs rdiff -u -r1.301 -r1.302 src/sys/ufs/lfs/lfs_vnops.c
cvs rdiff -u -r1.23 -r1.24 src/sys/ufs/lfs/ulfs_extern.h
cvs rdiff -u -r1.14 -r1.15 src/sys/ufs/lfs/ulfs_inode.c
cvs rdiff -u -r1.21 -r1.22 src/sys/ufs/lfs/ulfs_readwrite.c
cvs rdiff -u -r1.43 -r1.44 src/sys/ufs/lfs/ulfs_vnops.c
cvs rdiff -u -r1.17 -r1.18 src/sys/ufs/lfs/ulfsmount.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_rename.c
diff -u src/sys/ufs/lfs/lfs_rename.c:1.20 src/sys/ufs/lfs/lfs_rename.c:1.21
--- src/sys/ufs/lfs/lfs_rename.c:1.20	Mon Jun 20 02:05:25 2016
+++ src/sys/ufs/lfs/lfs_rename.c	Mon Jun 20 03:36:09 2016
@@ -1,5 +1,5 @@
-/*	$NetBSD: lfs_rename.c,v 1.20 2016/06/20 02:05:25 dholland Exp $	*/
-/*  from NetBSD: ufs_rename.c,v 1.11 2014/05/25 13:45:39 hannken Exp  */
+/*	$NetBSD: lfs_rename.c,v 1.21 2016/06/20 03:36:09 dholland Exp $	*/
+/*  from NetBSD: ufs_rename.c,v 1.12 2015/03/27 17:27:56 riastradh Exp  */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -89,7 +89,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_rename.c,v 1.20 2016/06/20 02:05:25 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_rename.c,v 1.21 2016/06/20 03:36:09 dholland Exp $");
 
 #include 
 #include 

Index: src/sys/ufs/lfs/lfs_vnops.c
diff -u src/sys/ufs/lfs/lfs_vnops.c:1.301 src/sys/ufs/lfs/lfs_vnops.c:1.302
--- src/sys/ufs/lfs/lfs_vnops.c:1.301	Mon Jun 20 02:42:08 2016
+++ src/sys/ufs/lfs/lfs_vnops.c	Mon Jun 20 03:36:09 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_vnops.c,v 1.301 2016/06/20 02:42:08 dholland Exp $	*/
+/*	$NetBSD: lfs_vnops.c,v 1.302 2016/06/20 03:36:09 dholland Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  *	@(#)lfs_vnops.c	8.13 (Berkeley) 6/10/95
  */
 
-/*  from NetBSD: ufs_vnops.c,v 1.225 2015/03/17 09:39:29 hannken Exp  */
+/*  from NetBSD: ufs_vnops.c,v 1.232 2016/05/19 18:32:03 riastradh Exp  */
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -125,7 +125,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.301 2016/06/20 02:42:08 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.302 2016/06/20 03:36:09 dholland Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"

Index: src/sys/ufs/lfs/ulfs_extern.h
diff -u src/sys/ufs/lfs/ulfs_extern.h:1.23 src/sys/ufs/lfs/ulfs_extern.h:1.24
--- src/sys/ufs/lfs/ulfs_extern.h:1.23	Mon Jun 20 02:31:47 2016
+++ src/sys/ufs/lfs/ulfs_extern.h	Mon Jun 20 03:36:09 2016
@@ -1,5 +1,5 @@
-/*	$NetBSD: ulfs_extern.h,v 1.23 2016/06/20 02:31:47 dholland Exp $	*/
-/*  from NetBSD: ufs_extern.h,v 1.78 2015/03/17 09:39:29 hannken Exp   */
+/*	$NetBSD: ulfs_extern.h,v 1.24 2016/06/20 03:36:09 dholland Exp $	*/
+/*  from NetBSD: ufs_extern.h,v 1.79 2015/03/27 17:27:56 riastradh Exp   */
 
 /*-
  * Copyright (c) 1991, 1993, 1994

Index: src/sys/ufs/lfs/ulfs_inode.c
diff -u src/sys/ufs/lfs/ulfs_inode.c:1.14 src/sys/ufs/lfs/ulfs_inode.c:1.15
--- src/sys/ufs/lfs/ulfs_inode.c:1.14	Mon Jun 20 03:11:21 2016
+++ src/sys/ufs/lfs/ulfs_inode.c	Mon Jun 20 03:36:09 2016
@@ -1,5 +1,5 @@
-/*	$NetBSD: ulfs_inode.c,v 1.14 2016/06/20 03:11:21 dholland Exp $	*/
-/*  from NetBSD: ufs_inode.c,v 1.93 2015/04/15 14:39:24 riastradh  */
+/*	$NetBSD: ulfs_inode.c,v 1.15 2016/06/20 03:36:09 dholland Exp $	*/
+/*  from NetBSD: 

CVS commit: src/sys/ufs/lfs

2016-06-19 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Jun 20 03:29:52 UTC 2016

Modified Files:
src/sys/ufs/lfs: lfs_extern.h lfs_inode.h lfs_kernel.h ulfs_bswap.h
ulfs_dirhash.h ulfs_inode.h ulfs_quota.h ulfs_quota1.h

Log Message:
u_int{8,16,32,64}_t -> uint{8,16,32,64}_t in remaining lfs headers.


To generate a diff of this commit:
cvs rdiff -u -r1.110 -r1.111 src/sys/ufs/lfs/lfs_extern.h
cvs rdiff -u -r1.15 -r1.16 src/sys/ufs/lfs/lfs_inode.h
cvs rdiff -u -r1.2 -r1.3 src/sys/ufs/lfs/lfs_kernel.h
cvs rdiff -u -r1.7 -r1.8 src/sys/ufs/lfs/ulfs_bswap.h
cvs rdiff -u -r1.9 -r1.10 src/sys/ufs/lfs/ulfs_dirhash.h
cvs rdiff -u -r1.20 -r1.21 src/sys/ufs/lfs/ulfs_inode.h
cvs rdiff -u -r1.6 -r1.7 src/sys/ufs/lfs/ulfs_quota.h
cvs rdiff -u -r1.4 -r1.5 src/sys/ufs/lfs/ulfs_quota1.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_extern.h
diff -u src/sys/ufs/lfs/lfs_extern.h:1.110 src/sys/ufs/lfs/lfs_extern.h:1.111
--- src/sys/ufs/lfs/lfs_extern.h:1.110	Wed Aug 12 18:28:01 2015
+++ src/sys/ufs/lfs/lfs_extern.h	Mon Jun 20 03:29:52 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_extern.h,v 1.110 2015/08/12 18:28:01 dholland Exp $	*/
+/*	$NetBSD: lfs_extern.h,v 1.111 2016/06/20 03:29:52 dholland Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -271,10 +271,10 @@ extern const struct genfs_ops lfs_genfso
 #endif /* defined(_KERNEL) */
 
 /* lfs_cksum.c */
-u_int32_t cksum(void *, size_t);
-u_int32_t lfs_cksum_part(void *, size_t, u_int32_t);
+uint32_t cksum(void *, size_t);
+uint32_t lfs_cksum_part(void *, size_t, uint32_t);
 #define lfs_cksum_fold(sum)	(sum)
-u_int32_t lfs_sb_cksum(struct lfs *);
+uint32_t lfs_sb_cksum(struct lfs *);
 
 __END_DECLS
 

Index: src/sys/ufs/lfs/lfs_inode.h
diff -u src/sys/ufs/lfs/lfs_inode.h:1.15 src/sys/ufs/lfs/lfs_inode.h:1.16
--- src/sys/ufs/lfs/lfs_inode.h:1.15	Mon Jun 20 02:25:03 2016
+++ src/sys/ufs/lfs/lfs_inode.h	Mon Jun 20 03:29:52 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_inode.h,v 1.15 2016/06/20 02:25:03 dholland Exp $	*/
+/*	$NetBSD: lfs_inode.h,v 1.16 2016/06/20 03:29:52 dholland 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  */
 
@@ -81,7 +81,7 @@ struct ulfs_lookup_results {
 	doff_t	  ulr_endoff;	/* End of useful stuff in directory. */
 	doff_t	  ulr_diroff;	/* Offset in dir, where we found last entry. */
 	doff_t	  ulr_offset;	/* Offset of free space in directory. */
-	u_int32_t ulr_reclen;	/* Size of found directory entry. */
+	uint32_t ulr_reclen;	/* Size of found directory entry. */
 };
 
 /* notyet XXX */
@@ -107,7 +107,7 @@ struct inode {
 	struct	vnode *i_vnode;	/* Vnode associated with this inode. */
 	struct  ulfsmount *i_ump; /* Mount point associated with this inode. */
 	struct	vnode *i_devvp;	/* Vnode for block I/O. */
-	u_int32_t i_flag;	/* flags, see below */
+	uint32_t i_flag;	/* flags, see below */
 	dev_t	  i_dev;	/* Device associated with the inode. */
 	ino_t	  i_number;	/* The identity of the inode. */
 
@@ -137,14 +137,14 @@ struct inode {
 	 *
 	 * These fields are currently only used by LFS.
 	 */
-	u_int16_t i_mode;	/* IFMT, permissions; see below. */
+	uint16_t i_mode;	/* IFMT, permissions; see below. */
 	int16_t   i_nlink;	/* File link count. */
-	u_int64_t i_size;	/* File byte count. */
-	u_int32_t i_flags;	/* Status flags (chflags). */
+	uint64_t i_size;	/* File byte count. */
+	uint32_t i_flags;	/* Status flags (chflags). */
 	int32_t   i_gen;	/* Generation number. */
-	u_int32_t i_uid;	/* File owner. */
-	u_int32_t i_gid;	/* File group. */
-	u_int16_t i_omode;	/* Old mode, for ulfs_reclaim. */
+	uint32_t i_uid;		/* File owner. */
+	uint32_t i_gid;		/* File group. */
+	uint16_t i_omode;	/* Old mode, for ulfs_reclaim. */
 
 	struct dirhash *i_dirhash;	/* Hashing for large directories */
 
@@ -175,7 +175,7 @@ struct inode {
  */
 struct lfs_inode_ext {
 	off_t	  lfs_osize;		/* size of file on disk */
-	u_int64_t lfs_effnblocks;  /* number of blocks when i/o completes */
+	uint64_t  lfs_effnblocks;  /* number of blocks when i/o completes */
 	size_t	  lfs_fragsize[ULFS_NDADDR]; /* size of on-disk direct blocks */
 	TAILQ_ENTRY(inode) lfs_dchain;  /* Dirop chain. */
 	TAILQ_ENTRY(inode) lfs_pchain;  /* Paging chain. */
@@ -184,7 +184,7 @@ struct lfs_inode_ext {
 #define LFSI_WRAPBLOCK0x04
 #define LFSI_WRAPWAIT 0x08
 #define LFSI_BMAP 0x10
-	u_int32_t lfs_iflags;   /* Inode flags */
+	uint32_t lfs_iflags;		/* Inode flags */
 	daddr_t   lfs_hiblk;		/* Highest lbn held by inode */
 #ifdef _KERNEL
 	SPLAY_HEAD(lfs_splay, lbnentry) lfs_lbtree; /* Tree of balloc'd lbns */

Index: src/sys/ufs/lfs/lfs_kernel.h
diff -u src/sys/ufs/lfs/lfs_kernel.h:1.2 src/sys/ufs/lfs/lfs_kernel.h:1.3
--- src/sys/ufs/lfs/lfs_kernel.h:1.2	Wed Aug 12 18:24:14 2015
+++ 

CVS commit: src/sys/ufs/lfs

2016-06-19 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Jun 20 03:25:46 UTC 2016

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

Log Message:
Massedit u_int{8,16,32,64}_t to uint{8,16,32,64}_t. This effectively
merges ufs/dinode.h 1.25.


To generate a diff of this commit:
cvs rdiff -u -r1.198 -r1.199 src/sys/ufs/lfs/lfs.h
cvs rdiff -u -r1.45 -r1.46 src/sys/ufs/lfs/lfs_accessors.h
cvs rdiff -u -r1.12 -r1.13 src/sys/ufs/lfs/ulfs_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/lfs/lfs.h
diff -u src/sys/ufs/lfs/lfs.h:1.198 src/sys/ufs/lfs/lfs.h:1.199
--- src/sys/ufs/lfs/lfs.h:1.198	Sun Jun 19 22:38:23 2016
+++ src/sys/ufs/lfs/lfs.h	Mon Jun 20 03:25:46 2016
@@ -1,6 +1,6 @@
-/*	$NetBSD: lfs.h,v 1.198 2016/06/19 22:38:23 dholland Exp $	*/
+/*	$NetBSD: lfs.h,v 1.199 2016/06/20 03:25:46 dholland Exp $	*/
 
-/*  from NetBSD: dinode.h,v 1.24 2013/06/09 17:55:46 dholland 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  */
 
 /*-
@@ -350,18 +350,18 @@
  */
 
 struct lfs_dirheader32 {
-	u_int32_t dh_ino;		/* inode number of entry */
-	u_int16_t dh_reclen;		/* length of this record */
-	u_int8_t  dh_type; 		/* file type, see below */
-	u_int8_t  dh_namlen;		/* length of string in d_name */
+	uint32_t dh_ino;		/* inode number of entry */
+	uint16_t dh_reclen;		/* length of this record */
+	uint8_t  dh_type; 		/* file type, see below */
+	uint8_t  dh_namlen;		/* length of string in d_name */
 };
 
 struct lfs_dirheader64 {
-	u_int32_t dh_inoA;		/* inode number of entry */
-	u_int32_t dh_inoB;		/* inode number of entry */
-	u_int16_t dh_reclen;		/* length of this record */
-	u_int8_t  dh_type; 		/* file type, see below */
-	u_int8_t  dh_namlen;		/* length of string in d_name */
+	uint32_t dh_inoA;		/* inode number of entry */
+	uint32_t dh_inoB;		/* inode number of entry */
+	uint16_t dh_reclen;		/* length of this record */
+	uint8_t  dh_type; 		/* file type, see below */
+	uint8_t  dh_namlen;		/* length of string in d_name */
 };
 
 union lfs_dirheader {
@@ -399,13 +399,13 @@ union lfs_dirtemplate {
  * This is the old format of directories, sans type element.
  */
 struct lfs_odirtemplate {
-	u_int32_t	dot_ino;
+	uint32_t	dot_ino;
 	int16_t		dot_reclen;
-	u_int16_t	dot_namlen;
+	uint16_t	dot_namlen;
 	char		dot_name[4];	/* must be multiple of 4 */
-	u_int32_t	dotdot_ino;
+	uint32_t	dotdot_ino;
 	int16_t		dotdot_reclen;
-	u_int16_t	dotdot_namlen;
+	uint16_t	dotdot_namlen;
 	char		dotdot_name[4];	/* ditto */
 };
 #endif
@@ -422,10 +422,10 @@ struct lfs_odirtemplate {
  */
 
 struct lfs32_dinode {
-	u_int16_t	di_mode;	/*   0: IFMT, permissions; see below. */
+	uint16_t	di_mode;	/*   0: IFMT, permissions; see below. */
 	int16_t		di_nlink;	/*   2: File link count. */
-	u_int32_t	di_inumber;	/*   4: Inode number. */
-	u_int64_t	di_size;	/*   8: File byte count. */
+	uint32_t	di_inumber;	/*   4: Inode number. */
+	uint64_t	di_size;	/*   8: File byte count. */
 	int32_t		di_atime;	/*  16: Last access time. */
 	int32_t		di_atimensec;	/*  20: Last access time. */
 	int32_t		di_mtime;	/*  24: Last modified time. */
@@ -434,22 +434,22 @@ struct lfs32_dinode {
 	int32_t		di_ctimensec;	/*  36: Last inode change time. */
 	int32_t		di_db[ULFS_NDADDR]; /*  40: Direct disk blocks. */
 	int32_t		di_ib[ULFS_NIADDR]; /*  88: Indirect disk blocks. */
-	u_int32_t	di_flags;	/* 100: Status flags (chflags). */
-	u_int32_t	di_blocks;	/* 104: Blocks actually held. */
+	uint32_t	di_flags;	/* 100: Status flags (chflags). */
+	uint32_t	di_blocks;	/* 104: Blocks actually held. */
 	int32_t		di_gen;		/* 108: Generation number. */
-	u_int32_t	di_uid;		/* 112: File owner. */
-	u_int32_t	di_gid;		/* 116: File group. */
-	u_int64_t	di_modrev;	/* 120: i_modrev for NFSv4 */
+	uint32_t	di_uid;		/* 112: File owner. */
+	uint32_t	di_gid;		/* 116: File group. */
+	uint64_t	di_modrev;	/* 120: i_modrev for NFSv4 */
 };
 
 struct lfs64_dinode {
-	u_int16_t	di_mode;	/*   0: IFMT, permissions; see below. */
+	uint16_t	di_mode;	/*   0: IFMT, permissions; see below. */
 	int16_t		di_nlink;	/*   2: File link count. */
-	u_int32_t	di_uid;		/*   4: File owner. */
-	u_int32_t	di_gid;		/*   8: File group. */
-	u_int32_t	di_blksize;	/*  12: Inode blocksize. */
-	u_int64_t	di_size;	/*  16: File byte count. */
-	u_int64_t	di_blocks;	/*  24: Bytes actually held. */
+	uint32_t	di_uid;		/*   4: File owner. */
+	uint32_t	di_gid;		/*   8: File group. */
+	uint32_t	di_blksize;	/*  12: Inode blocksize. */
+	uint64_t	di_size;	/*  16: File byte count. */
+	uint64_t	di_blocks;	/*  24: Bytes actually held. */
 	int64_t		di_atime;	/*  32: Last access time. */
 	int64_t		di_mtime;	/*  40: Last modified time. */
 	int64_t		di_ctime;	/*  48: Last inode change time. */
@@ -459,15 +459,15 @@ struct lfs64_dinode {
 	int32_t		di_ctimensec;	/*  72: Last 

CVS commit: src/sys/ufs/lfs

2016-06-19 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Jun 20 03:11:21 UTC 2016

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

Log Message:
Merge ufs_inode.c 1.93: missing unlock on error path.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/ufs/lfs/ulfs_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/ulfs_inode.c
diff -u src/sys/ufs/lfs/ulfs_inode.c:1.13 src/sys/ufs/lfs/ulfs_inode.c:1.14
--- src/sys/ufs/lfs/ulfs_inode.c:1.13	Mon Jun 20 02:25:03 2016
+++ src/sys/ufs/lfs/ulfs_inode.c	Mon Jun 20 03:11:21 2016
@@ -1,5 +1,5 @@
-/*	$NetBSD: ulfs_inode.c,v 1.13 2016/06/20 02:25:03 dholland Exp $	*/
-/*  from NetBSD: ufs_inode.c,v 1.92 2014/10/29 01:13:28 christos Exp  */
+/*	$NetBSD: ulfs_inode.c,v 1.14 2016/06/20 03:11:21 dholland Exp $	*/
+/*  from NetBSD: ufs_inode.c,v 1.93 2015/04/15 14:39:24 riastradh  */
 
 /*
  * Copyright (c) 1991, 1993
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ulfs_inode.c,v 1.13 2016/06/20 02:25:03 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ulfs_inode.c,v 1.14 2016/06/20 03:11:21 dholland Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_lfs.h"
@@ -226,6 +226,7 @@ ulfs_balloc_range(struct vnode *vp, off_
 	VM_PROT_WRITE, 0, PGO_SYNCIO | PGO_PASTEOF | PGO_NOBLOCKALLOC |
 	PGO_NOTIMESTAMP | PGO_GLOCKHELD);
 	if (error) {
+		genfs_node_unlock(vp);
 		goto out;
 	}
 



CVS commit: src/sys/ufs/lfs

2016-06-19 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Jun 20 02:42:08 UTC 2016

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

Log Message:
With the previous we seem to have the changes from -r1.225 of ufs_vnops.c.
(as that was stuff from moving ffs to the new vcache and lfs has also been
moved, this is not surprising)


To generate a diff of this commit:
cvs rdiff -u -r1.300 -r1.301 src/sys/ufs/lfs/lfs_vnops.c
cvs rdiff -u -r1.42 -r1.43 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.300 src/sys/ufs/lfs/lfs_vnops.c:1.301
--- src/sys/ufs/lfs/lfs_vnops.c:1.300	Mon Jun 20 02:33:01 2016
+++ src/sys/ufs/lfs/lfs_vnops.c	Mon Jun 20 02:42:08 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_vnops.c,v 1.300 2016/06/20 02:33:01 dholland Exp $	*/
+/*	$NetBSD: lfs_vnops.c,v 1.301 2016/06/20 02:42:08 dholland Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  *	@(#)lfs_vnops.c	8.13 (Berkeley) 6/10/95
  */
 
-/*  from NetBSD: ufs_vnops.c,v 1.224 2014/10/29 01:13:28 christos Exp  */
+/*  from NetBSD: ufs_vnops.c,v 1.225 2015/03/17 09:39:29 hannken Exp  */
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -125,7 +125,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.300 2016/06/20 02:33:01 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.301 2016/06/20 02:42:08 dholland Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"

Index: src/sys/ufs/lfs/ulfs_vnops.c
diff -u src/sys/ufs/lfs/ulfs_vnops.c:1.42 src/sys/ufs/lfs/ulfs_vnops.c:1.43
--- src/sys/ufs/lfs/ulfs_vnops.c:1.42	Mon Jun 20 02:31:47 2016
+++ src/sys/ufs/lfs/ulfs_vnops.c	Mon Jun 20 02:42:08 2016
@@ -1,5 +1,5 @@
-/*	$NetBSD: ulfs_vnops.c,v 1.42 2016/06/20 02:31:47 dholland Exp $	*/
-/*  from NetBSD: ufs_vnops.c,v 1.224 2014/10/29 01:13:28 christos Exp  */
+/*	$NetBSD: ulfs_vnops.c,v 1.43 2016/06/20 02:42:08 dholland Exp $	*/
+/*  from NetBSD: ufs_vnops.c,v 1.225 2015/03/17 09:39:29 hannken Exp  */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ulfs_vnops.c,v 1.42 2016/06/20 02:31:47 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ulfs_vnops.c,v 1.43 2016/06/20 02:42:08 dholland Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_lfs.h"



CVS commit: src/sys/ufs/lfs

2016-06-19 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Jun 20 02:33:02 UTC 2016

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

Log Message:
ulfs_makeinode -> lfs_makeinode


To generate a diff of this commit:
cvs rdiff -u -r1.299 -r1.300 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.299 src/sys/ufs/lfs/lfs_vnops.c:1.300
--- src/sys/ufs/lfs/lfs_vnops.c:1.299	Mon Jun 20 02:31:47 2016
+++ src/sys/ufs/lfs/lfs_vnops.c	Mon Jun 20 02:33:01 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_vnops.c,v 1.299 2016/06/20 02:31:47 dholland Exp $	*/
+/*	$NetBSD: lfs_vnops.c,v 1.300 2016/06/20 02:33:01 dholland 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.299 2016/06/20 02:31:47 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.300 2016/06/20 02:33:01 dholland Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -178,7 +178,7 @@ static int lfs_setextattr(void *v);
 static int lfs_listextattr(void *v);
 static int lfs_deleteextattr(void *v);
 
-static int ulfs_makeinode(struct vattr *vap, struct vnode *,
+static int lfs_makeinode(struct vattr *vap, struct vnode *,
 		  const struct ulfs_lookup_results *,
 		  struct vnode **, struct componentname *);
 
@@ -359,7 +359,7 @@ const struct vnodeopv_desc lfs_fifoop_op
  * Allocate a new inode.
  */
 static int
-ulfs_makeinode(struct vattr *vap, struct vnode *dvp,
+lfs_makeinode(struct vattr *vap, struct vnode *dvp,
 	const struct ulfs_lookup_results *ulr,
 	struct vnode **vpp, struct componentname *cnp)
 {
@@ -719,7 +719,7 @@ lfs_symlink(void *v)
 		return error;
 
 	fstrans_start(dvp->v_mount, FSTRANS_SHARED);
-	error = ulfs_makeinode(ap->a_vap, dvp, ulr, vpp, ap->a_cnp);
+	error = lfs_makeinode(ap->a_vap, dvp, ulr, vpp, ap->a_cnp);
 	if (error) {
 		goto out;
 	}
@@ -807,7 +807,7 @@ lfs_mknod(void *v)
 		return error;
 
 	fstrans_start(ap->a_dvp->v_mount, FSTRANS_SHARED);
-	error = ulfs_makeinode(vap, dvp, ulr, vpp, ap->a_cnp);
+	error = lfs_makeinode(vap, dvp, ulr, vpp, ap->a_cnp);
 
 	/* Either way we're done with the dirop at this point */
 	UNMARK_VNODE(dvp);
@@ -891,7 +891,7 @@ lfs_create(void *v)
 		return error;
 
 	fstrans_start(dvp->v_mount, FSTRANS_SHARED);
-	error = ulfs_makeinode(vap, dvp, ulr, vpp, ap->a_cnp);
+	error = lfs_makeinode(vap, dvp, ulr, vpp, ap->a_cnp);
 	if (error) {
 		fstrans_done(dvp->v_mount);
 		goto out;
@@ -971,7 +971,7 @@ lfs_mkdir(void *v)
 	}
 
 	/*
-	 * Must simulate part of ulfs_makeinode here to acquire the inode,
+	 * Must simulate part of lfs_makeinode here to acquire the inode,
 	 * but not have it entered in the parent directory. The entry is
 	 * made later after writing "." and ".." entries.
 	 */



CVS commit: src/sys/ufs/lfs

2016-06-19 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Jun 20 02:31:47 UTC 2016

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

Log Message:
Merge (effectively) -r1.78 of ufs_extern.h: shift ulfs_makeinode to
lfs_vnops.c and make it file-static there, as that's the only place
it's used.


To generate a diff of this commit:
cvs rdiff -u -r1.298 -r1.299 src/sys/ufs/lfs/lfs_vnops.c
cvs rdiff -u -r1.22 -r1.23 src/sys/ufs/lfs/ulfs_extern.h
cvs rdiff -u -r1.41 -r1.42 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.298 src/sys/ufs/lfs/lfs_vnops.c:1.299
--- src/sys/ufs/lfs/lfs_vnops.c:1.298	Mon Jun 20 02:25:03 2016
+++ src/sys/ufs/lfs/lfs_vnops.c	Mon Jun 20 02:31:47 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_vnops.c,v 1.298 2016/06/20 02:25:03 dholland Exp $	*/
+/*	$NetBSD: lfs_vnops.c,v 1.299 2016/06/20 02:31:47 dholland 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.298 2016/06/20 02:25:03 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.299 2016/06/20 02:31:47 dholland Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -178,6 +178,10 @@ static int lfs_setextattr(void *v);
 static int lfs_listextattr(void *v);
 static int lfs_deleteextattr(void *v);
 
+static int ulfs_makeinode(struct vattr *vap, struct vnode *,
+		  const struct ulfs_lookup_results *,
+		  struct vnode **, struct componentname *);
+
 /* Global vfs data structures for lfs. */
 int (**lfs_vnodeop_p)(void *);
 const struct vnodeopv_entry_desc lfs_vnodeop_entries[] = {
@@ -352,6 +356,75 @@ const struct vnodeopv_desc lfs_fifoop_op
 #undef	LFS_READWRITE
 
 /*
+ * Allocate a new inode.
+ */
+static int
+ulfs_makeinode(struct vattr *vap, struct vnode *dvp,
+	const struct ulfs_lookup_results *ulr,
+	struct vnode **vpp, struct componentname *cnp)
+{
+	struct inode	*ip;
+	struct vnode	*tvp;
+	int		error;
+
+	error = vcache_new(dvp->v_mount, dvp, vap, cnp->cn_cred, );
+	if (error)
+		return error;
+	error = vn_lock(tvp, LK_EXCLUSIVE);
+	if (error) {
+		vrele(tvp);
+		return error;
+	}
+	lfs_mark_vnode(tvp);
+	*vpp = tvp;
+	ip = VTOI(tvp);
+	ip->i_flag |= IN_ACCESS | IN_CHANGE | IN_UPDATE;
+	ip->i_nlink = 1;
+	DIP_ASSIGN(ip, nlink, 1);
+
+	/* Authorize setting SGID if needed. */
+	if (ip->i_mode & ISGID) {
+		error = kauth_authorize_vnode(cnp->cn_cred, KAUTH_VNODE_WRITE_SECURITY,
+		tvp, NULL, genfs_can_chmod(tvp->v_type, cnp->cn_cred, ip->i_uid,
+		ip->i_gid, MAKEIMODE(vap->va_type, vap->va_mode)));
+		if (error) {
+			ip->i_mode &= ~ISGID;
+			DIP_ASSIGN(ip, mode, ip->i_mode);
+		}
+	}
+
+	if (cnp->cn_flags & ISWHITEOUT) {
+		ip->i_flags |= UF_OPAQUE;
+		DIP_ASSIGN(ip, flags, ip->i_flags);
+	}
+
+	/*
+	 * Make sure inode goes to disk before directory entry.
+	 */
+	if ((error = lfs_update(tvp, NULL, NULL, UPDATE_DIROP)) != 0)
+		goto bad;
+	error = ulfs_direnter(dvp, ulr, tvp,
+			  cnp, ip->i_number, LFS_IFTODT(ip->i_mode), NULL);
+	if (error)
+		goto bad;
+	*vpp = tvp;
+	return (0);
+
+ bad:
+	/*
+	 * Write error occurred trying to update the inode
+	 * or the directory so must deallocate the inode.
+	 */
+	ip->i_nlink = 0;
+	DIP_ASSIGN(ip, nlink, 0);
+	ip->i_flag |= IN_CHANGE;
+	/* If IN_ADIROP, account for it */
+	lfs_unmark_vnode(tvp);
+	vput(tvp);
+	return (error);
+}
+
+/*
  * Synch an open file.
  */
 /* ARGSUSED */
@@ -2297,3 +2370,4 @@ lfs_deleteextattr(void *v)
 	/* XXX Not implemented for ULFS2 file systems. */
 	return (EOPNOTSUPP);
 }
+

Index: src/sys/ufs/lfs/ulfs_extern.h
diff -u src/sys/ufs/lfs/ulfs_extern.h:1.22 src/sys/ufs/lfs/ulfs_extern.h:1.23
--- src/sys/ufs/lfs/ulfs_extern.h:1.22	Mon Jun 20 02:25:03 2016
+++ src/sys/ufs/lfs/ulfs_extern.h	Mon Jun 20 02:31:47 2016
@@ -1,5 +1,5 @@
-/*	$NetBSD: ulfs_extern.h,v 1.22 2016/06/20 02:25:03 dholland Exp $	*/
-/*  from NetBSD: ufs_extern.h,v 1.77 2014/10/29 01:13:28 christos Exp   */
+/*	$NetBSD: ulfs_extern.h,v 1.23 2016/06/20 02:31:47 dholland Exp $	*/
+/*  from NetBSD: ufs_extern.h,v 1.78 2015/03/17 09:39:29 hannken Exp   */
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -154,9 +154,6 @@ int	ulfs_fhtovp(struct mount *, struct u
 /* ulfs_vnops.c */
 void	ulfs_vinit(struct mount *, int (**)(void *),
 		  int (**)(void *), struct vnode **);
-int	ulfs_makeinode(struct vattr *vap, struct vnode *,
-		  const struct ulfs_lookup_results *,
-		  struct vnode **, struct componentname *);
 int	ulfs_gop_alloc(struct vnode *, off_t, off_t, int, kauth_cred_t);
 void	ulfs_gop_markupdate(struct vnode *, int);
 int	ulfs_bufio(enum uio_rw, struct vnode *, void *, size_t, off_t, int,

Index: src/sys/ufs/lfs/ulfs_vnops.c
diff -u src/sys/ufs/lfs/ulfs_vnops.c:1.41 src/sys/ufs/lfs/ulfs_vnops.c:1.42
--- 

CVS commit: src/sys/ufs/lfs

2016-06-19 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Jun 20 02:25:04 UTC 2016

Modified Files:
src/sys/ufs/lfs: lfs_inode.h lfs_vnops.c ulfs_extern.h ulfs_inode.c
ulfs_inode.h ulfs_lookup.c ulfs_quota2.c ulfs_vfsops.c ulfs_vnops.c
ulfsmount.h

Log Message:
Note more already-merged versions:

inode.h 1.68 is subsumed by ulfs_inode.h 1.19
inode.h 1.69-1.72 do not apply to lfs
ufs_extern.h 1.74 was covered when lfs was moved to the new vnode cache
ufs_extern.h 1.75 is equivalent to ulfs_extern.h 1.13
ufs_extern.h 1.76-1.77 do not apply to lfs
ufsmount.h 1.42 does not apply to lfs
ufs_inode.c 1.90 is subsumed by ulfs_inode.c 1.10
ufs_inode.c 1.91-1.92 do not apply to lfs
ufs_lookup.c 1.130 is subsumed by ulfs_lookup.c 1.24
ufs_lookup.c 1.131 is equivalent to ulfs_lookup.c 1.20
ufs_lookup.c 1.132 is equivalent to ulfs_lookup.c 1.21
ufs_lookup.c 1.133 is equivalent to ulfs_lookup.c 1.22
ufs_lookup.c 1.134 is equivalent to ulfs_lookup.c 1.23
ufs_lookup.c 1.135 is equivalent to ulfs_lookup.c 1.25
ufs_quota2.c 1.38 is equivalent to ulfs_quota2.c 1.17
ufs_quota2.c 1.39 is equivalent to ulfs_quota2.c 1.16
ufs_quota2.c 1.40 is equivalent to ulfs_quota2.c 1.18
ufs_vfsops.c 1.53 is subsumed by lfs_vfsops.c 1.324
ufs_vfsops.c 1.54 is subsumed by lfs_vfsops.c 1.324
ufs_vnops.c 1.223-1.224 do not apply to lfs


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/ufs/lfs/lfs_inode.h
cvs rdiff -u -r1.297 -r1.298 src/sys/ufs/lfs/lfs_vnops.c
cvs rdiff -u -r1.21 -r1.22 src/sys/ufs/lfs/ulfs_extern.h
cvs rdiff -u -r1.12 -r1.13 src/sys/ufs/lfs/ulfs_inode.c
cvs rdiff -u -r1.19 -r1.20 src/sys/ufs/lfs/ulfs_inode.h
cvs rdiff -u -r1.38 -r1.39 src/sys/ufs/lfs/ulfs_lookup.c
cvs rdiff -u -r1.26 -r1.27 src/sys/ufs/lfs/ulfs_quota2.c
cvs rdiff -u -r1.11 -r1.12 src/sys/ufs/lfs/ulfs_vfsops.c
cvs rdiff -u -r1.40 -r1.41 src/sys/ufs/lfs/ulfs_vnops.c
cvs rdiff -u -r1.16 -r1.17 src/sys/ufs/lfs/ulfsmount.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.14 src/sys/ufs/lfs/lfs_inode.h:1.15
--- src/sys/ufs/lfs/lfs_inode.h:1.14	Mon Jun 20 01:06:23 2016
+++ src/sys/ufs/lfs/lfs_inode.h	Mon Jun 20 02:25:03 2016
@@ -1,6 +1,6 @@
-/*	$NetBSD: lfs_inode.h,v 1.14 2016/06/20 01:06:23 dholland Exp $	*/
+/*	$NetBSD: lfs_inode.h,v 1.15 2016/06/20 02:25:03 dholland Exp $	*/
 /*  from NetBSD: ulfs_inode.h,v 1.5 2013/06/06 00:51:50 dholland Exp  */
-/*  from NetBSD: inode.h,v 1.67 2014/05/14 13:46:19 martin Exp  */
+/*  from NetBSD: inode.h,v 1.72 2016/06/03 15:36:03 christos Exp  */
 
 /*
  * Copyright (c) 1982, 1989, 1993

Index: src/sys/ufs/lfs/lfs_vnops.c
diff -u src/sys/ufs/lfs/lfs_vnops.c:1.297 src/sys/ufs/lfs/lfs_vnops.c:1.298
--- src/sys/ufs/lfs/lfs_vnops.c:1.297	Mon Jun 20 00:00:47 2016
+++ src/sys/ufs/lfs/lfs_vnops.c	Mon Jun 20 02:25:03 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_vnops.c,v 1.297 2016/06/20 00:00:47 dholland Exp $	*/
+/*	$NetBSD: lfs_vnops.c,v 1.298 2016/06/20 02:25:03 dholland Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  *	@(#)lfs_vnops.c	8.13 (Berkeley) 6/10/95
  */
 
-/*  from NetBSD: ufs_vnops.c,v 1.222 2014/10/18 08:33:30 snj Exp  */
+/*  from NetBSD: ufs_vnops.c,v 1.224 2014/10/29 01:13:28 christos Exp  */
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -125,7 +125,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.297 2016/06/20 00:00:47 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.298 2016/06/20 02:25:03 dholland Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"

Index: src/sys/ufs/lfs/ulfs_extern.h
diff -u src/sys/ufs/lfs/ulfs_extern.h:1.21 src/sys/ufs/lfs/ulfs_extern.h:1.22
--- src/sys/ufs/lfs/ulfs_extern.h:1.21	Sun Jun 19 21:58:42 2016
+++ src/sys/ufs/lfs/ulfs_extern.h	Mon Jun 20 02:25:03 2016
@@ -1,5 +1,5 @@
-/*	$NetBSD: ulfs_extern.h,v 1.21 2016/06/19 21:58:42 dholland Exp $	*/
-/*  from NetBSD: ufs_extern.h,v 1.73 2013/06/16 13:33:30 hannken Exp   */
+/*	$NetBSD: ulfs_extern.h,v 1.22 2016/06/20 02:25:03 dholland Exp $	*/
+/*  from NetBSD: ufs_extern.h,v 1.77 2014/10/29 01:13:28 christos Exp   */
 
 /*-
  * Copyright (c) 1991, 1993, 1994

Index: src/sys/ufs/lfs/ulfs_inode.c
diff -u src/sys/ufs/lfs/ulfs_inode.c:1.12 src/sys/ufs/lfs/ulfs_inode.c:1.13
--- src/sys/ufs/lfs/ulfs_inode.c:1.12	Sat Nov 14 22:03:54 2015
+++ src/sys/ufs/lfs/ulfs_inode.c	Mon Jun 20 02:25:03 2016
@@ -1,5 +1,5 @@
-/*	$NetBSD: ulfs_inode.c,v 1.12 2015/11/14 22:03:54 pgoyette Exp $	*/
-/*  from NetBSD: ufs_inode.c,v 1.89 2013/01/22 09:39:18 dholland Exp  */
+/*	$NetBSD: ulfs_inode.c,v 1.13 2016/06/20 02:25:03 dholland Exp $	*/
+/*  from NetBSD: ufs_inode.c,v 1.92 2014/10/29 01:13:28 christos Exp  */
 
 /*
  * Copyright (c) 1991, 1993
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: 

CVS commit: src/sys/ufs/lfs

2016-06-19 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Jun 20 02:05:25 UTC 2016

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

Log Message:
fix typo in previous


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/ufs/lfs/lfs_rename.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/ufs/lfs/lfs_rename.c
diff -u src/sys/ufs/lfs/lfs_rename.c:1.19 src/sys/ufs/lfs/lfs_rename.c:1.20
--- src/sys/ufs/lfs/lfs_rename.c:1.19	Mon Jun 20 01:20:01 2016
+++ src/sys/ufs/lfs/lfs_rename.c	Mon Jun 20 02:05:25 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_rename.c,v 1.19 2016/06/20 01:20:01 dholland Exp $	*/
+/*	$NetBSD: lfs_rename.c,v 1.20 2016/06/20 02:05:25 dholland Exp $	*/
 /*  from NetBSD: ufs_rename.c,v 1.11 2014/05/25 13:45:39 hannken Exp  */
 
 /*-
@@ -89,7 +89,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_rename.c,v 1.19 2016/06/20 01:20:01 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_rename.c,v 1.20 2016/06/20 02:05:25 dholland Exp $");
 
 #include 
 #include 
@@ -697,7 +697,7 @@ ulfs_gro_genealogy(struct mount *mp, kau
 		}
 
 		/* Neither -- keep ascending the family tree.  */
-		error = vcache_get(mp, _ino, sizeof(dotdot_no), );
+		error = vcache_get(mp, _ino, sizeof(dotdot_ino), );
 		vput(vp);
 		if (error)
 			return error;



CVS commit: src/sys/ufs/lfs

2016-06-19 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Jun 20 02:03:32 UTC 2016

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

Log Message:
Merge some cosmetic changes from ffs_quota2.c 1.5. I didn't merge the
whitespace changes.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 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.25 src/sys/ufs/lfs/ulfs_quota2.c:1.26
--- src/sys/ufs/lfs/ulfs_quota2.c:1.25	Mon Jun 20 01:23:04 2016
+++ src/sys/ufs/lfs/ulfs_quota2.c	Mon Jun 20 02:03:32 2016
@@ -1,6 +1,6 @@
-/*	$NetBSD: ulfs_quota2.c,v 1.25 2016/06/20 01:23:04 dholland Exp $	*/
+/*	$NetBSD: ulfs_quota2.c,v 1.26 2016/06/20 02:03:32 dholland Exp $	*/
 /*  from NetBSD: ufs_quota2.c,v 1.37 2014/01/29 20:13:04 bouyer Exp  */
-/*  from NetBSD: ffs_quota2.c,v 1.4 2011/06/12 03:36:00 rmind Exp  */
+/*  from NetBSD: ffs_quota2.c,v 1.5 2015/02/22 14:12:48 maxv Exp  */
 
 /*-
   * Copyright (c) 2010 Manuel Bouyer
@@ -29,7 +29,7 @@
   */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ulfs_quota2.c,v 1.25 2016/06/20 01:23:04 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ulfs_quota2.c,v 1.26 2016/06/20 02:03:32 dholland Exp $");
 
 #include 
 #include 
@@ -1565,7 +1565,7 @@ lfs_quota2_mount(struct mount *mp)
 {
 	struct ulfsmount *ump = VFSTOULFS(mp);
 	struct lfs *fs = ump->um_lfs;
-	int error = 0;
+	int error;
 	struct vnode *vp;
 	struct lwp *l = curlwp;
 
@@ -1580,15 +1580,17 @@ lfs_quota2_mount(struct mount *mp)
 		mp->mnt_stat.f_mntonname);
 		return EINVAL;
 	}
+
+	error = 0;
 if ((fs->lfs_quota_flags & FS_Q2_DO_TYPE(ULFS_USRQUOTA)) &&
 fs->lfs_quotaino[ULFS_USRQUOTA] == 0) {
-printf("%s: no user quota inode\n",
+printf("%s: No user quota inode\n",
 		mp->mnt_stat.f_mntonname); 
 error = EINVAL;
 }
 if ((fs->lfs_quota_flags & FS_Q2_DO_TYPE(ULFS_GRPQUOTA)) &&
 fs->lfs_quotaino[ULFS_GRPQUOTA] == 0) {
-printf("%s: no group quota inode\n",
+printf("%s: No group quota inode\n",
 		mp->mnt_stat.f_mntonname);
 error = EINVAL;
 }
@@ -1628,6 +1630,7 @@ lfs_quota2_mount(struct mount *mp)
 		mutex_exit(vp->v_interlock);
 		VOP_UNLOCK(vp);
 	}
+
 	mp->mnt_flag |= MNT_QUOTA;
 	return 0;
 }



CVS commit: src/sys/ufs/lfs

2016-06-19 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Jun 20 01:56:21 UTC 2016

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

Log Message:
Merge -r1.11 of extattr.h:
Bump UFS1 extended attribute max name length to 256


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/ufs/lfs/ulfs_extattr.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/ulfs_extattr.h
diff -u src/sys/ufs/lfs/ulfs_extattr.h:1.2 src/sys/ufs/lfs/ulfs_extattr.h:1.3
--- src/sys/ufs/lfs/ulfs_extattr.h:1.2	Thu Jun  6 00:48:04 2013
+++ src/sys/ufs/lfs/ulfs_extattr.h	Mon Jun 20 01:56:21 2016
@@ -1,5 +1,5 @@
-/*	$NetBSD: ulfs_extattr.h,v 1.2 2013/06/06 00:48:04 dholland Exp $	*/
-/*  from NetBSD: extattr.h,v 1.10 2011/10/09 21:15:34 chs Exp  */
+/*	$NetBSD: ulfs_extattr.h,v 1.3 2016/06/20 01:56:21 dholland Exp $	*/
+/*  from NetBSD: extattr.h,v 1.11 2014/12/19 10:59:21 manu Exp  */
 
 /*-
  * Copyright (c) 1999-2001 Robert N. M. Watson
@@ -44,7 +44,7 @@
 #define	ULFS_EXTATTR_FSROOTSUBDIR	".attribute"
 #define	ULFS_EXTATTR_SUBDIR_SYSTEM	"system"
 #define	ULFS_EXTATTR_SUBDIR_USER		"user"
-#define	ULFS_EXTATTR_MAXEXTATTRNAME	65	/* including null */
+#define	ULFS_EXTATTR_MAXEXTATTRNAME	256	/* including null */
 
 #define	ULFS_EXTATTR_ATTR_FLAG_INUSE	0x0001	/* attr has been set */
 #define	ULFS_EXTATTR_PERM_KERNEL		0x



CVS commit: src/sys/ufs/lfs

2016-06-19 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Jun 20 01:53:38 UTC 2016

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

Log Message:
Merge -r1.37 of ufs_dirhash.c:
clear i_dirhash sooner, but what lock protects it?


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/ufs/lfs/ulfs_dirhash.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_dirhash.c
diff -u src/sys/ufs/lfs/ulfs_dirhash.c:1.16 src/sys/ufs/lfs/ulfs_dirhash.c:1.17
--- src/sys/ufs/lfs/ulfs_dirhash.c:1.16	Mon Jun 20 00:00:47 2016
+++ src/sys/ufs/lfs/ulfs_dirhash.c	Mon Jun 20 01:53:38 2016
@@ -1,5 +1,5 @@
-/*	$NetBSD: ulfs_dirhash.c,v 1.16 2016/06/20 00:00:47 dholland Exp $	*/
-/*  from NetBSD: ufs_dirhash.c,v 1.36 2014/02/25 18:30:13 pooka Exp  */
+/*	$NetBSD: ulfs_dirhash.c,v 1.17 2016/06/20 01:53:38 dholland Exp $	*/
+/*  from NetBSD: ufs_dirhash.c,v 1.37 2014/12/20 00:28:05 christos Exp  */
 
 /*
  * Copyright (c) 2001, 2002 Ian Dowse.  All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ulfs_dirhash.c,v 1.16 2016/06/20 00:00:47 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ulfs_dirhash.c,v 1.17 2016/06/20 01:53:38 dholland Exp $");
 
 /*
  * This implements a hash-based lookup scheme for ULFS directories.
@@ -258,6 +258,7 @@ ulfsdirhash_build(struct inode *ip)
 	return (0);
 
 fail:
+	ip->i_dirhash = NULL;
 	DIRHASH_UNLOCK(dh);
 	if (dh->dh_hash != NULL) {
 		for (i = 0; i < narrays; i++)
@@ -269,7 +270,6 @@ fail:
 		kmem_free(dh->dh_blkfree, dh->dh_blkfreesz);
 	mutex_destroy(>dh_lock);
 	pool_cache_put(ulfsdirhash_cache, dh);
-	ip->i_dirhash = NULL;
 	atomic_add_int(_dirhashmem, -memreqd);
 	return (-1);
 }
@@ -286,6 +286,8 @@ ulfsdirhash_free(struct inode *ip)
 	if ((dh = ip->i_dirhash) == NULL)
 		return;
 
+	ip->i_dirhash = NULL;
+
 	if (dh->dh_onlist) {
 		DIRHASHLIST_LOCK();
 		if (dh->dh_onlist)
@@ -306,7 +308,6 @@ ulfsdirhash_free(struct inode *ip)
 	}
 	mutex_destroy(>dh_lock);
 	pool_cache_put(ulfsdirhash_cache, dh);
-	ip->i_dirhash = NULL;
 
 	atomic_add_int(_dirhashmem, -mem);
 }



CVS commit: src/sys/ufs/lfs

2016-06-19 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Jun 20 01:50:14 UTC 2016

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

Log Message:
Merge -r1.46 of ufs_extattr.c: Fix uninitialized mutex usage


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 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.11 src/sys/ufs/lfs/ulfs_extattr.c:1.12
--- src/sys/ufs/lfs/ulfs_extattr.c:1.11	Mon Jun 20 01:47:58 2016
+++ src/sys/ufs/lfs/ulfs_extattr.c	Mon Jun 20 01:50:13 2016
@@ -1,5 +1,5 @@
-/*	$NetBSD: ulfs_extattr.c,v 1.11 2016/06/20 01:47:58 dholland Exp $	*/
-/*  from NetBSD: ufs_extattr.c,v 1.45 2014/11/15 05:03:55 manu Exp  */
+/*	$NetBSD: ulfs_extattr.c,v 1.12 2016/06/20 01:50:13 dholland Exp $	*/
+/*  from NetBSD: ufs_extattr.c,v 1.46 2014/11/19 16:26:47 manu Exp  */
 
 /*-
  * Copyright (c) 1999-2002 Robert N. M. Watson
@@ -49,7 +49,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ulfs_extattr.c,v 1.11 2016/06/20 01:47:58 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ulfs_extattr.c,v 1.12 2016/06/20 01:50:13 dholland Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_lfs.h"
@@ -1103,6 +1103,9 @@ vop_getextattr {
 	struct ulfsmount *ump = VFSTOULFS(mp);
 	int error;
 
+	if (!(ump->um_extattr.uepm_flags & ULFS_EXTATTR_UEPM_STARTED))
+		return (EOPNOTSUPP);
+
 	ulfs_extattr_uepm_lock(ump);
 
 	error = ulfs_extattr_get(ap->a_vp, ap->a_attrnamespace, ap->a_name,
@@ -1129,9 +1132,6 @@ ulfs_extattr_get(struct vnode *vp, int a
 	size_t len, old_len;
 	int error = 0;
 
-	if (!(ump->um_extattr.uepm_flags & ULFS_EXTATTR_UEPM_STARTED))
-		return (EOPNOTSUPP);
-
 	if (strlen(name) == 0)
 		return (EINVAL);
 
@@ -1221,6 +1221,9 @@ vop_listextattr {
 	struct ulfsmount *ump = VFSTOULFS(mp);
 	int error;
 
+	if (!(ump->um_extattr.uepm_flags & ULFS_EXTATTR_UEPM_STARTED))
+		return (EOPNOTSUPP);
+
 	ulfs_extattr_uepm_lock(ump);
 
 	error = ulfs_extattr_list(ap->a_vp, ap->a_attrnamespace,
@@ -1247,9 +1250,6 @@ ulfs_extattr_list(struct vnode *vp, int 
 	size_t listsize = 0;
 	int error = 0;
 
-	if (!(ump->um_extattr.uepm_flags & ULFS_EXTATTR_UEPM_STARTED))
-		return (EOPNOTSUPP);
-
 	/*
 	 * XXX: We can move this inside the loop and iterate on individual
 	 *	attributes.
@@ -1348,6 +1348,9 @@ vop_deleteextattr {
 	struct ulfsmount *ump = VFSTOULFS(mp); 
 	int error;
 
+	if (!(ump->um_extattr.uepm_flags & ULFS_EXTATTR_UEPM_STARTED))
+		return (EOPNOTSUPP);
+
 	ulfs_extattr_uepm_lock(ump);
 
 	error = ulfs_extattr_rm(ap->a_vp, ap->a_attrnamespace, ap->a_name,
@@ -1377,6 +1380,9 @@ vop_setextattr {
 	struct ulfsmount *ump = VFSTOULFS(mp); 
 	int error;
 
+	if (!(ump->um_extattr.uepm_flags & ULFS_EXTATTR_UEPM_STARTED))
+		return (EOPNOTSUPP);
+
 	ulfs_extattr_uepm_lock(ump);
 
 	/*
@@ -1415,8 +1421,7 @@ ulfs_extattr_set(struct vnode *vp, int a
 
 	if (vp->v_mount->mnt_flag & MNT_RDONLY)
 		return (EROFS);
-	if (!(ump->um_extattr.uepm_flags & ULFS_EXTATTR_UEPM_STARTED))
-		return (EOPNOTSUPP);
+
 	if (!ulfs_extattr_valid_attrname(attrnamespace, name))
 		return (EINVAL);
 
@@ -1535,8 +1540,7 @@ ulfs_extattr_rm(struct vnode *vp, int at
 
 	if (vp->v_mount->mnt_flag & MNT_RDONLY)  
 		return (EROFS);
-	if (!(ump->um_extattr.uepm_flags & ULFS_EXTATTR_UEPM_STARTED))
-		return (EOPNOTSUPP);
+
 	if (!ulfs_extattr_valid_attrname(attrnamespace, name))
 		return (EINVAL);
 
@@ -1609,12 +1613,10 @@ ulfs_extattr_vnode_inactive(struct vnode
 	if (!(ump->um_extattr.uepm_flags & ULFS_EXTATTR_UEPM_INITIALIZED))
 		return;
 
-	ulfs_extattr_uepm_lock(ump);
-
-	if (!(ump->um_extattr.uepm_flags & ULFS_EXTATTR_UEPM_STARTED)) {
-		ulfs_extattr_uepm_unlock(ump);
+	if (!(ump->um_extattr.uepm_flags & ULFS_EXTATTR_UEPM_STARTED))
 		return;
-	}
+
+	ulfs_extattr_uepm_lock(ump);
 
 	LIST_FOREACH(uele, >um_extattr.uepm_list, uele_entries)
 		ulfs_extattr_rm(vp, uele->uele_attrnamespace,



CVS commit: src/sys/ufs/lfs

2016-06-19 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Jun 20 01:47:58 UTC 2016

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

Log Message:
Merge -r1.45 of ufs_extattr.c:
Fix UFS1 extended attribute backend autocreation deadlock


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 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.10 src/sys/ufs/lfs/ulfs_extattr.c:1.11
--- src/sys/ufs/lfs/ulfs_extattr.c:1.10	Mon Jun 20 01:44:05 2016
+++ src/sys/ufs/lfs/ulfs_extattr.c	Mon Jun 20 01:47:58 2016
@@ -1,5 +1,5 @@
-/*	$NetBSD: ulfs_extattr.c,v 1.10 2016/06/20 01:44:05 dholland Exp $	*/
-/*  from NetBSD: ufs_extattr.c,v 1.44 2014/11/14 10:09:50 manu  */
+/*	$NetBSD: ulfs_extattr.c,v 1.11 2016/06/20 01:47:58 dholland Exp $	*/
+/*  from NetBSD: ufs_extattr.c,v 1.45 2014/11/15 05:03:55 manu Exp  */
 
 /*-
  * Copyright (c) 1999-2002 Robert N. M. Watson
@@ -49,7 +49,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ulfs_extattr.c,v 1.10 2016/06/20 01:44:05 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ulfs_extattr.c,v 1.11 2016/06/20 01:47:58 dholland Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_lfs.h"
@@ -210,9 +210,9 @@ ulfs_extattr_valid_attrname(int attrname
 /*
  * Autocreate an attribute storage
  */
-static struct ulfs_extattr_list_entry *
+static int
 ulfs_extattr_autocreate_attr(struct vnode *vp, int attrnamespace,
-const char *attrname, struct lwp *l)
+const char *attrname, struct lwp *l, struct ulfs_extattr_list_entry **uelep)
 {
 	struct mount *mp = vp->v_mount;
 	struct ulfsmount *ump = VFSTOULFS(mp);
@@ -246,11 +246,21 @@ ulfs_extattr_autocreate_attr(struct vnod
 		break;
 	default:
 		PNBUF_PUT(path);
-		return NULL;
+		*uelep = NULL;
+		return EINVAL;
 		break;
 	}
 
 	/*
+	 * Release extended attribute mount lock, otherwise
+	 * we can deadlock with another thread that would lock 
+	 * vp after we unlock it below, and call 
+	 * ulfs_extattr_uepm_lock(ump), for instance
+	 * in ulfs_getextattr().
+	 */
+	ulfs_extattr_uepm_unlock(ump);
+
+	/*
 	 * XXX unlock/lock should only be done when setting extattr
 	 * on backing store or one of its parent directory 
 	 * including root, but we always do it for now.
@@ -261,7 +271,12 @@ ulfs_extattr_autocreate_attr(struct vnod
 	pb = pathbuf_create(path);
 	NDINIT(, CREATE, LOCKPARENT, pb);
 	
-	error = vn_open(, O_CREAT|O_RDWR, 0600);
+	/*
+	 * Since we do not hold ulfs_extattr_uepm_lock anymore,
+	 * another thread may race with us for backend creation,
+	 * but only one can succeed here thanks to O_EXCL
+	 */
+	error = vn_open(, O_CREAT|O_EXCL|O_RDWR, 0600);
 
 	/*
 	 * Reacquire the lock on the vnode
@@ -269,10 +284,13 @@ ulfs_extattr_autocreate_attr(struct vnod
 	KASSERT(VOP_ISLOCKED(vp) == 0);
 	vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
 
+	ulfs_extattr_uepm_lock(ump);
+
 	if (error != 0) {
 		pathbuf_destroy(pb);
 		PNBUF_PUT(path);
-		return NULL;
+		*uelep = NULL;
+		return error;
 	}
 
 	KASSERT(nd.ni_vp != NULL);
@@ -300,7 +318,8 @@ ulfs_extattr_autocreate_attr(struct vnod
 		printf("%s: write uef header failed for %s, error = %d\n", 
 		   __func__, attrname, error);
 		vn_close(backing_vp, FREAD|FWRITE, l->l_cred);
-		return NULL;
+		*uelep = NULL;
+		return error;
 	}
 
 	/*
@@ -313,7 +332,8 @@ ulfs_extattr_autocreate_attr(struct vnod
 		printf("%s: enable %s failed, error %d\n", 
 		   __func__, attrname, error);
 		vn_close(backing_vp, FREAD|FWRITE, l->l_cred);
-		return NULL;
+		*uelep = NULL;
+		return error;
 	}
 
 	uele = ulfs_extattr_find_attr(ump, attrnamespace, attrname);
@@ -321,13 +341,15 @@ ulfs_extattr_autocreate_attr(struct vnod
 		printf("%s: atttribute %s created but not found!\n",
 		   __func__, attrname);
 		vn_close(backing_vp, FREAD|FWRITE, l->l_cred);
-		return NULL;
+		*uelep = NULL;
+		return ESRCH; /* really internal error */
 	}
 
 	printf("%s: EA backing store autocreated for %s\n",
 	   mp->mnt_stat.f_mntonname, attrname);
 
-	return uele;
+	*uelep = uele;
+	return 0;
 }
 
 /*
@@ -1405,10 +1427,17 @@ ulfs_extattr_set(struct vnode *vp, int a
 
 	attribute = ulfs_extattr_find_attr(ump, attrnamespace, name);
 	if (!attribute) {
-		attribute =  ulfs_extattr_autocreate_attr(vp, attrnamespace, 
-			 name, l);
-		if  (!attribute)
-			return (ENODATA);
+		error = ulfs_extattr_autocreate_attr(vp, attrnamespace, 
+		name, l, );
+		if (error == EEXIST) {
+			/* Another thread raced us for backend creation */
+			error = 0;
+			attribute = 
+			ulfs_extattr_find_attr(ump, attrnamespace, name);
+		}
+
+		if (error || !attribute)
+			return ENODATA;
 	}
 
 	/*



CVS commit: src/sys/ufs/lfs

2016-06-19 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Jun 20 01:44:05 UTC 2016

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

Log Message:
Merge -r1.44 of ufs_extattr.c and related change -r1.302 of ffs_vfops.c:
fix use-after-free on failed unmount with extended attributes enabled.


To generate a diff of this commit:
cvs rdiff -u -r1.349 -r1.350 src/sys/ufs/lfs/lfs_vfsops.c
cvs rdiff -u -r1.9 -r1.10 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/lfs_vfsops.c
diff -u src/sys/ufs/lfs/lfs_vfsops.c:1.349 src/sys/ufs/lfs/lfs_vfsops.c:1.350
--- src/sys/ufs/lfs/lfs_vfsops.c:1.349	Mon Oct 19 04:22:18 2015
+++ src/sys/ufs/lfs/lfs_vfsops.c	Mon Jun 20 01:44:05 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_vfsops.c,v 1.349 2015/10/19 04:22:18 dholland Exp $	*/
+/*	$NetBSD: lfs_vfsops.c,v 1.350 2016/06/20 01:44:05 dholland Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007, 2007
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.349 2015/10/19 04:22:18 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.350 2016/06/20 01:44:05 dholland Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_lfs.h"
@@ -1248,18 +1248,6 @@ lfs_mountfs(struct vnode *devvp, struct 
 		}
 	}
 
-#ifdef LFS_EXTATTR
-	/*
-	 * Initialize file-backed extended attributes for ULFS1 file
-	 * systems.
-	 *
-	 * XXX: why is this limited to ULFS1?
-	 */
-	if (ump->um_fstype == ULFS1) {
-		ulfs_extattr_uepm_init(>um_extattr);
-	}
-#endif
-
 #ifdef LFS_KERNEL_RFW
 	lfs_roll_forward(fs, mp, l);
 #endif
@@ -1372,6 +1360,7 @@ lfs_unmount(struct mount *mp, int mntfla
 		}
 		if (ump->um_extattr.uepm_flags & ULFS_EXTATTR_UEPM_INITIALIZED) {
 			ulfs_extattr_uepm_destroy(>um_extattr);
+			mp->mnt_flag &= ~MNT_EXTATTR;
 		}
 	}
 #endif

Index: src/sys/ufs/lfs/ulfs_extattr.c
diff -u src/sys/ufs/lfs/ulfs_extattr.c:1.9 src/sys/ufs/lfs/ulfs_extattr.c:1.10
--- src/sys/ufs/lfs/ulfs_extattr.c:1.9	Mon Jun 20 00:00:47 2016
+++ src/sys/ufs/lfs/ulfs_extattr.c	Mon Jun 20 01:44:05 2016
@@ -1,5 +1,5 @@
-/*	$NetBSD: ulfs_extattr.c,v 1.9 2016/06/20 00:00:47 dholland Exp $	*/
-/*  from NetBSD: ufs_extattr.c,v 1.43 2014/02/07 15:29:23 hannken Exp  */
+/*	$NetBSD: ulfs_extattr.c,v 1.10 2016/06/20 01:44:05 dholland Exp $	*/
+/*  from NetBSD: ufs_extattr.c,v 1.44 2014/11/14 10:09:50 manu  */
 
 /*-
  * Copyright (c) 1999-2002 Robert N. M. Watson
@@ -49,7 +49,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ulfs_extattr.c,v 1.9 2016/06/20 00:00:47 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ulfs_extattr.c,v 1.10 2016/06/20 01:44:05 dholland Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_lfs.h"
@@ -384,10 +384,11 @@ ulfs_extattr_uepm_destroy(struct ulfs_ex
 		panic("ulfs_extattr_uepm_destroy: called while still started");
 
 	/*
-	 * It's not clear that either order for the next two lines is
+	 * It's not clear that either order for the next three lines is
 	 * ideal, and it should never be a problem if this is only called
 	 * during unmount, and with vfs_busy().
 	 */
+	uepm->uepm_flags &= ~ULFS_EXTATTR_UEPM_STARTED;
 	uepm->uepm_flags &= ~ULFS_EXTATTR_UEPM_INITIALIZED;
 	mutex_destroy(>uepm_lock);
 }
@@ -403,6 +404,9 @@ ulfs_extattr_start(struct mount *mp, str
 
 	ump = VFSTOULFS(mp);
 
+	if (!(ump->um_extattr.uepm_flags & ULFS_EXTATTR_UEPM_INITIALIZED))
+		ulfs_extattr_uepm_init(>um_extattr); 
+
 	ulfs_extattr_uepm_lock(ump);
 
 	if (!(ump->um_extattr.uepm_flags & ULFS_EXTATTR_UEPM_INITIALIZED)) {



CVS commit: src/sys/ufs/lfs

2016-06-19 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Jun 20 01:23:04 UTC 2016

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

Log Message:
Remove stray 'n' in file. silly control key...


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 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.24 src/sys/ufs/lfs/ulfs_quota2.c:1.25
--- src/sys/ufs/lfs/ulfs_quota2.c:1.24	Mon Jun 20 00:09:42 2016
+++ src/sys/ufs/lfs/ulfs_quota2.c	Mon Jun 20 01:23:04 2016
@@ -1,4 +1,4 @@
-n/*	$NetBSD: ulfs_quota2.c,v 1.24 2016/06/20 00:09:42 dholland Exp $	*/
+/*	$NetBSD: ulfs_quota2.c,v 1.25 2016/06/20 01:23:04 dholland Exp $	*/
 /*  from NetBSD: ufs_quota2.c,v 1.37 2014/01/29 20:13:04 bouyer Exp  */
 /*  from NetBSD: ffs_quota2.c,v 1.4 2011/06/12 03:36:00 rmind Exp  */
 
@@ -29,7 +29,7 @@ n/*	$NetBSD: ulfs_quota2.c,v 1.24 2016/0
   */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ulfs_quota2.c,v 1.24 2016/06/20 00:09:42 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ulfs_quota2.c,v 1.25 2016/06/20 01:23:04 dholland Exp $");
 
 #include 
 #include 



CVS commit: src/sys/ufs/lfs

2016-06-19 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Jun 20 01:20:01 UTC 2016

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

Log Message:
Merge ufs_rename.c 1.11: ufs_gro_genealogy: use vcache_get() to lookup DOTDOT.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/ufs/lfs/lfs_rename.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/ufs/lfs/lfs_rename.c
diff -u src/sys/ufs/lfs/lfs_rename.c:1.18 src/sys/ufs/lfs/lfs_rename.c:1.19
--- src/sys/ufs/lfs/lfs_rename.c:1.18	Mon Jun 20 00:00:47 2016
+++ src/sys/ufs/lfs/lfs_rename.c	Mon Jun 20 01:20:01 2016
@@ -1,5 +1,5 @@
-/*	$NetBSD: lfs_rename.c,v 1.18 2016/06/20 00:00:47 dholland Exp $	*/
-/*  from NetBSD: ufs_rename.c,v 1.10 2014/02/06 10:57:12 hannken Exp  */
+/*	$NetBSD: lfs_rename.c,v 1.19 2016/06/20 01:20:01 dholland Exp $	*/
+/*  from NetBSD: ufs_rename.c,v 1.11 2014/05/25 13:45:39 hannken Exp  */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -89,7 +89,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lfs_rename.c,v 1.18 2016/06/20 00:00:47 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_rename.c,v 1.19 2016/06/20 01:20:01 dholland Exp $");
 
 #include 
 #include 
@@ -697,20 +697,15 @@ ulfs_gro_genealogy(struct mount *mp, kau
 		}
 
 		/* Neither -- keep ascending the family tree.  */
-
-		/*
-		 * Unlock vp so that we can lock the parent, but keep
-		 * vp referenced until after we have found the parent,
-		 * so that dotdot_ino will not be recycled.
-		 *
-		 * XXX This guarantees that vp's inode number will not
-		 * be recycled, but why can't dotdot_ino be recycled?
-		 */
-		VOP_UNLOCK(vp);
-		error = VFS_VGET(mp, dotdot_ino, );
-		vrele(vp);
+		error = vcache_get(mp, _ino, sizeof(dotdot_no), );
+		vput(vp);
 		if (error)
 			return error;
+		error = vn_lock(dvp, LK_EXCLUSIVE);
+		if (error) {
+			vrele(dvp);
+			return error;
+		}
 
 		KASSERT(dvp != NULL);
 		KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE);



  1   2   3   >