Commit 5915136d4d3954867cced8a2297bddd16caf36a1
Committed by
James Bottomley
1 parent
53203244a4
Exists in
master
and in
7 other branches
[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>
Showing 1 changed file with 14 additions and 8 deletions Side-by-side Diff
drivers/scsi/sr.c
... | ... | @@ -684,14 +684,20 @@ |
684 | 684 | cd->capacity = 0x1fffff; |
685 | 685 | sector_size = 2048; /* A guess, just in case */ |
686 | 686 | } else { |
687 | -#if 0 | |
688 | - if (cdrom_get_last_written(&cd->cdi, | |
689 | - &cd->capacity)) | |
690 | -#endif | |
691 | - cd->capacity = 1 + ((buffer[0] << 24) | | |
692 | - (buffer[1] << 16) | | |
693 | - (buffer[2] << 8) | | |
694 | - buffer[3]); | |
687 | + long last_written; | |
688 | + | |
689 | + cd->capacity = 1 + ((buffer[0] << 24) | (buffer[1] << 16) | | |
690 | + (buffer[2] << 8) | buffer[3]); | |
691 | + /* | |
692 | + * READ_CAPACITY doesn't return the correct size on | |
693 | + * certain UDF media. If last_written is larger, use | |
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 | 701 | sector_size = (buffer[4] << 24) | |
696 | 702 | (buffer[5] << 16) | (buffer[6] << 8) | buffer[7]; |
697 | 703 | switch (sector_size) { |