From: Guoqing Jiang <guoqing.jiang@cloud.ionos.com>
To: Jan Kara <jack@suse.cz>, Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org
Subject: Re: [PATCH 2/2] bdev: Refresh bdev size for disks without partitioning
Date: Mon, 21 Oct 2019 10:49:54 +0200 [thread overview]
Message-ID: <4d58a159-e935-1200-1a71-8eb252fc5bdc@cloud.ionos.com> (raw)
In-Reply-To: <20191021083808.19335-2-jack@suse.cz>
On 10/21/19 10:38 AM, Jan Kara wrote:
> Currently, block device size in not updated on second and further open
> for block devices where partition scan is disabled. This is particularly
> annoying for example for DVD drives as that means block device size does
> not get updated once the media is inserted into a drive if the device is
> already open when inserting the media. This is actually always the case
> for example when pktcdvd is in use.
>
> Fix the problem by revalidating block device size on every open even for
> devices with partition scan disabled.
>
> Signed-off-by: Jan Kara <jack@suse.cz>
> ---
> fs/block_dev.c | 19 ++++++++++---------
> 1 file changed, 10 insertions(+), 9 deletions(-)
>
> diff --git a/fs/block_dev.c b/fs/block_dev.c
> index 88c6d35ec71d..d612468ee66b 100644
> --- a/fs/block_dev.c
> +++ b/fs/block_dev.c
> @@ -1403,11 +1403,7 @@ static void flush_disk(struct block_device *bdev, bool kill_dirty)
> "resized disk %s\n",
> bdev->bd_disk ? bdev->bd_disk->disk_name : "");
> }
> -
> - if (!bdev->bd_disk)
> - return;
> - if (disk_part_scan_enabled(bdev->bd_disk))
> - bdev->bd_invalidated = 1;
> + bdev->bd_invalidated = 1;
> }
>
> /**
> @@ -1514,10 +1510,15 @@ 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);
> + if (disk_part_scan_enabled(bdev->bd_disk)) {
> + if (invalidate)
> + invalidate_partitions(bdev->bd_disk, bdev);
> + else
> + rescan_partitions(bdev->bd_disk, bdev);
Maybe use the new common helper to replace above.
Thanks,
Guoqing
> + } else {
> + check_disk_size_change(bdev->bd_disk, bdev, !invalidate);
> + bdev->bd_invalidated = 0;
> + }
> }
>
> /*
next prev parent reply other threads:[~2019-10-21 8:49 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 ` [PATCH 1/2] bdev: Factor out bdev revalidation into a common helper Jan Kara
2019-10-22 7:58 ` 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 [this message]
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=4d58a159-e935-1200-1a71-8eb252fc5bdc@cloud.ionos.com \
--to=guoqing.jiang@cloud.ionos.com \
--cc=axboe@kernel.dk \
--cc=jack@suse.cz \
--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).