From d1daeabf0da5bfa1943272ce508e2ba785730bf0 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Tue, 10 Jun 2008 10:20:53 -0500 Subject: [SCSI] sr: fix corrupt CD data after media change and delay Reported-by: Geert Uytterhoeven 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 Cc: Stable Tree Signed-off-by: James Bottomley --- drivers/scsi/sr.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers') diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index 7ee86d4a7618..c82df8bd4d89 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c @@ -178,6 +178,9 @@ int sr_test_unit_ready(struct scsi_device *sdev, struct scsi_sense_hdr *sshdr) the_result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, 0, sshdr, SR_TIMEOUT, retries--); + if (scsi_sense_valid(sshdr) && + sshdr->sense_key == UNIT_ATTENTION) + sdev->changed = 1; } while (retries > 0 && (!scsi_status_is_good(the_result) || -- cgit v1.2.3 From 3ed7897242b7efe977f3a8d06d4e5a4ebe28b10e Mon Sep 17 00:00:00 2001 From: Mike Christie Date: Wed, 11 Jun 2008 19:21:00 -0500 Subject: [SCSI] scsi_host regression: fix scsi host leak commit 9c7701088a61cc0cf8a6e1c68d1e74e3cc2ee0b7 Author: Dave Young Date: Tue Jan 22 14:01:34 2008 +0800 scsi: use class iteration api Isn't a correct replacement for the original hand rolled host lookup. The problem is that class_find_child would get a reference to the host's class device which is never released. Since the host class device holds a reference to the host gendev, the host can never be freed. In 2.6.26 we started using class_find_device, and this function also gets a reference to the device, so we end up with an extra ref and the host will not get released. This patch adds a put_device to balance the class_find_device() get. I kept the scsi_host_get in scsi_host_lookup, because the target layer is using scsi_host_lookup and it looks like it needs the SHOST_DEL check. Signed-off-by: Mike Christie Signed-off-by: James Bottomley --- drivers/scsi/hosts.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index 3690360d7a79..c6457bfc8a49 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c @@ -456,6 +456,10 @@ static int __scsi_host_match(struct device *dev, void *data) * * Return value: * A pointer to located Scsi_Host or NULL. + * + * The caller must do a scsi_host_put() to drop the reference + * that scsi_host_get() took. The put_device() below dropped + * the reference from class_find_device(). **/ struct Scsi_Host *scsi_host_lookup(unsigned short hostnum) { @@ -463,9 +467,10 @@ struct Scsi_Host *scsi_host_lookup(unsigned short hostnum) struct Scsi_Host *shost = ERR_PTR(-ENXIO); cdev = class_find_device(&shost_class, &hostnum, __scsi_host_match); - if (cdev) + if (cdev) { shost = scsi_host_get(class_to_shost(cdev)); - + put_device(cdev); + } return shost; } EXPORT_SYMBOL(scsi_host_lookup); -- cgit v1.2.3 From f93daa3f7ff4f0cc13acc7452a00feb1c586102a Mon Sep 17 00:00:00 2001 From: Jeff Mahoney Date: Fri, 13 Jun 2008 10:38:00 -0400 Subject: [SCSI] dpt_i2o: Add PROC_IA64 define This fixes the following compile failure: drivers/scsi/dpt_i2o.c:83: error: 'PROC_IA64' undeclared here (not in a function) Mark Salyzyn indicated that IA64 must report itself as PROC_INTEL, so I've changed the comment for PROC_INTEL. Signed-off-by: Jeff Mahoney Acked-by: Mark Salyzyn Signed-off-by: James Bottomley --- drivers/scsi/dpt/dptsig.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/scsi/dpt/dptsig.h b/drivers/scsi/dpt/dptsig.h index 72c8992fdf21..a6644b332b53 100644 --- a/drivers/scsi/dpt/dptsig.h +++ b/drivers/scsi/dpt/dptsig.h @@ -85,7 +85,7 @@ typedef unsigned int sigINT; /* ------------------------------------------------------------------ */ /* What type of processor the file is meant to run on. */ /* This will let us know whether to read sigWORDs as high/low or low/high. */ -#define PROC_INTEL 0x00 /* Intel 80x86 */ +#define PROC_INTEL 0x00 /* Intel 80x86/ia64 */ #define PROC_MOTOROLA 0x01 /* Motorola 68K */ #define PROC_MIPS4000 0x02 /* MIPS RISC 4000 */ #define PROC_ALPHA 0x03 /* DEC Alpha */ @@ -104,6 +104,7 @@ typedef unsigned int sigINT; #define PROC_486 0x08 /* Intel 80486 */ #define PROC_PENTIUM 0x10 /* Intel 586 aka P5 aka Pentium */ #define PROC_SEXIUM 0x20 /* Intel 686 aka P6 aka Pentium Pro or MMX */ +#define PROC_IA64 0x40 /* Intel IA64 processor */ /* PROC_i960: */ #define PROC_960RX 0x01 /* Intel 80960RC/RD */ -- cgit v1.2.3