CVS commit: src/sys/ufs/lfs

2024-02-17 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Feb 17 09:08:21 UTC 2024

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

Log Message:
Whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 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.24 src/sys/ufs/lfs/ulfs_inode.h:1.25
--- src/sys/ufs/lfs/ulfs_inode.h:1.24	Sat Jun 10 05:29:36 2017
+++ src/sys/ufs/lfs/ulfs_inode.h	Sat Feb 17 09:08:21 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: ulfs_inode.h,v 1.24 2017/06/10 05:29:36 maya Exp $	*/
+/*	$NetBSD: ulfs_inode.h,v 1.25 2024/02/17 09:08:21 mlelstv Exp $	*/
 /*  from NetBSD: inode.h,v 1.72 2016/06/03 15:36:03 christos Exp  */
 
 /*
@@ -147,7 +147,7 @@ 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. */
+	int32_t  ufid_gen;	/* Generation number. */
 };
 /* Filehandle structure for exported LFSes */
 struct lfid {



CVS commit: src/sys/ufs/lfs

2024-02-17 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Feb 17 09:08:21 UTC 2024

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

Log Message:
Whitespace.


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



CVS commit: src/sys/ufs/lfs

2023-04-11 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Apr 11 14:50:47 UTC 2023

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

Log Message:
lfs: Assert page identity doesn't change.

Forgot what I was debugging when I inserted a relookup in my local
tree months or years ago, but whatever it was, if that solved a
problem, this KDASSERT will make the problem more obvious.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 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.26 src/sys/ufs/lfs/lfs_pages.c:1.27
--- src/sys/ufs/lfs/lfs_pages.c:1.26	Sat Sep  5 16:30:13 2020
+++ src/sys/ufs/lfs/lfs_pages.c	Tue Apr 11 14:50:47 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_pages.c,v 1.26 2020/09/05 16:30:13 riastradh Exp $	*/
+/*	$NetBSD: lfs_pages.c,v 1.27 2023/04/11 14:50:47 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.26 2020/09/05 16:30:13 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_pages.c,v 1.27 2023/04/11 14:50:47 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -499,6 +499,9 @@ retry:
 			while (pg->flags & PG_BUSY) {
 uvm_pagewait(pg, vp->v_uobj.vmobjlock, "lfsput2");
 rw_enter(vp->v_uobj.vmobjlock, RW_WRITER);
+/* XXX Page can't change identity here? */
+KDASSERT(pg ==
+uvm_pagelookup(>v_uobj, off));
 			}
 			uvm_pagelock(pg);
 			uvm_pageactivate(pg);



CVS commit: src/sys/ufs/lfs

2023-04-11 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Apr 11 14:50:47 UTC 2023

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

Log Message:
lfs: Assert page identity doesn't change.

Forgot what I was debugging when I inserted a relookup in my local
tree months or years ago, but whatever it was, if that solved a
problem, this KDASSERT will make the problem more obvious.


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



CVS commit: src/sys/ufs/lfs

2022-04-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Apr 24 20:32:44 UTC 2022

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

Log Message:
lfs: fix lint warning about empty declaration


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 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.50 src/sys/ufs/lfs/lfs_accessors.h:1.51
--- src/sys/ufs/lfs/lfs_accessors.h:1.50	Mon Sep  7 02:28:12 2020
+++ src/sys/ufs/lfs/lfs_accessors.h	Sun Apr 24 20:32:44 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_accessors.h,v 1.50 2020/09/07 02:28:12 riastradh Exp $	*/
+/*	$NetBSD: lfs_accessors.h,v 1.51 2022/04/24 20:32:44 rillig 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  */
@@ -486,24 +486,24 @@ lfs_copy_dinode(STRUCT_LFS *fs,
 		}		\
 	}			\
 
