From: Ram Gupta <ram.gupta5@gmail.com>
Date: Thu, 25 Oct 2007 15:03:28 +0000 (-0500)
Subject: fs: Fix to correct the mbcache entries counter
X-Git-Tag: v2.6.24-rc2~146
X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=f9e83489cbb3670df810d4f9fe308cde88faa0a9;p=users%2Fjedix%2Flinux-maple.git

fs: Fix to correct the mbcache entries counter

This patch fixes the c_entry_count counter of the mbcache. Currently
it increments the counter first & allocate the cache entry later. In
case of failure to allocate the entry due to insufficient memory this
counter is still left incremented. This patch fixes this anomaly.

Signed-off-by: Ram Gupta <ram.gupta5@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
---

diff --git a/fs/mbcache.c b/fs/mbcache.c
index 1046cbefbfbf..eb31b73e7d69 100644
--- a/fs/mbcache.c
+++ b/fs/mbcache.c
@@ -403,9 +403,9 @@ mb_cache_entry_alloc(struct mb_cache *cache)
 {
 	struct mb_cache_entry *ce;
 
-	atomic_inc(&cache->c_entry_count);
 	ce = kmem_cache_alloc(cache->c_entry_cache, GFP_KERNEL);
 	if (ce) {
+		atomic_inc(&cache->c_entry_count);
 		INIT_LIST_HEAD(&ce->e_lru_list);
 		INIT_LIST_HEAD(&ce->e_block_list);
 		ce->e_cache = cache;