Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern Add two sysctls one that does verbose transaction l...
details: https://anonhg.NetBSD.org/src/rev/6a6e01fd2a52
branches: trunk
changeset: 760596:6a6e01fd2a52
user: christos <christos%NetBSD.org@localhost>
date: Sat Jan 08 20:37:05 2011 +0000
description:
Add two sysctls one that does verbose transaction logging and a second one
that disables flushing the disk cache (which is fast but dangerous for
data integrity). From simon a long while back.
diffstat:
sys/kern/vfs_wapbl.c | 115 +++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 98 insertions(+), 17 deletions(-)
diffs (194 lines):
diff -r 539568f0d3f1 -r 6a6e01fd2a52 sys/kern/vfs_wapbl.c
--- a/sys/kern/vfs_wapbl.c Sat Jan 08 20:29:13 2011 +0000
+++ b/sys/kern/vfs_wapbl.c Sat Jan 08 20:37:05 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_wapbl.c,v 1.38 2010/11/09 16:30:26 hannken Exp $ */
+/* $NetBSD: vfs_wapbl.c,v 1.39 2011/01/08 20:37:05 christos Exp $ */
/*-
* Copyright (c) 2003, 2008, 2009 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
#define WAPBL_INTERNAL
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.38 2010/11/09 16:30:26 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.39 2011/01/08 20:37:05 christos Exp $");
#include <sys/param.h>
#include <sys/bitops.h>
@@ -45,6 +45,7 @@
#include <sys/param.h>
#include <sys/namei.h>
#include <sys/proc.h>
+#include <sys/sysctl.h>
#include <sys/uio.h>
#include <sys/vnode.h>
#include <sys/file.h>
@@ -73,6 +74,10 @@
#define wapbl_calloc(n, s) malloc((n)*(s), M_WAPBL, M_WAITOK | M_ZERO)
#endif
+static struct sysctllog *wapbl_sysctl;
+static int wapbl_flush_disk_cache = 1;
+static int wapbl_verbose_commit = 0;
+
#else /* !_KERNEL */
#include <assert.h>
#include <errno.h>
@@ -260,6 +265,66 @@
};
static int
+wapbl_sysctl_init(void)
+{
+ int rv;
+ const struct sysctlnode *rnode, *cnode;
+
+ wapbl_sysctl = NULL;
+
+ rv = sysctl_createv(&wapbl_sysctl, 0, NULL, &rnode,
+ CTLFLAG_PERMANENT,
+ CTLTYPE_NODE, "vfs", NULL,
+ NULL, 0, NULL, 0,
+ CTL_VFS, CTL_EOL);
+ if (rv)
+ return rv;
+
+ rv = sysctl_createv(&wapbl_sysctl, 0, &rnode, &rnode,
+ CTLFLAG_PERMANENT,
+ CTLTYPE_NODE, "wapbl",
+ SYSCTL_DESCR("WAPBL journaling options"),
+ NULL, 0, NULL, 0,
+ CTL_CREATE, CTL_EOL);
+ if (rv)
+ return rv;
+
+ rv = sysctl_createv(&wapbl_sysctl, 0, &rnode, &cnode,
+ CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
+ CTLTYPE_INT, "flush_disk_cache",
+ SYSCTL_DESCR("flush disk cache"),
+ NULL, 0, &wapbl_flush_disk_cache, 0,
+ CTL_CREATE, CTL_EOL);
+ if (rv)
+ return rv;
+
+ rv = sysctl_createv(&wapbl_sysctl, 0, &rnode, &cnode,
+ CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
+ CTLTYPE_INT, "verbose_commit",
+ SYSCTL_DESCR("show time and size of wapbl log commits"),
+ NULL, 0, &wapbl_verbose_commit, 0,
+ CTL_CREATE, CTL_EOL);
+ return rv;
+}
+
+static void
+wapbl_init(void)
+{
+ malloc_type_attach(M_WAPBL);
+ wapbl_sysctl_init();
+}
+
+#ifdef notyet
+static int
+wapbl_fini(bool interface)
+{
+ if (aio_sysctl != NULL)
+ sysctl_teardown(&aio_sysctl);
+ return 0;
+}
+#endif
+
+static int
wapbl_start_flush_inodes(struct wapbl *wl, struct wapbl_replay *wr)
{
int error, i;
@@ -1327,6 +1392,13 @@
/* Calculate amount of space needed to flush */
flushsize = wapbl_transaction_len(wl);
+ if (wapbl_verbose_commit) {
+ struct timespec ts;
+ getnanotime(&ts);
+ printf("%s: %lld.%06ld this transaction = %zu bytes\n",
+ __func__, (long long)ts.tv_sec,
+ (long)ts.tv_nsec, flushsize);
+ }
if (flushsize > (wl->wl_circ_size - wl->wl_reserved_bytes)) {
/*
@@ -1791,7 +1863,7 @@
KASSERT(iph > 0);
- return MAX(1, howmany(wl->wl_inohashcnt, iph))*blocklen;
+ return MAX(1, howmany(wl->wl_inohashcnt, iph)) * blocklen;
}
@@ -1810,8 +1882,8 @@
KASSERT(bph > 0);
len = wl->wl_bcount;
- len += howmany(wl->wl_bufcount, bph)*blocklen;
- len += howmany(wl->wl_dealloccnt, bph)*blocklen;
+ len += howmany(wl->wl_bufcount, bph) * blocklen;
+ len += howmany(wl->wl_dealloccnt, bph) * blocklen;
len += wapbl_transaction_inodes_len(wl);
return len;
@@ -1834,12 +1906,15 @@
int force = 1;
daddr_t pbn;
- /* XXX Calc checksum here, instead we do this for now */
- error = VOP_IOCTL(wl->wl_devvp, DIOCCACHESYNC, &force, FWRITE, FSCRED);
- if (error) {
- WAPBL_PRINTF(WAPBL_PRINT_ERROR,
- ("wapbl_write_commit: DIOCCACHESYNC on dev 0x%"PRIx64
- " returned %d\n", wl->wl_devvp->v_rdev, error));
+ if (wapbl_flush_disk_cache) {
+ /* XXX Calc checksum here, instead we do this for now */
+ error = VOP_IOCTL(wl->wl_devvp, DIOCCACHESYNC, &force,
+ FWRITE, FSCRED);
+ if (error) {
+ WAPBL_PRINTF(WAPBL_PRINT_ERROR,
+ ("wapbl_write_commit: DIOCCACHESYNC on dev 0x%x "
+ "returned %d\n", wl->wl_devvp->v_rdev, error));
+ }
}
wc->wc_head = head;
@@ -1867,11 +1942,14 @@
if (error)
return error;
- error = VOP_IOCTL(wl->wl_devvp, DIOCCACHESYNC, &force, FWRITE, FSCRED);
- if (error) {
- WAPBL_PRINTF(WAPBL_PRINT_ERROR,
- ("wapbl_write_commit: DIOCCACHESYNC on dev 0x%"PRIx64
- " returned %d\n", wl->wl_devvp->v_rdev, error));
+ if (wapbl_flush_disk_cache) {
+ error = VOP_IOCTL(wl->wl_devvp, DIOCCACHESYNC, &force,
+ FWRITE, FSCRED);
+ if (error) {
+ WAPBL_PRINTF(WAPBL_PRINT_ERROR,
+ ("wapbl_write_commit: DIOCCACHESYNC on dev 0x%x "
+ "returned %d\n", wl->wl_devvp->v_rdev, error));
+ }
}
/*
@@ -2723,9 +2801,12 @@
switch (cmd) {
case MODULE_CMD_INIT:
- malloc_type_attach(M_WAPBL);
+ wapbl_init();
return 0;
case MODULE_CMD_FINI:
+#ifdef notyet
+ return wapbl_fini(true);
+#endif
return EOPNOTSUPP;
default:
return ENOTTY;
Home |
Main Index |
Thread Index |
Old Index