-LFS_DEF_DINO_ACCESSOR(uint16_t, uint16_t, mode);
-LFS_DEF_DINO_ACCESSOR(int16_t, int16_t, nlink);
-LFS_DEF_DINO_ACCESSOR(uint64_t, uint32_t, inumber);
-LFS_DEF_DINO_ACCESSOR(uint64_t, uint64_t, size);
-LFS_DEF_DINO_ACCESSOR(int64_t, int32_t, atime);
-LFS_DEF_DINO_ACCESSOR(int32_t, int32_t, atimensec);
-LFS_DEF_DINO_ACCESSOR(int64_t, int32_t, mtime);
-LFS_DEF_DINO_ACCESSOR(int32_t, int32_t, mtimensec);
-LFS_DEF_DINO_ACCESSOR(int64_t, int32_t, ctime);
-LFS_DEF_DINO_ACCESSOR(int32_t, int32_t, ctimensec);
-LFS_DEF_DINO_ACCESSOR(uint32_t, uint32_t, flags);
-LFS_DEF_DINO_ACCESSOR(uint64_t, uint32_t, blocks);
-LFS_DEF_DINO_ACCESSOR(int32_t, int32_t, gen);
-LFS_DEF_DINO_ACCESSOR(uint32_t, uint32_t, uid);
-LFS_DEF_DINO_ACCESSOR(uint32_t, uint32_t, gid);
+LFS_DEF_DINO_ACCESSOR(uint16_t, uint16_t, mode)
+LFS_DEF_DINO_ACCESSOR(int16_t, int16_t, nlink)
+LFS_DEF_DINO_ACCESSOR(uint64_t, uint32_t, inumber)
+LFS_DEF_DINO_ACCESSOR(uint64_t, uint64_t, size)
+LFS_DEF_DINO_ACCESSOR(int64_t, int32_t, atime)
+LFS_DEF_DINO_ACCESSOR(int32_t, int32_t, atimensec)
+LFS_DEF_DINO_ACCESSOR(int64_t, int32_t, mtime)
+LFS_DEF_DINO_ACCESSOR(int32_t, int32_t, mtimensec)
+LFS_DEF_DINO_ACCESSOR(int64_t, int32_t, ctime)
+LFS_DEF_DINO_ACCESSOR(int32_t, int32_t, ctimensec)
+LFS_DEF_DINO_ACCESSOR(uint32_t, uint32_t, flags)
+LFS_DEF_DINO_ACCESSOR(uint64_t, uint32_t, blocks)
+LFS_DEF_DINO_ACCESSOR(int32_t, int32_t, gen)
+LFS_DEF_DINO_ACCESSOR(uint32_t, uint32_t, uid)
+LFS_DEF_DINO_ACCESSOR(uint32_t, uint32_t, gid)
 
 /* XXX this should be done differently (it's a fake field) */
-LFS_DEF_DINO_ACCESSOR(int64_t, int32_t, rdev);
+LFS_DEF_DINO_ACCESSOR(int64_t, int32_t, rdev)
 
 static __inline daddr_t
 lfs_dino_getdb(STRUCT_LFS *fs, union lfs_dinode *dip, unsigned ix)
@@ -747,10 +747,10 @@ lfs_iblock_set(STRUCT_LFS *fs, void *blo
 		}		\
 	}			\
 
-LFS_DEF_FI_ACCESSOR(uint32_t, uint32_t, nblocks);
-LFS_DEF_FI_ACCESSOR(uint32_t, uint32_t, version);
-LFS_DEF_FI_ACCESSOR(uint64_t, uint32_t, ino);
-LFS_DEF_FI_ACCESSOR(uint32_t, uint32_t, lastlength);
+LFS_DEF_FI_ACCESSOR(uint32_t, uint32_t, nblocks)
+LFS_DEF_FI_ACCESSOR(uint32_t, uint32_t, version)
+LFS_DEF_FI_ACCESSOR(uint64_t, uint32_t, ino)
+LFS_DEF_FI_ACCESSOR(uint32_t, uint32_t, lastlength)
 
 static __inline daddr_t
 lfs_fi_getblock(STRUCT_LFS *fs, FINFO *fip, unsigned idx)
@@ -882,11 +882,11 @@ lfs_ii_setblock(STRUCT_LFS *fs, IINFO *i
 		}		\
 	}			\
 
