Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/ufs/lfs change lfs_nextsegsleep and lfs_allclean_wakeup ...
details: https://anonhg.NetBSD.org/src/rev/f2d2d1222b39
branches: trunk
changeset: 355349:f2d2d1222b39
user: maya <maya%NetBSD.org@localhost>
date: Wed Jul 26 16:42:37 2017 +0000
description:
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?
diffstat:
sys/ufs/lfs/lfs.h | 4 ++--
sys/ufs/lfs/lfs_extern.h | 4 ++--
sys/ufs/lfs/lfs_segment.c | 6 +++---
sys/ufs/lfs/lfs_subr.c | 8 ++++----
sys/ufs/lfs/lfs_syscalls.c | 10 +++++-----
sys/ufs/lfs/lfs_vfsops.c | 14 ++++++++++++--
sys/ufs/lfs/lfs_vnops.c | 7 +++----
7 files changed, 31 insertions(+), 22 deletions(-)
diffs (205 lines):
diff -r a32596fab789 -r f2d2d1222b39 sys/ufs/lfs/lfs.h
--- a/sys/ufs/lfs/lfs.h Wed Jul 26 15:32:09 2017 +0000
+++ b/sys/ufs/lfs/lfs.h Wed Jul 26 16:42:37 2017 +0000
@@ -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 @@
/* XXX: should be replaced with a condvar */
int lfs_availsleep;
/* This one replaces &lfs_nextseg... all ditto */
- int lfs_nextsegsleep;
+ kcondvar_t lfs_nextsegsleep;
/* Cleaner lwp, set on first bmapv syscall. */
struct lwp *lfs_cleaner_thread;
diff -r a32596fab789 -r f2d2d1222b39 sys/ufs/lfs/lfs_extern.h
--- a/sys/ufs/lfs/lfs_extern.h Wed Jul 26 15:32:09 2017 +0000
+++ b/sys/ufs/lfs/lfs_extern.h Wed Jul 26 16:42:37 2017 +0000
@@ -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 @@
#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 */
diff -r a32596fab789 -r f2d2d1222b39 sys/ufs/lfs/lfs_segment.c
--- a/sys/ufs/lfs/lfs_segment.c Wed Jul 26 15:32:09 2017 +0000
+++ b/sys/ufs/lfs/lfs_segment.c Wed Jul 26 16:42:37 2017 +0000
@@ -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 <sys/cdefs.h>
-__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 @@
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 */
diff -r a32596fab789 -r f2d2d1222b39 sys/ufs/lfs/lfs_subr.c
--- a/sys/ufs/lfs/lfs_subr.c Wed Jul 26 15:32:09 2017 +0000
+++ b/sys/ufs/lfs/lfs_subr.c Wed Jul 26 16:42:37 2017 +0000
@@ -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 <sys/cdefs.h>
-__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 <sys/param.h>
#include <sys/systm.h>
@@ -649,6 +649,6 @@
if (fs->lfs_nowrap > 0)
return;
- wakeup(&fs->lfs_nextsegsleep);
- wakeup(&lfs_allclean_wakeup);
+ cv_broadcast(&fs->lfs_nextsegsleep);
+ cv_broadcast(&lfs_allclean_wakeup);
}
diff -r a32596fab789 -r f2d2d1222b39 sys/ufs/lfs/lfs_syscalls.c
--- a/sys/ufs/lfs/lfs_syscalls.c Wed Jul 26 15:32:09 2017 +0000
+++ b/sys/ufs/lfs/lfs_syscalls.c Wed Jul 26 16:42:37 2017 +0000
@@ -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 2017/07/26 16:42:37 maya Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007, 2007, 2008
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lfs_syscalls.c,v 1.174 2017/04/17 08:32:01 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_syscalls.c,v 1.175 2017/07/26 16:42:37 maya Exp $");
#ifndef LFS
# define LFS /* for prototypes in syscallargs.h */
@@ -899,7 +899,7 @@
u_long timeout;
int error;
- KERNEL_LOCK(1, NULL);
+ mutex_enter(&lfs_lock);
if (fsidp == NULL || (mntp = vfs_getvfs(fsidp)) == NULL)
addr = &lfs_allclean_wakeup;
else
@@ -909,8 +909,8 @@
* XXX IS THAT WHAT IS INTENDED?
*/
timeout = tvtohz(tv);
- error = tsleep(addr, PCATCH | PVFS, "segment", timeout);
- KERNEL_UNLOCK_ONE(NULL);
+ error = cv_timedwait_sig(addr, &lfs_lock, timeout);
+ mutex_exit(&lfs_lock);
return (error == ERESTART ? EINTR : 0);
}
diff -r a32596fab789 -r f2d2d1222b39 sys/ufs/lfs/lfs_vfsops.c
--- a/sys/ufs/lfs/lfs_vfsops.c Wed Jul 26 15:32:09 2017 +0000
+++ b/sys/ufs/lfs/lfs_vfsops.c Wed Jul 26 16:42:37 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_vfsops.c,v 1.359 2017/04/17 08:32:01 hannken Exp $ */
+/* $NetBSD: lfs_vfsops.c,v 1.360 2017/07/26 16:42:37 maya Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007, 2007
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.359 2017/04/17 08:32:01 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.360 2017/07/26 16:42:37 maya Exp $");
#if defined(_KERNEL_OPT)
#include "opt_lfs.h"
@@ -860,6 +860,7 @@
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,6 +1092,13 @@
cv_init(&fs->lfs_sleeperscv, "lfs_slp");
cv_init(&fs->lfs_diropscv, "lfs_dirop");
cv_init(&fs->lfs_stopcv, "lfsstop");
+ cv_init(&fs->lfs_nextsegsleep, "segment");
+
+ /* Initialize values for all LFS mounts */
+ if (!lfs_mounted_once) {
+ cv_init(&lfs_allclean_wakeup, "segment");
+ lfs_mounted_once = true;
+ }
/* Set the file system readonly/modify bits. */
fs->lfs_ronly = ronly;
@@ -1409,6 +1417,8 @@
cv_destroy(&fs->lfs_sleeperscv);
cv_destroy(&fs->lfs_diropscv);
cv_destroy(&fs->lfs_stopcv);
+ cv_destroy(&fs->lfs_nextsegsleep);
+
rw_destroy(&fs->lfs_fraglock);
rw_destroy(&fs->lfs_iflock);
diff -r a32596fab789 -r f2d2d1222b39 sys/ufs/lfs/lfs_vnops.c
--- a/sys/ufs/lfs/lfs_vnops.c Wed Jul 26 15:32:09 2017 +0000
+++ b/sys/ufs/lfs/lfs_vnops.c Wed Jul 26 16:42:37 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_vnops.c,v 1.317 2017/06/10 05:29:36 maya Exp $ */
+/* $NetBSD: lfs_vnops.c,v 1.318 2017/07/26 16:42:37 maya Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -125,7 +125,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.317 2017/06/10 05:29:36 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.318 2017/07/26 16:42:37 maya Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -1305,8 +1305,7 @@
lfs_wakeup_cleaner(fs);
}
if (waitfor) {
- mtsleep(&fs->lfs_nextsegsleep, PCATCH | PUSER, "segment",
- 0, &lfs_lock);
+ cv_wait_sig(&fs->lfs_nextsegsleep, &lfs_lock);
}
return 0;
Home |
Main Index |
Thread Index |
Old Index