Received: by 2002:a4a:3008:0:0:0:0:0 with SMTP id q8-v6csp3612112oof; Mon, 10 Sep 2018 18:02:11 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZjwRFEgmp/Vx3oujd5IqcKUH9SQbfNtQs6e76oMCZnDMOy/Y+zR6AfzquoToEgqk/ELros X-Received: by 2002:a63:2d05:: with SMTP id t5-v6mr25598719pgt.403.1536627731216; Mon, 10 Sep 2018 18:02:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536627731; cv=none; d=google.com; s=arc-20160816; b=Ju3z3qo1KIOhv6mlBmVM55y2hlozffcdx18KUIAXQyFTDipO5hGASHbSC6Sh+ESaho UVZ8Dwsf6hjVWJ+Fmx58jPxCfII9mJYhI+iY/pCdVQJsoGLA8N3XNEMHdLjRrDojTNCa n4JTrg+k9aZh6Ofg3u5o9UQBnq5h67cvPNGaJNBH+LwQ1dgtqCiJ8roetJS0mhgYqzut kWawFbKCJp+MlfgARF/AOvmfjrzbMYeXptgJ/srJZO4tCQy2+1Qgw7rhb4YGH94rL4nE 2hWyRIxJ33YeMrHqJqnfaIG2vl/JsNGvZ7M9AH8h+r82fZ4G5z+5fvmcf9JTt3y8+Mff RXTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=F/Ujmlt8E/VVdfTBhg3WWtj8otY/h1MAxTTeNdLwcoo=; b=iVHVqwKHlKLoVb3ize6rvjvsnpvEJKn7LYMzO4Imp88etiNlLKuvt5Aqq34o3Hbyaj fsuoKPm4LPu0wJEgtoswsHame/L3271X2hOP+3hf7OJviz4Zlvt9wB++Icjht2nLEf6H eZLST9TWoX95Tblx26d2WJ2GN0LIC1NcgRm+u9SzG6sVEuaXoYqrvczF+AeYPwgDX6gm p5nPytyo+7NfKJtXCkt6uqpYkhFqCzcgg+lam2ivuDO0hGCs8Yy9BNK7ypDTElIDsrgE D2GZKsXS6t2FrkD4/9fIT3ZhkrC84lHouKAV6KsA0SGAuRMCcB/2RP4ENSFywBEdJVc5 1oyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mNGd3xFe; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w71-v6si17610408pgd.362.2018.09.10.18.01.55; Mon, 10 Sep 2018 18:02:11 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=mNGd3xFe; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726720AbeIKF5H (ORCPT + 99 others); Tue, 11 Sep 2018 01:57:07 -0400 Received: from mail-oi0-f67.google.com ([209.85.218.67]:34200 "EHLO mail-oi0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726570AbeIKF5B (ORCPT ); Tue, 11 Sep 2018 01:57:01 -0400 Received: by mail-oi0-f67.google.com with SMTP id 13-v6so44097468ois.1; Mon, 10 Sep 2018 18:00:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=F/Ujmlt8E/VVdfTBhg3WWtj8otY/h1MAxTTeNdLwcoo=; b=mNGd3xFe9RnHw0mgiTexji1wEGMMEIz3Yl+FIgGUe5sFxNy1/hX8o2R7MpLgHOp7/B IIZYp+x1M/bqdXoRW27/ahqSGVOsWQtOS/WtqP/ycfCFMg9g6GOUqOLr7vKTZ50FfR16 Sn7HdL/jlLjH+AdlRT8J3WIGiU5B85rDNWJtLXnN9FnXp92oL2LNYuBFkGfw4K6QrMqK RWir2PpLCb3ltV3iv7qKcj1RRiSDaLrNT1pcUkL0Gj1/afOgBAyFxn7poSe9/sSEpzS5 R6zwFq0vlqUrsHbsjfLjXA4VHifglkKAVv7TNluNmJ1xGX2aKo1mvoimOnoYquE45v6Y e4DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=F/Ujmlt8E/VVdfTBhg3WWtj8otY/h1MAxTTeNdLwcoo=; b=b/SIfx7JK9aVW2gH/DwZzcG9dWP0KJ7vwrrcfRlm/BdtsgUagqwfRUx2UYr+E5RWWh 0byFm2hRObeYog4CvGr40yT2IozDXR+u9qlnFE9yGuxkerACNfBBHkCV++PI2QUbuvj9 LfV9MX1lkAKq5K2Cg6qIQzhfL9jur8dxW220qCzLxXZ59EC+pglKHVyvCMaMkNBWLbuG 6FQwv2IQMNAFeux5tcx9YUCBhCBh1XRLMhcfpkpJXPsxok3yFl3ytIWHRcdNve0mm0Dg pnt3PHUJ5nC6uBF8zw4YbFVSEma6n4nUJqPlVqRNOULKqdE46C9okAwv5GBwXj/XOBtx w2Jg== X-Gm-Message-State: APzg51Abq6X38kuucAv4hufxQQWSt2/iObnAT3a7LIj/L0Os6NiAMx8r zTajk245p2CgWHB+TQU+/8fGplI1cOTwJxVZO7E= X-Received: by 2002:aca:e643:: with SMTP id d64-v6mr25782882oih.81.1536627619919; Mon, 10 Sep 2018 18:00:19 -0700 (PDT) MIME-Version: 1.0 References: <1536406766-27021-1-git-send-email-zhongjiang@huawei.com> In-Reply-To: <1536406766-27021-1-git-send-email-zhongjiang@huawei.com> From: Junhui Tang Date: Tue, 11 Sep 2018 08:59:52 +0800 Message-ID: Subject: Re: [PATCH] bcache: remove unnecessary null poiner check in cache_set_free To: zhongjiang@huawei.com Cc: colyli@suse.de, Kent Overstreet , linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch is NOT OK to me=EF=BC=8Cmaybe many cache in a cache_set, and so= me cache are not registered yet, so ca is possible NULL. zhong jiang =E4=BA=8E2018=E5=B9=B49=E6=9C=888=E6=97= =A5=E5=91=A8=E5=85=AD =E4=B8=8B=E5=8D=887:52=E5=86=99=E9=81=93=EF=BC=9A > > The iterator in for_each_cache is never null, therefore, remove > the redundant null pointer check. > > Signed-off-by: zhong jiang > --- > drivers/md/bcache/super.c | 11 +++++------ > 1 file changed, 5 insertions(+), 6 deletions(-) > > diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c > index 94c756c..2d26f9e 100644 > --- a/drivers/md/bcache/super.c > +++ b/drivers/md/bcache/super.c > @@ -1513,12 +1513,11 @@ static void cache_set_free(struct closure *cl) > bch_btree_cache_free(c); > bch_journal_free(c); > > - for_each_cache(ca, c, i) > - if (ca) { > - ca->set =3D NULL; > - c->cache[ca->sb.nr_this_dev] =3D NULL; > - kobject_put(&ca->kobj); > - } > + for_each_cache(ca, c, i) { > + ca->set =3D NULL; > + c->cache[ca->sb.nr_this_dev] =3D NULL; > + kobject_put(&ca->kobj); > + } > > bch_bset_sort_state_free(&c->sort); > free_pages((unsigned long) c->uuids, ilog2(bucket_pages(c))); > -- > 1.7.12.4 >