Received: by 2002:a4a:301c:0:0:0:0:0 with SMTP id q28-v6csp856322oof; Tue, 25 Sep 2018 05:41:35 -0700 (PDT) X-Google-Smtp-Source: ACcGV61UlHlhUk3zsEmrtbPS0IheTTAgC5Lx8+ZA7Wlf/sFzpKteAeYRzArb8EKTtyKgjcl675UJ X-Received: by 2002:a62:591a:: with SMTP id n26-v6mr1042146pfb.94.1537879294920; Tue, 25 Sep 2018 05:41:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537879294; cv=none; d=google.com; s=arc-20160816; b=eXhXNK0MvxOMnACr15R1j3FwKxbfM7Vfy+2NxSihan09NRB/WwDJZxfvdm6VpTd8/q yi83jfjtutIvKhK2TE5fvG+WRodFbl50XGWPrO0EB1bnBNFZNJzXqusqUTpAw/cD9ITR Tyq15NWT+sQop6KU7ozphja7gZjuCY5c2kEwX4BLlM6c4zcUXvO4vYjlBiSlp0Wfha85 qaw2EIHOT1M27H4Ja9n5ptrVShayNaZVPFCHy5+MzTkCgn1ZH4/Pbx/Xomp0ApoHDWOh LrjzvDxuoN8g3IPpJy1810lJ5iR/J2hkDi0HeaBpekwYAuoTLzg+rl6tzmvaPfvaB3SZ d4fQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=UpMqATuW/AsGw6bXgZqymZqDqPhhnsLp6YsLAFXanwM=; b=q21XoXGJxys3TkjA3dOe/oZpWYx27uF95/EH4NAe5Ao+PCoj/AD3W70BAwx2eue+Fz JcJ28cn6PM5Fwq0+nTWLkspJgkBv0KtF0XiSPJXGBugBHmW4T1+6bND3W9lWkJhtq/+w OzKFubJRGKa1FVdrtyb0Y6t8V9hSgdlcvHEW8fQzQ0anEPR2yfe/HGBjXbf3Eld4l2Gq 74z/Fkc0oBRE8FlCgJRaXhPfYzoZj+H3hzFLnKTIW460DSbhE5g/PP6cPJvtWK/3BYfs ZBtcfdXsKxA5R6anfsf+umliCDrlIyTh5E67/wDr58s2QKuHLIrpjBHhHtfKhytJkEyA 9HyQ== 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 x188-v6si2142599pfx.19.2018.09.25.05.41.19; Tue, 25 Sep 2018 05:41:34 -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; 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 S1729096AbeIYSs3 (ORCPT + 99 others); Tue, 25 Sep 2018 14:48:29 -0400 Received: from mx2.suse.de ([195.135.220.15]:34926 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728773AbeIYSs3 (ORCPT ); Tue, 25 Sep 2018 14:48:29 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id EBC1FAEA3; Tue, 25 Sep 2018 12:41:03 +0000 (UTC) Subject: Re: [PATCH 1/2] split original if-condition code into separate ones To: Dongbo Cao Cc: kent.overstreet@gmail.com, linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org References: <20180925060945.6731-1-cdbdyx@163.com> From: Coly Li Message-ID: Date: Tue, 25 Sep 2018 20:40:57 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: <20180925060945.6731-1-cdbdyx@163.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/25/18 2:09 PM, Dongbo Cao wrote: > to make it clearly to debug. > > Signed-off-by: Dongbo Cao The patch added to my for-next, with minor changes to fix checkpatch.pl warnings. Thanks. Coly Li > --- > drivers/md/bcache/super.c | 81 +++++++++++++++++++++++++++++++-------- > 1 file changed, 66 insertions(+), 15 deletions(-) > > diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c > index fa4058e4..0c0f6d8f 100644 > --- a/drivers/md/bcache/super.c > +++ b/drivers/md/bcache/super.c > @@ -2017,6 +2017,8 @@ static int cache_alloc(struct cache *ca) > size_t free; > size_t btree_buckets; > struct bucket *b; > + int ret = -ENOMEM; > + const char *err = NULL; > > __module_get(THIS_MODULE); > kobject_init(&ca->kobj, &bch_cache_ktype); > @@ -2034,27 +2036,76 @@ static int cache_alloc(struct cache *ca) > */ > btree_buckets = ca->sb.njournal_buckets ?: 8; > free = roundup_pow_of_two(ca->sb.nbuckets) >> 10; > - > - if (!init_fifo(&ca->free[RESERVE_BTREE], btree_buckets, GFP_KERNEL) || > - !init_fifo_exact(&ca->free[RESERVE_PRIO], prio_buckets(ca), GFP_KERNEL) || > - !init_fifo(&ca->free[RESERVE_MOVINGGC], free, GFP_KERNEL) || > - !init_fifo(&ca->free[RESERVE_NONE], free, GFP_KERNEL) || > - !init_fifo(&ca->free_inc, free << 2, GFP_KERNEL) || > - !init_heap(&ca->heap, free << 3, GFP_KERNEL) || > - !(ca->buckets = vzalloc(array_size(sizeof(struct bucket), > - ca->sb.nbuckets))) || > - !(ca->prio_buckets = kzalloc(array3_size(sizeof(uint64_t), > - prio_buckets(ca), 2), > - GFP_KERNEL)) || > - !(ca->disk_buckets = alloc_bucket_pages(GFP_KERNEL, ca))) > - return -ENOMEM; > + > + if (!init_fifo(&ca->free[RESERVE_BTREE], btree_buckets, > + GFP_KERNEL)) { > + err = "ca->free[RESERVE_BTREE] alloc failed"; > + goto err_btree_alloc; > + } > + if (!init_fifo_exact(&ca->free[RESERVE_PRIO], prio_buckets(ca), > + GFP_KERNEL)) { > + err = "ca->free[RESERVE_PRIO] alloc failed"; > + goto err_prio_alloc; > + } > + if (!init_fifo(&ca->free[RESERVE_MOVINGGC], free, GFP_KERNEL)) { > + err = "ca->free[RESERVE_MOVINGGC] alloc failed"; > + goto err_movinggc_alloc; > + } > + if (!init_fifo(&ca->free[RESERVE_NONE], free, GFP_KERNEL)) { > + err = "ca->free[RESERVE_NONE] alloc failed"; > + goto err_none_alloc; > + } > + if (!init_fifo(&ca->free_inc, free << 2, GFP_KERNEL)) { > + err = "ca->free_inc alloc failed"; > + goto err_free_inc_alloc; > + } > + if (!init_heap(&ca->heap, free << 3, GFP_KERNEL)) { > + err = "ca->heap alloc failed"; > + goto err_heap_alloc; > + } > + if (!(ca->buckets = vzalloc(array_size(sizeof(struct bucket), > + ca->sb.nbuckets)))) { > + err = "ca->buckets alloc failed"; > + goto err_buckets_alloc; > + } > + if (!(ca->prio_buckets = kzalloc(array3_size(sizeof(uint64_t), > + prio_buckets(ca), 2), > + GFP_KERNEL))) { > + err = "ca->prio_buckets alloc failed"; > + goto err_prio_buckets_alloc; > + } > + if (!(ca->disk_buckets = alloc_bucket_pages(GFP_KERNEL, ca))) { > + err = "ca->disk_buckets alloc failed"; > + goto err_disk_buckets_alloc; > + } > > ca->prio_last_buckets = ca->prio_buckets + prio_buckets(ca); > > for_each_bucket(b, ca) > atomic_set(&b->pin, 0); > - > return 0; > + > +err_disk_buckets_alloc: > + kfree(ca->prio_buckets); > +err_prio_buckets_alloc: > + vfree(ca->buckets); > +err_buckets_alloc: > + free_heap(&ca->heap); > +err_heap_alloc: > + free_fifo(&ca->free_inc); > +err_free_inc_alloc: > + free_fifo(&ca->free[RESERVE_NONE]); > +err_none_alloc: > + free_fifo(&ca->free[RESERVE_MOVINGGC]); > +err_movinggc_alloc: > + free_fifo(&ca->free[RESERVE_PRIO]); > +err_prio_alloc: > + free_fifo(&ca->free[RESERVE_BTREE]); > +err_btree_alloc: > + module_put(THIS_MODULE); > + if (err) > + pr_notice("error %s: %s", ca->cache_dev_name, err); > + return ret; > } > > static int register_cache(struct cache_sb *sb, struct page *sb_page,