Disk size update on first open

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxx>
SUSE Labs, CR



[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux