From nobody Fri Nov 29 18:42:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1632780084; cv=none; d=zohomail.com; s=zohoarc; b=NT8tZKxsIwq1Gl9Lkl4j6qfQyS9OWefs4bsabz9Khv+Vy2PQtxgeyaXcssdeVj2qrAn4xzRdReO5wf6Eu9D9wl74nDKWE65V6855myx/z+ouPKk0XMsDayvuVSpar+W/nSPmuulpR6HeAYkp6eFIEjGJFL/NXXsYm1e8ElLCnfE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632780084; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hYL8LO+ietZVLiEWE2oEBW5mwRVdCiTP81FH5yaWaJI=; b=nPm00hJfUgS7IhYOYrc+Gm4wdw3fevnUtEoIOi3eLOB4H6vBPVaTvw230FoC0lY6HYCWJ4H3FB8Do63/IMDA+TGMKLKADXJq8Dr0Kboj3ilD4LHOc+1B3c1EJuBP080PdToK6W6WcusM59U5pIqt7d02Cg8aThB9nd8rAvg7/AQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1632780084033830.2316552412987; Mon, 27 Sep 2021 15:01:24 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.197198.350175 (Exim 4.92) (envelope-from ) id 1mUygE-00012h-21; Mon, 27 Sep 2021 22:00:58 +0000 Received: by outflank-mailman (output) from mailman id 197198.350175; Mon, 27 Sep 2021 22:00:58 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mUygD-00012a-UK; Mon, 27 Sep 2021 22:00:57 +0000 Received: by outflank-mailman (input) for mailman id 197198; Mon, 27 Sep 2021 22:00:56 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mUygC-0000mS-EJ for xen-devel@lists.xenproject.org; Mon, 27 Sep 2021 22:00:56 +0000 Received: from bombadil.infradead.org (unknown [2607:7c80:54:e::133]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 92853f46-28ba-4555-aa0d-75f551b4771f; Mon, 27 Sep 2021 22:00:49 +0000 (UTC) Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mUyfw-004Sue-Cr; Mon, 27 Sep 2021 22:00:40 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list X-Inumbo-ID: 92853f46-28ba-4555-aa0d-75f551b4771f DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=hYL8LO+ietZVLiEWE2oEBW5mwRVdCiTP81FH5yaWaJI=; b=1BIITuUWUphtncAHlR3onSNJxl M6CmnasxwYUC18J5dAsyxcU45RRwAvsUth2gvXvlZCPWdpLhxADiTdWmmJnwp3Uk6w06QS7PX+wFY xppaHnOXRVB6MSKkNlcAfcp3c19hINrak2wAZGn+6pA7bP0hbBcVLP+ysEnGBFB8hzMRoaOxh9d8N EmHK04hOyMeu/LPfTOWs+mRlcoafAuyFpBBN3nOB+ukUTwMoJKSfcf/9HcGCwOOXot+mH5FL/B6ke PyL9SssBEH7fnKGJu6Uq+ETgRscCbWtIhSkBzmnno/dRwxrZeb5mjc5Tr1f/Pm86EFqDvRow06OXL BrqrshjA==; From: Luis Chamberlain To: axboe@kernel.dk, colyli@suse.de, kent.overstreet@gmail.com, kbusch@kernel.org, sagi@grimberg.me, vishal.l.verma@intel.com, dan.j.williams@intel.com, dave.jiang@intel.com, ira.weiny@intel.com, konrad.wilk@oracle.com, roger.pau@citrix.com, boris.ostrovsky@oracle.com, jgross@suse.com, sstabellini@kernel.org, minchan@kernel.org, ngupta@vflare.org, senozhatsky@chromium.org Cc: xen-devel@lists.xenproject.org, nvdimm@lists.linux.dev, linux-nvme@lists.infradead.org, linux-bcache@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH v2 02/10] bcache: add error handling support for add_disk() Date: Mon, 27 Sep 2021 15:00:31 -0700 Message-Id: <20210927220039.1064193-3-mcgrof@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210927220039.1064193-1-mcgrof@kernel.org> References: <20210927220039.1064193-1-mcgrof@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Luis Chamberlain X-ZohoMail-DKIM: pass (identity @infradead.org) X-ZM-MESSAGEID: 1632780085172100009 Content-Type: text/plain; charset="utf-8" We never checked for errors on add_disk() as this function returned void. Now that this is fixed, use the shiny new error handling. This driver doesn't do any unwinding with blk_cleanup_disk() even on errors after add_disk() and so we follow that tradition. Acked-by: Coly Li Signed-off-by: Luis Chamberlain --- drivers/md/bcache/super.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index f2874c77ff79..f0c32cdd6594 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -1082,7 +1082,9 @@ int bch_cached_dev_run(struct cached_dev *dc) closure_sync(&cl); } =20 - add_disk(d->disk); + ret =3D add_disk(d->disk); + if (ret) + goto out; bd_link_disk_holder(dc->bdev, dc->disk.disk); /* * won't show up in the uevent file, use udevadm monitor -e instead @@ -1534,10 +1536,11 @@ static void flash_dev_flush(struct closure *cl) =20 static int flash_dev_run(struct cache_set *c, struct uuid_entry *u) { + int err =3D -ENOMEM; struct bcache_device *d =3D kzalloc(sizeof(struct bcache_device), GFP_KERNEL); if (!d) - return -ENOMEM; + goto err_ret; =20 closure_init(&d->cl, NULL); set_closure_fn(&d->cl, flash_dev_flush, system_wq); @@ -1551,9 +1554,12 @@ static int flash_dev_run(struct cache_set *c, struct= uuid_entry *u) bcache_device_attach(d, c, u - c->uuids); bch_sectors_dirty_init(d); bch_flash_dev_request_init(d); - add_disk(d->disk); + err =3D add_disk(d->disk); + if (err) + goto err; =20 - if (kobject_add(&d->kobj, &disk_to_dev(d->disk)->kobj, "bcache")) + err =3D kobject_add(&d->kobj, &disk_to_dev(d->disk)->kobj, "bcache"); + if (err) goto err; =20 bcache_device_link(d, c, "volume"); @@ -1567,7 +1573,8 @@ static int flash_dev_run(struct cache_set *c, struct = uuid_entry *u) return 0; err: kobject_put(&d->kobj); - return -ENOMEM; +err_ret: + return err; } =20 static int flash_devs_run(struct cache_set *c) --=20 2.30.2