From patchwork Fri Oct 15 23:52:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 12563071 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8DA202C94 for ; Fri, 15 Oct 2021 23:53:01 +0000 (UTC) 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=+2LEMN1XpiXKACzO2eJ6NkEHApTLeNqeZiilGza0YlE=; b=Jjlk8pvArEGMnx4jkmd2938ccV ob+hr+a1J3MtEl2X0rDuA8TL+WP3gCuxl30kYrFyV8X0i9xaOxYLaXHc/Alp1hJWbVPwuxWdcqyVs gIdLRUBfIKutjBUP3eTW8MVIGPp8BofTZ9vvIv2RzLIXWmU924dlWbeaQVGq4Xqv0PUwBccp0qJHP jbs8GF+gSRDcGeDm6xm+yCHucQhkZsUxuN+j9J9c0PbGSi2o4OyuhdYJscVdmK3d0938vB9eSP/g4 xUx3XqpUyB5m9VQVzTZaaUigf6jY54ZsR0OkgjwU4P6pmIqWY4+BYbpuWPnPZJFVmJcGIV/qLlH1i 7U18sTtg==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mbWzs-009C2v-VN; Fri, 15 Oct 2021 23:52:20 +0000 From: Luis Chamberlain To: axboe@kernel.dk, geoff@infradead.org, mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org, jim@jtan.com, minchan@kernel.org, ngupta@vflare.org, senozhatsky@chromium.org, richard@nod.at, miquel.raynal@bootlin.com, vigneshr@ti.com, dan.j.williams@intel.com, vishal.l.verma@intel.com, dave.jiang@intel.com, ira.weiny@intel.com, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me Cc: linux-block@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-mtd@lists.infradead.org, nvdimm@lists.linux.dev, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH 01/13] block/brd: add error handling support for add_disk() Date: Fri, 15 Oct 2021 16:52:07 -0700 Message-Id: <20211015235219.2191207-2-mcgrof@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211015235219.2191207-1-mcgrof@kernel.org> References: <20211015235219.2191207-1-mcgrof@kernel.org> Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: Luis Chamberlain We never checked for errors on add_disk() as this function returned void. Now that this is fixed, use the shiny new error handling. Signed-off-by: Luis Chamberlain --- drivers/block/brd.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/block/brd.c b/drivers/block/brd.c index 530b31240203..6065f493876f 100644 --- a/drivers/block/brd.c +++ b/drivers/block/brd.c @@ -372,6 +372,7 @@ static int brd_alloc(int i) struct brd_device *brd; struct gendisk *disk; char buf[DISK_NAME_LEN]; + int err = -ENOMEM; mutex_lock(&brd_devices_mutex); list_for_each_entry(brd, &brd_devices, brd_list) { @@ -422,16 +423,20 @@ static int brd_alloc(int i) /* Tell the block layer that this is not a rotational device */ blk_queue_flag_set(QUEUE_FLAG_NONROT, disk->queue); blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, disk->queue); - add_disk(disk); + err = add_disk(disk); + if (err) + goto out_cleanup_disk; return 0; +out_cleanup_disk: + blk_cleanup_disk(disk); out_free_dev: mutex_lock(&brd_devices_mutex); list_del(&brd->brd_list); mutex_unlock(&brd_devices_mutex); kfree(brd); - return -ENOMEM; + return err; } static void brd_probe(dev_t dev) From patchwork Fri Oct 15 23:52:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 12563067 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 89E8A2C89 for ; Fri, 15 Oct 2021 23:53:01 +0000 (UTC) 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=bWrYy27/Ft+aLDChsLBGCGZJ9I29Pbmku4dc9v02/r0=; b=IY2ti5CFu7tk7l/1b1dOBrzqFV aY9UvoJKkeTLc2QMRNWX6uc1JjZmitgQWYAqCJrHP3ukaJAS1Znz/MF42OZxUAt/7nUAnIiAlaBdw qxqWz+L6WdoNhUxemK8IqK8TTz5PiYshQ9/0IYTCEPZsgX8UFxP25gp3gw4mI5zwxPE0jpzsJMdNF piTCgmlnkXlxAQxhoX2yeSSTMZLJghSLJlHFu34Sux+hr4llFOQyl8BtkdxpGRy5hn40pVSQcZxr9 8NMljnWNJV+SY+YkxBhw9vXuVPxdhVfyQszbzyQE3EdW1D1TeSngbhl2jloBhz2cfG6cuZlUSHqj0 9sJQoaow==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mbWzt-009C2x-0D; Fri, 15 Oct 2021 23:52:21 +0000 From: Luis Chamberlain To: axboe@kernel.dk, geoff@infradead.org, mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org, jim@jtan.com, minchan@kernel.org, ngupta@vflare.org, senozhatsky@chromium.org, richard@nod.at, miquel.raynal@bootlin.com, vigneshr@ti.com, dan.j.williams@intel.com, vishal.l.verma@intel.com, dave.jiang@intel.com, ira.weiny@intel.com, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me Cc: linux-block@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-mtd@lists.infradead.org, nvdimm@lists.linux.dev, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH 02/13] nvme-multipath: add error handling support for add_disk() Date: Fri, 15 Oct 2021 16:52:08 -0700 Message-Id: <20211015235219.2191207-3-mcgrof@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211015235219.2191207-1-mcgrof@kernel.org> References: <20211015235219.2191207-1-mcgrof@kernel.org> Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: Luis Chamberlain We never checked for errors on add_disk() as this function returned void. Now that this is fixed, use the shiny new error handling. Since we now can tell for sure when a disk was added, move setting the bit NVME_NSHEAD_DISK_LIVE only when we did add the disk successfully. Nothing to do here as the cleanup is done elsewhere. We take care and use test_and_set_bit() because it is protects against two nvme paths simultaneously calling device_add_disk() on the same namespace head. Signed-off-by: Luis Chamberlain Reviewed-by: Keith Busch Reviewed-by: Chaitanya Kulkarni --- drivers/nvme/host/multipath.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c index e8ccdd398f78..022837f7be41 100644 --- a/drivers/nvme/host/multipath.c +++ b/drivers/nvme/host/multipath.c @@ -496,13 +496,23 @@ int nvme_mpath_alloc_disk(struct nvme_ctrl *ctrl, struct nvme_ns_head *head) static void nvme_mpath_set_live(struct nvme_ns *ns) { struct nvme_ns_head *head = ns->head; + int rc; if (!head->disk) return; + /* + * test_and_set_bit() is used because it is protecting against two nvme + * paths simultaneously calling device_add_disk() on the same namespace + * head. + */ if (!test_and_set_bit(NVME_NSHEAD_DISK_LIVE, &head->flags)) { - device_add_disk(&head->subsys->dev, head->disk, - nvme_ns_id_attr_groups); + rc = device_add_disk(&head->subsys->dev, head->disk, + nvme_ns_id_attr_groups); + if (rc) { + clear_bit(NVME_NSHEAD_DISK_LIVE, &ns->flags); + return; + } nvme_add_ns_head_cdev(head); } From patchwork Fri Oct 15 23:52:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 12563073 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DF69B2C83 for ; Fri, 15 Oct 2021 23:52:59 +0000 (UTC) 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=DvHJoJ6f5lcZ7SxjJw+FCx0/QeyauIuzT+VR1mX8TXg=; b=WqCyvtnbtX6HCtzZaWprhI8LPk 5tMl9B0oF0EnGaItbPWV7xbxJK+adiN9VVCKXB/M2GfWARUCCV3T8KEibbRJSz3aDW6D5OiiZ6wHM 8qVdKF6pH8EuHs+LXs8oZUWIXquKFEIiOMG2uZKBH76SzWh+nIWHrJl917TzDIZ9kexOKM/c1kpGw ctvD5cKhgD4w9OjHiY4gg0T19gbDx3FNpEBK1lWDk4szfCMyZBsc95SSS4z3rgXwuQgY7qYbT06ZV /k0UT1eSzKtGk/dxuCBoCyHY4EUkQx/2ywUk0fjyNsOOJPqbW7Po+r4y4oz+envQB/gqmy2MIlmOD zNztSqMA==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mbWzt-009C2z-1G; Fri, 15 Oct 2021 23:52:21 +0000 From: Luis Chamberlain To: axboe@kernel.dk, geoff@infradead.org, mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org, jim@jtan.com, minchan@kernel.org, ngupta@vflare.org, senozhatsky@chromium.org, richard@nod.at, miquel.raynal@bootlin.com, vigneshr@ti.com, dan.j.williams@intel.com, vishal.l.verma@intel.com, dave.jiang@intel.com, ira.weiny@intel.com, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me Cc: linux-block@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-mtd@lists.infradead.org, nvdimm@lists.linux.dev, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH 03/13] nvdimm/btt: do not call del_gendisk() if not needed Date: Fri, 15 Oct 2021 16:52:09 -0700 Message-Id: <20211015235219.2191207-4-mcgrof@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211015235219.2191207-1-mcgrof@kernel.org> References: <20211015235219.2191207-1-mcgrof@kernel.org> Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: Luis Chamberlain We know we don't need del_gendisk() if we haven't added the disk, so just skip it. This should fix a bug on older kernels, as del_gendisk() became able to deal with disks not added only recently, after the patch titled "block: add flag for add_disk() completion notation". Signed-off-by: Luis Chamberlain Reviewed-by: Dan Williams --- drivers/nvdimm/btt.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c index 52de60b7adee..29cc7325e890 100644 --- a/drivers/nvdimm/btt.c +++ b/drivers/nvdimm/btt.c @@ -1538,7 +1538,6 @@ static int btt_blk_init(struct btt *btt) int rc = nd_integrity_init(btt->btt_disk, btt_meta_size(btt)); if (rc) { - del_gendisk(btt->btt_disk); blk_cleanup_disk(btt->btt_disk); return rc; } From patchwork Fri Oct 15 23:52:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 12563075 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 266652C88 for ; Fri, 15 Oct 2021 23:53:01 +0000 (UTC) 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=vmoV/2yvLiwBFQQklXCjpC+/vAkb2GZd/kil2P+K9LY=; b=k0iIsRd4etFUTdob28o4ORiDN4 +B5FyF731o7hr+GINXvlvMEAMpsLwW5pC/OKgrZhFwyicCWbpFYSPPBTrBIjvSuVnrLjhUSLYS++y oRkzDGAOTsEh93X+qg4nyS4uWEdS1lTDNed0oMklQ8zbFZvEmtlBlaap7C7u4S3ktr+flejwhLn6v kgxKkRW5rGqDNa6Cku4cssrBYgKN0s5RFNPfDoSHCSG9iQEucDFOEf6fvVjlMBFP7jCkT/hLFNSOo cpEoBq/XBYeFkTadkfricUfOXARU2LfOTVXw3vn1MHJ8F/i5S8b+Km/fw6MNqjRctXbmhviSiCcL6 I9TcNhtA==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mbWzt-009C31-2Y; Fri, 15 Oct 2021 23:52:21 +0000 From: Luis Chamberlain To: axboe@kernel.dk, geoff@infradead.org, mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org, jim@jtan.com, minchan@kernel.org, ngupta@vflare.org, senozhatsky@chromium.org, richard@nod.at, miquel.raynal@bootlin.com, vigneshr@ti.com, dan.j.williams@intel.com, vishal.l.verma@intel.com, dave.jiang@intel.com, ira.weiny@intel.com, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me Cc: linux-block@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-mtd@lists.infradead.org, nvdimm@lists.linux.dev, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH 04/13] nvdimm/btt: use goto error labels on btt_blk_init() Date: Fri, 15 Oct 2021 16:52:10 -0700 Message-Id: <20211015235219.2191207-5-mcgrof@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211015235219.2191207-1-mcgrof@kernel.org> References: <20211015235219.2191207-1-mcgrof@kernel.org> Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: Luis Chamberlain This will make it easier to share common error paths. Signed-off-by: Luis Chamberlain Reviewed-by: Dan Williams --- 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 29cc7325e890..23ee8c005db5 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) From patchwork Fri Oct 15 23:52:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 12563083 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DF7092CA2 for ; Fri, 15 Oct 2021 23:53:03 +0000 (UTC) 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=RKU66AnJzLKhhgSWEHLOfZ4aIkidqzrddEWqP9yNa3s=; b=UugAONMm6/wnZ05Z4bZ9yyKh6X KFV4rfmmnHgothVOIuV/TFKkY1zNfOQBPL40cl4mER4xCUNxb2kIwEVMH6FLMJx6LKFtVgONty1oN dd7CTQ1YT6LhT1cPhh7gSo5vwFx8mn4XGoXURPXq9roHayZCz6yjgwG5FrlmZNL/NOdsBYUyLts2B sOytoWSq1Fhn1N0j8GABu++u+OMc++l8EodzqQk5+nEtN9wK4dpOCeiQHOZb285rkxlJE17nVdwOd ih74ELEhzbUwySf+C/0rLdDXm4hUhncMAhRqDJAtUJ0f2Nh7q5dpKI8TT3TfLGIqfXNtkbm7ijxSn GCFn5W/A==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mbWzt-009C33-3r; Fri, 15 Oct 2021 23:52:21 +0000 From: Luis Chamberlain To: axboe@kernel.dk, geoff@infradead.org, mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org, jim@jtan.com, minchan@kernel.org, ngupta@vflare.org, senozhatsky@chromium.org, richard@nod.at, miquel.raynal@bootlin.com, vigneshr@ti.com, dan.j.williams@intel.com, vishal.l.verma@intel.com, dave.jiang@intel.com, ira.weiny@intel.com, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me Cc: linux-block@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-mtd@lists.infradead.org, nvdimm@lists.linux.dev, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH 05/13] nvdimm/btt: add error handling support for add_disk() Date: Fri, 15 Oct 2021 16:52:11 -0700 Message-Id: <20211015235219.2191207-6-mcgrof@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211015235219.2191207-1-mcgrof@kernel.org> References: <20211015235219.2191207-1-mcgrof@kernel.org> Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: Luis Chamberlain We never checked for errors on add_disk() as this function returned void. Now that this is fixed, use the shiny new error handling. Signed-off-by: Luis Chamberlain --- drivers/nvdimm/btt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c index 23ee8c005db5..57b921c5fbb5 100644 --- a/drivers/nvdimm/btt.c +++ b/drivers/nvdimm/btt.c @@ -1542,7 +1542,9 @@ static int btt_blk_init(struct btt *btt) } set_capacity(btt->btt_disk, btt->nlba * btt->sector_size >> 9); - device_add_disk(&btt->nd_btt->dev, btt->btt_disk, NULL); + rc = device_add_disk(&btt->nd_btt->dev, btt->btt_disk, NULL); + if (rc) + goto out_cleanup_disk; btt->nd_btt->size = btt->nlba * (u64)btt->sector_size; nvdimm_check_and_set_ro(btt->btt_disk); From patchwork Fri Oct 15 23:52:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 12563079 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 88A192C9F for ; Fri, 15 Oct 2021 23:53:02 +0000 (UTC) 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=hsYRy5mW2eSZFEqOw8JTWcpX/S1jq2Dljgzx3k3VBB0=; b=4qYouVdUDaZ9hGTY8MQXFlbFyd qSG1TWWt6r4mDH+ndWEvwZquGw21w0+K6x0hLpbV5ZWQg30bDMD2lm0NIioVBlmI9FNXtwh5F3Im3 cO1Z6feIyOIr95sNTbAdStTFRwOns15uWcOUEqMUSMsLodOt/EP0CFlMkNj5kkv5qGJoE6Z9wZVSx e597Rd8spjMhtWsfUdteabS8FXKUWM8zb0gLDsx4Cg33y33GpQKoVhxeF0Po4j0Vc1LVAgnw7Ok6b 6FtkBnZKvGVXhrSITJ82MFfElkErBY6atCwJMO70CFV81fcMs3cG7cQRZO/hWZ8uLEAueo0l5hPdp or/n0HTQ==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mbWzt-009C35-5A; Fri, 15 Oct 2021 23:52:21 +0000 From: Luis Chamberlain To: axboe@kernel.dk, geoff@infradead.org, mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org, jim@jtan.com, minchan@kernel.org, ngupta@vflare.org, senozhatsky@chromium.org, richard@nod.at, miquel.raynal@bootlin.com, vigneshr@ti.com, dan.j.williams@intel.com, vishal.l.verma@intel.com, dave.jiang@intel.com, ira.weiny@intel.com, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me Cc: linux-block@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-mtd@lists.infradead.org, nvdimm@lists.linux.dev, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH 06/13] nvdimm/blk: avoid calling del_gendisk() on early failures Date: Fri, 15 Oct 2021 16:52:12 -0700 Message-Id: <20211015235219.2191207-7-mcgrof@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211015235219.2191207-1-mcgrof@kernel.org> References: <20211015235219.2191207-1-mcgrof@kernel.org> Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: Luis Chamberlain If nd_integrity_init() fails we'd get del_gendisk() called, but that's not correct as we should only call that if we're done with device_add_disk(). Fix this by providing unwinding prior to the devm call being registered and moving the devm registration to the very end. This should fix calling del_gendisk() if nd_integrity_init() fails. I only spotted this issue through code inspection. It does not fix any real world bug. Signed-off-by: Luis Chamberlain --- drivers/nvdimm/blk.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/nvdimm/blk.c b/drivers/nvdimm/blk.c index 088d3dd6f6fa..591fa1f86f1e 100644 --- a/drivers/nvdimm/blk.c +++ b/drivers/nvdimm/blk.c @@ -240,6 +240,7 @@ static int nsblk_attach_disk(struct nd_namespace_blk *nsblk) resource_size_t available_disk_size; struct gendisk *disk; u64 internal_nlba; + int rc; internal_nlba = div_u64(nsblk->size, nsblk_internal_lbasize(nsblk)); available_disk_size = internal_nlba * nsblk_sector_size(nsblk); @@ -256,20 +257,26 @@ static int nsblk_attach_disk(struct nd_namespace_blk *nsblk) blk_queue_logical_block_size(disk->queue, nsblk_sector_size(nsblk)); blk_queue_flag_set(QUEUE_FLAG_NONROT, disk->queue); - if (devm_add_action_or_reset(dev, nd_blk_release_disk, disk)) - return -ENOMEM; - if (nsblk_meta_size(nsblk)) { - int rc = nd_integrity_init(disk, nsblk_meta_size(nsblk)); + rc = nd_integrity_init(disk, nsblk_meta_size(nsblk)); if (rc) - return rc; + goto out_before_devm_err; } set_capacity(disk, available_disk_size >> SECTOR_SHIFT); device_add_disk(dev, disk, NULL); + + /* nd_blk_release_disk() is called if this fails */ + if (devm_add_action_or_reset(dev, nd_blk_release_disk, disk)) + return -ENOMEM; + nvdimm_check_and_set_ro(disk); return 0; + +out_before_devm_err: + blk_cleanup_disk(disk); + return rc; } static int nd_blk_probe(struct device *dev) From patchwork Fri Oct 15 23:52:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 12563065 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0FAC42C87 for ; Fri, 15 Oct 2021 23:53:01 +0000 (UTC) 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=vLYLL0oFZhxGylgSJPWXsGjPK2psQoUWyxkb9au47Xw=; b=VKj0PyAggUPHY58Y64VhZFHAZk FhpZFFJ2m6Cm3SHaekc0CDiJyLp+OD6ip4tp6f0fm0KLP8DzK5r4zUN+TBF+Zr9exRvHYoP1U4ZSo xvSMZDGCzyHG9yaWXd/DzzmwcgGlruPb5+CD0ctA68F79eEVs002wvsQCyuEyhihClXsJYS97NwsL 0m5eBo0Qkmdn5r8hNV7zk/1puPeJ1cjcM3zzlg31bplOURK1wIXcWSlBuo2kj1ISDbTfOi3ggEGBn h4r+mufchQFxCHDsxXaWIpgxoqkHJHOwvHKOU/0fa0aDDgmXK1any8EXm3niZiuki8Z2zds4ZpISB ehigutRw==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mbWzt-009C37-6Y; Fri, 15 Oct 2021 23:52:21 +0000 From: Luis Chamberlain To: axboe@kernel.dk, geoff@infradead.org, mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org, jim@jtan.com, minchan@kernel.org, ngupta@vflare.org, senozhatsky@chromium.org, richard@nod.at, miquel.raynal@bootlin.com, vigneshr@ti.com, dan.j.williams@intel.com, vishal.l.verma@intel.com, dave.jiang@intel.com, ira.weiny@intel.com, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me Cc: linux-block@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-mtd@lists.infradead.org, nvdimm@lists.linux.dev, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH 07/13] nvdimm/blk: add error handling support for add_disk() Date: Fri, 15 Oct 2021 16:52:13 -0700 Message-Id: <20211015235219.2191207-8-mcgrof@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211015235219.2191207-1-mcgrof@kernel.org> References: <20211015235219.2191207-1-mcgrof@kernel.org> Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: Luis Chamberlain We never checked for errors on add_disk() as this function returned void. Now that this is fixed, use the shiny new error handling. Since nvdimm/blk uses devm we just need to move the devm registration towards the end. And in hindsight, that seems to also provide a fix given del_gendisk() should not be called unless the disk was already added via add_disk(). The probably of that issue happening is low though, like OOM while calling devm_add_action(), so the fix is minor. We manually unwind in case of add_disk() failure prior to the devm registration. Signed-off-by: Luis Chamberlain --- drivers/nvdimm/blk.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/nvdimm/blk.c b/drivers/nvdimm/blk.c index 591fa1f86f1e..9f1eb41404ac 100644 --- a/drivers/nvdimm/blk.c +++ b/drivers/nvdimm/blk.c @@ -265,7 +265,9 @@ static int nsblk_attach_disk(struct nd_namespace_blk *nsblk) } set_capacity(disk, available_disk_size >> SECTOR_SHIFT); - device_add_disk(dev, disk, NULL); + rc = device_add_disk(dev, disk, NULL); + if (rc) + goto out_before_devm_err; /* nd_blk_release_disk() is called if this fails */ if (devm_add_action_or_reset(dev, nd_blk_release_disk, disk)) From patchwork Fri Oct 15 23:52:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 12563087 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C8A22C89 for ; Fri, 15 Oct 2021 23:53:09 +0000 (UTC) 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=omBKsWTl8Q/WM0k3AiOvEAjN+m9JDz574ka/nFE6G1U=; b=d3DuD+ntkjsX5wdLWBQUee/Kd4 Ka8WmB4Njz7ZuaQfe42890YC5Ei+XlqIQYf4otyg27DZOBzEGweA/XIOCjKPda0mlZIzkM7zD/S89 iRhbQwv0j63NfvXxDgtGtbzvfUTCh27v8rZE+AF0P6syYrDRfKVk9jlkvpepJhtdx6+Jm1HCpnzga j2DB1Xq9POr6uTmUluGCTwaiWICaNRsoR0OOUh3SceEzWf+EyVjAqPcSSSigfoLZxnBoBvzU3+Qbq r8FvoHNO6DLtHVeHtR3K3mezUwJnnmY7WWf9Llyug1fVocMzeKBs7pTKHfPacFnLhenLwBhkZDZgh toPZ4UoQ==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mbWzt-009C3A-7r; Fri, 15 Oct 2021 23:52:21 +0000 From: Luis Chamberlain To: axboe@kernel.dk, geoff@infradead.org, mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org, jim@jtan.com, minchan@kernel.org, ngupta@vflare.org, senozhatsky@chromium.org, richard@nod.at, miquel.raynal@bootlin.com, vigneshr@ti.com, dan.j.williams@intel.com, vishal.l.verma@intel.com, dave.jiang@intel.com, ira.weiny@intel.com, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me Cc: linux-block@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-mtd@lists.infradead.org, nvdimm@lists.linux.dev, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH 08/13] zram: add error handling support for add_disk() Date: Fri, 15 Oct 2021 16:52:14 -0700 Message-Id: <20211015235219.2191207-9-mcgrof@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211015235219.2191207-1-mcgrof@kernel.org> References: <20211015235219.2191207-1-mcgrof@kernel.org> Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: Luis Chamberlain We never checked for errors on add_disk() as this function returned void. Now that this is fixed, use the shiny new error handling. Signed-off-by: Luis Chamberlain Acked-by: Minchan Kim --- drivers/block/zram/zram_drv.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index 0a9309a2ef54..bdbded107e6b 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -1983,7 +1983,9 @@ static int zram_add(void) blk_queue_max_write_zeroes_sectors(zram->disk->queue, UINT_MAX); blk_queue_flag_set(QUEUE_FLAG_STABLE_WRITES, zram->disk->queue); - device_add_disk(NULL, zram->disk, zram_disk_attr_groups); + ret = device_add_disk(NULL, zram->disk, zram_disk_attr_groups); + if (ret) + goto out_cleanup_disk; strlcpy(zram->compressor, default_compressor, sizeof(zram->compressor)); @@ -1991,6 +1993,8 @@ static int zram_add(void) pr_info("Added device: %s\n", zram->disk->disk_name); return device_id; +out_cleanup_disk: + blk_cleanup_disk(zram->disk); out_free_idr: idr_remove(&zram_index_idr, device_id); out_free_dev: From patchwork Fri Oct 15 23:52:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 12563077 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D207E2C96 for ; Fri, 15 Oct 2021 23:53:01 +0000 (UTC) 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=7R5PYVFPXskQk20vzfFqzumtxD4zBhl8b3RLHCGuP34=; b=bA1zIwdhWBpvlfjPHf65YiWw1w wNKSsZycfKU6wTo+TriKrwHhsylyC8eMhzSF0i7XqaBSV9dMtcoJk5uBzoLZCuWHqAJPs4dhdPV+q S0GVi7stXEDsLti3GghX0YK306V30lxJcY2QeyKFi5sry6O3IOwJdxPd1N4J0z6KXmrD0rOVcpCn3 yvEnSxF2UYqoZdvec8gr0V7GX1sNtN9FOWzqjb1O5OqYYjndYWTsx0gJJlK8uyVSJ12gIWFem2lsk h2GuzJdczHuexPRYg/FSSqNpsJTDLZbJXCRvYTM13PUle1YJcEgXxka426Nkl54BSAznT4EB7w/RK xoviz0/Q==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mbWzt-009C3D-99; Fri, 15 Oct 2021 23:52:21 +0000 From: Luis Chamberlain To: axboe@kernel.dk, geoff@infradead.org, mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org, jim@jtan.com, minchan@kernel.org, ngupta@vflare.org, senozhatsky@chromium.org, richard@nod.at, miquel.raynal@bootlin.com, vigneshr@ti.com, dan.j.williams@intel.com, vishal.l.verma@intel.com, dave.jiang@intel.com, ira.weiny@intel.com, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me Cc: linux-block@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-mtd@lists.infradead.org, nvdimm@lists.linux.dev, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH 09/13] z2ram: add error handling support for add_disk() Date: Fri, 15 Oct 2021 16:52:15 -0700 Message-Id: <20211015235219.2191207-10-mcgrof@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211015235219.2191207-1-mcgrof@kernel.org> References: <20211015235219.2191207-1-mcgrof@kernel.org> Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: Luis Chamberlain We never checked for errors on add_disk() as this function returned void. Now that this is fixed, use the shiny new error handling. Only the disk is cleaned up inside z2ram_register_disk() as the caller deals with the rest. Signed-off-by: Luis Chamberlain --- drivers/block/z2ram.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/block/z2ram.c b/drivers/block/z2ram.c index 4eef218108c6..ccc52c935faf 100644 --- a/drivers/block/z2ram.c +++ b/drivers/block/z2ram.c @@ -318,6 +318,7 @@ static const struct blk_mq_ops z2_mq_ops = { static int z2ram_register_disk(int minor) { struct gendisk *disk; + int err; disk = blk_mq_alloc_disk(&tag_set, NULL); if (IS_ERR(disk)) @@ -333,8 +334,10 @@ static int z2ram_register_disk(int minor) sprintf(disk->disk_name, "z2ram"); z2ram_gendisk[minor] = disk; - add_disk(disk); - return 0; + err = add_disk(disk); + if (err) + blk_cleanup_disk(disk); + return err; } static int __init z2_init(void) From patchwork Fri Oct 15 23:52:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 12563069 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 88A122C85 for ; Fri, 15 Oct 2021 23:53:00 +0000 (UTC) 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=IGHq/zn5r0bFrYNjymK6TXitnBNWw/sSmMius/3bC28=; b=rbJob0wAmG/PeQWeRRrtcYxYFJ YRzLLYnhKrbq9c5C3ei247lq9ND1TVEr+sI9h97FxuA1tDfOtKvVSODpgJJ/i5ca6MJz5xP4IMZD0 k8GLy6j5oqZLDBGq6gK+63F5oR4QWzhbpUf2yaRiQDDfd4AeZudkLHLPi6u++tOTgiZ1+ocHLyxwm NPrl9ADXuHopptXncDabSkoGhP5reCekk4mql+zkVM2KP3vBJufj+i8EcsZ3KxkVw2szdVftlSWsC 5jb2rMt8UQgpZTbkrS1+3YEmXkD2hhNaGQp9g1hn3QxwQHZoeI5/vA1VNosR6YWl+x1OyPfZeZ/mg VZqAqmPQ==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mbWzt-009C3F-AU; Fri, 15 Oct 2021 23:52:21 +0000 From: Luis Chamberlain To: axboe@kernel.dk, geoff@infradead.org, mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org, jim@jtan.com, minchan@kernel.org, ngupta@vflare.org, senozhatsky@chromium.org, richard@nod.at, miquel.raynal@bootlin.com, vigneshr@ti.com, dan.j.williams@intel.com, vishal.l.verma@intel.com, dave.jiang@intel.com, ira.weiny@intel.com, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me Cc: linux-block@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-mtd@lists.infradead.org, nvdimm@lists.linux.dev, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH 10/13] ps3disk: add error handling support for add_disk() Date: Fri, 15 Oct 2021 16:52:16 -0700 Message-Id: <20211015235219.2191207-11-mcgrof@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211015235219.2191207-1-mcgrof@kernel.org> References: <20211015235219.2191207-1-mcgrof@kernel.org> Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: Luis Chamberlain We never checked for errors on add_disk() as this function returned void. Now that this is fixed, use the shiny new error handling. Signed-off-by: Luis Chamberlain Tested-by: Geoff Levand --- drivers/block/ps3disk.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/block/ps3disk.c b/drivers/block/ps3disk.c index 8d51efbe045d..3054adf77460 100644 --- a/drivers/block/ps3disk.c +++ b/drivers/block/ps3disk.c @@ -467,9 +467,13 @@ static int ps3disk_probe(struct ps3_system_bus_device *_dev) gendisk->disk_name, priv->model, priv->raw_capacity >> 11, get_capacity(gendisk) >> 11); - device_add_disk(&dev->sbd.core, gendisk, NULL); - return 0; + error = device_add_disk(&dev->sbd.core, gendisk, NULL); + if (error) + goto fail_cleanup_disk; + return 0; +fail_cleanup_disk: + blk_cleanup_disk(gendisk); fail_free_tag_set: blk_mq_free_tag_set(&priv->tag_set); fail_teardown: From patchwork Fri Oct 15 23:52:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 12563081 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4EB972CA9 for ; Fri, 15 Oct 2021 23:53:05 +0000 (UTC) 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=6NZfHmNoX5N/dbslA9tEZ3wm71g//v2MOeHuD/3FoC0=; b=IqiWkGJxOs4RZJjHpZ7nll994s uQA7UIW+Ocik9GPEuu98PXKCk2c1/R4dmgJNmMK7hIT0CSmMm2dNOhTyBQnJAcQVps9OAi5PycSEB lFwC/uYATxJhPiYhXVyPODu4sXxqnG/Kv6uAQzwaYmHA5XxAypucqitped5paW7j/jY5YdjpBuwNO JXXnDjWd7gRdgfbjhElarcK95Xm273zx4UiqerCVkP3oitZ1QvMbY/dK2IjadIAuhraTLxgzCGeBo hA6DJrWJ+8rFDTxLBOZlKX+fmT/H5hwAwFdfvcPhQB8OtMJQQqLRwkmCHBpjn7W+8UVgkpKB5sRdm X3RLj42w==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mbWzt-009C3H-Bn; Fri, 15 Oct 2021 23:52:21 +0000 From: Luis Chamberlain To: axboe@kernel.dk, geoff@infradead.org, mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org, jim@jtan.com, minchan@kernel.org, ngupta@vflare.org, senozhatsky@chromium.org, richard@nod.at, miquel.raynal@bootlin.com, vigneshr@ti.com, dan.j.williams@intel.com, vishal.l.verma@intel.com, dave.jiang@intel.com, ira.weiny@intel.com, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me Cc: linux-block@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-mtd@lists.infradead.org, nvdimm@lists.linux.dev, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH 11/13] ps3vram: add error handling support for add_disk() Date: Fri, 15 Oct 2021 16:52:17 -0700 Message-Id: <20211015235219.2191207-12-mcgrof@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211015235219.2191207-1-mcgrof@kernel.org> References: <20211015235219.2191207-1-mcgrof@kernel.org> Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: Luis Chamberlain We never checked for errors on add_disk() as this function returned void. Now that this is fixed, use the shiny new error handling. Signed-off-by: Luis Chamberlain Acked-by: Geoff Levand --- drivers/block/ps3vram.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/block/ps3vram.c b/drivers/block/ps3vram.c index c7b19e128b03..af2a0d09c598 100644 --- a/drivers/block/ps3vram.c +++ b/drivers/block/ps3vram.c @@ -755,9 +755,14 @@ static int ps3vram_probe(struct ps3_system_bus_device *dev) dev_info(&dev->core, "%s: Using %llu MiB of GPU memory\n", gendisk->disk_name, get_capacity(gendisk) >> 11); - device_add_disk(&dev->core, gendisk, NULL); + error = device_add_disk(&dev->core, gendisk, NULL); + if (error) + goto out_cleanup_disk; + return 0; +out_cleanup_disk: + blk_cleanup_disk(gendisk); out_cache_cleanup: remove_proc_entry(DEVICE_NAME, NULL); ps3vram_cache_cleanup(dev); From patchwork Fri Oct 15 23:52:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 12563061 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7597E2C81 for ; Fri, 15 Oct 2021 23:52:59 +0000 (UTC) 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=HyZ2KI/h/gpVdjlPSyGH7uhBE8wL3JrrLi6b2qQqvAU=; b=yj5zwz6Fs1lJD22XifEcv2Orrv prK+DP1Qo/XEWtRbfWO8+3LeJ2D/W40Mrnlx/po3H3Bj1sdJ7LjC46VZzVbijZLDUfyDQ0lcraB4A O1+ZnXCViST9WOLXPEp6QEw5iFwg7Nl2NTJjTFNWAiBSCkRT/eFF+ufsLZ35VSvWT+Me6Bl5b+zW4 qnUeG+hWSyDlJEc6UGDHcC2VRpwbRbnamAoY23a1KoJTax19zGzqc5vZVqn6CEFYHaBNHVowexejt 7tFP6vpdjs9kA32INEEkgOr2mGidDR806UqktII1c799hggCz3zG9h/QDk29AdLY2mx1RJDCSEpjY mzPuYCUA==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mbWzt-009C3J-DB; Fri, 15 Oct 2021 23:52:21 +0000 From: Luis Chamberlain To: axboe@kernel.dk, geoff@infradead.org, mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org, jim@jtan.com, minchan@kernel.org, ngupta@vflare.org, senozhatsky@chromium.org, richard@nod.at, miquel.raynal@bootlin.com, vigneshr@ti.com, dan.j.williams@intel.com, vishal.l.verma@intel.com, dave.jiang@intel.com, ira.weiny@intel.com, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me Cc: linux-block@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-mtd@lists.infradead.org, nvdimm@lists.linux.dev, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH 12/13] block/sunvdc: add error handling support for add_disk() Date: Fri, 15 Oct 2021 16:52:18 -0700 Message-Id: <20211015235219.2191207-13-mcgrof@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211015235219.2191207-1-mcgrof@kernel.org> References: <20211015235219.2191207-1-mcgrof@kernel.org> Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: Luis Chamberlain We never checked for errors on add_disk() as this function returned void. Now that this is fixed, use the shiny new error handling. We re-use the same free tag call, so we also add a label for that as well. Signed-off-by: Luis Chamberlain --- drivers/block/sunvdc.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/block/sunvdc.c b/drivers/block/sunvdc.c index 4d4bb810c2ae..6f45a53f7cbf 100644 --- a/drivers/block/sunvdc.c +++ b/drivers/block/sunvdc.c @@ -826,8 +826,8 @@ static int probe_disk(struct vdc_port *port) if (IS_ERR(g)) { printk(KERN_ERR PFX "%s: Could not allocate gendisk.\n", port->vio.name); - blk_mq_free_tag_set(&port->tag_set); - return PTR_ERR(g); + err = PTR_ERR(g); + goto out_free_tag; } port->disk = g; @@ -879,9 +879,17 @@ static int probe_disk(struct vdc_port *port) port->vdisk_size, (port->vdisk_size >> (20 - 9)), port->vio.ver.major, port->vio.ver.minor); - device_add_disk(&port->vio.vdev->dev, g, NULL); + err = device_add_disk(&port->vio.vdev->dev, g, NULL); + if (err) + goto out_cleanup_disk; return 0; + +out_cleanup_disk: + blk_cleanup_disk(g); +out_free_tag: + blk_mq_free_tag_set(&port->tag_set); + return err; } static struct ldc_channel_config vdc_ldc_cfg = { From patchwork Fri Oct 15 23:52:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 12563085 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C8F232C89 for ; Fri, 15 Oct 2021 23:53:04 +0000 (UTC) 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=OEudjQURI1tjI6DN2XbbpoNvfS6WRIGCcJ/ZL9K/jW0=; b=0i4mMLZDva/pK7opYP5oiPP3fv rQ5uBC0tGPAZX1/i/6SCFM7QhjhhhwAbuLFbiv/1f5wb0lapDOFHvxZvxtSMncixscY8/BqQSkmHR bKufKXpomn+5Yt6hm7SI2U9JkzvsrqfhY87yB6+iGoFmOvdJBFKy++RKFa2jbpnEvtU/qeCq8RCeX E1A3LHGJOU8cUFmZUHPIFWQtnl8JnCheJuo9YAIxyhYZ8WZAAsNq9omJMDUKNdlNj8ckazv7XBMVp mh+OlppW3pioNclIkbHstsm1EwaGp1IDGWQEb8jm1JZqdCFS8tbGBnG1UoMmly0+bewl7yE/bHwXJ s5LUHtJQ==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mbWzt-009C3L-EQ; Fri, 15 Oct 2021 23:52:21 +0000 From: Luis Chamberlain To: axboe@kernel.dk, geoff@infradead.org, mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org, jim@jtan.com, minchan@kernel.org, ngupta@vflare.org, senozhatsky@chromium.org, richard@nod.at, miquel.raynal@bootlin.com, vigneshr@ti.com, dan.j.williams@intel.com, vishal.l.verma@intel.com, dave.jiang@intel.com, ira.weiny@intel.com, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me Cc: linux-block@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-mtd@lists.infradead.org, nvdimm@lists.linux.dev, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH 13/13] mtd/ubi/block: add error handling support for add_disk() Date: Fri, 15 Oct 2021 16:52:19 -0700 Message-Id: <20211015235219.2191207-14-mcgrof@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211015235219.2191207-1-mcgrof@kernel.org> References: <20211015235219.2191207-1-mcgrof@kernel.org> Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: Luis Chamberlain We never checked for errors on add_disk() as this function returned void. Now that this is fixed, use the shiny new error handling. Signed-off-by: Luis Chamberlain --- drivers/mtd/ubi/block.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/ubi/block.c b/drivers/mtd/ubi/block.c index e003b4b44ffa..062e6c2c45f5 100644 --- a/drivers/mtd/ubi/block.c +++ b/drivers/mtd/ubi/block.c @@ -447,12 +447,18 @@ int ubiblock_create(struct ubi_volume_info *vi) list_add_tail(&dev->list, &ubiblock_devices); /* Must be the last step: anyone can call file ops from now on */ - add_disk(dev->gd); + ret = add_disk(dev->gd); + if (ret) + goto out_destroy_wq; + dev_info(disk_to_dev(dev->gd), "created from ubi%d:%d(%s)", dev->ubi_num, dev->vol_id, vi->name); mutex_unlock(&devices_mutex); return 0; +out_destroy_wq: + list_del(&dev->list); + destroy_workqueue(dev->wq); out_remove_minor: idr_remove(&ubiblock_minor_idr, gd->first_minor); out_cleanup_disk: