Received: by 10.223.176.5 with SMTP id f5csp489726wra; Tue, 6 Feb 2018 02:24:46 -0800 (PST) X-Google-Smtp-Source: AH8x225U3rM6CWHdbFIKL/e7km+0IirWgaawZCW2E66D4z4fKleSaB0o2rB2eS322Hv6r4c9rf82 X-Received: by 2002:a17:902:b189:: with SMTP id s9-v6mr1908312plr.243.1517912686353; Tue, 06 Feb 2018 02:24:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517912686; cv=none; d=google.com; s=arc-20160816; b=UNjVY8wOtut5deksZ+q7xIoAFPRRUUkgmwdOakaF7VK7YLREzqmYnfkaPPVUMTxejz wArVEWlz40dgjEHw8rVJrH6he2tIpIWm4L76TULnPZb7LPSzN+2ub++3RyOmAnd6EsDZ RUouHmg6HnZ1iMgt/chjyVSvbNuMuk6I+v1ddvVVRhiR6wU3CA3bN0T9YVoIUP2eFaI5 AhdS7Y2kc9wwtY6HEDTj4JbEm7YPYxQfTXlIuJDyeXSfoEHulOEuqhNwi1cl8V9nt2kx pdIbmTuL93VYHk4rKeolyu63YPX2BCnVqwdFkkQEEp+8wUF/bNB58susv4iGfcfhBWhR QQsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=W35jJMfpLIENcuVp6tFv8MQnTrRaU0Po0xUz4vcb0DA=; b=sZYA5qMbcfIDOfj4g+T2qDoyh0Zh1z4ZSHsrq+L+ggtXCAeDU8EK4fnphlZGWC8eUg JWhCfO6gSpvpAv3EE0Z8iF0c6jZctzvGcdDJzhQ590/y1HFGpZbE0rwLXbhTrIRJdgq+ AxIqUL7tAOrDZ8PM2IO6PU2m8V4GeuugBJqzOK0AzwjIObxPJSJODlunsX2lzzXJW0cc BUvvJ/6lpTSAfO0hvdbjS2mzgT/TQPkHYMxJ8NWSDOMIspDn+zhxX4Odv4Q4fs6wX30F vmPPq5GXamK3NS8/j1sBs2wn+3AZuanaHSIzNXbHAaxHMKGS4GVUddX3HRvhicuqVWmH DcBQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a81si1479026pfc.258.2018.02.06.02.24.31; Tue, 06 Feb 2018 02:24:46 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752650AbeBFKWp (ORCPT + 99 others); Tue, 6 Feb 2018 05:22:45 -0500 Received: from mx2.suse.de ([195.135.220.15]:58148 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752187AbeBFKWi (ORCPT ); Tue, 6 Feb 2018 05:22:38 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id D9FE8AD03; Tue, 6 Feb 2018 10:22:36 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id D2DDA1E0AB2; Tue, 6 Feb 2018 11:22:34 +0100 (CET) Date: Tue, 6 Feb 2018 11:22:34 +0100 From: Jan Kara To: Wang Long Cc: darrick.wong@oracle.com, tytso@mit.edu, jack@suse.com, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] jbd2: remove the conditional test Message-ID: <20180206102234.s3yjrtjkfaup5vas@quack2.suse.cz> References: <1517840679-5902-1-git-send-email-wanglong19@meituan.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1517840679-5902-1-git-send-email-wanglong19@meituan.com> User-Agent: NeoMutt/20170421 (1.8.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 05-02-18 22:24:39, Wang Long wrote: > 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 Looks good. You can add: Reviewed-by: Jan Kara Honza > --- > 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 > > -- Jan Kara SUSE Labs, CR