]>
Commit | Line | Data |
---|---|---|
cd378b7b GKH |
1 | From stable-bounces@linux.kernel.org Wed Jun 18 16:15:38 2008 |
2 | From: James Bottomley <James.Bottomley@HansenPartnership.com> | |
3 | Date: Wed, 18 Jun 2008 23:15:14 GMT | |
4 | Subject: SCSI: sr: fix corrupt CD data after media change and delay | |
5 | To: jejb@kernel.org, stable@kernel.org | |
6 | Message-ID: <200806182315.m5INFEvO031323@hera.kernel.org> | |
7 | ||
8 | From: James Bottomley <James.Bottomley@HansenPartnership.com> | |
9 | ||
10 | commit: d1daeabf0da5bfa1943272ce508e2ba785730bf0 upstream | |
11 | ||
12 | Reported-by: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com> | |
13 | ||
14 | If you delay 30s or more before mounting a CD after inserting it then | |
15 | the kernel has the wrong value for the CD size. | |
16 | ||
17 | http://marc.info/?t=121276133000001 | |
18 | ||
19 | The problem is in sr_test_unit_ready(): the function eats unit | |
20 | attentions without adjusting the sdev->changed status. This means | |
21 | that when the CD signals changed media via unit attention, we can | |
22 | ignore it. Fix by making sr_test_unit_ready() adjust the changed | |
23 | status. | |
24 | ||
25 | Reported-by: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com> | |
26 | Tested-by: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com> | |
27 | Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com> | |
28 | Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> | |
29 | ||
30 | --- | |
31 | drivers/scsi/sr.c | 3 +++ | |
32 | 1 file changed, 3 insertions(+) | |
33 | ||
34 | --- a/drivers/scsi/sr.c | |
35 | +++ b/drivers/scsi/sr.c | |
36 | @@ -178,6 +178,9 @@ int sr_test_unit_ready(struct scsi_devic | |
37 | the_result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, | |
38 | 0, sshdr, SR_TIMEOUT, | |
39 | retries--); | |
40 | + if (scsi_sense_valid(sshdr) && | |
41 | + sshdr->sense_key == UNIT_ATTENTION) | |
42 | + sdev->changed = 1; | |
43 | ||
44 | } while (retries > 0 && | |
45 | (!scsi_status_is_good(the_result) || |