Scale the number of log buffers based on their size.

Proof of concept.

With 8x256k log buffers, we have a 2MB window of active log buffer
writes. With 16k log buffers, it is only 128k. With smaller log
buffers, we could use a lot more of them in the same 2MB window.
Hence scale the number of log buffers dynamically at mount time
based on the size configured.

Motivation is workloads with high sync transaction rate - we can
have many more transactions in flight at once with lots of small
logbufs vs few large once.

XXX: does not work - never had time to trace reason for it.

Signed-off-by: Dave Chinner <dgc@sgi.com>
---
 fs/xfs/xfs_log.c      |   14 ++++++++------
 fs/xfs/xfs_log_priv.h |    3 ++-
 2 files changed, 10 insertions(+), 7 deletions(-)

Index: 2.6.x-xfs-new/fs/xfs/xfs_log.c
===================================================================
--- 2.6.x-xfs-new.orig/fs/xfs/xfs_log.c	2008-05-16 23:13:48.355095505 +1000
+++ 2.6.x-xfs-new/fs/xfs/xfs_log.c	2008-05-17 00:09:08.510570565 +1000
@@ -1097,11 +1097,6 @@ xlog_get_iclog_buffer_size(xfs_mount_t	*
 	int size;
 	int xhdrs;
 
-	if (mp->m_logbufs <= 0)
-		log->l_iclog_bufs = XLOG_MAX_ICLOGS;
-	else
-		log->l_iclog_bufs = mp->m_logbufs;
-
 	/*
 	 * Buffer size passed in from mount system call.
 	 */
@@ -1164,7 +1159,14 @@ xlog_get_iclog_buffer_size(xfs_mount_t	*
 		}
 	}
 
-done:	/* are we being asked to make the sizes selected above visible? */
+done:
+	if (mp->m_logbufs <= 0)
+		log->l_iclog_bufs = XLOG_MAX_ICLOG_BYTES / log->l_iclog_size;
+	else
+		log->l_iclog_bufs = mp->m_logbufs;
+	log->l_iclog_bufs = min(log->l_iclog_bufs, XLOG_MAX_ICLOGS);
+
+	/* are we being asked to make the sizes selected above visible? */
 	if (mp->m_logbufs == 0)
 		mp->m_logbufs = log->l_iclog_bufs;
 	if (mp->m_logbsize == 0)
Index: 2.6.x-xfs-new/fs/xfs/xfs_log_priv.h
===================================================================
--- 2.6.x-xfs-new.orig/fs/xfs/xfs_log_priv.h	2008-05-09 11:57:29.000000000 +1000
+++ 2.6.x-xfs-new/fs/xfs/xfs_log_priv.h	2008-05-17 00:09:08.518569534 +1000
@@ -30,7 +30,8 @@ struct xfs_mount;
  */
 
 #define XLOG_MIN_ICLOGS		2
-#define XLOG_MAX_ICLOGS		8
+#define XLOG_MAX_ICLOGS		128
+#define XLOG_MAX_ICLOG_BYTES	(2*1024*1024)
 #define XLOG_HEADER_MAGIC_NUM	0xFEEDbabe	/* Invalid cycle number */
 #define XLOG_VERSION_1		1
 #define XLOG_VERSION_2		2		/* Large IClogs, Log sunit */
