提交 32c356d7 编写于 作者: J James Bottomley

[SCSI] fix removable device inability to detect disk changes

On Tue, 12 Aug 2008 15:08:14 +0200
Giuliano Pochini <pochini@shiny.it> wrote:

> Fujitsu magneto-optical drive, Adaptec 29160 and
> Linux Jay 2.6.26 #7 SMP Sun Aug 10 18:34:22 CEST 2008 ppc 7455, altivec supported PowerMac3,6 GNU/Linux
>
> When I insert a disk and I mount it, scsi_test_unit_ready() is called and
> the do-while loop gets sshdr->sense_key == UNIT_ATTENTION in the first
> cycle and 0 in the second one. So the if below misses the UNIT_ATTENTION
> and sdev->changed = 1 is not executed. At this point bad things can
> happen... I'm not sure how to fix this. Any clue ?

The problem is essentially caused by us eating UNIT_ATTENTION
conditions in scsi_test_unit_ready().  Fix by updating the ->changed
flag when this happens if the media is removable.

[pochini@shiny.it: updates to tidy up patch]
Signed-off-by: NGiuliano Pochini <pochini@shiny.it>
Signed-off-by: NJames Bottomley <James.Bottomley@HansenPartnership.com>
上级 26e9a397
...@@ -2105,23 +2105,22 @@ scsi_test_unit_ready(struct scsi_device *sdev, int timeout, int retries, ...@@ -2105,23 +2105,22 @@ scsi_test_unit_ready(struct scsi_device *sdev, int timeout, int retries,
do { do {
result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, 0, sshdr, result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, 0, sshdr,
timeout, retries); timeout, retries);
} while ((driver_byte(result) & DRIVER_SENSE) && if (sdev->removable && scsi_sense_valid(sshdr) &&
sshdr && sshdr->sense_key == UNIT_ATTENTION && sshdr->sense_key == UNIT_ATTENTION)
--retries); sdev->changed = 1;
} while (scsi_sense_valid(sshdr) &&
sshdr->sense_key == UNIT_ATTENTION && --retries);
if (!sshdr) if (!sshdr)
/* could not allocate sense buffer, so can't process it */ /* could not allocate sense buffer, so can't process it */
return result; return result;
if ((driver_byte(result) & DRIVER_SENSE) && sdev->removable) { if (sdev->removable && scsi_sense_valid(sshdr) &&
(sshdr->sense_key == UNIT_ATTENTION ||
if ((scsi_sense_valid(sshdr)) && sshdr->sense_key == NOT_READY)) {
((sshdr->sense_key == UNIT_ATTENTION) ||
(sshdr->sense_key == NOT_READY))) {
sdev->changed = 1; sdev->changed = 1;
result = 0; result = 0;
} }
}
if (!sshdr_external) if (!sshdr_external)
kfree(sshdr); kfree(sshdr);
return result; return result;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册