Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3437598pxa; Tue, 25 Aug 2020 23:34:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzR9bq+BbjMQTIFeMDF2KZZoqLH5a6O7SFou1vdoVedMXofHk71M+7SY0KP7K2Z29YyEMXo X-Received: by 2002:a50:fd94:: with SMTP id o20mr10319278edt.357.1598423687748; Tue, 25 Aug 2020 23:34:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598423687; cv=none; d=google.com; s=arc-20160816; b=cfYGpGqKsNCmmEgx3W6NFGOOfn4dmMYGdSpi7c0/Ebkr7I5lN3I6MRDgZlPAvXx2Ds Qur6ZKno7sLsqq7/jM5BisD1YbC6xMzUVan9NnjG5Ym3UmB5/MXJoiKOOLD70FmCm3hq K0bHbxWfTQBwVYUHoGys+Y7H0mwOm8akIf5FyYHJJI+/FqhvmkfC3tYqtrqvleuMCJ31 rCoWrL2WDqFSe63kwJ8ighKHgXdZNNR+9r3xtCU+cJToAAxfDhiyJQILk9Ar6UQSl8qi zD+eBghyABpmR3f4u3hJoDra1EyJ5wpbj8UxyFNLCrxTXnJBwB7I9e3z7fvCNezGkf1X zt1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BQ4CpzfWadwZaE1eVDKbctMggquiS6KqfZ6j9IqjVrY=; b=Z1pk0t6lqm7xMTZXjcc/jhjkK3j8MnGd3WDXCwqTMEDMhbCA449dtQ5rtHlsZVsa/1 K+SDyBxNmEk0tvENyutdzTc5nBT1vy4glYjMBbaWeGWtsmd3zHqIIvkGXgFAhag1SxYx WdekH6haea5DYgLEyJ1HlHYeK4A4SBAm00dZKe3kMVBt2ujZEq2F7apa7bpwel8Zok9r 8Ftwo35CYeB4L6/mFIUv8e4zCM6dCYbFpUok5GF3EI4qAsnx0rTdiqzK3vrtz0JU1CHi Y/zW9jBW50DokceBtJy7vspRPIctDNeOLwnDMwmwuGjIUc2MrVtYiWmDfSZ/gYAmH1EH N/Hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=hJ7usYVt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w13si852546edt.439.2020.08.25.23.34.24; Tue, 25 Aug 2020 23:34:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=hJ7usYVt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726730AbgHZGdi (ORCPT + 99 others); Wed, 26 Aug 2020 02:33:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726186AbgHZGdi (ORCPT ); Wed, 26 Aug 2020 02:33:38 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2E6CC061574; Tue, 25 Aug 2020 23:33:37 -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=BQ4CpzfWadwZaE1eVDKbctMggquiS6KqfZ6j9IqjVrY=; b=hJ7usYVtBMK1Utl0NhqloD27al wRs+XR6pFpF4xRObEsxz4gmW1UWfEXF9PcUEsOS3KUumK17uZnxY/xwdTkSG3k+37tH1LQgHgbGgU y3NENpeUmn587R/DgaqpHlHQBnK2AC800feAkM4YbK2TpzeyFKfFbXT5IluFMTQ5Hi9p2O9u4m1Eh AD5PrxrECjMWSyId6MkqZ7TFwv6XNUjghCEf7LgcoHnlLC83QK+N/TwX7aF3DPkHQYwkNh3Egt5pP xIlpeQyhiE1ii18RhhFXfSVz6klFMLL5M9phXtn986IMaBslzyeaMHPAyTn5w7JRcmXLOJavGtzDV VfxR7esw==; Received: from 213-225-6-196.nat.highway.a1.net ([213.225.6.196] helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kAozy-0001AA-Vy; Wed, 26 Aug 2020 06:33:31 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Denis Efremov , "David S. Miller" , Song Liu , Al Viro , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-ide@vger.kernel.org, linux-raid@vger.kernel.org, linux-scsi@vger.kernel.org, linux-m68k@lists.linux-m68k.org Subject: [PATCH 03/19] block: cleanup del_gendisk a bit Date: Wed, 26 Aug 2020 08:24:30 +0200 Message-Id: <20200826062446.31860-4-hch@lst.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200826062446.31860-1-hch@lst.de> References: <20200826062446.31860-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Merge three hidden gendisk checks into one. Signed-off-by: Christoph Hellwig --- block/genhd.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/block/genhd.c b/block/genhd.c index cb9a51be35b053..df6485223a2c3d 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -973,22 +973,22 @@ void del_gendisk(struct gendisk *disk) disk->flags &= ~GENHD_FL_UP; up_write(&disk->lookup_sem); - if (!(disk->flags & GENHD_FL_HIDDEN)) + WARN_ON(!disk->queue); + + if (!(disk->flags & GENHD_FL_HIDDEN)) { sysfs_remove_link(&disk_to_dev(disk)->kobj, "bdi"); - if (disk->queue) { + /* * Unregister bdi before releasing device numbers (as they can * get reused and we'd get clashes in sysfs). */ - if (!(disk->flags & GENHD_FL_HIDDEN)) - bdi_unregister(disk->queue->backing_dev_info); + bdi_unregister(disk->queue->backing_dev_info); blk_unregister_queue(disk); + blk_unregister_region(disk_devt(disk), disk->minors); } else { - WARN_ON(1); + blk_unregister_queue(disk); } - if (!(disk->flags & GENHD_FL_HIDDEN)) - blk_unregister_region(disk_devt(disk), disk->minors); /* * Remove gendisk pointer from idr so that it cannot be looked up * while RCU period before freeing gendisk is running to prevent -- 2.28.0