From: Jan Kara <jack@suse.cz>
To: Jens Axboe <axboe@kernel.dk>
Cc: <linux-block@vger.kernel.org>, Jan Kara <jack@suse.cz>
Subject: [PATCH 1/2] bdev: Factor out bdev revalidation into a common helper
Date: Mon, 21 Oct 2019 10:37:59 +0200 [thread overview]
Message-ID: <20191021083808.19335-1-jack@suse.cz> (raw)
In-Reply-To: <20191021083132.5351-1-jack@suse.cz>
Factor out code handling revalidation of bdev on disk change into a
common helper.
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/block_dev.c | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 9c073dbdc1b0..88c6d35ec71d 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1512,6 +1512,14 @@ EXPORT_SYMBOL(bd_set_size);
static void __blkdev_put(struct block_device *bdev, fmode_t mode, int for_part);
+static void bdev_disk_changed(struct block_device *bdev, bool invalidate)
+{
+ if (invalidate)
+ invalidate_partitions(bdev->bd_disk, bdev);
+ else
+ rescan_partitions(bdev->bd_disk, bdev);
+}
+
/*
* bd_mutex locking:
*
@@ -1594,12 +1602,9 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
* The latter is necessary to prevent ghost
* partitions on a removed medium.
*/
- if (bdev->bd_invalidated) {
- if (!ret)
- rescan_partitions(disk, bdev);
- else if (ret == -ENOMEDIUM)
- invalidate_partitions(disk, bdev);
- }
+ if (bdev->bd_invalidated &&
+ (!ret || ret == -ENOMEDIUM))
+ bdev_disk_changed(bdev, ret == -ENOMEDIUM);
if (ret)
goto out_clear;
@@ -1632,12 +1637,9 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
if (bdev->bd_disk->fops->open)
ret = bdev->bd_disk->fops->open(bdev, mode);
/* the same as first opener case, read comment there */
- if (bdev->bd_invalidated) {
- if (!ret)
- rescan_partitions(bdev->bd_disk, bdev);
- else if (ret == -ENOMEDIUM)
- invalidate_partitions(bdev->bd_disk, bdev);
- }
+ if (bdev->bd_invalidated &&
+ (!ret || ret == -ENOMEDIUM))
+ bdev_disk_changed(bdev, ret == -ENOMEDIUM);
if (ret)
goto out_unlock_bdev;
}
--
2.16.4
next prev parent reply other threads:[~2019-10-21 8:38 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-21 8:37 [PATCH 0/2] bdev: Refresh bdev size for disks without partitioning Jan Kara
2019-10-21 8:37 ` Jan Kara [this message]
2019-10-22 7:58 ` [PATCH 1/2] bdev: Factor out bdev revalidation into a common helper Damien Le Moal
2019-10-22 9:15 ` Jan Kara
2019-10-22 9:31 ` Damien Le Moal
2019-10-21 8:38 ` [PATCH 2/2] bdev: Refresh bdev size for disks without partitioning Jan Kara
2019-10-21 8:49 ` Guoqing Jiang
2019-10-21 9:12 ` Jan Kara
2019-10-21 9:27 ` Guoqing Jiang
2019-10-21 9:36 ` Johannes Thumshirn
2019-10-21 9:38 ` Guoqing Jiang
2019-10-21 9:40 ` Jan Kara
2019-10-21 9:43 ` Guoqing Jiang
2019-11-03 14:53 ` [PATCH 0/2] " Jens Axboe
2019-11-04 8:08 ` Jan Kara
2019-11-04 23:48 ` Christoph Hellwig
2019-11-05 8:59 ` Jan Kara
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=20191021083808.19335-1-jack@suse.cz \
--to=jack@suse.cz \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
/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).