Bug 4688

Summary: CD devices have their capacity set incorrectly, preventing reading of large dvd's
Product: IO/Storage Reporter: Chuck Williams (chuck)
Component: Block LayerAssignee: Jens Axboe (axboe)
Status: REJECTED INSUFFICIENT_DATA    
Severity: high CC: alexn, bunk
Priority: P2    
Hardware: i386   
OS: Linux   
Kernel Version: 2.6.12rc2 Subsystem:
Regression: --- Bisected commit-id:

Description Chuck Williams 2005-05-30 11:49:26 UTC
Distribution:  Debian
Hardware Environment:  i386 with cd/dvd combo drive
Software Environment:  Nothing extra required
Problem Description:  The capacity of a cd/dvd drive can be set incorrectly to a
low value, which prevents reading blocks at addresses above this value on large
dvd's.  When setting the capacity, ide-cd.c hard-codes the limit to 0x1fffff (on
line 2233) if there is no media in the drive.  This limit is too small for large
dvd's.

Steps to reproduce:  Boot Linux with no media in a cd/dvd drive, then later
mount the drive with a large data dvd and attempt to read files at block
addresses above ox1fffff.

Patches and Workarounds:  I worked around this problem by booting Linux with a
large dvd in the drive.  This sets the capacity large enough at least for this
dvd.  Also, I found an analysis and possible patch to correct the problem on the
Suse list.  The patch changes block_dev.c to always reset the drive capacity in
do_open():

Posting:  http://lists.suse.com/archive/packet-writing/2004-Dec/0023.html
Patch proposed by posting:

--- linux/fs/block_dev.c.orig 2004-12-25 08:26:10.000000000 +0000
+++ linux/fs/block_dev.c 2004-12-31 17:24:12.000000000 +0000
@@ -630,6 +630,7 @@
                                if (ret)
                                        goto out;
                        }
+ bd_set_size(bdev,(loff_t)get_capacity(disk)<<9);
                        if (bdev->bd_invalidated)
                                rescan_partitions(bdev->bd_disk, bdev);
                } else {

I have not independently tried this patch, although it seems it would be a
correct solution.
Comment 1 Alexander Nyberg 2005-05-30 14:47:28 UTC
Please check if this problem is still in 2.6.12-rc5 and if it is mail this whole
thing to axboe@suse.de and CC linux-kernel@vger.kernel.org
Comment 2 Adrian Bunk 2006-03-05 04:29:32 UTC
I'm assuiming this issue is already fixed.

Please reopen this bug if it's still present in recent 2.6 kernels.