[lkml]   [2014]   [Jul]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH] Allow increasing the buffer-head per-CPU LRU size
Allow increasing the buffer-head per-CPU LRU size to allow efficient
filesystem operations that access many blocks for each transaction.
For example, creating a file in a large ext4 directory with quota
enabled will accesses multiple buffer heads and will overflow the LRU
at the default 8-block LRU size:

* parent directory inode table block (ctime, nlinks for subdirs)
* new inode bitmap
* inode table block
* 2 quota blocks
* directory leaf block (not reused, but pollutes one cache entry)
* 2 levels htree blocks (only one is reused, other pollutes cache)
* 2 levels indirect/index blocks (only one is reused)

The buffer-head per-CPU LRU size can be changed at config time, and its
default value is raised to 16.

Signed-off-by: Liang Zhen <>
Signed-off-by: Andreas Dilger <>
fs/Kconfig | 9 +++++++++
fs/buffer.c | 3 +--
2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/fs/Kconfig b/fs/Kconfig
index c229f82..afea808 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -268,4 +268,13 @@ endif # NETWORK_FILESYSTEMS
source "fs/nls/Kconfig"
source "fs/dlm/Kconfig"

+config BH_LRU_SIZE
+ int "buffer head per-CPU LRU size"
+ range 8 64
+ default "16"
+ help
+ This sets the per-CPU LRU size for buffer heads in memory.
+ More complex filesystems may be modiyfing multiple blocks
+ within a single transaction, so keeping the buffer heads in
+ CPU-local cache speeds up modifations significantly.
diff --git a/fs/buffer.c b/fs/buffer.c
index 6024877..b83fa63 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -1255,8 +1255,7 @@ static struct buffer_head *__bread_slow(struct
buffer_head *bh)
* The LRUs themselves only need locking against invalidate_bh_lrus.
We use
* a local interrupt disable for that.
-#define BH_LRU_SIZE 8

struct bh_lru {
struct buffer_head *bhs[BH_LRU_SIZE];

 \ /
  Last update: 2014-07-04 11:21    [W:1.204 / U:0.676 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site