From patchwork Mon Apr 29 09:08:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zheng Liu X-Patchwork-Id: 240342 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id A4BB22C00AA for ; Mon, 29 Apr 2013 18:51:17 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757161Ab3D2IvI (ORCPT ); Mon, 29 Apr 2013 04:51:08 -0400 Received: from mail-pa0-f41.google.com ([209.85.220.41]:34456 "EHLO mail-pa0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752580Ab3D2IvH (ORCPT ); Mon, 29 Apr 2013 04:51:07 -0400 Received: by mail-pa0-f41.google.com with SMTP id kq12so2814081pab.14 for ; Mon, 29 Apr 2013 01:51:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer; bh=9IsWCTAXukdux71zDAZmgtExJ0acmIvdAm5FjRK4OO4=; b=AwUlFEFFWbjkDExrgbtKA4px5lraqivPIubz3LR1B494NKItUth8TTdv99dGbiJKCf Daqhl2yOXWeatjfyQs1W/zegYZGg2TmO/EpTj0uWJnGFTUPDPb+tZCEJuvPdgzTLUzx7 +yIwCRcq0ZikVlpqirg0Acq4XM4Pftp1pY1XzP89XzpuI2sGQCHpVDZ76ImJqYYxbLTh ejDgpHRLX9wx8WB0ePumXpaAiWUT6WuB8BVHl7aCUt1Yt/Zd9HmD+sr1S4ZOFv6Mq1aN m9kM8iGOFQ48oEGcb17F8VoVlEQnULGteYmxg3NpxXOenRa+qI/+/D7ANqXOvzoYLYOE wtvQ== X-Received: by 10.68.213.1 with SMTP id no1mr69668989pbc.163.1367225467300; Mon, 29 Apr 2013 01:51:07 -0700 (PDT) Received: from lz-desktop.taobao.ali.com ([182.92.247.2]) by mx.google.com with ESMTPSA id ze11sm24984338pab.22.2013.04.29.01.51.04 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 29 Apr 2013 01:51:06 -0700 (PDT) From: Zheng Liu To: linux-ext4@vger.kernel.org Cc: Zheng Liu , "Theodore Ts'o" Subject: [PATCH] jbd2: use kmem_cache_zalloc for allocating journal head Date: Mon, 29 Apr 2013 17:08:27 +0800 Message-Id: <1367226507-2990-1-git-send-email-wenqing.lz@taobao.com> X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Zheng Liu This commit tries to use kmem_cache_zalloc instead of kmem_cache_alloc/ memset when a new journal head is alloctated. Signed-off-by: Zheng Liu Cc: "Theodore Ts'o" --- Hi Ted, This patch could be folded into the commit: (28daf4fa) jbd2: use kmem_cache_zalloc instead of kmem_cache_alloc/memset Regards, - Zheng fs/jbd2/journal.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index a62f57a..e90c0bf 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -2327,13 +2327,13 @@ static struct journal_head *journal_alloc_journal_head(void) #ifdef CONFIG_JBD2_DEBUG atomic_inc(&nr_journal_heads); #endif - ret = kmem_cache_alloc(jbd2_journal_head_cache, GFP_NOFS); + ret = kmem_cache_zalloc(jbd2_journal_head_cache, GFP_NOFS); if (!ret) { jbd_debug(1, "out of memory for journal_head\n"); pr_notice_ratelimited("ENOMEM in %s, retrying.\n", __func__); while (!ret) { yield(); - ret = kmem_cache_alloc(jbd2_journal_head_cache, GFP_NOFS); + ret = kmem_cache_zalloc(jbd2_journal_head_cache, GFP_NOFS); } } return ret; @@ -2395,10 +2395,8 @@ struct journal_head *jbd2_journal_add_journal_head(struct buffer_head *bh) struct journal_head *new_jh = NULL; repeat: - if (!buffer_jbd(bh)) { + if (!buffer_jbd(bh)) new_jh = journal_alloc_journal_head(); - memset(new_jh, 0, sizeof(*new_jh)); - } jbd_lock_bh_journal_head(bh); if (buffer_jbd(bh)) {