From patchwork Wed Aug 18 14:45:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12444613 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 13E5DC4320A for ; Wed, 18 Aug 2021 14:49:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E8007610E5 for ; Wed, 18 Aug 2021 14:49:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238896AbhHROth (ORCPT ); Wed, 18 Aug 2021 10:49:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238483AbhHROte (ORCPT ); Wed, 18 Aug 2021 10:49:34 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50495C061764 for ; Wed, 18 Aug 2021 07:48:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=dd55p9fRZ62wbbImD+QX9EdhgJeWc+nuOzXi0JKVyCA=; b=l1zryiyRtXQPptsS1l9A+4Sqtn nHMccNf1gP8hz7L/4grDR/MKMkhM/kfGq3BqJW54rM70ipoVvrBe3opca6BApu/FT3wWRoxOBXlOb uBZtCXZnWVj2yirVmWcQ7rUDDfZxHETVddp4bPqtoIEMjW1fLk1FR2rLP1EZjzQ3vHCC7bDaGy208 xC9jf6QqxiMtY1FWckUOpsakdguw927pb42aCqS61quTjS+bLD7DpuMQTcxRMiIHOBU4k2VwtUfCh NKobUpcO6yKRFprCPkT7LEdHRlNyKXVwiqPMcPWtEB6JJjcbsIvdS6XsPIZGMUqTXHITQURa/4ojd 2kbEIpRQ==; Received: from [2001:4bb8:188:1b1:5a9e:9f39:5a86:b20c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mGMq4-003wVQ-5w; Wed, 18 Aug 2021 14:46:58 +0000 From: Christoph Hellwig To: Jens Axboe Cc: "Michael S. Tsirkin" , Jason Wang , "Martin K. Petersen" , Luis Chamberlain , linux-block@vger.kernel.org Subject: [PATCH 01/11] block: add a sanity check for a live disk in del_gendisk Date: Wed, 18 Aug 2021 16:45:32 +0200 Message-Id: <20210818144542.19305-2-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210818144542.19305-1-hch@lst.de> References: <20210818144542.19305-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Add a sanity check to del_gendisk to do nothing when the disk wasn't successfully added. This papers over the complete lack of add_disk error handling, which is about to get fixed gradually. Signed-off-by: Christoph Hellwig Reviewed-by: Hannes Reinecke --- block/genhd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/genhd.c b/block/genhd.c index 02cd9ec93e52..935f74c652f1 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -579,7 +579,7 @@ void del_gendisk(struct gendisk *disk) { might_sleep(); - if (WARN_ON_ONCE(!disk->queue)) + if (WARN_ON_ONCE(!disk_live(disk))) return; blk_integrity_del(disk); From patchwork Wed Aug 18 14:45:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12444615 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 4E4E2C432BE for ; Wed, 18 Aug 2021 14:49:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 364F4610D2 for ; Wed, 18 Aug 2021 14:49:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238483AbhHROuU (ORCPT ); Wed, 18 Aug 2021 10:50:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238961AbhHROuT (ORCPT ); Wed, 18 Aug 2021 10:50:19 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF31AC061764 for ; Wed, 18 Aug 2021 07:49:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=oSraqT5Od7AFAD1YVJjRhxExyuP9kDMh/G943lpHfAA=; b=Ba7xAVBLMKM8HaH25kl/b5XFOc PqeyIgCtd8ntY7SPONiHtgxkjobCq9a+qwzqXAzEb1ZOJY4iqZtssAh+2TjxzOnGYZtnBsXDwNV+U +tMn5raDTCPF6jq7pRjOaN1NHP7ljez8L2SToH8/AkDAQIbq+5JVgpRbqORl2veZOWP/mbgG4+4UZ HYsg6droeWs5NjLIYxOatXnwMxxYV7VKVafvWs5CFf1vhcR3rxFGyVzYzxoYTK1xRk635n4mw2BWR DQDDvFDgLmR/AFPGBC5enA4JedBuFhaV0zutupog4Oz79OoC/ZDetej/cReYBb8haJTFTj3C+Lg9G NEirPBhQ==; Received: from [2001:4bb8:188:1b1:5a9e:9f39:5a86:b20c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mGMrI-003wdU-V7; Wed, 18 Aug 2021 14:48:24 +0000 From: Christoph Hellwig To: Jens Axboe Cc: "Michael S. Tsirkin" , Jason Wang , "Martin K. Petersen" , Luis Chamberlain , linux-block@vger.kernel.org Subject: [PATCH 02/11] block: fold register_disk into device_add_disk Date: Wed, 18 Aug 2021 16:45:33 +0200 Message-Id: <20210818144542.19305-3-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210818144542.19305-1-hch@lst.de> References: <20210818144542.19305-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org There is no real reason these should be separate. Also simplify the groups assignment a bit. Signed-off-by: Christoph Hellwig --- block/genhd.c | 131 +++++++++++++++++++++++--------------------------- 1 file changed, 60 insertions(+), 71 deletions(-) diff --git a/block/genhd.c b/block/genhd.c index 935f74c652f1..ec4be5889fbf 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -409,71 +409,6 @@ static void disk_scan_partitions(struct gendisk *disk) blkdev_put(bdev, FMODE_READ); } -static void register_disk(struct device *parent, struct gendisk *disk, - const struct attribute_group **groups) -{ - struct device *ddev = disk_to_dev(disk); - int err; - - ddev->parent = parent; - - dev_set_name(ddev, "%s", disk->disk_name); - - /* delay uevents, until we scanned partition table */ - dev_set_uevent_suppress(ddev, 1); - - if (groups) { - WARN_ON(ddev->groups); - ddev->groups = groups; - } - if (device_add(ddev)) - return; - if (!sysfs_deprecated) { - err = sysfs_create_link(block_depr, &ddev->kobj, - kobject_name(&ddev->kobj)); - if (err) { - device_del(ddev); - return; - } - } - - /* - * avoid probable deadlock caused by allocating memory with - * GFP_KERNEL in runtime_resume callback of its all ancestor - * devices - */ - pm_runtime_set_memalloc_noio(ddev, true); - - disk->part0->bd_holder_dir = - kobject_create_and_add("holders", &ddev->kobj); - disk->slave_dir = kobject_create_and_add("slaves", &ddev->kobj); - - /* - * XXX: this is a mess, can't wait for real error handling in add_disk. - * Make sure ->slave_dir is NULL if we failed some of the registration - * so that the cleanup in bd_unlink_disk_holder works properly. - */ - if (bd_register_pending_holders(disk) < 0) { - kobject_put(disk->slave_dir); - disk->slave_dir = NULL; - } - - if (disk->flags & GENHD_FL_HIDDEN) - return; - - disk_scan_partitions(disk); - - /* announce the disk and partitions after all partitions are created */ - dev_set_uevent_suppress(ddev, 0); - disk_uevent(disk, KOBJ_ADD); - - if (disk->bdi->dev) { - err = sysfs_create_link(&ddev->kobj, &disk->bdi->dev->kobj, - "bdi"); - WARN_ON(err); - } -} - /** * device_add_disk - add disk information to kernel list * @parent: parent device for the disk @@ -490,6 +425,7 @@ void device_add_disk(struct device *parent, struct gendisk *disk, const struct attribute_group **groups) { + struct device *ddev = disk_to_dev(disk); int ret; /* @@ -538,17 +474,70 @@ void device_add_disk(struct device *parent, struct gendisk *disk, disk->flags |= GENHD_FL_SUPPRESS_PARTITION_INFO; disk->flags |= GENHD_FL_NO_PART_SCAN; } else { - struct device *dev = disk_to_dev(disk); - /* Register BDI before referencing it from bdev */ - dev->devt = MKDEV(disk->major, disk->first_minor); + ddev->devt = MKDEV(disk->major, disk->first_minor); ret = bdi_register(disk->bdi, "%u:%u", disk->major, disk->first_minor); WARN_ON(ret); - bdi_set_owner(disk->bdi, dev); - bdev_add(disk->part0, dev->devt); + bdi_set_owner(disk->bdi, ddev); + bdev_add(disk->part0, ddev->devt); + } + + /* delay uevents, until we scanned partition table */ + dev_set_uevent_suppress(ddev, 1); + + ddev->parent = parent; + ddev->groups = groups; + dev_set_name(ddev, "%s", disk->disk_name); + if (device_add(ddev)) + return; + if (!sysfs_deprecated) { + ret = sysfs_create_link(block_depr, &ddev->kobj, + kobject_name(&ddev->kobj)); + if (ret) { + device_del(ddev); + return; + } } - register_disk(parent, disk, groups); + + /* + * avoid probable deadlock caused by allocating memory with + * GFP_KERNEL in runtime_resume callback of its all ancestor + * devices + */ + pm_runtime_set_memalloc_noio(ddev, true); + + disk->part0->bd_holder_dir = + kobject_create_and_add("holders", &ddev->kobj); + disk->slave_dir = kobject_create_and_add("slaves", &ddev->kobj); + + /* + * XXX: this is a mess, can't wait for real error handling in add_disk. + * Make sure ->slave_dir is NULL if we failed some of the registration + * so that the cleanup in bd_unlink_disk_holder works properly. + */ + if (bd_register_pending_holders(disk) < 0) { + kobject_put(disk->slave_dir); + disk->slave_dir = NULL; + } + + if (!(disk->flags & GENHD_FL_HIDDEN)) { + disk_scan_partitions(disk); + + /* + * Announce the disk and partitions after all partitions are + * created. + */ + dev_set_uevent_suppress(ddev, 0); + disk_uevent(disk, KOBJ_ADD); + + if (disk->bdi->dev) { + ret = sysfs_create_link(&ddev->kobj, + &disk->bdi->dev->kobj, "bdi"); + WARN_ON(ret); + } + } + blk_register_queue(disk); disk_add_events(disk); From patchwork Wed Aug 18 14:45:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12444617 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 6E346C4338F for ; Wed, 18 Aug 2021 14:50:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5762B610E7 for ; Wed, 18 Aug 2021 14:50:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239310AbhHROux (ORCPT ); Wed, 18 Aug 2021 10:50:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239019AbhHROuw (ORCPT ); Wed, 18 Aug 2021 10:50:52 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EBCBC061764 for ; Wed, 18 Aug 2021 07:50:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=uwDZOjKwRsV1f7zGsAa+q2vxp2oFRpQ5/atld9PpQyE=; b=OoKmycKyyhgyIAnwtSr4YbOpIw xTBCMtVz1MIIFtVjqKE2gWfXj2s3G2iJFy3CW+2Lw0G2kGu3bI4o1ENtdHpfX7vln3PLnDRNU8FoY drUSRMya6Ou3DZFxKxw2INoBoEhGrPCP1tHAMjeSM+yfBxs8VJ4Uj2ZVOZVTg6zdmGB3xaYWkNUr9 kq27323C8W4jOSUHLxeg1N/Qazb/P9+N4ZvNbSSshaQgHAcpf+durv6pWjYVVqPthT4Os/5CLbV4X MkgPScnZm83rvtNvQKuxUlwwoAxlXMY4wc102PIBqmFMW3Xo5NauFSgeimjC7fKwsf38ON+i7ApFN 6BqVGlwA==; Received: from [2001:4bb8:188:1b1:5a9e:9f39:5a86:b20c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mGMsO-003whz-AS; Wed, 18 Aug 2021 14:49:31 +0000 From: Christoph Hellwig To: Jens Axboe Cc: "Michael S. Tsirkin" , Jason Wang , "Martin K. Petersen" , Luis Chamberlain , linux-block@vger.kernel.org Subject: [PATCH 03/11] block: call bdev_add later in device_add_disk Date: Wed, 18 Aug 2021 16:45:34 +0200 Message-Id: <20210818144542.19305-4-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210818144542.19305-1-hch@lst.de> References: <20210818144542.19305-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Once bdev_add is called userspace can open the block device. Ensure that the struct device, which is used for refcounting of the disk besides various other things, is fully setup at that point. Signed-off-by: Christoph Hellwig Reviewed-by: Hannes Reinecke --- block/genhd.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/block/genhd.c b/block/genhd.c index ec4be5889fbf..ab455f110be2 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -466,29 +466,14 @@ void device_add_disk(struct device *parent, struct gendisk *disk, disk_alloc_events(disk); - if (disk->flags & GENHD_FL_HIDDEN) { - /* - * Don't let hidden disks show up in /proc/partitions, - * and don't bother scanning for partitions either. - */ - disk->flags |= GENHD_FL_SUPPRESS_PARTITION_INFO; - disk->flags |= GENHD_FL_NO_PART_SCAN; - } else { - /* Register BDI before referencing it from bdev */ - ddev->devt = MKDEV(disk->major, disk->first_minor); - ret = bdi_register(disk->bdi, "%u:%u", - disk->major, disk->first_minor); - WARN_ON(ret); - bdi_set_owner(disk->bdi, ddev); - bdev_add(disk->part0, ddev->devt); - } - /* delay uevents, until we scanned partition table */ dev_set_uevent_suppress(ddev, 1); ddev->parent = parent; ddev->groups = groups; dev_set_name(ddev, "%s", disk->disk_name); + if (!(disk->flags & GENHD_FL_HIDDEN)) + ddev->devt = MKDEV(disk->major, disk->first_minor); if (device_add(ddev)) return; if (!sysfs_deprecated) { @@ -521,12 +506,25 @@ void device_add_disk(struct device *parent, struct gendisk *disk, disk->slave_dir = NULL; } - if (!(disk->flags & GENHD_FL_HIDDEN)) { + if (disk->flags & GENHD_FL_HIDDEN) { + /* + * Don't let hidden disks show up in /proc/partitions, + * and don't bother scanning for partitions either. + */ + disk->flags |= GENHD_FL_SUPPRESS_PARTITION_INFO; + disk->flags |= GENHD_FL_NO_PART_SCAN; + } else { + ret = bdi_register(disk->bdi, "%u:%u", + disk->major, disk->first_minor); + WARN_ON(ret); + bdi_set_owner(disk->bdi, ddev); + bdev_add(disk->part0, ddev->devt); + disk_scan_partitions(disk); /* * Announce the disk and partitions after all partitions are - * created. + * created. (for hidden disks uevents remain suppressed forever) */ dev_set_uevent_suppress(ddev, 0); disk_uevent(disk, KOBJ_ADD); From patchwork Wed Aug 18 14:45:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12444633 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 AD946C4338F for ; Wed, 18 Aug 2021 14:51:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 841AA610A6 for ; Wed, 18 Aug 2021 14:51:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239393AbhHROv7 (ORCPT ); Wed, 18 Aug 2021 10:51:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239019AbhHROv6 (ORCPT ); Wed, 18 Aug 2021 10:51:58 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65A58C061764 for ; Wed, 18 Aug 2021 07:51:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=KlTGPGXtD5pcKg1e/+kLFkuthMkxZfGhOC5GRsPi52E=; b=OTQRzpNK0Ut/NnC3H3FHEIJ2Fn g7/h4lhheh3iRQpXXo12CiJAEhX9pR3fqLVz69k/gLCsh7Z9K8tllXpCWNv2JJoQSheNZnDvKjtCf TDgcNAN0bz4qbAk+Bn2TsHq4o2C/oB1WkqvKN+iw/qjqdZ2+CLu0i6iW+cn9KaKwpjj9hzPRuo2tt ZTAJQazW+YTdLGBF/mEht2Ml8yQqItTCARXaiC5Ane0KT9i/6rFQvSfqW1+6JrxqObT/TYX/ab2FV T21qCa+04tr2RS5857VOauQbSfZK80iR2K6ujVFh3Ct+b/9uRMGItHGqOdhUP2X5nwUcmTVjwIeJi R0nza+sw==; Received: from [2001:4bb8:188:1b1:5a9e:9f39:5a86:b20c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mGMt6-003wlK-HD; Wed, 18 Aug 2021 14:50:05 +0000 From: Christoph Hellwig To: Jens Axboe Cc: "Michael S. Tsirkin" , Jason Wang , "Martin K. Petersen" , Luis Chamberlain , linux-block@vger.kernel.org Subject: [PATCH 04/11] block: create the bdi link earlier in device_add_disk Date: Wed, 18 Aug 2021 16:45:35 +0200 Message-Id: <20210818144542.19305-5-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210818144542.19305-1-hch@lst.de> References: <20210818144542.19305-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org This will simplify error handling going forward. Signed-off-by: Christoph Hellwig Reviewed-by: Hannes Reinecke --- block/genhd.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/block/genhd.c b/block/genhd.c index ab455f110be2..f05e58f214d2 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -518,8 +518,13 @@ void device_add_disk(struct device *parent, struct gendisk *disk, disk->major, disk->first_minor); WARN_ON(ret); bdi_set_owner(disk->bdi, ddev); - bdev_add(disk->part0, ddev->devt); + if (disk->bdi->dev) { + ret = sysfs_create_link(&ddev->kobj, + &disk->bdi->dev->kobj, "bdi"); + WARN_ON(ret); + } + bdev_add(disk->part0, ddev->devt); disk_scan_partitions(disk); /* @@ -528,12 +533,6 @@ void device_add_disk(struct device *parent, struct gendisk *disk, */ dev_set_uevent_suppress(ddev, 0); disk_uevent(disk, KOBJ_ADD); - - if (disk->bdi->dev) { - ret = sysfs_create_link(&ddev->kobj, - &disk->bdi->dev->kobj, "bdi"); - WARN_ON(ret); - } } blk_register_queue(disk); From patchwork Wed Aug 18 14:45:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12444635 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 857E5C43216 for ; Wed, 18 Aug 2021 14:52:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 68351610D2 for ; Wed, 18 Aug 2021 14:52:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238721AbhHROw7 (ORCPT ); Wed, 18 Aug 2021 10:52:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239606AbhHROw6 (ORCPT ); Wed, 18 Aug 2021 10:52:58 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C258C061764 for ; Wed, 18 Aug 2021 07:52:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=8mOfo5CAn4drO/2dqEnobIxexcb3A3V9vsqqifptuwA=; b=KBeCY4zh0j9yfBn+9KEHnMZeep N8OZxIUp61v82ZGUqaXRCl6f02tf60FKZjzP1miwl58unQTNbqWG5D4MQugprLP2zlIlB/NxaJzOR t9D/7YvuowW3Fw9e3jUoI73A7FV6pFPx2eJOc3yPqGdv6LqLMvtyWcoYe9CBSEVNHoUTarCJsrAVB iL+TG69GS+RyxWRLbH2wKdAmJ5EGbvXUWz71oJ4RoxzF72nyMKp29YY9Ld75A4hGbcKM2GZ0RAh2t och8DgavTK0xMv5d0Sp6xSwRnPE0h2xCmAcGU2FC6+bKkJcUkLjqYN2IfGFbmT7m4K89QMcenYOGg mrLYmRtw==; Received: from [2001:4bb8:188:1b1:5a9e:9f39:5a86:b20c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mGMtv-003woj-Un; Wed, 18 Aug 2021 14:50:57 +0000 From: Christoph Hellwig To: Jens Axboe Cc: "Michael S. Tsirkin" , Jason Wang , "Martin K. Petersen" , Luis Chamberlain , linux-block@vger.kernel.org Subject: [PATCH 05/11] block: call blk_integrity_add earlier in device_add_disk Date: Wed, 18 Aug 2021 16:45:36 +0200 Message-Id: <20210818144542.19305-6-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210818144542.19305-1-hch@lst.de> References: <20210818144542.19305-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Doing all the sysfs file creation before adding the bdev and thus allowing it to be opened will simplify the about to be added error handling. Signed-off-by: Christoph Hellwig Reviewed-by: Hannes Reinecke --- block/genhd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/genhd.c b/block/genhd.c index f05e58f214d2..75d900e4c82f 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -492,6 +492,8 @@ void device_add_disk(struct device *parent, struct gendisk *disk, */ pm_runtime_set_memalloc_noio(ddev, true); + blk_integrity_add(disk); + disk->part0->bd_holder_dir = kobject_create_and_add("holders", &ddev->kobj); disk->slave_dir = kobject_create_and_add("slaves", &ddev->kobj); @@ -538,7 +540,6 @@ void device_add_disk(struct device *parent, struct gendisk *disk, blk_register_queue(disk); disk_add_events(disk); - blk_integrity_add(disk); } EXPORT_SYMBOL(device_add_disk); From patchwork Wed Aug 18 14:45:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12444637 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 73011C4320A for ; Wed, 18 Aug 2021 14:53:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 51573610FA for ; Wed, 18 Aug 2021 14:53:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239629AbhHROyA (ORCPT ); Wed, 18 Aug 2021 10:54:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239584AbhHROx7 (ORCPT ); Wed, 18 Aug 2021 10:53:59 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA0E5C061764 for ; Wed, 18 Aug 2021 07:53:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=a2JloGblasW5oNsAQ+jctzqgD+TgZmEA/KKcUfVefPw=; b=lMZd7y8qlHKVJojrh5HoBg5Ww9 EvlM6HYxdCSNxHrKCHyzE5jMYYPPfYSNMa9OGivXlTI3yrO0pQKkjOMBmgQhAFnvp775uXslff7Fr WuXW1OOK6DQ7d1pBXZsYA6gFanLUUkUSG9akK1p2donmdnbmw6J8ROQ7exrdzLdRCLlGhmnriWpDP GP/WOuQnv953dp/wIayy71Q2sYdGmKXmlCEwFuwlzreBR94HsKNqCGWt2VEXXTqCO5axgJQEEmbSm RR3A09q8mBQX7yy6SQdN7Y1oBFbibExLU2cDqDgma60sOaLl+pxNNi+RbX4J6j/ZYLrOcleNYFHrs orAaWFeg==; Received: from [2001:4bb8:188:1b1:5a9e:9f39:5a86:b20c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mGMv0-003wrg-DN; Wed, 18 Aug 2021 14:52:04 +0000 From: Christoph Hellwig To: Jens Axboe Cc: "Michael S. Tsirkin" , Jason Wang , "Martin K. Petersen" , Luis Chamberlain , linux-block@vger.kernel.org Subject: [PATCH 06/11] block: call blk_register_queue earlier in device_add_disk Date: Wed, 18 Aug 2021 16:45:37 +0200 Message-Id: <20210818144542.19305-7-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210818144542.19305-1-hch@lst.de> References: <20210818144542.19305-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Ensure that all the sysfs bits are set up before bdev_add is called, as that will make the upcomding error handling much easier. However this means the call to disk_update_readahead has to be split as that requires a bdi. Also remove various sanity checks that don't make sense now that blk_register_queue only has a single caller. Signed-off-by: Christoph Hellwig --- block/blk-sysfs.c | 9 --------- block/genhd.c | 5 +++-- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index 7fd99487300c..614d9d47de36 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -856,15 +856,6 @@ int blk_register_queue(struct gendisk *disk) struct device *dev = disk_to_dev(disk); struct request_queue *q = disk->queue; - if (WARN_ON(!q)) - return -ENXIO; - - WARN_ONCE(blk_queue_registered(q), - "%s is registering an already registered queue\n", - kobject_name(&dev->kobj)); - - disk_update_readahead(disk); - ret = blk_trace_init_sysfs(dev); if (ret) return ret; diff --git a/block/genhd.c b/block/genhd.c index 75d900e4c82f..a54b4849242c 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -508,6 +508,8 @@ void device_add_disk(struct device *parent, struct gendisk *disk, disk->slave_dir = NULL; } + blk_register_queue(disk); + if (disk->flags & GENHD_FL_HIDDEN) { /* * Don't let hidden disks show up in /proc/partitions, @@ -537,8 +539,7 @@ void device_add_disk(struct device *parent, struct gendisk *disk, disk_uevent(disk, KOBJ_ADD); } - blk_register_queue(disk); - + disk_update_readahead(disk); disk_add_events(disk); } EXPORT_SYMBOL(device_add_disk); From patchwork Wed Aug 18 14:45:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12444639 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 96752C4338F for ; Wed, 18 Aug 2021 14:54:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 73EBC6108E for ; Wed, 18 Aug 2021 14:54:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239019AbhHROy4 (ORCPT ); Wed, 18 Aug 2021 10:54:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238721AbhHROyz (ORCPT ); Wed, 18 Aug 2021 10:54:55 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2944AC061764 for ; Wed, 18 Aug 2021 07:54:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=ay7ccmcF0PEcU74GdHCeiao/NWdqMbIpxVXMo32S+IQ=; b=oEWdT4FlP+4Bj4tQ2E6glgmbha EdFDIFyR1wulkxaVwcHgCZXLd+BJLoGwS+JY39x59e8USumpV2DCzMLv8EHbH/vJVY6MbGX4YwZAV KX1/HkRri2VJ/p1OEG235OgvO8COvZfZkXm3b5Xict16bRF7P1v5Ma63rU/lZvbfb/zanTo6flVyN cyUD9IwfWXKWHg7FfjQvbxOS34a96LP0mkUb7yTzUYJ46aKnEMOMvfqgEgGN6eylJ+9fPZfIBKnVc 5gmRRZiRZ8XpYagUFW7paIzVsljTnksdTVWoXwFCtbMRsrsFvQJBAWmB/ad/0IIqo1YRlkxFbKfGp PijALhTg==; Received: from [2001:4bb8:188:1b1:5a9e:9f39:5a86:b20c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mGMvq-003wuq-L6; Wed, 18 Aug 2021 14:52:53 +0000 From: Christoph Hellwig To: Jens Axboe Cc: "Michael S. Tsirkin" , Jason Wang , "Martin K. Petersen" , Luis Chamberlain , linux-block@vger.kernel.org Subject: [PATCH 07/11] block: return errors from blk_integrity_add Date: Wed, 18 Aug 2021 16:45:38 +0200 Message-Id: <20210818144542.19305-8-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210818144542.19305-1-hch@lst.de> References: <20210818144542.19305-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Luis Chamberlain Prepare for proper error handling in add_disk. Signed-off-by: Luis Chamberlain [hch: split from a larger patch] Signed-off-by: Christoph Hellwig Reviewed-by: Hannes Reinecke --- block/blk-integrity.c | 12 +++++++----- block/blk.h | 5 +++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/block/blk-integrity.c b/block/blk-integrity.c index 410da060d1f5..69a12177dfb6 100644 --- a/block/blk-integrity.c +++ b/block/blk-integrity.c @@ -431,13 +431,15 @@ void blk_integrity_unregister(struct gendisk *disk) } EXPORT_SYMBOL(blk_integrity_unregister); -void blk_integrity_add(struct gendisk *disk) +int blk_integrity_add(struct gendisk *disk) { - if (kobject_init_and_add(&disk->integrity_kobj, &integrity_ktype, - &disk_to_dev(disk)->kobj, "%s", "integrity")) - return; + int ret; - kobject_uevent(&disk->integrity_kobj, KOBJ_ADD); + ret = kobject_init_and_add(&disk->integrity_kobj, &integrity_ktype, + &disk_to_dev(disk)->kobj, "%s", "integrity"); + if (!ret) + kobject_uevent(&disk->integrity_kobj, KOBJ_ADD); + return ret; } void blk_integrity_del(struct gendisk *disk) diff --git a/block/blk.h b/block/blk.h index 148bdcd3aa08..c9727dd56da7 100644 --- a/block/blk.h +++ b/block/blk.h @@ -132,7 +132,7 @@ static inline bool integrity_req_gap_front_merge(struct request *req, bip_next->bip_vec[0].bv_offset); } -void blk_integrity_add(struct gendisk *); +int blk_integrity_add(struct gendisk *disk); void blk_integrity_del(struct gendisk *); #else /* CONFIG_BLK_DEV_INTEGRITY */ static inline bool blk_integrity_merge_rq(struct request_queue *rq, @@ -166,8 +166,9 @@ static inline bool bio_integrity_endio(struct bio *bio) static inline void bio_integrity_free(struct bio *bio) { } -static inline void blk_integrity_add(struct gendisk *disk) +static inline int blk_integrity_add(struct gendisk *disk) { + return 0; } static inline void blk_integrity_del(struct gendisk *disk) { From patchwork Wed Aug 18 14:45:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12444641 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 8D402C4338F for ; Wed, 18 Aug 2021 14:54:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 74298610E8 for ; Wed, 18 Aug 2021 14:54:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239664AbhHROz2 (ORCPT ); Wed, 18 Aug 2021 10:55:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239619AbhHROz0 (ORCPT ); Wed, 18 Aug 2021 10:55:26 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F15F0C0613D9 for ; Wed, 18 Aug 2021 07:54:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=z6gP+Sgjh/xdyvMaKhB1YrvAvetab/P3THFO9enj/W0=; b=gta/+3Mm8VjQnuzShRwjF9PKJ4 iicbZAFQCw4GuYkDpEI1KMJ3nI+gN1W5XCtEs1D1iy5O2WJOR5ZiJ0nze84zp0tN+rZSQXpfrwQcE 69XvCnNj+mZ3zZpUUAq54nf7cP0ZrQSsUp69A6Cg526eF6CWu0UndxcRQ2nVag54aN7lE9pgWNOSO zKvrFvCLjGL2wl0PQzY/lPjMkKb/zzdOnJIg4EtOUtHW524EXPFqmWUCfPeMvjZHuOG+PKFp2B/9t Sj5AMkzqnuQe5LVxrJ3W+gMyPUXnv+YVNqQXUqAzi7oq25lsnrAeuqw/zVTOC7Mms+6AZz69wD1Jd nZG+RNJg==; Received: from [2001:4bb8:188:1b1:5a9e:9f39:5a86:b20c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mGMwz-003wyF-7s; Wed, 18 Aug 2021 14:54:11 +0000 From: Christoph Hellwig To: Jens Axboe Cc: "Michael S. Tsirkin" , Jason Wang , "Martin K. Petersen" , Luis Chamberlain , linux-block@vger.kernel.org Subject: [PATCH 08/11] block: return errors from disk_alloc_events Date: Wed, 18 Aug 2021 16:45:39 +0200 Message-Id: <20210818144542.19305-9-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210818144542.19305-1-hch@lst.de> References: <20210818144542.19305-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Luis Chamberlain Prepare for proper error handling in add_disk. Signed-off-by: Luis Chamberlain [hch: split from a larger patch] Signed-off-by: Christoph Hellwig Reviewed-by: Hannes Reinecke --- block/blk.h | 2 +- block/disk-events.c | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/block/blk.h b/block/blk.h index c9727dd56da7..bbbcc1a64a2d 100644 --- a/block/blk.h +++ b/block/blk.h @@ -362,7 +362,7 @@ int bio_add_hw_page(struct request_queue *q, struct bio *bio, struct request_queue *blk_alloc_queue(int node_id); -void disk_alloc_events(struct gendisk *disk); +int disk_alloc_events(struct gendisk *disk); void disk_add_events(struct gendisk *disk); void disk_del_events(struct gendisk *disk); void disk_release_events(struct gendisk *disk); diff --git a/block/disk-events.c b/block/disk-events.c index 7445b8ff2775..8d5496e7592a 100644 --- a/block/disk-events.c +++ b/block/disk-events.c @@ -444,17 +444,17 @@ module_param_cb(events_dfl_poll_msecs, &disk_events_dfl_poll_msecs_param_ops, /* * disk_{alloc|add|del|release}_events - initialize and destroy disk_events. */ -void disk_alloc_events(struct gendisk *disk) +int disk_alloc_events(struct gendisk *disk) { struct disk_events *ev; if (!disk->fops->check_events || !disk->events) - return; + return 0; ev = kzalloc(sizeof(*ev), GFP_KERNEL); if (!ev) { pr_warn("%s: failed to initialize events\n", disk->disk_name); - return; + return -ENOMEM; } INIT_LIST_HEAD(&ev->node); @@ -466,6 +466,7 @@ void disk_alloc_events(struct gendisk *disk) INIT_DELAYED_WORK(&ev->dwork, disk_events_workfn); disk->ev = ev; + return 0; } void disk_add_events(struct gendisk *disk) From patchwork Wed Aug 18 14:45:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12444645 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 A73EFC4338F for ; Wed, 18 Aug 2021 14:56:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 83C266108E for ; Wed, 18 Aug 2021 14:56:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239393AbhHRO4l (ORCPT ); Wed, 18 Aug 2021 10:56:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238872AbhHRO4k (ORCPT ); Wed, 18 Aug 2021 10:56:40 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CA1EC061764 for ; Wed, 18 Aug 2021 07:56:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=b9mN09gS/ikMtMuuwj30sih1WzgUOqMQ0hKWLzxzUZU=; b=o38FQ+A+Hih2YFVQbdtQ+tmCAi A9tKBZQftoNmEJEvz5ohzzYr4k/+Ka7/eDx9tPDMSCTxmfrfb2kRvZxTvvTDPG/jsFXeeRD1admVK /QnOrhAou7eY7R0y2mloVH91TtXJY4klvjoAG/GJ1S2DxWuCD5ZMARxzRDlhFJ5NcDCUx4OWBpLgz 78uhzJwnG8dLJ1oEYlHnGOR8rlUfvXdx73Wn5bTJEw/dW3OA2nZjPWuqcnx/p4sgpo24LlVPrN+va 7dhz3cQkRVX8V1gM1EK6Jkyns9j1RgrGJSD81Y435WF6JQBzu6KAcTbic0dVr3YnL1bAOVjw5ejoX QK2ijS4g==; Received: from [2001:4bb8:188:1b1:5a9e:9f39:5a86:b20c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mGMxc-003wzy-Ft; Wed, 18 Aug 2021 14:54:38 +0000 From: Christoph Hellwig To: Jens Axboe Cc: "Michael S. Tsirkin" , Jason Wang , "Martin K. Petersen" , Luis Chamberlain , linux-block@vger.kernel.org Subject: [PATCH 09/11] block: add error handling for device_add_disk / add_disk Date: Wed, 18 Aug 2021 16:45:40 +0200 Message-Id: <20210818144542.19305-10-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210818144542.19305-1-hch@lst.de> References: <20210818144542.19305-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Luis Chamberlain Properly unwind on errors in device_add_disk. This is the initial work as drivers are not converted yet, which will follow in separate patches. Signed-off-by: Luis Chamberlain [hch: major rebase. All bugs are probably mine] Signed-off-by: Christoph Hellwig Reviewed-by: Hannes Reinecke --- block/genhd.c | 92 +++++++++++++++++++++++++++---------------- include/linux/genhd.h | 8 ++-- 2 files changed, 62 insertions(+), 38 deletions(-) diff --git a/block/genhd.c b/block/genhd.c index a54b4849242c..a925f773145f 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -417,11 +417,8 @@ static void disk_scan_partitions(struct gendisk *disk) * * This function registers the partitioning information in @disk * with the kernel. - * - * FIXME: error handling */ - -void device_add_disk(struct device *parent, struct gendisk *disk, +int device_add_disk(struct device *parent, struct gendisk *disk, const struct attribute_group **groups) { @@ -444,7 +441,8 @@ void device_add_disk(struct device *parent, struct gendisk *disk, * and all partitions from the extended dev_t space. */ if (disk->major) { - WARN_ON(!disk->minors); + if (WARN_ON(!disk->minors)) + return -EINVAL; if (disk->minors > DISK_MAX_PARTS) { pr_err("block: can't allocate more than %d partitions\n", @@ -452,19 +450,20 @@ void device_add_disk(struct device *parent, struct gendisk *disk, disk->minors = DISK_MAX_PARTS; } } else { - WARN_ON(disk->minors); + if (WARN_ON(disk->minors)) + return -EINVAL; ret = blk_alloc_ext_minor(); - if (ret < 0) { - WARN_ON(1); - return; - } + if (ret < 0) + return ret; disk->major = BLOCK_EXT_MAJOR; disk->first_minor = MINOR(ret); disk->flags |= GENHD_FL_EXT_DEVT; } - disk_alloc_events(disk); + ret = disk_alloc_events(disk); + if (ret) + goto out_free_ext_minor; /* delay uevents, until we scanned partition table */ dev_set_uevent_suppress(ddev, 1); @@ -474,15 +473,14 @@ void device_add_disk(struct device *parent, struct gendisk *disk, dev_set_name(ddev, "%s", disk->disk_name); if (!(disk->flags & GENHD_FL_HIDDEN)) ddev->devt = MKDEV(disk->major, disk->first_minor); - if (device_add(ddev)) - return; + ret = device_add(ddev); + if (ret) + goto out_disk_release_events; if (!sysfs_deprecated) { ret = sysfs_create_link(block_depr, &ddev->kobj, kobject_name(&ddev->kobj)); - if (ret) { - device_del(ddev); - return; - } + if (ret) + goto out_device_del; } /* @@ -492,23 +490,25 @@ void device_add_disk(struct device *parent, struct gendisk *disk, */ pm_runtime_set_memalloc_noio(ddev, true); - blk_integrity_add(disk); + ret = blk_integrity_add(disk); + if (ret) + goto out_del_block_link; disk->part0->bd_holder_dir = kobject_create_and_add("holders", &ddev->kobj); + if (!disk->part0->bd_holder_dir) + goto out_del_integrity; disk->slave_dir = kobject_create_and_add("slaves", &ddev->kobj); + if (!disk->slave_dir) + goto out_put_holder_dir; - /* - * XXX: this is a mess, can't wait for real error handling in add_disk. - * Make sure ->slave_dir is NULL if we failed some of the registration - * so that the cleanup in bd_unlink_disk_holder works properly. - */ - if (bd_register_pending_holders(disk) < 0) { - kobject_put(disk->slave_dir); - disk->slave_dir = NULL; - } + ret = bd_register_pending_holders(disk); + if (ret < 0) + goto out_put_slave_dir; - blk_register_queue(disk); + ret = blk_register_queue(disk); + if (ret) + goto out_put_slave_dir; if (disk->flags & GENHD_FL_HIDDEN) { /* @@ -520,13 +520,13 @@ void device_add_disk(struct device *parent, struct gendisk *disk, } else { ret = bdi_register(disk->bdi, "%u:%u", disk->major, disk->first_minor); - WARN_ON(ret); + if (ret) + goto out_unregister_queue; bdi_set_owner(disk->bdi, ddev); - if (disk->bdi->dev) { - ret = sysfs_create_link(&ddev->kobj, - &disk->bdi->dev->kobj, "bdi"); - WARN_ON(ret); - } + ret = sysfs_create_link(&ddev->kobj, + &disk->bdi->dev->kobj, "bdi"); + if (ret) + goto out_unregister_bdi; bdev_add(disk->part0, ddev->devt); disk_scan_partitions(disk); @@ -541,6 +541,30 @@ void device_add_disk(struct device *parent, struct gendisk *disk, disk_update_readahead(disk); disk_add_events(disk); + return 0; + +out_unregister_bdi: + if (!(disk->flags & GENHD_FL_HIDDEN)) + bdi_unregister(disk->bdi); +out_unregister_queue: + blk_unregister_queue(disk); +out_put_slave_dir: + kobject_put(disk->slave_dir); +out_put_holder_dir: + kobject_put(disk->part0->bd_holder_dir); +out_del_integrity: + blk_integrity_del(disk); +out_del_block_link: + if (!sysfs_deprecated) + sysfs_remove_link(block_depr, dev_name(ddev)); +out_device_del: + device_del(ddev); +out_disk_release_events: + disk_release_events(disk); +out_free_ext_minor: + if (disk->major == BLOCK_EXT_MAJOR) + blk_free_ext_minor(disk->first_minor); + return WARN_ON_ONCE(ret); /* keep until all callers handle errors */ } EXPORT_SYMBOL(device_add_disk); diff --git a/include/linux/genhd.h b/include/linux/genhd.h index 55acefdd8a20..c68d83c87f83 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h @@ -214,11 +214,11 @@ static inline dev_t disk_devt(struct gendisk *disk) void disk_uevent(struct gendisk *disk, enum kobject_action action); /* block/genhd.c */ -extern void device_add_disk(struct device *parent, struct gendisk *disk, - const struct attribute_group **groups); -static inline void add_disk(struct gendisk *disk) +int device_add_disk(struct device *parent, struct gendisk *disk, + const struct attribute_group **groups); +static inline int add_disk(struct gendisk *disk) { - device_add_disk(NULL, disk, NULL); + return device_add_disk(NULL, disk, NULL); } extern void del_gendisk(struct gendisk *gp); From patchwork Wed Aug 18 14:45:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12444647 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,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 115E3C4338F for ; Wed, 18 Aug 2021 14:57:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E18EA6104F for ; Wed, 18 Aug 2021 14:57:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239019AbhHRO5e (ORCPT ); Wed, 18 Aug 2021 10:57:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238721AbhHRO5e (ORCPT ); Wed, 18 Aug 2021 10:57:34 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84003C061764 for ; Wed, 18 Aug 2021 07:56:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=Qd0sXF5xrPEbaWjOwKTm9cjB+X5XukdXlt3emTp8RQs=; b=gDQUCikwydFHCxEoHzT+FM+LYY NHQ+7s0zAXYVlJicvASOmoVYFJ8RuSJoQvt5m0JjKeEayJDnjsZ3/JImcBBj7Emhe2Nwzycy3fan8 R1BZ6WFm3+ggeL3kfbygBRGX2qJALu7lVyNd3pA8HxETjzzokQYPvlLrUKZ4XrYIC8lm2HODn91KH bbzzwF7xRVnlg/DtJP1CawsWiExQl+Kmrew/xaeEyzB02s2KGWkHfw3mX+C9AQTVcl/MKugs/rKTn /3dIICUTpa41QMfOnx+j5wec/bsoC8VmoQB8uKeb3Az7X2at7Kh9GYPCIcwqrl9xQ/GRvK7OPz+bM lFp4XvWA==; Received: from [2001:4bb8:188:1b1:5a9e:9f39:5a86:b20c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mGMyE-003x3W-Of; Wed, 18 Aug 2021 14:55:34 +0000 From: Christoph Hellwig To: Jens Axboe Cc: "Michael S. Tsirkin" , Jason Wang , "Martin K. Petersen" , Luis Chamberlain , linux-block@vger.kernel.org Subject: [PATCH 10/11] virtio_blk: add error handling support for add_disk() Date: Wed, 18 Aug 2021 16:45:41 +0200 Message-Id: <20210818144542.19305-11-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210818144542.19305-1-hch@lst.de> References: <20210818144542.19305-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: 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 Reviewed-by: Hannes Reinecke --- drivers/block/virtio_blk.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 767b4f72a54d..63dc121a4c43 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -875,9 +875,14 @@ static int virtblk_probe(struct virtio_device *vdev) virtblk_update_capacity(vblk, false); virtio_device_ready(vdev); - device_add_disk(&vdev->dev, vblk->disk, virtblk_attr_groups); + err = device_add_disk(&vdev->dev, vblk->disk, virtblk_attr_groups); + if (err) + goto out_cleanup_disk; + return 0; +out_cleanup_disk: + blk_cleanup_disk(vblk->disk); out_free_tags: blk_mq_free_tag_set(&vblk->tag_set); out_free_vq: From patchwork Wed Aug 18 14:45:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12444649 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 1791DC4338F for ; Wed, 18 Aug 2021 14:57:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E5CAC610CB for ; Wed, 18 Aug 2021 14:57:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239664AbhHRO6Q (ORCPT ); Wed, 18 Aug 2021 10:58:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239048AbhHRO6O (ORCPT ); Wed, 18 Aug 2021 10:58:14 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBE6AC061764 for ; Wed, 18 Aug 2021 07:57:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=u6sEDEKJeyn9agbo4RDBEcfLQX3zqAiVl3J9mU164jo=; b=cK5PHZyBu1zPCgh9RW9JlNUKY/ 9iH0Qc/tdTCdxS248AKd9K3H3ddDYHQJy4mQG/4PDNmYG4tBBejJAvkeFpWijr245NaUFuwVeNabU PPlc6Wgr3Taco6Y0PWMwP8EjpiMw1sKbY//n8vxPj1r/NpY9dw/LGNDdJ/Sji8tPyOmeUvo0tQo+F Y2tVQ3uj7mOOvenrkpwlKfoBKG/Z/R9ag+UGpNPQIXt5LK5VSf3ItbfMa/rmRl/UfpiSAajj40EhK rjdL8l0ISfBhP9p/GaDpm+lOq135fDlW6n77hEFodVJ+JzigUZS/p+34l+k59BWt/dJdcrOBpXQlB M+jngDmQ==; Received: from [2001:4bb8:188:1b1:5a9e:9f39:5a86:b20c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mGMzd-003x9R-W7; Wed, 18 Aug 2021 14:56:47 +0000 From: Christoph Hellwig To: Jens Axboe Cc: "Michael S. Tsirkin" , Jason Wang , "Martin K. Petersen" , Luis Chamberlain , linux-block@vger.kernel.org Subject: [PATCH 11/11] null_blk: add error handling support for add_disk() Date: Wed, 18 Aug 2021 16:45:42 +0200 Message-Id: <20210818144542.19305-12-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210818144542.19305-1-hch@lst.de> References: <20210818144542.19305-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: 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. The actual cleanup in case of error is already handled by the caller of null_gendisk_register(). Signed-off-by: Luis Chamberlain Signed-off-by: Christoph Hellwig Reviewed-by: Hannes Reinecke --- drivers/block/null_blk/main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index f128242d1170..187d779c8ca0 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -1717,8 +1717,7 @@ static int null_gendisk_register(struct nullb *nullb) return ret; } - add_disk(disk); - return 0; + return add_disk(disk); } static int null_init_tag_set(struct nullb *nullb, struct blk_mq_tag_set *set)