Commit 5915136d authored by Tejun Heo's avatar Tejun Heo Committed by James Bottomley

[SCSI] sr: consider the last written sector when determining media size

On certain cases, UDF disc doesn't report capacity correctly via
READ_CAPACITY but TOC or trackinfo contains valid information which
can be obtained using cdrom_get_last_written().  ide-cd considers both
values and uses the larger one.  Do the same in sr.  This fixes
bko#9668.

 http://bugzilla.kernel.org/show_bug.cgi?id=9668Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Reported-by: default avatarMilan Kocian <milan.kocian@wq.cz>
Cc: Jan Kara <jack@suse.cz>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
parent 53203244
...@@ -684,14 +684,20 @@ static void get_sectorsize(struct scsi_cd *cd) ...@@ -684,14 +684,20 @@ static void get_sectorsize(struct scsi_cd *cd)
cd->capacity = 0x1fffff; cd->capacity = 0x1fffff;
sector_size = 2048; /* A guess, just in case */ sector_size = 2048; /* A guess, just in case */
} else { } else {
#if 0 long last_written;
if (cdrom_get_last_written(&cd->cdi,
&cd->capacity)) cd->capacity = 1 + ((buffer[0] << 24) | (buffer[1] << 16) |
#endif (buffer[2] << 8) | buffer[3]);
cd->capacity = 1 + ((buffer[0] << 24) | /*
(buffer[1] << 16) | * READ_CAPACITY doesn't return the correct size on
(buffer[2] << 8) | * certain UDF media. If last_written is larger, use
buffer[3]); * it instead.
*
* http://bugzilla.kernel.org/show_bug.cgi?id=9668
*/
if (!cdrom_get_last_written(&cd->cdi, &last_written))
cd->capacity = max_t(long, cd->capacity, last_written);
sector_size = (buffer[4] << 24) | sector_size = (buffer[4] << 24) |
(buffer[5] << 16) | (buffer[6] << 8) | buffer[7]; (buffer[5] << 16) | (buffer[6] << 8) | buffer[7];
switch (sector_size) { switch (sector_size) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment