mbox series

[0/2] bdev: Refresh bdev size for disks without partitioning

Message ID 20191021083132.5351-1-jack@suse.cz (mailing list archive)
Headers show
Series bdev: Refresh bdev size for disks without partitioning | expand

Message

Jan Kara Oct. 21, 2019, 8:37 a.m. UTC
Hello,

I've been debugging for quite a long time strange issues with encrypted DVDs
not being readable on Linux (bko#194965). In the end I've tracked down the
problem to the fact that block device size is not updated when the media is
inserted in case the DVD device is already open. This is IMO a bug in block
device code as the size gets properly update in case the device has partition
scanning enabled.  The following series fixes the problem by refreshing disk
size on each open even for devices with partition scanning disabled.

								Honza

Comments

Jens Axboe Nov. 3, 2019, 2:53 p.m. UTC | #1
On 10/21/19 2:37 AM, Jan Kara wrote:
> Hello,
> 
> I've been debugging for quite a long time strange issues with encrypted DVDs
> not being readable on Linux (bko#194965). In the end I've tracked down the
> problem to the fact that block device size is not updated when the media is
> inserted in case the DVD device is already open. This is IMO a bug in block
> device code as the size gets properly update in case the device has partition
> scanning enabled.  The following series fixes the problem by refreshing disk
> size on each open even for devices with partition scanning disabled.

It's really confusing to have different behavior for partition vs whole device.
This series looks good to me, the size change code is really hard to follow.

I don't see any serious objections here, I'm going to queue this up for
5.4.
Jan Kara Nov. 4, 2019, 8:08 a.m. UTC | #2
On Sun 03-11-19 07:53:10, Jens Axboe wrote:
> On 10/21/19 2:37 AM, Jan Kara wrote:
> > Hello,
> > 
> > I've been debugging for quite a long time strange issues with encrypted DVDs
> > not being readable on Linux (bko#194965). In the end I've tracked down the
> > problem to the fact that block device size is not updated when the media is
> > inserted in case the DVD device is already open. This is IMO a bug in block
> > device code as the size gets properly update in case the device has partition
> > scanning enabled.  The following series fixes the problem by refreshing disk
> > size on each open even for devices with partition scanning disabled.
> 
> It's really confusing to have different behavior for partition vs whole device.
> This series looks good to me, the size change code is really hard to follow.
> 
> I don't see any serious objections here, I'm going to queue this up for
> 5.4.

Thanks Jens! I'll look into refactoring the size change / revalidation code
so that it's easier to understand what's going on...

								Honza
Christoph Hellwig Nov. 4, 2019, 11:48 p.m. UTC | #3
On Mon, Nov 04, 2019 at 09:08:47AM +0100, Jan Kara wrote:
> Thanks Jens! I'll look into refactoring the size change / revalidation code
> so that it's easier to understand what's going on...

I actualy have a series for this.  I've started rebasing it on top
of you work and will need to do some testing.  My current WIP is here:

http://git.infradead.org/users/hch/block.git/shortlog/refs/heads/partition-cleanup
Jan Kara Nov. 5, 2019, 8:59 a.m. UTC | #4
On Mon 04-11-19 15:48:41, Christoph Hellwig wrote:
> On Mon, Nov 04, 2019 at 09:08:47AM +0100, Jan Kara wrote:
> > Thanks Jens! I'll look into refactoring the size change / revalidation code
> > so that it's easier to understand what's going on...
> 
> I actualy have a series for this.  I've started rebasing it on top
> of you work and will need to do some testing.  My current WIP is here:
> 
> http://git.infradead.org/users/hch/block.git/shortlog/refs/heads/partition-cleanup

Cool. Thanks for that! Skimming over the series it looks good to me. The
only remaining thing I wanted to look into is bdev->bd_invalidated
handling. Because the only thing it actually indicates in practice is that
DISK_EVENT_MEDIA_CHANGE was set in check_disk_change(). All the other call
chains end up clearing bdev->bd_invalidated before it has any effect. And
that just looks very cryptic to me... So my plan was to at least move the
setting of bdev->bd_invalidated to check_disk_change() and rename it to
something saner if I cannot come up with anything better for propagating
the information from check_disk_change() to __blkdev_get().

								Honza