nvdimm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Luis Chamberlain <mcgrof@kernel.org>
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 <mcgrof@kernel.org>
Subject: [PATCH 05/10] nvdimm/btt: use goto error labels on btt_blk_init()
Date: Fri, 27 Aug 2021 12:18:04 -0700	[thread overview]
Message-ID: <20210827191809.3118103-6-mcgrof@kernel.org> (raw)
In-Reply-To: <20210827191809.3118103-1-mcgrof@kernel.org>

This will make it easier to share common error paths.

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 drivers/nvdimm/btt.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c
index 3fd1bdb9fc05..275704d80109 100644
--- a/drivers/nvdimm/btt.c
+++ b/drivers/nvdimm/btt.c
@@ -1520,10 +1520,11 @@ static int btt_blk_init(struct btt *btt)
 {
 	struct nd_btt *nd_btt = btt->nd_btt;
 	struct nd_namespace_common *ndns = nd_btt->ndns;
+	int rc = -ENOMEM;
 
 	btt->btt_disk = blk_alloc_disk(NUMA_NO_NODE);
 	if (!btt->btt_disk)
-		return -ENOMEM;
+		goto out;
 
 	nvdimm_namespace_disk_name(ndns, btt->btt_disk->disk_name);
 	btt->btt_disk->first_minor = 0;
@@ -1535,19 +1536,23 @@ static int btt_blk_init(struct btt *btt)
 	blk_queue_flag_set(QUEUE_FLAG_NONROT, btt->btt_disk->queue);
 
 	if (btt_meta_size(btt)) {
-		int rc = nd_integrity_init(btt->btt_disk, btt_meta_size(btt));
-
-		if (rc) {
-			blk_cleanup_disk(btt->btt_disk);
-			return rc;
-		}
+		rc = nd_integrity_init(btt->btt_disk, btt_meta_size(btt));
+		if (rc)
+			goto out_cleanup_disk;
 	}
+
 	set_capacity(btt->btt_disk, btt->nlba * btt->sector_size >> 9);
 	device_add_disk(&btt->nd_btt->dev, btt->btt_disk, NULL);
+
 	btt->nd_btt->size = btt->nlba * (u64)btt->sector_size;
 	nvdimm_check_and_set_ro(btt->btt_disk);
 
 	return 0;
+
+out_cleanup_disk:
+	blk_cleanup_disk(btt->btt_disk);
+out:
+	return rc;
 }
 
 static void btt_blk_cleanup(struct btt *btt)
-- 
2.30.2


  parent reply	other threads:[~2021-08-27 19:18 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-27 19:17 [PATCH 00/10] block: first batch of add_disk() error handling conversions Luis Chamberlain
2021-08-27 19:18 ` [PATCH 01/10] block/brd: add error handling support for add_disk() Luis Chamberlain
2021-08-27 19:18 ` [PATCH 02/10] bcache: " Luis Chamberlain
2021-08-29  7:50   ` Coly Li
2021-08-27 19:18 ` [PATCH 03/10] nvme-multipath: " Luis Chamberlain
2021-08-27 20:29   ` Keith Busch
2021-08-30 21:08     ` Luis Chamberlain
2021-08-27 19:18 ` [PATCH 04/10] nvdimm/btt: do not call del_gendisk() if not needed Luis Chamberlain
2021-08-27 19:18 ` Luis Chamberlain [this message]
2021-08-27 19:18 ` [PATCH 06/10] nvdimm/btt: add error handling support for add_disk() Luis Chamberlain
2021-08-27 19:18 ` [PATCH 07/10] nvdimm/blk: avoid calling del_gendisk() on early failures Luis Chamberlain
2021-08-27 19:18 ` [PATCH 08/10] nvdimm/blk: add error handling support for add_disk() Luis Chamberlain
2021-08-27 19:18 ` [PATCH 09/10] xen-blkfront: " Luis Chamberlain
2021-08-27 19:18 ` [PATCH 10/10] zram: " Luis Chamberlain
2021-08-27 19:19 ` [PATCH 00/10] block: first batch of add_disk() error handling conversions Luis Chamberlain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210827191809.3118103-6-mcgrof@kernel.org \
    --to=mcgrof@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=boris.ostrovsky@oracle.com \
    --cc=colyli@suse.de \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=ira.weiny@intel.com \
    --cc=jgross@suse.com \
    --cc=kbusch@kernel.org \
    --cc=kent.overstreet@gmail.com \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-bcache@vger.kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=minchan@kernel.org \
    --cc=ngupta@vflare.org \
    --cc=nvdimm@lists.linux.dev \
    --cc=roger.pau@citrix.com \
    --cc=sagi@grimberg.me \
    --cc=senozhatsky@chromium.org \
    --cc=sstabellini@kernel.org \
    --cc=vishal.l.verma@intel.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).