Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp359571pxk; Thu, 3 Sep 2020 01:18:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwsEbBI5tIYPB+0JaHc9iZzbHSc4h2ahqdvWDSYSHmdiWtxldfvJ+164aU8cRSvoztey4e X-Received: by 2002:a17:906:2542:: with SMTP id j2mr915411ejb.442.1599121131602; Thu, 03 Sep 2020 01:18:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599121131; cv=none; d=google.com; s=arc-20160816; b=jQREsrNBgdZhwvivMsYup2An3URYDx1YE7ektqktzllhdQ6tqY1hNih8PQEawq/QnU 1c1d9tBY9L5YUkNGABKSi5GMPY/UTfnDb1yg6R9gW4pSuqsMucAolNV94jTJvzmyafP/ MAWMbFBbSOXTHvtqQOcOLhThjaYsQKo4Zc4Y1/vZYDWXb6vvPWRCMhXqdmpXpjFbQAu/ KpFg4cDHTPwwE6QtYOuem3+hz0XdOP2HQqdv3czwV2x2E5m7eUzjx2NEdn7m7BCVRiXA vz+yP2yXFpFeOuN/FXASzQJxxjVhyboGmtoLnqLk4Byeb2rXqfNsyGEWldW1nm1PeoVq SiYg== 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=XgwYo2Sg7gfnERWvC79K4ap0+DYU34E3F9ajl/LvCHY=; b=nzpP4QnL9iI58LZXlLcO1P3PPDnx12ZiBJJZUOq1QAXkZJmCp1pjs5sRULQ9K9WPqn dksxtvYazyhwu4m9zf1E7FqMv2bhYpr5J/qqNuCEPQC+GvfC5xj9pMJzhq/q8qLFsw1k zFzdM50c/IkdEQ5SlM514yhRTurWBpaXhX/Se+09h++rhAyZ0oGdGVSdl+TlK5zsOT9h 5wBqfSLlvzeA+QMFzQVgYOrc6CH1yMqc+O6im0yqmb8VU2P+gVHziGL/Nuzj6/dI64zw PpjVuNTv5G3UoeJTW7iF3bUT4J5ofyn1YHhuzxJ//eYB4CpEb8cUUuCmnrtaTQCNSO7k /17g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=F820K3wr; 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 y25si1209545eds.168.2020.09.03.01.18.28; Thu, 03 Sep 2020 01:18:51 -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=F820K3wr; 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 S1728972AbgICIRO (ORCPT + 99 others); Thu, 3 Sep 2020 04:17:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727872AbgICIBd (ORCPT ); Thu, 3 Sep 2020 04:01:33 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95EB5C061247; Thu, 3 Sep 2020 01:01:32 -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=XgwYo2Sg7gfnERWvC79K4ap0+DYU34E3F9ajl/LvCHY=; b=F820K3wrYlVe1pAOZnsOECbEYY zVNZAQYiFPWwZ7O0vPXhKMaVEIfNpF0zFgmV6+2r+Hg4/4ARN45yTUKNM9sI68M0bXkMFzxMmkBy/ FMY+34FwLLkLmdstN37e4NFpsystC8kAfQeOivaOdutbLi0VMa9EIXAuJ9TgVcMDjSqTlGFwzR3IX fC9NvGxc2bG4sKkwo2B48rHoroBjeLPVz7IZ1lLq9nsTckShMQnnY2GYgLuDhtfBKUUJ06MFDBSd2 64fZXbhKJZc7vNeDbMRjiFLWUuWlPHoUJJsi5SAtGtb1UMc8pLdM/C8ZtCKmRl1IIChh/4inRVqUp yDMbVSxw==; Received: from [2001:4bb8:184:af1:c70:4a89:bc61:2] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kDkBQ-0006aB-7k; Thu, 03 Sep 2020 08:01:24 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Denis Efremov , "David S. Miller" , Song Liu , Al Viro , Finn Thain , Michael Schmitz , 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: Thu, 3 Sep 2020 10:01:03 +0200 Message-Id: <20200903080119.441674-4-hch@lst.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200903080119.441674-1-hch@lst.de> References: <20200903080119.441674-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 | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/block/genhd.c b/block/genhd.c index 44f69f4b2c5aa6..ec9b64207d9c2e 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -948,6 +948,9 @@ void del_gendisk(struct gendisk *disk) might_sleep(); + if (WARN_ON_ONCE(!disk->queue)) + return; + blk_integrity_del(disk); disk_del_events(disk); @@ -970,20 +973,18 @@ void del_gendisk(struct gendisk *disk) disk->flags &= ~GENHD_FL_UP; up_write(&disk->lookup_sem); - if (!(disk->flags & GENHD_FL_HIDDEN)) + 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); - blk_unregister_queue(disk); - } else { - WARN_ON(1); + bdi_unregister(disk->queue->backing_dev_info); } + blk_unregister_queue(disk); + if (!(disk->flags & GENHD_FL_HIDDEN)) blk_unregister_region(disk_devt(disk), disk->minors); /* -- 2.28.0