Received: by 10.223.176.5 with SMTP id f5csp141925wra; Mon, 5 Feb 2018 18:32:58 -0800 (PST) X-Google-Smtp-Source: AH8x227wmpzCUFe9q1kBZaQ4yXMyASUh6MCpykqLLTm14oIKY/llZkBd3co4eMcJxw1BVU7477n4 X-Received: by 10.99.120.199 with SMTP id t190mr679042pgc.180.1517884377969; Mon, 05 Feb 2018 18:32:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517884377; cv=none; d=google.com; s=arc-20160816; b=wrU2zHihTl53ynB5CPuahr5SnZ8Q8kFi1bmebBIbDvpToZ9MvqvAOxadMne08JVYLT ujVc7O7vRcGCk/zSnm4PpexqsTQLTYCYRK1xBTIjB5oVF3BQt7U//Lg2UCijWn6deNvY 3FusQOBYqxjeruPPgTkT7n4neHlLwG36yp1QYKGcrWOstQhHjge3e/B4U9KyD/CUoFH4 37hd6wzkjuvX2HRHoi91ZWj/zHZ5m2Abuza8sK7vPrztgvhvEBGZUg3fKaZJ2Vx/Csw1 yzE4uDVTDzYQibMZ37bDIo1Qlsp46gXRP0LGqoZEswSrgjMgsl17P3mTBMCOZK4EB+5G 0DEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter:arc-authentication-results; bh=SDPPHtVvs+v5H9we5N/1mq/f7AF1Ad7wCllDyYavuaU=; b=aTi3WkI1iqgzHx6TcoUDBFOn3PCUJr7pBaAaMLseRNRZh3WnehRR0B8S5guoYXk2Mu jDQdqT0S2vZxGWMt0NxTdGKKHgUnBgphLWEonHsm/Ay6LjVpa5k2G3bdVX8UZsoVNoBd W6MysuYuC0qQ5bWG5kVLL/Qxw0AlSJ71TY05AN+alp66LY1LspfQHpyIvnYaq5gkrcsf VDWzIe37+uzMhqt7TLr8GYktpw6XM3RK99DV/AqPJnOsKxGN+39X/M5L+3hcu9ZhY5hl XYN93sUiKnWbWinKrOBhMt+JwvB43v/4jnRy2vKdQFyHVOfaKCMCV1DPVk7DNI+IOZ5B CJYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@meituan.com header.s=20130113 header.b=cbw+gQ0A; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=meituan.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v8-v6si1890584plp.785.2018.02.05.18.32.43; Mon, 05 Feb 2018 18:32:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@meituan.com header.s=20130113 header.b=cbw+gQ0A; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=meituan.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752470AbeBFCb3 (ORCPT + 99 others); Mon, 5 Feb 2018 21:31:29 -0500 Received: from mx-fe5-210.meituan.com ([103.37.138.210]:41547 "EHLO mx02.meituan.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752568AbeBFCbX (ORCPT ); Mon, 5 Feb 2018 21:31:23 -0500 Received: from localhost (localhost [127.0.0.1]) by dx-it-mx02.dx.sankuai.com (Postfix) with ESMTP id 08C2E2975BF8; Tue, 6 Feb 2018 10:31:18 +0800 (CST) Received: from mx02.meituan.com ([127.0.0.1]) by localhost (dx-it-mx02.dx.sankuai.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id QoTprAPmQXqL; Tue, 6 Feb 2018 10:31:17 +0800 (CST) Received: from localhost (localhost [127.0.0.1]) by dx-it-mx02.dx.sankuai.com (Postfix) with ESMTP id A6A2D2975C00; Tue, 6 Feb 2018 10:31:17 +0800 (CST) DKIM-Filter: OpenDKIM Filter v2.9.2 dx-it-mx02.dx.sankuai.com A6A2D2975C00 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meituan.com; s=20130113; t=1517884277; bh=SDPPHtVvs+v5H9we5N/1mq/f7AF1Ad7wCllDyYavuaU=; h=From:To:Subject:Date:Message-Id; b=cbw+gQ0AcoKklr/xOiHga5NYbgrnXZhWye7z5p7aJ+aQWB+r12l6Vk7rc3lKw+BRN vozAD2po/wzmceTU6sO+fi6PruT5LEDo66IW9rlfefSMaV0l6I09r6JRPFo7FzV4vs 4hk/OV5ud2p1+uuBOCzHUTF7VNgEgzlC0VvmdvQ4= X-Virus-Scanned: amavisd-new at dx-it-mx02.dx.sankuai.com Received: from mx02.meituan.com ([127.0.0.1]) by localhost (dx-it-mx02.dx.sankuai.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id CRbdB9AjgBf9; Tue, 6 Feb 2018 10:31:17 +0800 (CST) Received: from localhost.localdomain.info (unknown [103.37.140.11]) by dx-it-mx02.dx.sankuai.com (Postfix) with ESMTPA id 98E2E2975BDE; Tue, 6 Feb 2018 10:31:08 +0800 (CST) From: Wang Long To: darrick.wong@oracle.com, tytso@mit.edu, jack@suse.com Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] jbd2: remove the conditional test Date: Mon, 5 Feb 2018 22:24:39 +0800 Message-Id: <1517840679-5902-1-git-send-email-wanglong19@meituan.com> X-Mailer: git-send-email 1.8.3.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org kmem_cache_destroy already handles null pointers, so we can remove the conditional test entirely. This patch also set NULL after the kmem_cache_destroy in function jbd2_journal_destroy_handle_cache. Signed-off-by: Wang Long --- fs/jbd2/journal.c | 18 +++++++----------- fs/jbd2/revoke.c | 12 ++++-------- fs/jbd2/transaction.c | 6 ++---- 3 files changed, 13 insertions(+), 23 deletions(-) diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index 93016bb..3c27a61a 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -2286,8 +2286,7 @@ static void jbd2_journal_destroy_slabs(void) int i; for (i = 0; i < JBD2_MAX_SLABS; i++) { - if (jbd2_slab[i]) - kmem_cache_destroy(jbd2_slab[i]); + kmem_cache_destroy(jbd2_slab[i]); jbd2_slab[i] = NULL; } } @@ -2388,10 +2387,8 @@ static int jbd2_journal_init_journal_head_cache(void) static void jbd2_journal_destroy_journal_head_cache(void) { - if (jbd2_journal_head_cache) { - kmem_cache_destroy(jbd2_journal_head_cache); - jbd2_journal_head_cache = NULL; - } + kmem_cache_destroy(jbd2_journal_head_cache); + jbd2_journal_head_cache = NULL; } /* @@ -2649,11 +2646,10 @@ static int __init jbd2_journal_init_handle_cache(void) static void jbd2_journal_destroy_handle_cache(void) { - if (jbd2_handle_cache) - kmem_cache_destroy(jbd2_handle_cache); - if (jbd2_inode_cache) - kmem_cache_destroy(jbd2_inode_cache); - + kmem_cache_destroy(jbd2_handle_cache); + jbd2_handle_cache = NULL; + kmem_cache_destroy(jbd2_inode_cache); + jbd2_inode_cache = NULL; } /* diff --git a/fs/jbd2/revoke.c b/fs/jbd2/revoke.c index 696ef15..240779e 100644 --- a/fs/jbd2/revoke.c +++ b/fs/jbd2/revoke.c @@ -180,14 +180,10 @@ static struct jbd2_revoke_record_s *find_revoke_record(journal_t *journal, void jbd2_journal_destroy_revoke_caches(void) { - if (jbd2_revoke_record_cache) { - kmem_cache_destroy(jbd2_revoke_record_cache); - jbd2_revoke_record_cache = NULL; - } - if (jbd2_revoke_table_cache) { - kmem_cache_destroy(jbd2_revoke_table_cache); - jbd2_revoke_table_cache = NULL; - } + kmem_cache_destroy(jbd2_revoke_record_cache); + jbd2_revoke_record_cache = NULL; + kmem_cache_destroy(jbd2_revoke_table_cache); + jbd2_revoke_table_cache = NULL; } int __init jbd2_journal_init_revoke_caches(void) diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c index ac31103..3b642e0 100644 --- a/fs/jbd2/transaction.c +++ b/fs/jbd2/transaction.c @@ -49,10 +49,8 @@ int __init jbd2_journal_init_transaction_cache(void) void jbd2_journal_destroy_transaction_cache(void) { - if (transaction_cache) { - kmem_cache_destroy(transaction_cache); - transaction_cache = NULL; - } + kmem_cache_destroy(transaction_cache); + transaction_cache = NULL; } void jbd2_journal_free_transaction(transaction_t *transaction) -- 1.8.3.1