Re: [patch 2/3] dentries: Add constructor

Previous thread: [patch 3/3] dentries: dentry defragmentation by Christoph Lameter on Monday, August 25, 2008 - 2:20 pm. (3 messages)

Next thread: [patch 0/3] Dentry support for Slab Fragmentation Reduction by Christoph Lameter on Monday, August 25, 2008 - 2:20 pm. (1 message)
From: Christoph Lameter
Date: Monday, August 25, 2008 - 2:20 pm

In order to support defragmentation on the dentry cache we need to have
a determined object state at all times. Without a constructor the object
would have a random state after allocation.

So provide a constructor.

Cc: Alexander Viro <viro@ftp.linux.org.uk>
Cc: Christoph Hellwig <hch@infradead.org>
Reviewed-by: Rik van Riel <riel@redhat.com>
Signed-off-by: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Christoph Lameter <cl@linux-foundation.org>

---
 fs/dcache.c |   26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

Index: linux-next/fs/dcache.c
===================================================================
--- linux-next.orig/fs/dcache.c	2008-08-25 15:54:27.000000000 -0500
+++ linux-next/fs/dcache.c	2008-08-25 15:55:10.000000000 -0500
@@ -890,6 +890,16 @@
 	.seeks = DEFAULT_SEEKS,
 };
 
+static void dcache_ctor(void *p)
+{
+	struct dentry *dentry = p;
+
+	spin_lock_init(&dentry->d_lock);
+	dentry->d_inode = NULL;
+	INIT_LIST_HEAD(&dentry->d_lru);
+	INIT_LIST_HEAD(&dentry->d_alias);
+}
+
 /**
  * d_alloc	-	allocate a dcache entry
  * @parent: parent of entry to allocate
@@ -927,8 +937,6 @@
 
 	atomic_set(&dentry->d_count, 1);
 	dentry->d_flags = DCACHE_UNHASHED;
-	spin_lock_init(&dentry->d_lock);
-	dentry->d_inode = NULL;
 	dentry->d_parent = NULL;
 	dentry->d_sb = NULL;
 	dentry->d_op = NULL;
@@ -938,9 +946,7 @@
 	dentry->d_cookie = NULL;
 #endif
 	INIT_HLIST_NODE(&dentry->d_hash);
-	INIT_LIST_HEAD(&dentry->d_lru);
 	INIT_LIST_HEAD(&dentry->d_subdirs);
-	INIT_LIST_HEAD(&dentry->d_alias);
 
 	if (parent) {
 		dentry->d_parent = dget(parent);
@@ -2268,14 +2274,10 @@
 {
 	int loop;
 
-	/* 
-	 * A constructor could be added for stable state like the lists,
-	 * but it is probably not worth it because of the cache nature
-	 * of the dcache. 
-	 */
-	dentry_cache = KMEM_CACHE(dentry,
-		SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|SLAB_MEM_SPREAD);
-	
+	dentry_cache = kmem_cache_create("dentry_cache", sizeof(struct ...
From: Pekka Enberg
Date: Sunday, August 31, 2008 - 7:50 am

Applied, thanks!
--

Previous thread: [patch 3/3] dentries: dentry defragmentation by Christoph Lameter on Monday, August 25, 2008 - 2:20 pm. (3 messages)

Next thread: [patch 0/3] Dentry support for Slab Fragmentation Reduction by Christoph Lameter on Monday, August 25, 2008 - 2:20 pm. (1 message)