Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/fs/udf Cleanup VAT writout. To prevent issues with the s...
details: https://anonhg.NetBSD.org/src/rev/804e8bffdd8f
branches: trunk
changeset: 815531:804e8bffdd8f
user: reinoud <reinoud%NetBSD.org@localhost>
date: Tue May 24 09:55:57 2016 +0000
description:
Cleanup VAT writout. To prevent issues with the sequential writing strategy
trying to write on blocks that are lost due to the synchronisation, don't just
bluntly do synchronize device caches, but split out on strategies.
diffstat:
sys/fs/udf/udf.h | 5 ++-
sys/fs/udf/udf_readwrite.c | 17 +++++++++++++-
sys/fs/udf/udf_strat_bootstrap.c | 13 ++++++++++-
sys/fs/udf/udf_strat_direct.c | 14 +++++++++++-
sys/fs/udf/udf_strat_rmw.c | 15 ++++++++++++-
sys/fs/udf/udf_strat_sequential.c | 42 +++++++++++++++++++++++++++++++++++---
sys/fs/udf/udf_subr.c | 38 +++++++++++++---------------------
sys/fs/udf/udf_subr.h | 5 ++-
8 files changed, 110 insertions(+), 39 deletions(-)
diffs (truncated from 417 to 300 lines):
diff -r baa40b78c4ef -r 804e8bffdd8f sys/fs/udf/udf.h
--- a/sys/fs/udf/udf.h Tue May 24 09:16:56 2016 +0000
+++ b/sys/fs/udf/udf.h Tue May 24 09:55:57 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: udf.h,v 1.51 2016/05/10 15:23:39 reinoud Exp $ */
+/* $NetBSD: udf.h,v 1.52 2016/05/24 09:55:57 reinoud Exp $ */
/*
* Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -76,7 +76,7 @@
#define UDF_DEBUG_RESERVE 0x1000000
/* initial value of udf_verbose */
-#define UDF_DEBUGGING 0
+#define UDF_DEBUGGING (0)
#ifdef UDF_DEBUG
#define DPRINTF(name, arg) { \
@@ -252,6 +252,7 @@
int (*read_logvol_dscr) (struct udf_strat_args *args);
int (*write_logvol_dscr) (struct udf_strat_args *args);
void (*queuebuf) (struct udf_strat_args *args);
+ void (*sync_caches) (struct udf_strat_args *args);
void (*discstrat_init) (struct udf_strat_args *args);
void (*discstrat_finish) (struct udf_strat_args *args);
};
diff -r baa40b78c4ef -r 804e8bffdd8f sys/fs/udf/udf_readwrite.c
--- a/sys/fs/udf/udf_readwrite.c Tue May 24 09:16:56 2016 +0000
+++ b/sys/fs/udf/udf_readwrite.c Tue May 24 09:55:57 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_readwrite.c,v 1.11 2011/06/12 03:35:55 rmind Exp $ */
+/* $NetBSD: udf_readwrite.c,v 1.12 2016/05/24 09:55:57 reinoud Exp $ */
/*
* Copyright (c) 2007, 2008 Reinoud Zandijk
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: udf_readwrite.c,v 1.11 2011/06/12 03:35:55 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_readwrite.c,v 1.12 2016/05/24 09:55:57 reinoud Exp $");
#endif /* not lint */
@@ -696,6 +696,19 @@
void
+udf_synchronise_caches(struct udf_mount *ump)
+{
+ struct udf_strategy *strategy = ump->strategy;
+ struct udf_strat_args args;
+
+ KASSERT(strategy);
+ args.ump = ump;
+
+ (strategy->sync_caches)(&args);
+}
+
+
+void
udf_discstrat_init(struct udf_mount *ump)
{
struct udf_strategy *strategy = ump->strategy;
diff -r baa40b78c4ef -r 804e8bffdd8f sys/fs/udf/udf_strat_bootstrap.c
--- a/sys/fs/udf/udf_strat_bootstrap.c Tue May 24 09:16:56 2016 +0000
+++ b/sys/fs/udf/udf_strat_bootstrap.c Tue May 24 09:55:57 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_strat_bootstrap.c,v 1.4 2014/11/10 18:46:33 maxv Exp $ */
+/* $NetBSD: udf_strat_bootstrap.c,v 1.5 2016/05/24 09:55:57 reinoud Exp $ */
/*
* Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: udf_strat_bootstrap.c,v 1.4 2014/11/10 18:46:33 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_strat_bootstrap.c,v 1.5 2016/05/24 09:55:57 reinoud Exp $");
#endif /* not lint */
@@ -115,6 +115,14 @@
VOP_STRATEGY(ump->devvp, buf);
}
+
+static void
+udf_sync_caches_bootstrap(struct udf_strat_args *args)
+{
+ /* empty */
+}
+
+
static void
udf_discstrat_init_bootstrap(struct udf_strat_args *args)
{
@@ -137,6 +145,7 @@
udf_read_logvol_dscr_bootstrap,
udf_write_logvol_dscr_bootstrap,
udf_queuebuf_bootstrap,
+ udf_sync_caches_bootstrap,
udf_discstrat_init_bootstrap,
udf_discstrat_finish_bootstrap
};
diff -r baa40b78c4ef -r 804e8bffdd8f sys/fs/udf/udf_strat_direct.c
--- a/sys/fs/udf/udf_strat_direct.c Tue May 24 09:16:56 2016 +0000
+++ b/sys/fs/udf/udf_strat_direct.c Tue May 24 09:55:57 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_strat_direct.c,v 1.13 2015/10/06 08:57:34 hannken Exp $ */
+/* $NetBSD: udf_strat_direct.c,v 1.14 2016/05/24 09:55:57 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.13 2015/10/06 08:57:34 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_strat_direct.c,v 1.14 2016/05/24 09:55:57 reinoud Exp $");
#endif /* not lint */
@@ -393,6 +393,15 @@
static void
+udf_sync_caches_direct(struct udf_strat_args *args)
+{
+ struct udf_mount *ump = args->ump;
+
+ udf_mmc_synchronise_caches(ump);
+}
+
+
+static void
udf_discstrat_init_direct(struct udf_strat_args *args)
{
struct udf_mount *ump = args->ump;
@@ -441,6 +450,7 @@
udf_read_nodedscr_direct,
udf_write_nodedscr_direct,
udf_queue_buf_direct,
+ udf_sync_caches_direct,
udf_discstrat_init_direct,
udf_discstrat_finish_direct
};
diff -r baa40b78c4ef -r 804e8bffdd8f sys/fs/udf/udf_strat_rmw.c
--- a/sys/fs/udf/udf_strat_rmw.c Tue May 24 09:16:56 2016 +0000
+++ b/sys/fs/udf/udf_strat_rmw.c Tue May 24 09:55:57 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_strat_rmw.c,v 1.27 2015/10/06 08:57:34 hannken Exp $ */
+/* $NetBSD: udf_strat_rmw.c,v 1.28 2016/05/24 09:55:57 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.27 2015/10/06 08:57:34 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_strat_rmw.c,v 1.28 2016/05/24 09:55:57 reinoud Exp $");
#endif /* not lint */
@@ -1005,6 +1005,16 @@
/* --------------------------------------------------------------------- */
+static void
+udf_sync_caches_rmw(struct udf_strat_args *args)
+{
+ struct udf_mount *ump = args->ump;
+
+ udf_mmc_synchronise_caches(ump);
+}
+
+/* --------------------------------------------------------------------- */
+
static void
udf_shedule_read_callback(struct buf *buf)
{
@@ -1495,6 +1505,7 @@
udf_read_nodedscr_rmw,
udf_write_nodedscr_rmw,
udf_queuebuf_rmw,
+ udf_sync_caches_rmw,
udf_discstrat_init_rmw,
udf_discstrat_finish_rmw
};
diff -r baa40b78c4ef -r 804e8bffdd8f sys/fs/udf/udf_strat_sequential.c
--- a/sys/fs/udf/udf_strat_sequential.c Tue May 24 09:16:56 2016 +0000
+++ b/sys/fs/udf/udf_strat_sequential.c Tue May 24 09:55:57 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_strat_sequential.c,v 1.14 2015/10/06 08:57:34 hannken Exp $ */
+/* $NetBSD: udf_strat_sequential.c,v 1.15 2016/05/24 09:55:57 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.14 2015/10/06 08:57:34 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_strat_sequential.c,v 1.15 2016/05/24 09:55:57 reinoud Exp $");
#endif /* not lint */
@@ -86,6 +86,7 @@
kmutex_t discstrat_mutex; /* disc strategy */
int run_thread; /* thread control */
+ int sync_req; /* thread control */
int cur_queue;
struct disk_strategy old_strategy_setting;
@@ -287,6 +288,30 @@
/* --------------------------------------------------------------------- */
+static void
+udf_sync_caches_seq(struct udf_strat_args *args)
+{
+ struct udf_mount *ump = args->ump;
+ struct strat_private *priv = PRIV(ump);
+
+ /* we might be called during unmount inadvertedly, be on safe side */
+ if (!priv)
+ return;
+
+ /* signal our thread that there might be something to do */
+ priv->sync_req = 1;
+ cv_signal(&priv->discstrat_cv);
+
+ mutex_enter(&priv->discstrat_mutex);
+ while (priv->sync_req) {
+ cv_timedwait(&priv->discstrat_cv,
+ &priv->discstrat_mutex, hz/8);
+ }
+ mutex_exit(&priv->discstrat_mutex);
+}
+
+/* --------------------------------------------------------------------- */
+
/* TODO convert to lb_size */
static void
udf_VAT_mapping_update(struct udf_mount *ump, struct buf *buf, uint32_t lb_map)
@@ -539,7 +564,7 @@
empty = 1;
mutex_enter(&priv->discstrat_mutex);
- while (priv->run_thread || !empty) {
+ while (priv->run_thread || !empty || priv->sync_req) {
/* process the current selected queue */
udf_doshedule(ump);
empty = (bufq_peek(priv->queues[UDF_SHED_READING]) == NULL);
@@ -547,9 +572,16 @@
empty &= (bufq_peek(priv->queues[UDF_SHED_SEQWRITING]) == NULL);
/* wait for more if needed */
- if (empty)
+ if (empty) {
+ if (priv->sync_req) {
+ /* on sync, we need to simulate a read->write transition */
+ udf_mmc_synchronise_caches(ump);
+ priv->cur_queue = UDF_SHED_READING;
+ priv->sync_req = 0;
+ }
cv_timedwait(&priv->discstrat_cv,
&priv->discstrat_mutex, hz/8);
+ }
}
mutex_exit(&priv->discstrat_mutex);
@@ -621,6 +653,7 @@
/* create our disk strategy thread */
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")) {
@@ -673,6 +706,7 @@
udf_read_logvol_dscr_seq,
udf_write_logvol_dscr_seq,
udf_queuebuf_seq,
+ udf_sync_caches_seq,
udf_discstrat_init_seq,
udf_discstrat_finish_seq
};
diff -r baa40b78c4ef -r 804e8bffdd8f sys/fs/udf/udf_subr.c
--- a/sys/fs/udf/udf_subr.c Tue May 24 09:16:56 2016 +0000
+++ b/sys/fs/udf/udf_subr.c Tue May 24 09:55:57 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_subr.c,v 1.137 2016/05/10 15:23:39 reinoud Exp $ */
+/* $NetBSD: udf_subr.c,v 1.138 2016/05/24 09:55:57 reinoud Exp $ */
/*
* Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -29,7 +29,7 @@
Home |
Main Index |
Thread Index |
Old Index