diff options
author | Tejun Heo <tj@kernel.org> | 2009-09-03 22:38:02 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2009-10-02 10:45:46 -0400 |
commit | 5915136d4d3954867cced8a2297bddd16caf36a1 (patch) | |
tree | 4aa0480c498d16db22874c0e6c3cbf7746e23187 /drivers/scsi/sr.c | |
parent | 53203244a4f9988f132ef481867ff47d6bd055b5 (diff) |
[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=9668
Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: Milan Kocian <milan.kocian@wq.cz>
Cc: Jan Kara <jack@suse.cz>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi/sr.c')
-rw-r--r-- | drivers/scsi/sr.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index eb61f7a70e1d..d6f340f48a3b 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c | |||
@@ -684,14 +684,20 @@ static void get_sectorsize(struct scsi_cd *cd) | |||
684 | cd->capacity = 0x1fffff; | 684 | cd->capacity = 0x1fffff; |
685 | sector_size = 2048; /* A guess, just in case */ | 685 | sector_size = 2048; /* A guess, just in case */ |
686 | } else { | 686 | } else { |
687 | #if 0 | 687 | long last_written; |
688 | if (cdrom_get_last_written(&cd->cdi, | 688 | |
689 | &cd->capacity)) | 689 | cd->capacity = 1 + ((buffer[0] << 24) | (buffer[1] << 16) | |
690 | #endif | 690 | (buffer[2] << 8) | buffer[3]); |
691 | cd->capacity = 1 + ((buffer[0] << 24) | | 691 | /* |
692 | (buffer[1] << 16) | | 692 | * READ_CAPACITY doesn't return the correct size on |
693 | (buffer[2] << 8) | | 693 | * certain UDF media. If last_written is larger, use |
694 | buffer[3]); | 694 | * it instead. |
695 | * | ||
696 | * http://bugzilla.kernel.org/show_bug.cgi?id=9668 | ||
697 | */ | ||
698 | if (!cdrom_get_last_written(&cd->cdi, &last_written)) | ||
699 | cd->capacity = max_t(long, cd->capacity, last_written); | ||
700 | |||
695 | sector_size = (buffer[4] << 24) | | 701 | sector_size = (buffer[4] << 24) | |
696 | (buffer[5] << 16) | (buffer[6] << 8) | buffer[7]; | 702 | (buffer[5] << 16) | (buffer[6] << 8) | buffer[7]; |
697 | switch (sector_size) { | 703 | switch (sector_size) { |