All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luis Chamberlain <mcgrof@kernel.org>
To: axboe@kernel.dk, hch@lst.de, penguin-kernel@i-love.sakura.ne.jp,
	dan.j.williams@intel.com, vishal.l.verma@intel.com,
	dave.jiang@intel.com, ira.weiny@intel.com, richard@nod.at,
	miquel.raynal@bootlin.com, vigneshr@ti.com, efremov@linux.com,
	song@kernel.org, martin.petersen@oracle.com, hare@suse.de,
	jack@suse.cz, ming.lei@redhat.com, tj@kernel.org,
	mcgrof@kernel.org
Cc: linux-mtd@lists.infradead.org, linux-scsi@vger.kernel.org,
	linux-raid@vger.kernel.org, linux-block@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH v5 01/14] nvdimm/btt: use goto error labels on btt_blk_init()
Date: Wed,  3 Nov 2021 16:04:24 -0700	[thread overview]
Message-ID: <20211103230437.1639990-2-mcgrof@kernel.org> (raw)
In-Reply-To: <20211103230437.1639990-1-mcgrof@kernel.org>

This will make it easier to share common error paths.

Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 drivers/nvdimm/btt.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c
index 9b9d5e506e11..5cb6d7ac6e36 100644
--- a/drivers/nvdimm/btt.c
+++ b/drivers/nvdimm/btt.c
@@ -1519,6 +1519,7 @@ 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)
@@ -1534,19 +1535,22 @@ 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);
+	return rc;
 }
 
 static void btt_blk_cleanup(struct btt *btt)
-- 
2.33.0


WARNING: multiple messages have this Message-ID (diff)
From: Luis Chamberlain <mcgrof@kernel.org>
To: axboe@kernel.dk, hch@lst.de, penguin-kernel@i-love.sakura.ne.jp,
	dan.j.williams@intel.com, vishal.l.verma@intel.com,
	dave.jiang@intel.com, ira.weiny@intel.com, richard@nod.at,
	miquel.raynal@bootlin.com, vigneshr@ti.com, efremov@linux.com,
	song@kernel.org, martin.petersen@oracle.com, hare@suse.de,
	jack@suse.cz, ming.lei@redhat.com, tj@kernel.org,
	mcgrof@kernel.org
Cc: linux-mtd@lists.infradead.org, linux-scsi@vger.kernel.org,
	linux-raid@vger.kernel.org, linux-block@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH v5 01/14] nvdimm/btt: use goto error labels on btt_blk_init()
Date: Wed,  3 Nov 2021 16:04:24 -0700	[thread overview]
Message-ID: <20211103230437.1639990-2-mcgrof@kernel.org> (raw)
In-Reply-To: <20211103230437.1639990-1-mcgrof@kernel.org>

This will make it easier to share common error paths.

Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 drivers/nvdimm/btt.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c
index 9b9d5e506e11..5cb6d7ac6e36 100644
--- a/drivers/nvdimm/btt.c
+++ b/drivers/nvdimm/btt.c
@@ -1519,6 +1519,7 @@ 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)
@@ -1534,19 +1535,22 @@ 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);
+	return rc;
 }
 
 static void btt_blk_cleanup(struct btt *btt)
-- 
2.33.0


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  reply	other threads:[~2021-11-03 23:04 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-03 23:04 [PATCH v5 00/14] last set for add_disk() error handling Luis Chamberlain
2021-11-03 23:04 ` Luis Chamberlain
2021-11-03 23:04 ` Luis Chamberlain [this message]
2021-11-03 23:04   ` [PATCH v5 01/14] nvdimm/btt: use goto error labels on btt_blk_init() Luis Chamberlain
2021-11-03 23:04 ` [PATCH v5 02/14] nvdimm/btt: add error handling support for add_disk() Luis Chamberlain
2021-11-03 23:04   ` Luis Chamberlain
2021-11-03 23:04 ` [PATCH v5 03/14] nvdimm/blk: avoid calling del_gendisk() on early failures Luis Chamberlain
2021-11-03 23:04   ` Luis Chamberlain
2021-11-03 23:04 ` [PATCH v5 04/14] nvdimm/blk: add error handling support for add_disk() Luis Chamberlain
2021-11-03 23:04   ` Luis Chamberlain
2021-11-03 23:04 ` [PATCH v5 05/14] nvdimm/pmem: cleanup the disk if pmem_release_disk() is yet assigned Luis Chamberlain
2021-11-03 23:04   ` Luis Chamberlain
2021-11-03 23:04 ` [PATCH v5 06/14] nvdimm/pmem: use add_disk() error handling Luis Chamberlain
2021-11-03 23:04   ` Luis Chamberlain
2021-11-03 23:04 ` [PATCH v5 07/14] z2ram: add error handling support for add_disk() Luis Chamberlain
2021-11-03 23:04   ` Luis Chamberlain
2021-11-03 23:04 ` [PATCH v5 08/14] block/sunvdc: " Luis Chamberlain
2021-11-03 23:04   ` Luis Chamberlain
2021-11-03 23:04 ` [PATCH v5 09/14] mtd/ubi/block: " Luis Chamberlain
2021-11-03 23:04   ` Luis Chamberlain
2021-11-03 23:04 ` [PATCH v5 10/14] ataflop: remove ataflop_probe_lock mutex Luis Chamberlain
2021-11-03 23:04   ` Luis Chamberlain
2021-11-03 23:04 ` [PATCH v5 11/14] block: update __register_blkdev() probe documentation Luis Chamberlain
2021-11-03 23:04   ` Luis Chamberlain
2021-11-03 23:04 ` [PATCH v5 12/14] ataflop: address add_disk() error handling on probe Luis Chamberlain
2021-11-03 23:04   ` Luis Chamberlain
2021-11-03 23:04 ` [PATCH v5 13/14] floppy: " Luis Chamberlain
2021-11-03 23:04   ` Luis Chamberlain
2021-11-03 23:04 ` [PATCH v5 14/14] block: add __must_check for *add_disk*() callers Luis Chamberlain
2021-11-03 23:04   ` Luis Chamberlain
2021-11-04 11:49 ` [PATCH v5 00/14] last set for add_disk() error handling Jens Axboe
2021-11-04 11:49   ` Jens Axboe
2021-11-04 12:53   ` Jens Axboe
2021-11-04 12:53     ` Jens Axboe
2021-11-04 17:07     ` Luis Chamberlain
2021-11-04 17:07       ` Luis Chamberlain
2021-11-04 17:10       ` Jens Axboe
2021-11-04 17:10         ` Jens Axboe
2021-11-04 18:16         ` Luis Chamberlain
2021-11-04 18:16           ` 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=20211103230437.1639990-2-mcgrof@kernel.org \
    --to=mcgrof@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=efremov@linux.com \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=ira.weiny@intel.com \
    --cc=jack@suse.cz \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=ming.lei@redhat.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=richard@nod.at \
    --cc=song@kernel.org \
    --cc=tj@kernel.org \
    --cc=vigneshr@ti.com \
    --cc=vishal.l.verma@intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.