Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1447926imm; Wed, 26 Sep 2018 18:48:35 -0700 (PDT) X-Google-Smtp-Source: ACcGV63A2Sjg6fwFidtwEBij7Hv3jjl+qK8rtNmkvKMd01Zvz5BRmyEmfXUYp3fr5YCl3amx3/Pa X-Received: by 2002:a17:902:59dd:: with SMTP id d29-v6mr8559135plj.34.1538012915450; Wed, 26 Sep 2018 18:48:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538012915; cv=none; d=google.com; s=arc-20160816; b=Iqvq4k55wjcvosIM6kZW/7euI+Ht2sX9Fo1V/EcVMU9dP7DD23d6bP4WTXRBcOm5iX H5zr6df2fYlEkmVGnTwiQ7E1zbwC7OlqosqOCRSufbXvw2ZN0FcVHZIVdjCG6yVCUVfW NetSHILvDmN/4ZpKsgH8Uo1se8TDqyLbNbWJZy0G3WIjbO+9nDaOgeGtypQVA/h5QhCV 99GaQVlSkFzrrbqVQbYjgPKKTTI6wuJC+QcEQovBX+1mv/ESYwOoEE8lRGb6C1xUf8zV q65wZmVXDUCjiqG/BVnwRPmwGRlz+Jj3NLM0u9ghTx1C4yEy5oxE1vtBp7q0xK35Y/X4 wYxA== 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=cgjWQ9vvSWgFms7x52Ymr4O2HtWhXz4xo4bVnE3A2WU=; b=vkz958tA/AAuUy/OUfb18pDsTeVQBnVG6WbTKvvDSw2WxW7w98G9XVmYaV2qRk30Fz k0ir+AQvd8gV0V1xBIpllJzk5nEdxNehTrP1VX3tZUaXMH0jWeHpTvOO5gZ6HNDHTzPD +fuo6EELhhylXnL9ufrQMBRlu/4lUbGHYWEk+oP+kGM6CfZxKt9RRVlqpLIKDPUOMBHo T8LnH1n3TN9Lo73BbLkMw3T+c1kv+IqbNhY5i7rjiLUPhssg3TKtgwt7Bvhaxb/wFeN0 rEnb5Ucj4p+HKXzPq9TEPqY+N0Gx5fCuD6mW5BpOYVkhjQKWdlmh+v6eqKMq/D+9m9zA F5kA== 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 1-v6si596989pln.415.2018.09.26.18.48.20; Wed, 26 Sep 2018 18:48:35 -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 S1727077AbeI0IEB (ORCPT + 99 others); Thu, 27 Sep 2018 04:04:01 -0400 Received: from mx2.suse.de ([195.135.220.15]:40318 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726653AbeI0IEA (ORCPT ); Thu, 27 Sep 2018 04:04:00 -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 5AA71AFAF; Thu, 27 Sep 2018 01:48:10 +0000 (UTC) Subject: Re: [PATCH] split if-condition code in bch_cache_set_alloc To: Dongbo Cao Cc: kent.overstreet@gmail.com, linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org References: <20180926090032.1881-1-cdbdyx@163.com> From: Coly Li Message-ID: Date: Thu, 27 Sep 2018 09:48:03 +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: <20180926090032.1881-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/26/18 5:00 PM, Dongbo Cao wrote: > rebase my local code and commit it again. > > Signed-off-by: Dongbo Cao Hi Dongbo, The above commit log does not explain why you make this change (it might belong to changelog). Could you please to make it to be more informative ? Thanks. Coly Li > --- > drivers/md/bcache/super.c | 114 +++++++++++++++++++++++++++++++------- > 1 file changed, 93 insertions(+), 21 deletions(-) > > diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c > index a2cc354c..03099c4c 100644 > --- a/drivers/md/bcache/super.c > +++ b/drivers/md/bcache/super.c > @@ -1691,10 +1691,13 @@ void bch_cache_set_unregister(struct cache_set *c) > struct cache_set *bch_cache_set_alloc(struct cache_sb *sb) > { > int iter_size; > - struct cache_set *c = kzalloc(sizeof(struct cache_set), GFP_KERNEL); > + const char *err = NULL; > > - if (!c) > - return NULL; > + struct cache_set *c = kzalloc(sizeof(struct cache_set), GFP_KERNEL); > + if (!c) { > + err = "cache_set alloc failed"; > + goto err_cache_set_alloc; > + } > > __module_get(THIS_MODULE); > closure_init(&c->cl, NULL); > @@ -1750,22 +1753,65 @@ struct cache_set *bch_cache_set_alloc(struct cache_sb *sb) > iter_size = (sb->bucket_size / sb->block_size + 1) * > sizeof(struct btree_iter_set); > > - if (!(c->devices = kcalloc(c->nr_uuids, sizeof(void *), GFP_KERNEL)) || > - mempool_init_slab_pool(&c->search, 32, bch_search_cache) || > - mempool_init_kmalloc_pool(&c->bio_meta, 2, > - sizeof(struct bbio) + sizeof(struct bio_vec) * > - bucket_pages(c)) || > - mempool_init_kmalloc_pool(&c->fill_iter, 1, iter_size) || > - bioset_init(&c->bio_split, 4, offsetof(struct bbio, bio), > - BIOSET_NEED_BVECS|BIOSET_NEED_RESCUER) || > - !(c->uuids = alloc_bucket_pages(GFP_KERNEL, c)) || > - !(c->moving_gc_wq = alloc_workqueue("bcache_gc", > - WQ_MEM_RECLAIM, 0)) || > - bch_journal_alloc(c) || > - bch_btree_cache_alloc(c) || > - bch_open_buckets_alloc(c) || > - bch_bset_sort_state_init(&c->sort, ilog2(c->btree_pages))) > - goto err; > + c->devices = kcalloc(c->nr_uuids, sizeof(void *), GFP_KERNEL); > + if (!c->devices) { > + err = "c->devices alloc failed"; > + goto err_devices_alloc; > + } > + > + if (mempool_init_slab_pool(&c->search, 32, bch_search_cache)) { > + err = "c->search alloc failed"; > + goto err_search_alloc; > + } > + > + if (mempool_init_kmalloc_pool(&c->bio_meta, 2, sizeof(struct bbio) > + + sizeof(struct bio_vec) * bucket_pages(c))) { > + err = "c->bio_meta alloc failed"; > + goto err_bio_meta_alloc; > + } > + > + if (mempool_init_kmalloc_pool(&c->fill_iter, 1, iter_size)) { > + err = "c->fill_iter alloc failed"; > + goto err_fill_iter_alloc; > + } > + > + if (bioset_init(&c->bio_split, 4, offsetof(struct bbio, bio), > + BIOSET_NEED_BVECS|BIOSET_NEED_RESCUER)) { > + err = "c->bio_split init failed"; > + goto err_bio_split_init; > + } > + > + c->uuids = alloc_bucket_pages(GFP_KERNEL, c); > + if (!c->uuids) { > + err = "c->uuids alloc failed"; > + goto err_uuids_alloc; > + } > + > + c->moving_gc_wq = alloc_workqueue("bcache_gc", WQ_MEM_RECLAIM, 0); > + if (!c->moving_gc_wq) { > + err = "c->moving_gc_wq alloc failed"; > + goto err_moving_gc_wq_alloc; > + } > + > + if (bch_journal_alloc(c)) { > + err = "bch_journal_alloc failed"; > + goto err_bch_journal_alloc; > + } > + > + if (bch_btree_cache_alloc(c)) { > + err = "bch_btree_cache_alloc failed"; > + goto err_bch_btree_cache_alloc; > + } > + > + if (bch_open_buckets_alloc(c)) { > + err = "bch_open_buckets_alloc failed"; > + goto err_bch_open_buckets_alloc; > + } > + > + if (bch_bset_sort_state_init(&c->sort, ilog2(c->btree_pages))) { > + err = "bch_bset_sort_state_init failed"; > + goto err_bch_bset_sort_state_init; > + } > > c->congested_read_threshold_us = 2000; > c->congested_write_threshold_us = 20000; > @@ -1773,8 +1819,34 @@ struct cache_set *bch_cache_set_alloc(struct cache_sb *sb) > WARN_ON(test_and_clear_bit(CACHE_SET_IO_DISABLE, &c->flags)); > > return c; > -err: > - bch_cache_set_unregister(c); > + > +err_bch_bset_sort_state_init: > + bch_open_buckets_free(c); > +err_bch_open_buckets_alloc: > + bch_btree_cache_free(c); > +err_bch_btree_cache_alloc: > + bch_journal_free(c); > +err_bch_journal_alloc: > + destroy_workqueue(c->moving_gc_wq); > +err_moving_gc_wq_alloc: > + free_pages((unsigned long) c->uuids, ilog2(bucket_pages(c))); > +err_uuids_alloc: > + bioset_exit(&c->bio_split); > +err_bio_split_init: > + mempool_exit(&c->fill_iter); > +err_fill_iter_alloc: > + mempool_exit(&c->bio_meta); > +err_bio_meta_alloc: > + mempool_exit(&c->search); > +err_search_alloc: > + kfree(c->devices); > +err_devices_alloc: > + bch_cache_accounting_destroy(&c->accounting); > + kfree(c); > + module_put(THIS_MODULE); > +err_cache_set_alloc: > + if (err) > + pr_notice("error cache set %s: %s", c->sb.set_uuid, err); > return NULL; > } >