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 <sys/cdefs.h>
-__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 <sys/param.h>
 #include <sys/systm.h>
@@ -561,6 +561,7 @@ lfs_segunlock(struct lfs *fs)
 			lfs_unmark_dirop(fs);
 	} else {
 		--fs->lfs_seglock;
+		KASSERT(fs->lfs_seglock != 0);
 		mutex_exit(&lfs_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(&lfs_lock);
@@ -585,15 +586,11 @@ lfs_writer_enter(struct lfs *fs, const c
 		++fs->lfs_diropwait;
 		error = mtsleep(&fs->lfs_writer, PRIBIO+1, wmesg, 0,
 				&lfs_lock);
+		KASSERT(error == 0);
 		--fs->lfs_diropwait;
 	}
 
-	if (error)
-		fs->lfs_writer--;
-
 	mutex_exit(&lfs_lock);
-
-	return error;
 }
 
 int

Reply via email to