Thu Oct 1 12:28:34 2009 UTC ()
Add dealloccnt to list of things to be considered in the stetson-harrison
decision making algorithm for flushing a wapbl transation.


(pooka)
diff -r1.27 -r1.28 src/sys/kern/vfs_wapbl.c

cvs diff -r1.27 -r1.28 src/sys/kern/vfs_wapbl.c (expand / switch to unified diff)

--- src/sys/kern/vfs_wapbl.c 2009/10/01 07:42:45 1.27
+++ src/sys/kern/vfs_wapbl.c 2009/10/01 12:28:34 1.28
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: vfs_wapbl.c,v 1.27 2009/10/01 07:42:45 pooka Exp $ */ 1/* $NetBSD: vfs_wapbl.c,v 1.28 2009/10/01 12:28:34 pooka Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2003, 2008, 2009 The NetBSD Foundation, Inc. 4 * Copyright (c) 2003, 2008, 2009 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Wasabi Systems, Inc. 8 * by Wasabi Systems, Inc.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -26,27 +26,27 @@ @@ -26,27 +26,27 @@
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32/* 32/*
33 * This implements file system independent write ahead filesystem logging. 33 * This implements file system independent write ahead filesystem logging.
34 */ 34 */
35 35
36#define WAPBL_INTERNAL 36#define WAPBL_INTERNAL
37 37
38#include <sys/cdefs.h> 38#include <sys/cdefs.h>
39__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.27 2009/10/01 07:42:45 pooka Exp $"); 39__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.28 2009/10/01 12:28:34 pooka Exp $");
40 40
41#include <sys/param.h> 41#include <sys/param.h>
42 42
43#ifdef _KERNEL 43#ifdef _KERNEL
44#include <sys/param.h> 44#include <sys/param.h>
45#include <sys/namei.h> 45#include <sys/namei.h>
46#include <sys/proc.h> 46#include <sys/proc.h>
47#include <sys/uio.h> 47#include <sys/uio.h>
48#include <sys/vnode.h> 48#include <sys/vnode.h>
49#include <sys/file.h> 49#include <sys/file.h>
50#include <sys/malloc.h> 50#include <sys/malloc.h>
51#include <sys/resourcevar.h> 51#include <sys/resourcevar.h>
52#include <sys/conf.h> 52#include <sys/conf.h>
@@ -774,36 +774,40 @@ wapbl_begin(struct wapbl *wl, const char @@ -774,36 +774,40 @@ wapbl_begin(struct wapbl *wl, const char
774 KDASSERT(wl); 774 KDASSERT(wl);
775 775
776 /* 776 /*
777 * XXX this needs to be made much more sophisticated. 777 * XXX this needs to be made much more sophisticated.
778 * perhaps each wapbl_begin could reserve a specified 778 * perhaps each wapbl_begin could reserve a specified
779 * number of buffers and bytes. 779 * number of buffers and bytes.
780 */ 780 */
781 mutex_enter(&wl->wl_mtx); 781 mutex_enter(&wl->wl_mtx);
782 lockcount = wl->wl_lock_count; 782 lockcount = wl->wl_lock_count;
783 doflush = ((wl->wl_bufbytes + (lockcount * MAXPHYS)) > 783 doflush = ((wl->wl_bufbytes + (lockcount * MAXPHYS)) >
784 wl->wl_bufbytes_max / 2) || 784 wl->wl_bufbytes_max / 2) ||
785 ((wl->wl_bufcount + (lockcount * 10)) > 785 ((wl->wl_bufcount + (lockcount * 10)) >
786 wl->wl_bufcount_max / 2) || 786 wl->wl_bufcount_max / 2) ||
787 (wapbl_transaction_len(wl) > wl->wl_circ_size / 2); 787 (wapbl_transaction_len(wl) > wl->wl_circ_size / 2) ||
 788 (wl->wl_dealloccnt >=
 789 (wl->wl_dealloclim - (wl->wl_dealloclim >> 8)));
788 mutex_exit(&wl->wl_mtx); 790 mutex_exit(&wl->wl_mtx);
789 791
790 if (doflush) { 792 if (doflush) {
791 WAPBL_PRINTF(WAPBL_PRINT_FLUSH, 793 WAPBL_PRINTF(WAPBL_PRINT_FLUSH,
792 ("force flush lockcnt=%d bufbytes=%zu " 794 ("force flush lockcnt=%d bufbytes=%zu "
793 "(max=%zu) bufcount=%zu (max=%zu)\n", 795 "(max=%zu) bufcount=%zu (max=%zu) "
 796 "dealloccnt %d (lim=%d)\n",
794 lockcount, wl->wl_bufbytes, 797 lockcount, wl->wl_bufbytes,
795 wl->wl_bufbytes_max, wl->wl_bufcount, 798 wl->wl_bufbytes_max, wl->wl_bufcount,
796 wl->wl_bufcount_max)); 799 wl->wl_bufcount_max,
 800 wl->wl_dealloccnt, wl->wl_dealloclim));
797 } 801 }
798 802
799 if (doflush) { 803 if (doflush) {
800 int error = wapbl_flush(wl, 0); 804 int error = wapbl_flush(wl, 0);
801 if (error) 805 if (error)
802 return error; 806 return error;
803 } 807 }
804 808
805 rw_enter(&wl->wl_rwlock, RW_READER); 809 rw_enter(&wl->wl_rwlock, RW_READER);
806 mutex_enter(&wl->wl_mtx); 810 mutex_enter(&wl->wl_mtx);
807 wl->wl_lock_count++; 811 wl->wl_lock_count++;
808 mutex_exit(&wl->wl_mtx); 812 mutex_exit(&wl->wl_mtx);
809 813