-LFS_DEF_IF_ACCESSOR(uint32_t, uint32_t, version);
-LFS_DEF_IF_ACCESSOR(int64_t, int32_t, daddr);
-LFS_DEF_IF_ACCESSOR(uint64_t, uint32_t, nextfree);
-LFS_DEF_IF_ACCESSOR(uint64_t, uint32_t, atime_sec);
-LFS_DEF_IF_ACCESSOR(uint32_t, uint32_t, atime_nsec);
+LFS_DEF_IF_ACCESSOR(uint32_t, uint32_t, version)
+LFS_DEF_IF_ACCESSOR(int64_t, int32_t, daddr)
+LFS_DEF_IF_ACCESSOR(uint64_t, uint32_t, nextfree)
+LFS_DEF_IF_ACCESSOR(uint64_t, uint32_t, atime_sec)
+LFS_DEF_IF_ACCESSOR(uint32_t, uint32_t, atime_nsec)
 
 /*
  * Cleaner information structure.  This resides in the ifile and is used
@@ -921,13 +921,13 @@ LFS_DEF_IF_ACCESSOR(uint32_t, uint32_t, 
 		}		\
 	}			\
 
-LFS_DEF_CI_ACCESSOR(uint32_t, uint32_t, clean);
-LFS_DEF_CI_ACCESSOR(uint32_t, uint32_t, dirty);
-LFS_DEF_CI_ACCESSOR(int64_t, int32_t, bfree);
-LFS_DEF_CI_ACCESSOR(int64_t, int32_t, avail);
-LFS_DEF_CI_ACCESSOR(uint64_t, uint32_t, free_head);
-LFS_DEF_CI_ACCESSOR(uint64_t, uint32_t, free_tail);
-LFS_DEF_CI_ACCESSOR(uint32_t, uint32_t, flags);
+LFS_DEF_CI_ACCESSOR(uint32_t, uint32_t, clean)
+LFS_DEF_CI_ACCESSOR(uint32_t, uint32_t, dirty)
+LFS_DEF_CI_ACCESSOR(int64_t, int32_t, bfree)
+LFS_DEF_CI_ACCESSOR(int64_t, int32_t, avail)
+LFS_DEF_CI_ACCESSOR(uint64_t, uint32_t, free_head)
+LFS_DEF_CI_ACCESSOR(uint64_t, uint32_t, free_tail)
+LFS_DEF_CI_ACCESSOR(uint32_t, uint32_t, flags)
 
 static __inline void
 lfs_ci_shiftcleantodirty(STRUCT_LFS *fs, CLEANERINFO *cip, unsigned num)
@@ -1067,17 +1067,17 @@ segsum_finfobase(STRUCT_LFS 

CVS commit: src/sys/ufs/lfs

2022-04-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Apr 24 20:32:44 UTC 2022

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

Log Message:
lfs: fix lint warning about empty declaration


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



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

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.



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-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.



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-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.



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.



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-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.



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: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.



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-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.



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.



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.



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 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.



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: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.



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: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.



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.



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: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.



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: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.



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.



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.



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.



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.



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: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.



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: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.



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.



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.



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.



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: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.



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: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.



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-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.



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

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.



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-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.



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.



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-06-19 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jun 20 00:49:12 UTC 2019

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

Log Message:
unifdef -DLFS_READWRITE ulfs_readwrite.c


To generate a diff of this commit:
cvs rdiff -u -r1.323 -r1.324 src/sys/ufs/lfs/lfs_vnops.c
cvs rdiff -u -r1.24 -r1.25 src/sys/ufs/lfs/ulfs_readwrite.c

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.323 src/sys/ufs/lfs/lfs_vnops.c:1.324
--- src/sys/ufs/lfs/lfs_vnops.c:1.323	Tue Jan  1 05:06:55 2019
+++ src/sys/ufs/lfs/lfs_vnops.c	Wed Jun 19 20:49:11 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_vnops.c,v 1.323 2019/01/01 10:06:55 hannken Exp $	*/
+/*	$NetBSD: lfs_vnops.c,v 1.324 2019/06/20 00:49:11 christos 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.323 2019/01/01 10:06:55 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.324 2019/06/20 00:49:11 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -350,9 +350,7 @@ const struct vnodeopv_entry_desc lfs_fif
 const struct vnodeopv_desc lfs_fifoop_opv_desc =
 	{ _fifoop_p, lfs_fifoop_entries };
 
-#define	LFS_READWRITE
 #include 
-#undef	LFS_READWRITE
 
 /*
  * Allocate a new inode.

Index: src/sys/ufs/lfs/ulfs_readwrite.c
diff -u src/sys/ufs/lfs/ulfs_readwrite.c:1.24 src/sys/ufs/lfs/ulfs_readwrite.c:1.25
--- src/sys/ufs/lfs/ulfs_readwrite.c:1.24	Sat Jun 10 01:29:36 2017
+++ src/sys/ufs/lfs/ulfs_readwrite.c	Wed Jun 19 20:49:11 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ulfs_readwrite.c,v 1.24 2017/06/10 05:29:36 maya Exp $	*/
+/*	$NetBSD: ulfs_readwrite.c,v 1.25 2019/06/20 00:49:11 christos Exp $	*/
 /*  from NetBSD: ufs_readwrite.c,v 1.120 2015/04/12 22:48:38 riastradh Exp  */
 
 /*-
@@ -33,9 +33,8 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: ulfs_readwrite.c,v 1.24 2017/06/10 05:29:36 maya Exp $");
+__KERNEL_RCSID(1, "$NetBSD: ulfs_readwrite.c,v 1.25 2019/06/20 00:49:11 christos Exp $");
 
-#ifdef LFS_READWRITE
 #define	FS			struct lfs
 #define	I_FS			i_lfs
 #define	READ			lfs_read
@@ -46,17 +45,6 @@ __KERNEL_RCSID(1, "$NetBSD: ulfs_readwri
 #define	BUFWR			lfs_bufwr
 #define	fs_sb_getbsize(fs)	lfs_sb_getbsize(fs)
 #define	fs_bmask		lfs_bmask
-#else
-#define	FS			struct fs
-#define	I_FS			i_fs
-#define	READ			ffs_read
-#define	READ_S			"ffs_read"
-#define	WRITE			ffs_write
-#define	WRITE_S			"ffs_write"
-#define	BUFRD			ffs_bufrd
-#define	BUFWR			ffs_bufwr
-#define fs_sb_getbsize(fs)	(fs)->fs_bsize
-#endif
 
 static int	ulfs_post_read_update(struct vnode *, int, int);
 static int	ulfs_post_write_update(struct vnode *, struct uio *, int,
@@ -95,20 +83,14 @@ READ(void *v)
 	/* XXX Eliminate me by refusing directory reads from userland.  */
 	if (vp->v_type == VDIR)
 		return BUFRD(vp, uio, ioflag, ap->a_cred);
