Patchwork jbd2: use kmem_cache_zalloc instead of kmem_cache_alloc/memset

login
register
mail settings
Submitter Zheng Liu
Date April 12, 2013, 12:24 p.m.
Message ID <1365769463-22071-1-git-send-email-wenqing.lz@taobao.com>
Download mbox | patch
Permalink /patch/236063/
State Accepted
Headers show

Comments

Zheng Liu - April 12, 2013, 12:24 p.m.
From: Zheng Liu <wenqing.lz@taobao.com>

Now jbd2_alloc_handle is only called by new_handle.  So this commit
uses kmem_cache_zalloc instead of kmem_cache_alloc/memset.

Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
---
 fs/jbd2/transaction.c | 1 -
 include/linux/jbd2.h  | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)
Theodore Ts'o - April 19, 2013, 9:50 p.m.
On Fri, Apr 12, 2013 at 08:24:23PM +0800, Zheng Liu wrote:
> From: Zheng Liu <wenqing.lz@taobao.com>
> 
> Now jbd2_alloc_handle is only called by new_handle.  So this commit
> uses kmem_cache_zalloc instead of kmem_cache_alloc/memset.
> 
> Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>

Thanks, applied.

					- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
index 63834eb..3abdad1 100644
--- a/fs/jbd2/transaction.c
+++ b/fs/jbd2/transaction.c
@@ -332,7 +332,6 @@  static handle_t *new_handle(int nblocks)
 	handle_t *handle = jbd2_alloc_handle(GFP_NOFS);
 	if (!handle)
 		return NULL;
-	memset(handle, 0, sizeof(*handle));
 	handle->h_buffer_credits = nblocks;
 	handle->h_ref = 1;
 
diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
index 04c04dc..c9fc7df 100644
--- a/include/linux/jbd2.h
+++ b/include/linux/jbd2.h
@@ -1146,7 +1146,7 @@  extern struct kmem_cache *jbd2_handle_cache;
 
 static inline handle_t *jbd2_alloc_handle(gfp_t gfp_flags)
 {
-	return kmem_cache_alloc(jbd2_handle_cache, gfp_flags);
+	return kmem_cache_zalloc(jbd2_handle_cache, gfp_flags);
 }
 
 static inline void jbd2_free_handle(handle_t *handle)