linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luis Chamberlain <mcgrof@kernel.org>
To: axboe@kernel.dk
Cc: hare@suse.de, bvanassche@acm.org, ming.lei@redhat.com,
	hch@infradead.org, jack@suse.cz, osandov@fb.com,
	linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
	Luis Chamberlain <mcgrof@kernel.org>
Subject: [RFC 6/6] fs/block_dev: replace GENHD_FL_UP with GENHD_FL_DISK_ADDED
Date: Thu, 15 Jul 2021 13:23:41 -0700	[thread overview]
Message-ID: <20210715202341.2016612-7-mcgrof@kernel.org> (raw)
In-Reply-To: <20210715202341.2016612-1-mcgrof@kernel.org>

The GENHD_FL_DISK_ADDED flag is what we really want, as the
flag GENHD_FL_UP could be set on a semi-initialized device.

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 fs/block_dev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/block_dev.c b/fs/block_dev.c
index 0c424a0cadaa..c41d0e550d39 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1338,7 +1338,8 @@ struct block_device *blkdev_get_no_open(dev_t dev)
 	disk = bdev->bd_disk;
 	if (!kobject_get_unless_zero(&disk_to_dev(disk)->kobj))
 		goto bdput;
-	if ((disk->flags & (GENHD_FL_UP | GENHD_FL_HIDDEN)) != GENHD_FL_UP)
+	if ((disk->flags &
+	    (GENHD_FL_DISK_ADDED | GENHD_FL_HIDDEN)) != GENHD_FL_DISK_ADDED)
 		goto put_disk;
 	if (!try_module_get(bdev->bd_disk->fops->owner))
 		goto put_disk;
@@ -1407,7 +1408,7 @@ struct block_device *blkdev_get_by_dev(dev_t dev, fmode_t mode, void *holder)
 
 	mutex_lock(&disk->open_mutex);
 	ret = -ENXIO;
-	if (!(disk->flags & GENHD_FL_UP))
+	if (!(disk->flags & GENHD_FL_DISK_ADDED))
 		goto abort_claiming;
 	if (bdev_is_partition(bdev))
 		ret = blkdev_get_part(bdev, mode);
-- 
2.27.0


  parent reply	other threads:[~2021-07-15 20:24 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-15 20:23 [RFC 0/6] block: enhance use of GENHD_FL_UP Luis Chamberlain
2021-07-15 20:23 ` [RFC 1/6] genhd: update docs for GENHD_FL_UP Luis Chamberlain
2021-07-16  5:50   ` Hannes Reinecke
2021-07-19  9:52   ` Christoph Hellwig
2021-07-15 20:23 ` [RFC 2/6] block: add flag for add_disk() completion notation Luis Chamberlain
2021-07-16  5:49   ` Hannes Reinecke
2021-07-16 20:00     ` Luis Chamberlain
2021-07-19 10:00   ` Christoph Hellwig
2021-07-19 22:38     ` Luis Chamberlain
2021-07-15 20:23 ` [RFC 3/6] md: replace GENHD_FL_UP with GENHD_FL_DISK_ADDED on is_mddev_broken() Luis Chamberlain
2021-07-16  5:51   ` Hannes Reinecke
2021-07-16 20:02     ` Luis Chamberlain
2021-07-28 19:20   ` Guilherme G. Piccoli
2021-07-15 20:23 ` [RFC 4/6] mmc/core/block: replace GENHD_FL_UP with GENHD_FL_DISK_ADDED Luis Chamberlain
2021-07-16  5:51   ` Hannes Reinecke
2021-07-15 20:23 ` [RFC 5/6] nvme: " Luis Chamberlain
2021-07-16  5:53   ` Hannes Reinecke
2021-07-15 20:23 ` Luis Chamberlain [this message]
2021-07-19  9:56 ` [RFC 0/6] block: enhance use of GENHD_FL_UP Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210715202341.2016612-7-mcgrof@kernel.org \
    --to=mcgrof@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=hare@suse.de \
    --cc=hch@infradead.org \
    --cc=jack@suse.cz \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=osandov@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).