Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/fs/udf Convert UDF file system code from the depricated ...
details: https://anonhg.NetBSD.org/src/rev/9f459f721ff4
branches: trunk
changeset: 376652:9f459f721ff4
user: reinoud <reinoud%NetBSD.org@localhost>
date: Tue Jun 27 09:58:50 2023 +0000
description:
Convert UDF file system code from the depricated tsleep(9)/wakeup(9) to the MP
friendly condvar(9). No functional change intended.
diffstat:
sys/fs/udf/udf.h | 6 +++-
sys/fs/udf/udf_strat_direct.c | 8 +++---
sys/fs/udf/udf_strat_rmw.c | 30 +++++++++++++++---------
sys/fs/udf/udf_strat_sequential.c | 47 ++++++++++++++++++++++++++++----------
sys/fs/udf/udf_vnops.c | 8 ++++--
5 files changed, 66 insertions(+), 33 deletions(-)
diffs (300 lines):
diff -r 472e5d6b5d46 -r 9f459f721ff4 sys/fs/udf/udf.h
--- a/sys/fs/udf/udf.h Tue Jun 27 09:10:25 2023 +0000
+++ b/sys/fs/udf/udf.h Tue Jun 27 09:58:50 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: udf.h,v 1.54 2022/08/07 11:06:19 andvar Exp $ */
+/* $NetBSD: udf.h,v 1.55 2023/06/27 09:58:50 reinoud Exp $ */
/*
* Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -76,7 +76,9 @@ extern int udf_verbose;
#define UDF_DEBUG_RESERVE 0x1000000
/* initial value of udf_verbose */
-#define UDF_DEBUGGING (0)
+#define UDF_DEBUGGING (0x0000000)
+//#define UDF_DEBUGGING (0x02fffff)
+
#ifdef UDF_DEBUG
#define DPRINTF(name, arg) { \
diff -r 472e5d6b5d46 -r 9f459f721ff4 sys/fs/udf/udf_strat_direct.c
--- a/sys/fs/udf/udf_strat_direct.c Tue Jun 27 09:10:25 2023 +0000
+++ b/sys/fs/udf/udf_strat_direct.c Tue Jun 27 09:58:50 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_strat_direct.c,v 1.15 2022/01/15 10:55:53 msaitoh Exp $ */
+/* $NetBSD: udf_strat_direct.c,v 1.16 2023/06/27 09:58:50 reinoud Exp $ */
/*
* Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: udf_strat_direct.c,v 1.15 2022/01/15 10:55:53 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_strat_direct.c,v 1.16 2023/06/27 09:58:50 reinoud Exp $");
#endif /* not lint */
@@ -116,7 +116,7 @@ udf_wr_nodedscr_callback(struct buf *buf
if (udf_node->outstanding_nodedscr == 0) {
/* unlock the node */
UDF_UNLOCK_NODE(udf_node, 0);
- wakeup(&udf_node->outstanding_nodedscr);
+ cv_broadcast(&udf_node->node_lock);
}
putiobuf(buf);
@@ -223,7 +223,7 @@ out:
udf_node->outstanding_nodedscr--;
if (udf_node->outstanding_nodedscr == 0) {
UDF_UNLOCK_NODE(udf_node, 0);
- wakeup(&udf_node->outstanding_nodedscr);
+ cv_broadcast(&udf_node->node_lock);
}
return error;
diff -r 472e5d6b5d46 -r 9f459f721ff4 sys/fs/udf/udf_strat_rmw.c
--- a/sys/fs/udf/udf_strat_rmw.c Tue Jun 27 09:10:25 2023 +0000
+++ b/sys/fs/udf/udf_strat_rmw.c Tue Jun 27 09:58:50 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_strat_rmw.c,v 1.30 2022/01/15 10:55:53 msaitoh Exp $ */
+/* $NetBSD: udf_strat_rmw.c,v 1.31 2023/06/27 09:58:50 reinoud Exp $ */
/*
* Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: udf_strat_rmw.c,v 1.30 2022/01/15 10:55:53 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_strat_rmw.c,v 1.31 2023/06/27 09:58:50 reinoud Exp $");
#endif /* not lint */
@@ -756,7 +756,7 @@ udf_write_nodedscr_rmw(struct udf_strat_
if (udf_node->outstanding_nodedscr == 0) {
/* XXX still using wakeup! */
UDF_UNLOCK_NODE(udf_node, 0);
- wakeup(&udf_node->outstanding_nodedscr);
+ cv_broadcast(&udf_node->node_lock);
}
udf_puteccline(eccline);
@@ -1205,6 +1205,8 @@ udf_discstrat_thread(void *arg)
work = 1;
priv->thread_running = 1;
+ cv_broadcast(&priv->discstrat_cv);
+
mutex_enter(&priv->discstrat_mutex);
priv->num_floating = 0;
while (priv->run_thread || work || priv->num_floating) {
@@ -1356,7 +1358,8 @@ udf_discstrat_thread(void *arg)
priv->thread_running = 0;
priv->thread_finished = 1;
- wakeup(&priv->run_thread);
+ cv_broadcast(&priv->discstrat_cv);
+
kthread_exit(0);
/* not reached */
}
@@ -1459,9 +1462,11 @@ udf_discstrat_init_rmw(struct udf_strat_
}
/* wait for thread to spin up */
+ mutex_enter(&priv->discstrat_mutex);
while (!priv->thread_running) {
- tsleep(&priv->thread_running, PRIBIO+1, "udfshedstart", hz);
+ cv_timedwait(&priv->discstrat_cv, &priv->discstrat_mutex, hz);
}
+ mutex_exit(&priv->discstrat_mutex);
}
@@ -1477,20 +1482,23 @@ udf_discstrat_finish_rmw(struct udf_stra
/* stop our sheduling thread */
KASSERT(priv->run_thread == 1);
priv->run_thread = 0;
- wakeup(priv->queue_lwp);
+
+ mutex_enter(&priv->discstrat_mutex);
while (!priv->thread_finished) {
- tsleep(&priv->run_thread, PRIBIO + 1, "udfshedfin", hz);
+ cv_broadcast(&priv->discstrat_cv);
+ cv_timedwait(&priv->discstrat_cv, &priv->discstrat_mutex, hz);
}
+ mutex_exit(&priv->discstrat_mutex);
+
/* kthread should be finished now */
+ cv_destroy(&priv->discstrat_cv);
+ mutex_destroy(&priv->discstrat_mutex);
+ mutex_destroy(&priv->seqwrite_mutex);
/* cleanup our pools */
pool_destroy(&priv->eccline_pool);
pool_destroy(&priv->ecclineblob_pool);
- cv_destroy(&priv->discstrat_cv);
- mutex_destroy(&priv->discstrat_mutex);
- mutex_destroy(&priv->seqwrite_mutex);
-
/* free our private space */
free(ump->strategy_private, M_UDFTEMP);
ump->strategy_private = NULL;
diff -r 472e5d6b5d46 -r 9f459f721ff4 sys/fs/udf/udf_strat_sequential.c
--- a/sys/fs/udf/udf_strat_sequential.c Tue Jun 27 09:10:25 2023 +0000
+++ b/sys/fs/udf/udf_strat_sequential.c Tue Jun 27 09:58:50 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_strat_sequential.c,v 1.19 2022/08/27 05:32:41 skrll Exp $ */
+/* $NetBSD: udf_strat_sequential.c,v 1.20 2023/06/27 09:58:50 reinoud Exp $ */
/*
* Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: udf_strat_sequential.c,v 1.19 2022/08/27 05:32:41 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_strat_sequential.c,v 1.20 2023/06/27 09:58:50 reinoud Exp $");
#endif /* not lint */
@@ -85,7 +85,10 @@ struct strat_private {
kcondvar_t discstrat_cv; /* to wait on */
kmutex_t discstrat_mutex; /* disc strategy */
+ int thread_running; /* thread control */
int run_thread; /* thread control */
+ int thread_finished; /* thread control */
+
int sync_req; /* thread control */
int cur_queue;
@@ -127,7 +130,7 @@ udf_wr_nodedscr_callback(struct buf *buf
if (udf_node->outstanding_nodedscr == 0) {
/* first unlock the node */
UDF_UNLOCK_NODE(udf_node, 0);
- wakeup(&udf_node->outstanding_nodedscr);
+ cv_broadcast(&udf_node->node_lock);
}
putiobuf(buf);
@@ -234,7 +237,7 @@ out:
udf_node->outstanding_nodedscr--;
if (udf_node->outstanding_nodedscr == 0) {
UDF_UNLOCK_NODE(udf_node, 0);
- wakeup(&udf_node->outstanding_nodedscr);
+ cv_broadcast(&udf_node->node_lock);
}
return error;
@@ -565,6 +568,10 @@ udf_discstrat_thread(void *arg)
int empty;
empty = 1;
+
+ priv->thread_running = 1;
+ cv_broadcast(&priv->discstrat_cv);
+
mutex_enter(&priv->discstrat_mutex);
while (priv->run_thread || !empty || priv->sync_req) {
/* process the current selected queue */
@@ -587,7 +594,10 @@ udf_discstrat_thread(void *arg)
}
mutex_exit(&priv->discstrat_mutex);
- wakeup(&priv->run_thread);
+ priv->thread_running = 0;
+ priv->thread_finished = 1;
+ cv_broadcast(&priv->discstrat_cv);
+
kthread_exit(0);
/* not reached */
}
@@ -654,13 +664,22 @@ udf_discstrat_init_seq(struct udf_strat_
vfs_timestamp(&priv->last_queued[UDF_SHED_SEQWRITING]);
/* create our disk strategy thread */
- priv->run_thread = 1;
- priv->sync_req = 0;
+ priv->thread_finished = 0;
+ priv->thread_running = 0;
+ priv->run_thread = 1;
+ priv->sync_req = 0;
if (kthread_create(PRI_NONE, 0 /* KTHREAD_MPSAFE*/, NULL /* cpu_info*/,
udf_discstrat_thread, ump, &priv->queue_lwp,
"%s", "udf_rw")) {
panic("fork udf_rw");
}
+
+ /* wait for thread to spin up */
+ mutex_enter(&priv->discstrat_mutex);
+ while (!priv->thread_running) {
+ cv_timedwait(&priv->discstrat_cv, &priv->discstrat_mutex, hz);
+ }
+ mutex_exit(&priv->discstrat_mutex);
}
@@ -669,7 +688,6 @@ udf_discstrat_finish_seq(struct udf_stra
{
struct udf_mount *ump = args->ump;
struct strat_private *priv = PRIV(ump);
- int error;
if (ump == NULL)
return;
@@ -677,11 +695,14 @@ udf_discstrat_finish_seq(struct udf_stra
/* stop our scheduling thread */
KASSERT(priv->run_thread == 1);
priv->run_thread = 0;
- wakeup(priv->queue_lwp);
- do {
- error = tsleep(&priv->run_thread, PRIBIO+1,
- "udfshedfin", hz);
- } while (error);
+
+ mutex_enter(&priv->discstrat_mutex);
+ while (!priv->thread_finished) {
+ cv_broadcast(&priv->discstrat_cv);
+ cv_timedwait(&priv->discstrat_cv, &priv->discstrat_mutex, hz);
+ }
+ mutex_exit(&priv->discstrat_mutex);
+
/* kthread should be finished now */
/* set back old device strategy method */
diff -r 472e5d6b5d46 -r 9f459f721ff4 sys/fs/udf/udf_vnops.c
--- a/sys/fs/udf/udf_vnops.c Tue Jun 27 09:10:25 2023 +0000
+++ b/sys/fs/udf/udf_vnops.c Tue Jun 27 09:58:50 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_vnops.c,v 1.126 2022/05/28 21:14:57 andvar Exp $ */
+/* $NetBSD: udf_vnops.c,v 1.127 2023/06/27 09:58:50 reinoud Exp $ */
/*
* Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -32,7 +32,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: udf_vnops.c,v 1.126 2022/05/28 21:14:57 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_vnops.c,v 1.127 2023/06/27 09:58:50 reinoud Exp $");
#endif /* not lint */
@@ -163,10 +163,12 @@ udf_reclaim(void *v)
udf_update(vp, NULL, NULL, NULL, UPDATE_CLOSE);
/* async check to see if all node descriptors are written out */
+ mutex_enter(&udf_node->node_mutex);
while ((volatile int) udf_node->outstanding_nodedscr > 0) {
vprint("udf_reclaim(): waiting for writeout\n", vp);
- tsleep(&udf_node->outstanding_nodedscr, PRIBIO, "recl wait", hz/8);
+ cv_timedwait(&udf_node->node_lock, &udf_node->node_mutex, hz/8);
}
+ mutex_exit(&udf_node->node_mutex);
/* dispose all node knowledge */
udf_dispose_node(udf_node);
Home |
Main Index |
Thread Index |
Old Index