Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[SCSI] sr: fix corrupt CD data after media change and delay

Reported-by: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>

If you delay 30s or more before mounting a CD after inserting it then
the kernel has the wrong value for the CD size.

http://marc.info/?t=121276133000001

The problem is in sr_test_unit_ready(): the function eats unit
attentions without adjusting the sdev->changed status. This means
that when the CD signals changed media via unit attention, we can
ignore it. Fix by making sr_test_unit_ready() adjust the changed
status.

Tested-by: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
Cc: Stable Tree <stable@kernel.org>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>

+3
+3
drivers/scsi/sr.c
··· 178 178 the_result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, 179 179 0, sshdr, SR_TIMEOUT, 180 180 retries--); 181 + if (scsi_sense_valid(sshdr) && 182 + sshdr->sense_key == UNIT_ATTENTION) 183 + sdev->changed = 1; 181 184 182 185 } while (retries > 0 && 183 186 (!scsi_status_is_good(the_result) ||