Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/ufs/lfs lfs_writer_enter can't fail; keep it simple and ...



details:   https://anonhg.NetBSD.org/src/rev/0218dbd472a2
branches:  trunk
changeset: 969561:0218dbd472a2
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Feb 23 08:42:53 2020 +0000

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

diffstat:

 sys/ufs/lfs/lfs_extern.h |   4 ++--
 sys/ufs/lfs/lfs_subr.c   |  15 ++++++---------
 2 files changed, 8 insertions(+), 11 deletions(-)

diffs (74 lines):

diff -r 6507300332fc -r 0218dbd472a2 sys/ufs/lfs/lfs_extern.h
--- a/sys/ufs/lfs/lfs_extern.h  Sun Feb 23 08:41:07 2020 +0000
+++ b/sys/ufs/lfs/lfs_extern.h  Sun Feb 23 08:42:53 2020 +0000
@@ -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 @@
 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 *);
diff -r 6507300332fc -r 0218dbd472a2 sys/ufs/lfs/lfs_subr.c
--- a/sys/ufs/lfs/lfs_subr.c    Sun Feb 23 08:41:07 2020 +0000
+++ b/sys/ufs/lfs/lfs_subr.c    Sun Feb 23 08:42:53 2020 +0000
@@ -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_unmark_dirop(fs);
        } else {
                --fs->lfs_seglock;
+               KASSERT(fs->lfs_seglock != 0);
                mutex_exit(&lfs_lock);
        }
 }
@@ -570,10 +571,10 @@
  *
  * 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 @@
                ++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



Home | Main Index | Thread Index | Old Index