From patchwork Mon Aug 23 20:29:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 501683 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8AA17C00143 for ; Mon, 23 Aug 2021 20:30:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7AC016103A for ; Mon, 23 Aug 2021 20:30:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232706AbhHWUbC (ORCPT ); Mon, 23 Aug 2021 16:31:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232647AbhHWUay (ORCPT ); Mon, 23 Aug 2021 16:30:54 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F270FC061575; Mon, 23 Aug 2021 13:30:11 -0700 (PDT) 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=PfrtPFCUd+vz1Tgg1hQkj8zJ7tYmGxUAcqUzPySlWYA=; b=yD4BOzsjmHnK5qg88RUylmmo4x LuD3Z1YAXTY3+2DEjNWJP8B8YDsBytZ5Ws7NCdyXH6+IszaNyI7RcYTgogrS1cStxeAm/VJNjQznF VNszelhZ8qUPHoYETHBXKOmV5TuUwNk6uZ5D9IsTnfKwo/d/rSMOb1805A8RyTFYRI9Im0zm4RzsM s9seiCCpfZI4ntuSYeM/w875HulOk2W/qDUW4yeGjFTVCPEOyXRPN8n2zBUoArUD5lfU3Ur41llbM 6j0unwzhFa84ekYFn58NNKW1yh7Re9B4iQQEfF8V1LfkgZOMWAxgpkMaBgejMHJmuttbRdBR+3Myq w3rQB8FA==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mIGZa-000ZjK-02; Mon, 23 Aug 2021 20:29:34 +0000 From: Luis Chamberlain To: axboe@kernel.dk, martin.petersen@oracle.com, jejb@linux.ibm.com, kbusch@kernel.org, sagi@grimberg.me, adrian.hunter@intel.com, beanhuo@micron.com, ulf.hansson@linaro.org, avri.altman@wdc.com, swboyd@chromium.org, agk@redhat.com, snitzer@redhat.com, josef@toxicpanda.com Cc: hch@infradead.org, hare@suse.de, bvanassche@acm.org, ming.lei@redhat.com, linux-scsi@vger.kernel.org, linux-nvme@lists.infradead.org, linux-mmc@vger.kernel.org, dm-devel@redhat.com, nbd@other.debian.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH 01/10] scsi/sd: use blk_cleanup_queue() insted of put_disk() Date: Mon, 23 Aug 2021 13:29:21 -0700 Message-Id: <20210823202930.137278-2-mcgrof@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210823202930.137278-1-mcgrof@kernel.org> References: <20210823202930.137278-1-mcgrof@kernel.org> MIME-Version: 1.0 Sender: Luis Chamberlain Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org The single put_disk() is useful if you know you're not doing a cleanup after add_disk(), but since we want to add support for that, just use the normal form of blk_cleanup_disk() to cleanup the queue and put the disk. Signed-off-by: Luis Chamberlain --- drivers/scsi/sd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 610ebba0d66e..7d5217905374 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -3508,7 +3508,7 @@ static int sd_probe(struct device *dev) out_free_index: ida_free(&sd_index_ida, index); out_put: - put_disk(gd); + blk_cleanup_disk(gd); out_free: sd_zbc_release_disk(sdkp); kfree(sdkp); From patchwork Mon Aug 23 20:29:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 502050 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 67C70C4320A for ; Mon, 23 Aug 2021 20:30:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 50C2B60E97 for ; Mon, 23 Aug 2021 20:30:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232696AbhHWUa4 (ORCPT ); Mon, 23 Aug 2021 16:30:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232404AbhHWUas (ORCPT ); Mon, 23 Aug 2021 16:30:48 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0387FC06175F; Mon, 23 Aug 2021 13:30:06 -0700 (PDT) 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=vcZytCs+3aE+pJZnIfeJteJaLaeBUv3H5n6Ya972Mjw=; b=aYu6mhnbiyATjp4QiEfJEQBVbf OPaaXkqiH9H7Ag7hYKlVfy/SfXLFAo1BzUouJ1s4mWbb4rq7EeHKiBhpuX2mEDBG4bgJ+nP6KMsI7 I0U91+7njxj4QNr/sb6TGWGS/DEGCDcxRb983z2ovIXySVexXWGiVRlSV9hFXRaBKeGBo4OYpnf3u zcKhdWCflmlIlZki5Pm1OPCvGe7/aSrrycL4c9juLZp8L3EC5ZEG2PnZWTJ33biaDkTyFqCtmHloC r9Cu93H5ttvttqe8KIscjnkDWRtxjRf02QD6fjQchxzWOEjnKPsDe6jFpiJfD3Gt2sTIE3ss2+87T pxfzrfMQ==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mIGZa-000ZjM-2N; Mon, 23 Aug 2021 20:29:34 +0000 From: Luis Chamberlain To: axboe@kernel.dk, martin.petersen@oracle.com, jejb@linux.ibm.com, kbusch@kernel.org, sagi@grimberg.me, adrian.hunter@intel.com, beanhuo@micron.com, ulf.hansson@linaro.org, avri.altman@wdc.com, swboyd@chromium.org, agk@redhat.com, snitzer@redhat.com, josef@toxicpanda.com Cc: hch@infradead.org, hare@suse.de, bvanassche@acm.org, ming.lei@redhat.com, linux-scsi@vger.kernel.org, linux-nvme@lists.infradead.org, linux-mmc@vger.kernel.org, dm-devel@redhat.com, nbd@other.debian.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH 02/10] scsi/sd: add error handling support for add_disk() Date: Mon, 23 Aug 2021 13:29:22 -0700 Message-Id: <20210823202930.137278-3-mcgrof@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210823202930.137278-1-mcgrof@kernel.org> References: <20210823202930.137278-1-mcgrof@kernel.org> MIME-Version: 1.0 Sender: Luis Chamberlain Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org 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 Reviewed-by: Christoph Hellwig --- drivers/scsi/sd.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 7d5217905374..7df6f20f28ec 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -3487,7 +3487,11 @@ static int sd_probe(struct device *dev) pm_runtime_set_autosuspend_delay(dev, sdp->host->hostt->rpm_autosuspend_delay); } - device_add_disk(dev, gd, NULL); + + error = device_add_disk(dev, gd, NULL); + if (error) + goto out_free_index; + if (sdkp->capacity) sd_dif_config_host(sdkp); From patchwork Mon Aug 23 20:29:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 501682 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A31D6C432BE for ; Mon, 23 Aug 2021 20:30:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8F39A6103A for ; Mon, 23 Aug 2021 20:30:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232724AbhHWUbD (ORCPT ); Mon, 23 Aug 2021 16:31:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232664AbhHWUaz (ORCPT ); Mon, 23 Aug 2021 16:30:55 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D136C06175F; Mon, 23 Aug 2021 13:30:12 -0700 (PDT) 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=FypvegGWnnERKpPFbzVBwYTOoDfKrjdj29vUEVZP6fM=; b=dXL5wz6Yf1z+ahQ9qQ4ttU+dvq DjGgq+pvaxdWUTKvohT9ASHu6tku5/rYy1EnPNgldrCFk3yD39TJVlfJquyRKLsHqIiJzFCCf9zEE pm5SGGJ9nDC2hZkbGVkLPM0JZ5eJrWMVm0fcjDrep10c3KefYRbJqoDJd5BS8uFm7nWFDfvwLHsBx pApfvgyB8P7yC2UUhuaOTb6nFwji1X7GiFAftJNsz19Qf0MbHX8jkKZOz8dZaYQnUc8PigRGJ7gFg MUNL9wHLjR9wr4OQpbU8crnqSh1l8kz9FMqTtRNZ1OYfFbNkqVgxJN2qG6FevH6gC9dTORyE+o81W fr2CZAQw==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mIGZa-000ZjO-4g; Mon, 23 Aug 2021 20:29:34 +0000 From: Luis Chamberlain To: axboe@kernel.dk, martin.petersen@oracle.com, jejb@linux.ibm.com, kbusch@kernel.org, sagi@grimberg.me, adrian.hunter@intel.com, beanhuo@micron.com, ulf.hansson@linaro.org, avri.altman@wdc.com, swboyd@chromium.org, agk@redhat.com, snitzer@redhat.com, josef@toxicpanda.com Cc: hch@infradead.org, hare@suse.de, bvanassche@acm.org, ming.lei@redhat.com, linux-scsi@vger.kernel.org, linux-nvme@lists.infradead.org, linux-mmc@vger.kernel.org, dm-devel@redhat.com, nbd@other.debian.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH 03/10] scsi/sr: use blk_cleanup_disk() instead of put_disk() Date: Mon, 23 Aug 2021 13:29:23 -0700 Message-Id: <20210823202930.137278-4-mcgrof@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210823202930.137278-1-mcgrof@kernel.org> References: <20210823202930.137278-1-mcgrof@kernel.org> MIME-Version: 1.0 Sender: Luis Chamberlain Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org The single put_disk() is useful if you know you're not doing a cleanup after add_disk(), but since we want to add support for that, just use the normal form of blk_cleanup_disk() to cleanup the queue and put the disk. Signed-off-by: Luis Chamberlain --- drivers/scsi/sr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index a0df27db4d61..dc78ad96e6f9 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c @@ -792,7 +792,7 @@ static int sr_probe(struct device *dev) clear_bit(minor, sr_index_bits); spin_unlock(&sr_index_lock); fail_put: - put_disk(disk); + blk_cleanup_disk(disk); mutex_destroy(&cd->lock); fail_free: kfree(cd); From patchwork Mon Aug 23 20:29:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 501680 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, UNWANTED_LANGUAGE_BODY, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E25ABC4338F for ; Mon, 23 Aug 2021 20:30:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CF64B60E97 for ; Mon, 23 Aug 2021 20:30:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232819AbhHWUbP (ORCPT ); Mon, 23 Aug 2021 16:31:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232638AbhHWUa7 (ORCPT ); Mon, 23 Aug 2021 16:30:59 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45D1DC061760; Mon, 23 Aug 2021 13:30:16 -0700 (PDT) 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=JwOWbBzkAnZ+cmq3j7KTpY4gX689ENExo/ts1u/1X/M=; b=oLoArWLSpDzDh0QIiWovAO+FVB WZVxwCC8x6MEcP2VL8z1RZZ/YStJ6ekAkvjA+VIVyJ2f+6L2JuRG94A8vco2j0HZ2VHjdZ1NEsjb6 uRXqh03SmhIQVd+aVXFzwlyQrHdYoHWtQ83jVGUFDbgELpfmegdKdOdDPIY07Pmk4c+5durRv2hKQ 5mKchatT2Op1+GMj5rJGMvvpm+YGR4/CwokOVNPxHDDxbF8/chbrRc2x/eJgDbMunVXFwfvl6yJzw HoEmoAcu+TKvxFSABoEDzpMsBH5uIWRqBkUcwm5Q4zQ+A+qlom774cSMcSlJGHxFdVoreF7pifkQl G4K3X9pQ==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mIGZa-000ZjQ-6z; Mon, 23 Aug 2021 20:29:34 +0000 From: Luis Chamberlain To: axboe@kernel.dk, martin.petersen@oracle.com, jejb@linux.ibm.com, kbusch@kernel.org, sagi@grimberg.me, adrian.hunter@intel.com, beanhuo@micron.com, ulf.hansson@linaro.org, avri.altman@wdc.com, swboyd@chromium.org, agk@redhat.com, snitzer@redhat.com, josef@toxicpanda.com Cc: hch@infradead.org, hare@suse.de, bvanassche@acm.org, ming.lei@redhat.com, linux-scsi@vger.kernel.org, linux-nvme@lists.infradead.org, linux-mmc@vger.kernel.org, dm-devel@redhat.com, nbd@other.debian.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH 04/10] scsi/sr: add error handling support for add_disk() Date: Mon, 23 Aug 2021 13:29:24 -0700 Message-Id: <20210823202930.137278-5-mcgrof@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210823202930.137278-1-mcgrof@kernel.org> References: <20210823202930.137278-1-mcgrof@kernel.org> MIME-Version: 1.0 Sender: Luis Chamberlain Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org 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 Reviewed-by: Christoph Hellwig --- drivers/scsi/sr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index dc78ad96e6f9..3e0c6f881521 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c @@ -779,7 +779,10 @@ static int sr_probe(struct device *dev) dev_set_drvdata(dev, cd); disk->flags |= GENHD_FL_REMOVABLE; sr_revalidate_disk(cd); - device_add_disk(&sdev->sdev_gendev, disk, NULL); + + error = device_add_disk(&sdev->sdev_gendev, disk, NULL); + if (error) + goto fail_minor; sdev_printk(KERN_DEBUG, sdev, "Attached scsi CD-ROM %s\n", cd->cdi.name); From patchwork Mon Aug 23 20:29:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 502047 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43DE4C4338F for ; Mon, 23 Aug 2021 20:30:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3011D6103A for ; Mon, 23 Aug 2021 20:30:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232746AbhHWUbE (ORCPT ); Mon, 23 Aug 2021 16:31:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232635AbhHWUaz (ORCPT ); Mon, 23 Aug 2021 16:30:55 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46E2FC061757; Mon, 23 Aug 2021 13:30:12 -0700 (PDT) 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=k5sSl0vYONsVC6k5VQFocYf3UMVF7iXDLEuoRb4cPTo=; b=ytFd4wxWicN567iPDaQzopBkVb JEyVQhLcVbjxFEKZmQ7+C9EZhZzxiVUSTFuO/z4gnGAnXuDbcZcpAvJMz1ga6UMI9IdifaxeWK3+h XskXFUN+TYORj+pU/KKuAKqjZMYm2Y5SMZvnBpJ+11VvVHW9nweZLpVLJyez2gZGD5ACl5WZaqed2 GP43jjy3zwcb09a9pAqe7/u9Hj6rXJMDeI4AEU1+fv9az905SqIVvvF2mrGGMbbOU0g8BHbj3Uics 276Gt+vykqsXpBeIdrJhIRgigovtHjEdKSiXWU+TBHwwbwbj4bq+yz48vbxLGXSQ0wKNFh9P0SVNj WJK6EXfQ==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mIGZa-000ZjS-8P; Mon, 23 Aug 2021 20:29:34 +0000 From: Luis Chamberlain To: axboe@kernel.dk, martin.petersen@oracle.com, jejb@linux.ibm.com, kbusch@kernel.org, sagi@grimberg.me, adrian.hunter@intel.com, beanhuo@micron.com, ulf.hansson@linaro.org, avri.altman@wdc.com, swboyd@chromium.org, agk@redhat.com, snitzer@redhat.com, josef@toxicpanda.com Cc: hch@infradead.org, hare@suse.de, bvanassche@acm.org, ming.lei@redhat.com, linux-scsi@vger.kernel.org, linux-nvme@lists.infradead.org, linux-mmc@vger.kernel.org, dm-devel@redhat.com, nbd@other.debian.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH 05/10] nvme: add error handling support for add_disk() Date: Mon, 23 Aug 2021 13:29:25 -0700 Message-Id: <20210823202930.137278-6-mcgrof@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210823202930.137278-1-mcgrof@kernel.org> References: <20210823202930.137278-1-mcgrof@kernel.org> MIME-Version: 1.0 Sender: Luis Chamberlain Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org 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/nvme/host/core.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 68acd33c3856..fe02e95173d8 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -3720,6 +3720,7 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid, struct gendisk *disk; struct nvme_id_ns *id; int node = ctrl->numa_node; + int rc; if (nvme_identify_ns(ctrl, nsid, ids, &id)) return; @@ -3775,7 +3776,10 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid, nvme_get_ctrl(ctrl); - device_add_disk(ctrl->device, ns->disk, nvme_ns_id_attr_groups); + rc = device_add_disk(ctrl->device, ns->disk, nvme_ns_id_attr_groups); + if (rc) + goto out_cleanup_ns_from_list; + if (!nvme_ns_head_multipath(ns->head)) nvme_add_ns_cdev(ns); @@ -3785,6 +3789,10 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid, return; + out_cleanup_ns_from_list: + down_write(&ctrl->namespaces_rwsem); + list_del_init(&ns->list); + up_write(&ctrl->namespaces_rwsem); out_unlink_ns: mutex_lock(&ctrl->subsys->lock); list_del_rcu(&ns->siblings); From patchwork Mon Aug 23 20:29:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 502048 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4D29C432BE for ; Mon, 23 Aug 2021 20:30:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D1FC760E97 for ; Mon, 23 Aug 2021 20:30:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232763AbhHWUbF (ORCPT ); Mon, 23 Aug 2021 16:31:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232666AbhHWUaz (ORCPT ); Mon, 23 Aug 2021 16:30:55 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD444C061764; Mon, 23 Aug 2021 13:30:12 -0700 (PDT) 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=e7rRtEm+k/UvglB8mkLZNHmTTdPjRwZAGNCpjle2wbI=; b=c2Vvmi8OhaKZfe1t6eRlDx2//+ ijrL3WWRkOpdOWip35YdrajKmu4R3cck3G01WY59I26MOGCS3TNzwZHW8JsW7zSLkUUPz7iYgFUDD MKXtK1/Xtb2phrfPafJL9wDteDqfLiV0T6Q5NSQQ+MgVYYmUwjgdDFAdZcXpn6lQqekefl+5VHU9I MKcSfXpK//ryiAMHNwYpEMLhDcyVwrtZ8OJG3B5dFwaNd7yCDksTm7ZUg97kPACpxpj4lfEp49hdC Oycb+X8ZT5b/dFJPCcvBdYF//BllWSZLrkCjHsvNXHDWpr2hMnSv3UxMzKpmjd3OTvqOV/vlSH52y yzyOWsow==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mIGZa-000ZjU-9o; Mon, 23 Aug 2021 20:29:34 +0000 From: Luis Chamberlain To: axboe@kernel.dk, martin.petersen@oracle.com, jejb@linux.ibm.com, kbusch@kernel.org, sagi@grimberg.me, adrian.hunter@intel.com, beanhuo@micron.com, ulf.hansson@linaro.org, avri.altman@wdc.com, swboyd@chromium.org, agk@redhat.com, snitzer@redhat.com, josef@toxicpanda.com Cc: hch@infradead.org, hare@suse.de, bvanassche@acm.org, ming.lei@redhat.com, linux-scsi@vger.kernel.org, linux-nvme@lists.infradead.org, linux-mmc@vger.kernel.org, dm-devel@redhat.com, nbd@other.debian.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH 06/10] mmc/core/block: add error handling support for add_disk() Date: Mon, 23 Aug 2021 13:29:26 -0700 Message-Id: <20210823202930.137278-7-mcgrof@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210823202930.137278-1-mcgrof@kernel.org> References: <20210823202930.137278-1-mcgrof@kernel.org> MIME-Version: 1.0 Sender: Luis Chamberlain Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org We never checked for errors on add_disk() as this function returned void. Now that this is fixed, use the shiny new error handling. The caller cleanups the disk already so all we need to do is just pass along the return value. Signed-off-by: Luis Chamberlain --- drivers/mmc/core/block.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index 4c11f171e56d..4f12c6d1e1b5 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -2432,7 +2432,9 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card, /* used in ->open, must be set before add_disk: */ if (area_type == MMC_BLK_DATA_AREA_MAIN) dev_set_drvdata(&card->dev, md); - device_add_disk(md->parent, md->disk, mmc_disk_attr_groups); + ret = device_add_disk(md->parent, md->disk, mmc_disk_attr_groups); + if (ret) + goto out; return md; err_kfree: From patchwork Mon Aug 23 20:29:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 502046 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69943C4338F for ; Mon, 23 Aug 2021 20:30:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5643D60E97 for ; Mon, 23 Aug 2021 20:30:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232921AbhHWUbQ (ORCPT ); Mon, 23 Aug 2021 16:31:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232568AbhHWUa7 (ORCPT ); Mon, 23 Aug 2021 16:30:59 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C22DC06175F; Mon, 23 Aug 2021 13:30:16 -0700 (PDT) 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=OfWwvKvXHF7mAR0YH9EVQI1Ai4xHJmlcz1fm4t+WkvQ=; b=c1NoizZM+bXC/4X0Kr/yu9qM/4 vogWc0nrHBCi45AdGqOBAij28BuUscFaMAFHbJ2yXQCp5OH9DacSlocg057cgyhEzAbp+eqUj9Zfh 6gWNmHJ2C2e/7/pq/RB+53totPFBi3AUR0PxzJLMVHEgo7uT0Z7UvGZdbbilsChDr2RBszTvYlsOb PELdLD+eJ6LkLyE4ocLD45dCwrtv3J3wf3TA8HC95Ydw3sT4gdo5pNlkSoYEw8a45/pSmg3NFnBWI GWZR46Bma5vyjALSf1nrc1KO1TqKtNpD5kmRJlERTgeNeRb6CWNyzFxwURUSlXc8oNnuujcl9QiQD if8hBZZA==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mIGZa-000ZjW-BM; Mon, 23 Aug 2021 20:29:34 +0000 From: Luis Chamberlain To: axboe@kernel.dk, martin.petersen@oracle.com, jejb@linux.ibm.com, kbusch@kernel.org, sagi@grimberg.me, adrian.hunter@intel.com, beanhuo@micron.com, ulf.hansson@linaro.org, avri.altman@wdc.com, swboyd@chromium.org, agk@redhat.com, snitzer@redhat.com, josef@toxicpanda.com Cc: hch@infradead.org, hare@suse.de, bvanassche@acm.org, ming.lei@redhat.com, linux-scsi@vger.kernel.org, linux-nvme@lists.infradead.org, linux-mmc@vger.kernel.org, dm-devel@redhat.com, nbd@other.debian.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH 07/10] md: add error handling support for add_disk() Date: Mon, 23 Aug 2021 13:29:27 -0700 Message-Id: <20210823202930.137278-8-mcgrof@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210823202930.137278-1-mcgrof@kernel.org> References: <20210823202930.137278-1-mcgrof@kernel.org> MIME-Version: 1.0 Sender: Luis Chamberlain Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org 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 just do the unwinding of what was not done before, and are sure to unlock prior to bailing. Signed-off-by: Luis Chamberlain --- drivers/md/md.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/md/md.c b/drivers/md/md.c index ae8fe54ea358..5c0d3536d7c7 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -5704,7 +5704,11 @@ static int md_alloc(dev_t dev, char *name) * through to md_open, so make sure it doesn't get too far */ mutex_lock(&mddev->open_mutex); - add_disk(disk); + error = add_disk(disk); + if (error) { + blk_cleanup_disk(disk); + goto abort_unlock; + } error = kobject_add(&mddev->kobj, &disk_to_dev(disk)->kobj, "%s", "md"); if (error) { @@ -5718,6 +5722,7 @@ static int md_alloc(dev_t dev, char *name) if (mddev->kobj.sd && sysfs_create_group(&mddev->kobj, &md_bitmap_group)) pr_debug("pointless warning\n"); + abort_unlock: mutex_unlock(&mddev->open_mutex); abort: mutex_unlock(&disks_mutex); From patchwork Mon Aug 23 20:29:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 501681 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E72DC432BE for ; Mon, 23 Aug 2021 20:30:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8A66A613D5 for ; Mon, 23 Aug 2021 20:30:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232787AbhHWUbF (ORCPT ); Mon, 23 Aug 2021 16:31:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232683AbhHWUa4 (ORCPT ); Mon, 23 Aug 2021 16:30:56 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C6B4C061575; Mon, 23 Aug 2021 13:30:13 -0700 (PDT) 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=ZwxyFXcOiGq8qChS2d1Notj23dWo1Us0XnbUDLeBwX8=; b=gwLOjM3XIyBov1gksucnFV6ooL M14P6xtIFkqJWDvnJ+/ICsQQuOeHg3bNCCgwD6eLd1QGFRv9hRZPIwrwVVrc4GRJ2n6pYIZ5XmSrw rcx7adfg7jhXfbkhk5O7HByT/5+LX1pVl9RViZEXYV9+8xJ3lT8eOaknnO+IUd6QKllMR3/xq5hgf N/goUQWSvkvYz8acad20DJCfe0uNYcHhGoEl2FNlkDkG744ujAzQBIJJRxGvJnJbLar1t7aga4T7o AhjcvHCAtsXTrVTXcoPwJ/DRxC2CyMVvuuTQ1zXJ5xHiLfHnsJzmkEfKV0hbmwsmiMIBYmw4pns41 bG+HsJfw==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mIGZa-000ZjY-Cl; Mon, 23 Aug 2021 20:29:34 +0000 From: Luis Chamberlain To: axboe@kernel.dk, martin.petersen@oracle.com, jejb@linux.ibm.com, kbusch@kernel.org, sagi@grimberg.me, adrian.hunter@intel.com, beanhuo@micron.com, ulf.hansson@linaro.org, avri.altman@wdc.com, swboyd@chromium.org, agk@redhat.com, snitzer@redhat.com, josef@toxicpanda.com Cc: hch@infradead.org, hare@suse.de, bvanassche@acm.org, ming.lei@redhat.com, linux-scsi@vger.kernel.org, linux-nvme@lists.infradead.org, linux-mmc@vger.kernel.org, dm-devel@redhat.com, nbd@other.debian.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH 08/10] dm: add add_disk() error handling Date: Mon, 23 Aug 2021 13:29:28 -0700 Message-Id: <20210823202930.137278-9-mcgrof@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210823202930.137278-1-mcgrof@kernel.org> References: <20210823202930.137278-1-mcgrof@kernel.org> MIME-Version: 1.0 Sender: Luis Chamberlain Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org 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/md/dm.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 7981b7287628..cd26fde4ab56 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -2077,15 +2077,21 @@ int dm_setup_md_queue(struct mapped_device *md, struct dm_table *t) if (r) return r; - add_disk(md->disk); + r = add_disk(md->disk); + if (r) + goto out_cleanup_disk; r = dm_sysfs_init(md); - if (r) { - del_gendisk(md->disk); - return r; - } + if (r) + goto out_del_gendisk; md->type = type; return 0; + +out_cleanup_disk: + blk_cleanup_disk(md->disk); +out_del_gendisk: + del_gendisk(md->disk); + return r; } struct mapped_device *dm_get_md(dev_t dev) From patchwork Mon Aug 23 20:29:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 501684 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E4E5C4320E for ; Mon, 23 Aug 2021 20:30:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0CC6D613D5 for ; Mon, 23 Aug 2021 20:30:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232660AbhHWUaz (ORCPT ); Mon, 23 Aug 2021 16:30:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232577AbhHWUas (ORCPT ); Mon, 23 Aug 2021 16:30:48 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 199ABC061757; Mon, 23 Aug 2021 13:30:05 -0700 (PDT) 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=tBgxszXJVE3wD+DPKaKiBalHK54CRKsYwj1PqeCiYBI=; b=X51iNcfbrjsh9zw8hQIvkBv0+h sjY5R1ERbqKv55YUOBYlpIhDxy8ZjM1qU+bDsC6pIVw4BHJZs6gHKGJfHyh0Qps+80/KALHr/SY0g BDDRFL45dDYI8t+/x6ysYf1JyT7VCdLot+PGhA4dc+mlTzbp3NzI34LEgXHVzArHgMjbkUb8b3x/F oUqYB+YYH5UA79OXmIgx1KoPPNh2XUja5D+5dtwW7OIu/T560+Rq7HgLcMVNTz0Gd3aYGbuBLICEB /EOrd10yViJZGkM50qd+4XUcQhtNdWlFwL5V3RoOk9uRR10HcVcQjMHu1REx9J5c5VYJEkKFj0c1S zG+NnczA==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mIGZa-000Zja-EG; Mon, 23 Aug 2021 20:29:34 +0000 From: Luis Chamberlain To: axboe@kernel.dk, martin.petersen@oracle.com, jejb@linux.ibm.com, kbusch@kernel.org, sagi@grimberg.me, adrian.hunter@intel.com, beanhuo@micron.com, ulf.hansson@linaro.org, avri.altman@wdc.com, swboyd@chromium.org, agk@redhat.com, snitzer@redhat.com, josef@toxicpanda.com Cc: hch@infradead.org, hare@suse.de, bvanassche@acm.org, ming.lei@redhat.com, linux-scsi@vger.kernel.org, linux-nvme@lists.infradead.org, linux-mmc@vger.kernel.org, dm-devel@redhat.com, nbd@other.debian.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Luis Chamberlain , Christoph Hellwig Subject: [PATCH 09/10] loop: add error handling support for add_disk() Date: Mon, 23 Aug 2021 13:29:29 -0700 Message-Id: <20210823202930.137278-10-mcgrof@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210823202930.137278-1-mcgrof@kernel.org> References: <20210823202930.137278-1-mcgrof@kernel.org> MIME-Version: 1.0 Sender: Luis Chamberlain Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org 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 Signed-off-by: Christoph Hellwig Reviewed-by: Christoph Hellwig --- drivers/block/loop.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index fa1c298a8cfb..b8b9e2349e77 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -2393,10 +2393,17 @@ static int loop_add(int i) disk->events = DISK_EVENT_MEDIA_CHANGE; disk->event_flags = DISK_EVENT_FLAG_UEVENT; sprintf(disk->disk_name, "loop%d", i); - add_disk(disk); + + err = add_disk(disk); + if (err) + goto out_cleanup_disk; + mutex_unlock(&loop_ctl_mutex); + return i; +out_cleanup_disk: + blk_cleanup_disk(disk); out_cleanup_tags: blk_mq_free_tag_set(&lo->tag_set); out_free_idr: From patchwork Mon Aug 23 20:29:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 501679 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB8E7C4320E for ; Mon, 23 Aug 2021 20:30:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9BE5760E97 for ; Mon, 23 Aug 2021 20:30:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232939AbhHWUbR (ORCPT ); Mon, 23 Aug 2021 16:31:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232627AbhHWUa7 (ORCPT ); Mon, 23 Aug 2021 16:30:59 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38582C061757; Mon, 23 Aug 2021 13:30:15 -0700 (PDT) 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=FjHYiJcoMRUSOg8mXjovmoG4YYRib0Dd4tpy9VAVPrM=; b=hkHkWpB6ezJIMqnl+yvYHudFX0 KnNgmD/FTenq3X7xrHQXRsABnQKwgg/eDx7kD3RFpSZWUmTtlc+Fdufz8qgOhQQcoL15xaZ7MJieu SUBv8DGDhp/kNOBDFMAUo+LEreTcbXrt5Z9ZqoBuxshCH1XAW1HHsTCrX598/J17imHBONknSSmEJ 1WtF9exW246DnTlPbNeHGfRpLBRxHS2H7I2rF9HvM8Zs+ioSxRu3EvDTNC+U5YEDSxQbNxt9zuelk 9PGFI2bGRt8zRan8ZuxrL3qSKPrvXiKUbSvCURZRp50A59RcYQabNse/nc9hPEFYLAtESKYmx/4mu rwG28cww==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mIGZa-000Zjc-Fg; Mon, 23 Aug 2021 20:29:34 +0000 From: Luis Chamberlain To: axboe@kernel.dk, martin.petersen@oracle.com, jejb@linux.ibm.com, kbusch@kernel.org, sagi@grimberg.me, adrian.hunter@intel.com, beanhuo@micron.com, ulf.hansson@linaro.org, avri.altman@wdc.com, swboyd@chromium.org, agk@redhat.com, snitzer@redhat.com, josef@toxicpanda.com Cc: hch@infradead.org, hare@suse.de, bvanassche@acm.org, ming.lei@redhat.com, linux-scsi@vger.kernel.org, linux-nvme@lists.infradead.org, linux-mmc@vger.kernel.org, dm-devel@redhat.com, nbd@other.debian.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Luis Chamberlain , Christoph Hellwig Subject: [PATCH 10/10] nbd: add error handling support for add_disk() Date: Mon, 23 Aug 2021 13:29:30 -0700 Message-Id: <20210823202930.137278-11-mcgrof@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210823202930.137278-1-mcgrof@kernel.org> References: <20210823202930.137278-1-mcgrof@kernel.org> MIME-Version: 1.0 Sender: Luis Chamberlain Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org 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 Signed-off-by: Christoph Hellwig Reviewed-by: Christoph Hellwig --- drivers/block/nbd.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index c38317979f74..95f84c9b31f2 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -1730,10 +1730,14 @@ static int nbd_dev_add(int index) disk->fops = &nbd_fops; disk->private_data = nbd; sprintf(disk->disk_name, "nbd%d", index); - add_disk(disk); + err = add_disk(disk); + if (err) + goto out_err_disk; nbd_total_devices++; return index; +out_err_disk: + blk_cleanup_disk(disk); out_free_idr: idr_remove(&nbd_index_idr, index); out_free_tags: