linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Disk size update on first open
@ 2019-10-18  9:37 Jan Kara
  0 siblings, 0 replies; only message in thread
From: Jan Kara @ 2019-10-18  9:37 UTC (permalink / raw)
  To: linux-block; +Cc: Jens Axboe

Hello,

I have been debugging weird failures when using encrypted DVDs (bko#194965
for interested) but in the end it all boils down to the fact that
__blkdev_get() updates i_size of bdev inode only of the first open. This
seems as a sensible thing to do but there is some weird behavior resulting
out of this for devices with removable media:

1) If someone has the device (such as /dev/sr0) open while inserting the
media, bdev size will not get updated. This results in the media being
accessible but the device size is wrong resulting in weird and hard to
debug failures.

2) This is especially annoying when pktcdvd is in the game as pktcdvd
device holds corresponding sr device permanently open.

Upon some inspection this seems to be an issue with how check_disk_change()
(called from sr_block_open()) interacts with __blkdev_get(). If partition
scan is enabled, check_disk_change() will call flush_disk() which sets
bdev->bd_invalidated. And __blkdev_get() seeing bd_invalidated will call
rescan_partitions() which ends up updating bdev size through
check_disk_size_change(). But without partitioning none of this happens and
the disk size remains stale.

Now it seems strange that partitioned and unpartitioned devices behave
differently. So I'd be inclined to just unify the behavior and use
bd_invalidated for unpartitioned devices as well. Does anyone see a problem
with that?

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-10-18  9:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-18  9:37 Disk size update on first open Jan Kara

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).