-#ifdef LFS_READWRITE
 	/* XXX Eliminate me by using ufs_bufio in lfs.  */
 	if (vp->v_type == VREG && ip->i_number == LFS_IFILE_INUM)
 		return BUFRD(vp, uio, ioflag, ap->a_cred);
-#endif
 	if ((u_int64_t)uio->uio_offset > fs->um_maxfilesize)
 		return (EFBIG);
 	if (uio->uio_resid == 0)
 		return (0);
 
-#ifndef LFS_READWRITE
-	if ((ip->i_flags & (SF_SNAPSHOT | SF_SNAPINVAL)) == SF_SNAPSHOT)
-		return ffs_snapshot_read(vp, uio, ioflag);
-#endif /* !LFS_READWRITE */
 
 	if (uio->uio_offset >= ip->i_size)
 		goto out;
@@ -167,9 +149,6 @@ BUFRD(struct vnode *vp, struct uio *uio,
 	if (uio->uio_resid == 0)
 		return 0;
 
-#ifndef LFS_READWRITE
-	KASSERT(!ISSET(ip->i_flags, (SF_SNAPSHOT | SF_SNAPINVAL)));
-#endif
 
 	if (uio->uio_offset >= ip->i_size)
 		goto out;
@@ -283,12 +262,10 @@ WRITE(void *v)
 	if (uio->uio_offset < 0 ||
 	(u_int64_t)uio->uio_offset + uio->uio_resid > fs->um_maxfilesize)
 		return (EFBIG);
-#ifdef LFS_READWRITE
 	/* Disallow writes to the Ifile, even if noschg flag is removed */
 	/* XXX can this go away when the Ifile is no longer in the namespace? */
 	if (vp == fs->lfs_ivnode)
 		return (EPERM);
-#endif
 	if (uio->uio_resid == 0)
 		return (0);
 
@@ -301,11 +278,9 @@ WRITE(void *v)
 
 	KASSERT(vp->v_type == VREG);
 
-#ifdef LFS_READWRITE
 	async = true;
 	lfs_availwait(fs, lfs_btofsb(fs, uio->uio_resid));
 	lfs_check(vp, LFS_UNUSED_LBN, 0);
-#endif /* !LFS_READWRITE */
 
 	preallocoff = round_page(lfs_blkroundup(fs, MAX(osize, uio->uio_offset)));
 	aflag = ioflag & IO_SYNC ? B_SYNC : 0;
@@ -420,18 +395,7 @@ WRITE(void *v)
 		 * XXXUBC simplistic async flushing.
 		 */
 
-#ifndef LFS_READWRITE
-		if (!async && oldoff >> 16 != uio->uio_offset >> 16) {
-			mutex_enter(vp->v_interlock);
-			error = VOP_PUTPAGES(vp, (oldoff >> 16) << 16,
-			(uio->uio_offset >> 16) << 16,
-			PGO_CLEANIT | PGO_LAZY);
-			if (error)
-break;
-		}
-#else
 		__USE(async);
-#endif
 	}
 	if (error == 0 && ioflag & IO_SYNC) {

CVS commit: src/sys/ufs/lfs

2019-06-19 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jun 20 00:49:12 UTC 2019

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

Log Message:
unifdef -DLFS_READWRITE ulfs_readwrite.c


To generate a diff of this commit:
cvs rdiff -u -r1.323 -r1.324 src/sys/ufs/lfs/lfs_vnops.c
cvs rdiff -u -r1.24 -r1.25 src/sys/ufs/lfs/ulfs_readwrite.c

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



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

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.



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-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.



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.



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.



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:   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.



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 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.



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 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.



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.



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);
 	}
 



Re: CVS commit: src/sys/ufs/lfs

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

For kicks, 'found by running COMPAT_LINUX', which does this (so does NFS).

LFS still comes with this warning that is very hard to miss:
WARNING: the log-structured file system is experimental
WARNING: it may cause system crashes and/or corrupt data
root file system type: lfs


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-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.



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 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.



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 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.



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.



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.



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-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.



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-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.



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);		\
-	

  1   2   3   4   5   6   >