[RESEND][PATCH 2/8][SCSI] mpt2sas : Fix for issue Missing delay not getting set during system bootup

2013-02-01 Thread Sreekanth Reddy
Missing delay is not getting set properly. The reason is it is not defined in 
the same file from where it is being invoked.

The fix is to move the missing delay module parameter from mpt2sas_base.c to 
mpt2sas_scsh.c.

Signed-off-by: Sreekanth Reddy 
Cc: sta...@vger.kernel.org
---  

diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.c 
b/drivers/scsi/mpt2sas/mpt2sas_base.c
index 0bb2b30..ce89b14 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_base.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_base.c
@@ -80,10 +80,6 @@ static int msix_disable = -1;
 module_param(msix_disable, int, 0);
 MODULE_PARM_DESC(msix_disable, " disable msix routed interrupts (default=0)");
 
-static int missing_delay[2] = {-1, -1};
-module_param_array(missing_delay, int, NULL, 0);
-MODULE_PARM_DESC(missing_delay, " device missing delay , io missing delay");
-
 static int mpt2sas_fwfault_debug;
 MODULE_PARM_DESC(mpt2sas_fwfault_debug, " enable detection of firmware fault "
"and halt firmware - (default=0)");
@@ -2183,7 +2179,7 @@ _base_display_ioc_capabilities(struct MPT2SAS_ADAPTER 
*ioc)
 }
 
 /**
- * _base_update_missing_delay - change the missing delay timers
+ * mpt2sas_base_update_missing_delay - change the missing delay timers
  * @ioc: per adapter object
  * @device_missing_delay: amount of time till device is reported missing
  * @io_missing_delay: interval IO is returned when there is a missing device
@@ -2194,8 +2190,8 @@ _base_display_ioc_capabilities(struct MPT2SAS_ADAPTER 
*ioc)
  * delay, as well as the io missing delay. This should be called at driver
  * load time.
  */
-static void
-_base_update_missing_delay(struct MPT2SAS_ADAPTER *ioc,
+void
+mpt2sas_base_update_missing_delay(struct MPT2SAS_ADAPTER *ioc,
u16 device_missing_delay, u8 io_missing_delay)
 {
u16 dmd, dmd_new, dmd_orignal;
@@ -4391,10 +4387,6 @@ mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc)
if (r)
goto out_free_resources;
 
-   if (missing_delay[0] != -1 && missing_delay[1] != -1)
-   _base_update_missing_delay(ioc, missing_delay[0],
-   missing_delay[1]);
-
return 0;
 
  out_free_resources:
diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.h 
b/drivers/scsi/mpt2sas/mpt2sas_base.h
index b46024c..ee7a030 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_base.h
+++ b/drivers/scsi/mpt2sas/mpt2sas_base.h
@@ -1054,6 +1054,9 @@ void mpt2sas_base_validate_event_type(struct 
MPT2SAS_ADAPTER *ioc, u32 *event_ty
 
 void mpt2sas_halt_firmware(struct MPT2SAS_ADAPTER *ioc);
 
+void mpt2sas_base_update_missing_delay(struct MPT2SAS_ADAPTER *ioc,
+   u16 device_missing_delay, u8 io_missing_delay);
+
 int mpt2sas_port_enable(struct MPT2SAS_ADAPTER *ioc);
 
 /* scsih shared API */
diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c 
b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
index af4e6c4..ab89b2d 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
@@ -101,6 +101,10 @@ static ushort max_sectors = 0x;
 module_param(max_sectors, ushort, 0);
 MODULE_PARM_DESC(max_sectors, "max sectors, range 64 to 32767  default=32767");
 
+static int missing_delay[2] = {-1, -1};
+module_param_array(missing_delay, int, NULL, 0);
+MODULE_PARM_DESC(missing_delay, " device missing delay , io missing delay");
+
 /* scsi-mid layer global parmeter is max_report_luns, which is 511 */
 #define MPT2SAS_MAX_LUN (16895)
 static int max_lun = MPT2SAS_MAX_LUN;
@@ -7303,7 +7307,9 @@ _firmware_event_work(struct work_struct *work)
case MPT2SAS_PORT_ENABLE_COMPLETE:
ioc->start_scan = 0;
 
-
+   if (missing_delay[0] != -1 && missing_delay[1] != -1)
+   mpt2sas_base_update_missing_delay(ioc, missing_delay[0],
+   missing_delay[1]);
 
dewtprintk(ioc, printk(MPT2SAS_INFO_FMT "port enable: complete "
"from worker thread\n", ioc->name));
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RESEND][PATCH 5/8][SCSI] mpt2sas : Fix for device scan following host reset could get stuck in a infinite loop

2013-02-01 Thread Sreekanth Reddy
Modified device scan routine so each configuration page read breaks from the 
while loop
when the ioc_status is not equal to MPI2_IOCSTATUS_SUCCESS.

Signed-off-by: Sreekanth Reddy 
Cc: sta...@vger.kernel.org
---

diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c 
b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
index 5073586..014caef 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
@@ -7097,12 +7097,15 @@ _scsih_scan_for_devices_after_reset(struct 
MPT2SAS_ADAPTER *ioc)
struct _sas_device *sas_device;
struct _sas_node *expander_device;
static struct _raid_device *raid_device;
+   u8 retry_count;
unsigned long flags;
 
printk(MPT2SAS_INFO_FMT "scan devices: start\n", ioc->name);
 
_scsih_sas_host_refresh(ioc);
 
+   printk(MPT2SAS_INFO_FMT "\tscan devices: expanders start\n",
+   ioc->name);
/* expanders */
handle = 0x;
while (!(mpt2sas_config_get_expander_pg0(ioc, &mpi_reply, &expander_pg0,
@@ -7111,6 +7114,13 @@ _scsih_scan_for_devices_after_reset(struct 
MPT2SAS_ADAPTER *ioc)
MPI2_IOCSTATUS_MASK;
if (ioc_status == MPI2_IOCSTATUS_CONFIG_INVALID_PAGE)
break;
+   if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
+   printk(MPT2SAS_INFO_FMT "\tbreak from expander scan: " \
+   "ioc_status(0x%04x), loginfo(0x%08x)\n",
+   ioc->name, ioc_status,
+   le32_to_cpu(mpi_reply.IOCLogInfo));
+   break;
+   }
handle = le16_to_cpu(expander_pg0.DevHandle);
spin_lock_irqsave(&ioc->sas_node_lock, flags);
expander_device = mpt2sas_scsih_expander_find_by_sas_address(
@@ -7119,13 +7129,26 @@ _scsih_scan_for_devices_after_reset(struct 
MPT2SAS_ADAPTER *ioc)
if (expander_device)
_scsih_refresh_expander_links(ioc, expander_device,
handle);
-   else
+   else {
+   printk(MPT2SAS_INFO_FMT "\tBEFORE adding expander: " \
+   "handle (0x%04x), sas_addr(0x%016llx)\n",
+   ioc->name, handle, (unsigned long long)
+   le64_to_cpu(expander_pg0.SASAddress));
_scsih_expander_add(ioc, handle);
+   printk(MPT2SAS_INFO_FMT "\tAFTER adding expander: " \
+   "handle (0x%04x), sas_addr(0x%016llx)\n",
+   ioc->name, handle, (unsigned long long)
+   le64_to_cpu(expander_pg0.SASAddress));
+   }
}
 
+   printk(MPT2SAS_INFO_FMT "\tscan devices: expanders complete\n",
+   ioc->name);
+
if (!ioc->ir_firmware)
goto skip_to_sas;
 
+   printk(MPT2SAS_INFO_FMT "\tscan devices phys disk start\n", ioc->name);
/* phys disk */
phys_disk_num = 0xFF;
while (!(mpt2sas_config_get_phys_disk_pg0(ioc, &mpi_reply,
@@ -7135,6 +7158,13 @@ _scsih_scan_for_devices_after_reset(struct 
MPT2SAS_ADAPTER *ioc)
MPI2_IOCSTATUS_MASK;
if (ioc_status == MPI2_IOCSTATUS_CONFIG_INVALID_PAGE)
break;
+   if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
+   printk(MPT2SAS_INFO_FMT "\tbreak from phys disk scan:" \
+   "ioc_status(0x%04x), loginfo(0x%08x)\n",
+   ioc->name, ioc_status,
+   le32_to_cpu(mpi_reply.IOCLogInfo));
+   break;
+   }
phys_disk_num = pd_pg0.PhysDiskNum;
handle = le16_to_cpu(pd_pg0.DevHandle);
spin_lock_irqsave(&ioc->sas_device_lock, flags);
@@ -7146,17 +7176,46 @@ _scsih_scan_for_devices_after_reset(struct 
MPT2SAS_ADAPTER *ioc)
&sas_device_pg0, MPI2_SAS_DEVICE_PGAD_FORM_HANDLE,
handle) != 0)
continue;
+   ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
+   MPI2_IOCSTATUS_MASK;
+   if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
+   printk(MPT2SAS_INFO_FMT "\tbreak from phys disk scan " \
+   "ioc_status(0x%04x), loginfo(0x%08x)\n",
+   ioc->name, ioc_status,
+   le32_to_cpu(mpi_reply.IOCLogInfo));
+   break;
+   }
parent_handle = le16_to_cpu(sas_device_pg0.ParentDevHandle);
if (!_scsih_get_sas_address(ioc, parent_handle,
&sas_address)) {
+   printk(MPT2SAS_INFO_FMT "\tBEFORE adding phys disk: " \
+   " handl

[RESEND][PATCH 6/8][SCSI] mpt2sas : When SCSI command is received with task atrribute not set, set it to SIMPLE

2013-02-01 Thread Sreekanth Reddy
When SCSI command is received with task attribute not set, set it to SIMPLE.
Previously it is set to untagged. This causes the firmware to fail the commands.

Signed-off-by: Sreekanth Reddy 
Cc: sta...@vger.kernel.org
---

diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c 
b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
index 014caef..3b150b8 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
@@ -3998,11 +3998,7 @@ _scsih_qcmd_lck(struct scsi_cmnd *scmd, void 
(*done)(struct scsi_cmnd *))
else
mpi_control |= MPI2_SCSIIO_CONTROL_SIMPLEQ;
} else
-/* MPI Revision I (UNIT = 0xA) - removed MPI2_SCSIIO_CONTROL_UNTAGGED */
-/* mpi_control |= MPI2_SCSIIO_CONTROL_UNTAGGED;
- */
-   mpi_control |= (0x500);
-
+   mpi_control |= MPI2_SCSIIO_CONTROL_SIMPLEQ;
} else
mpi_control |= MPI2_SCSIIO_CONTROL_SIMPLEQ;
/* Make sure Device is not raid volume.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: How to online remove an error scsi disk from the system?

2013-02-01 Thread Jack Wang
Hi All,
In our product system, we have several sata disks attached to one
machine. So when one of the disk fails, the jbd2(yes, we use ext4) will hang
forever and we will get something in /var/log/messages like below.
It seems to me that the io sent to the scsi layer is never returned back
with -EIO which is a little bit surprised for me(It should be a timeout
somewhere, right?). We have tried echo "offline" >
/sys/block/sdl/device/state, but it doesn't work. So is there any way for us
to let the scsi device returns all the io requests back with EIO so that all
the end_io can be called accordingly? Am I missing something here?

Thanks,
Tao
[Jack Wang] 
Hi Tao,

Have you tried:
 echo 1 > /sys/block/sdv/device/delete
 echo "- - -" > /sys/class/scsi_host/host

another way is :
find out which phy the disk attached to and:
echo 1 > /sys/class/sas_phy/phy-x:x:x/link_reset

Jack

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: How to online remove an error scsi disk from the system?

2013-02-01 Thread Tao Ma
On 02/01/2013 03:54 PM, Bart Van Assche wrote:
> On 02/01/13 07:13, Tao Ma wrote:
>> In our product system, we have several sata disks attached to one
>> machine. So when one of the disk fails, the jbd2(yes, we use ext4) will
>> hang forever and we will get something in /var/log/messages like below.
>> It seems to me that the io sent to the scsi layer is never returned back
>> with -EIO which is a little bit surprised for me(It should be a timeout
>> somewhere, right?). We have tried echo "offline" >
>> /sys/block/sdl/device/state, but it doesn't work. So is there any way
>> for us to let the scsi device returns all the io requests back with EIO
>> so that all the end_io can be called accordingly? Am I missing something
>> here?
> 
> Please note that I'm not familiar with SAS. But I found this in
> drivers/scsi/scsi_proc.c:
> 
>  * proc_scsi_write - handle writes to /proc/scsi/scsi
>  * @file: not used
>  * @buf: buffer to write
>  * @length: length of buf, at most PAGE_SIZE
>  * @ppos: not used
>  *
>  * Description: this provides a legacy mechanism to add or remove
>  * devices by Host, Channel, ID, and Lun.  To use,
>  * "echo 'scsi add-single-device 0 1 2 3' > /proc/scsi/scsi" or
>  * "echo 'scsi remove-single-device 0 1 2 3' > /proc/scsi/scsi" with
>  * "0 1 2 3" replaced by the Host, Channel, Id, and Lun.
Sorry, it doesn't work since it will also send some IOs to the scsi. And
it hangs...

bash  D  0 57479  57477 0x
 8817fee2dba0 0086  0002
 817c4ed5 00015f40 88180c7e45f8 88180c7e4040
 81a2d020 88180c7e45f8 00010fa4af09 0004
Call Trace:
 [] ? string+0x3f/0xd0
 [] ? vsnprintf+0x242/0x580
 [] ? fsnotify_clear_marks_by_inode+0x34/0xf0
 [] ? sysfs_delete_inode+0x0/0x60
 [] rwsem_down_failed_common+0x95/0x1c0
 [] rwsem_down_read_failed+0x26/0x30
 [] call_rwsem_down_read_failed+0x14/0x30
 [] ? kobject_release+0x0/0x1f0
 [] ? down_read+0x24/0x30
 [] get_super+0x74/0xc0
 [] fsync_bdev+0x1e/0x60
 [] invalidate_partition+0x2e/0x60
 [] del_gendisk+0x3e/0x130
 [] ? device_del+0x16a/0x1a0
 [] sd_remove+0x67/0xb0
 [] __device_release_driver+0x6f/0xe0
 [] device_release_driver+0x2d/0x40
 [] bus_remove_device+0x83/0xe0
 [] device_del+0x12f/0x1a0
 [] __scsi_remove_device+0xa5/0xb0
 [] scsi_remove_device+0x30/0x50
 [] proc_scsi_write+0x23f/0x280
 [] ? mntput_no_expire+0x39/0xd0
 [] proc_reg_write+0x7f/0xc0
 [] vfs_write+0xcc/0x1a0
 [] sys_write+0x55/0x90
 [] system_call_fastpath+0x16/0x1b


Thanks,
Tao
> 
> Bart.
> -- 
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: How to online remove an error scsi disk from the system?

2013-02-01 Thread Tao Ma
On 02/01/2013 04:50 PM, Jack Wang wrote:
> Hi All,
>   In our product system, we have several sata disks attached to one
> machine. So when one of the disk fails, the jbd2(yes, we use ext4) will hang
> forever and we will get something in /var/log/messages like below.
> It seems to me that the io sent to the scsi layer is never returned back
> with -EIO which is a little bit surprised for me(It should be a timeout
> somewhere, right?). We have tried echo "offline" >
> /sys/block/sdl/device/state, but it doesn't work. So is there any way for us
> to let the scsi device returns all the io requests back with EIO so that all
> the end_io can be called accordingly? Am I missing something here?
> 
> Thanks,
> Tao
> [Jack Wang] 
> Hi Tao,
> 
> Have you tried:
>  echo 1 > /sys/block/sdv/device/delete
It will do some IO first so it will hang doing IO.
>  echo "- - -" > /sys/class/scsi_host/host
What do you mean for this line?
> 
> another way is :
> find out which phy the disk attached to and:
> echo 1 > /sys/class/sas_phy/phy-x:x:x/link_reset
sorry, I have done it, but there is no response.

Thanks,
Tao
> 
> Jack
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: How to online remove an error scsi disk from the system?

2013-02-01 Thread Jack Wang

On 02/01/2013 04:50 PM, Jack Wang wrote:
> Hi All,
>   In our product system, we have several sata disks attached to one 
> machine. So when one of the disk fails, the jbd2(yes, we use ext4) 
> will hang forever and we will get something in /var/log/messages like
below.
> It seems to me that the io sent to the scsi layer is never returned 
> back with -EIO which is a little bit surprised for me(It should be a 
> timeout somewhere, right?). We have tried echo "offline" > 
> /sys/block/sdl/device/state, but it doesn't work. So is there any way 
> for us to let the scsi device returns all the io requests back with 
> EIO so that all the end_io can be called accordingly? Am I missing
something here?
> 
> Thanks,
> Tao
> [Jack Wang]
> Hi Tao,
> 
> Have you tried:
>  echo 1 > /sys/block/sdv/device/delete
It will do some IO first so it will hang doing IO.
>  echo "- - -" > /sys/class/scsi_host/host
What do you mean for this line?

[Jack Wang] Sorry I mean to let the driver rescan to get the disk back.
The line should be :
 echo "- - -" > /sys/class/scsi_host/hostx/scan.

Per above delete does not work , so no need to run this.
> 
> another way is :
> find out which phy the disk attached to and:
> echo 1 > /sys/class/sas_phy/phy-x:x:x/link_reset
sorry, I have done it, but there is no response.

[Jack Wang] 
What about
echo 1 > /sys/class/sas_phy/phy-x:x:x/hard_reset

?
Thanks,
Tao
> 
> Jack
> 
> --
> To unsubscribe from this list: send the line "unsubscribe 
> linux-kernel" in the body of a message to majord...@vger.kernel.org 
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the
body of a message to majord...@vger.kernel.org More majordomo info at
http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: How to online remove an error scsi disk from the system?

2013-02-01 Thread Bryn M. Reeves

On 02/01/2013 07:54 AM, Bart Van Assche wrote:

  * proc_scsi_write - handle writes to /proc/scsi/scsi
  * @file: not used
  * @buf: buffer to write
  * @length: length of buf, at most PAGE_SIZE
  * @ppos: not used
  *
  * Description: this provides a legacy mechanism to add or remove
  * devices by Host, Channel, ID, and Lun.  To use,
  * "echo 'scsi add-single-device 0 1 2 3' > /proc/scsi/scsi" or
  * "echo 'scsi remove-single-device 0 1 2 3' > /proc/scsi/scsi" with
  * "0 1 2 3" replaced by the Host, Channel, Id, and Lun.


The proc interface is deprecated; this can all be done via sysfs today, 
e.g.:


echo 1 > /sys/block/sdc/device/delete

Is equivalent to issuing scsi remove-single-device to proc.

Regards,
Bryn.


--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: How to online remove an error scsi disk from the system?

2013-02-01 Thread Tao Ma
On 02/01/2013 05:24 PM, Jack Wang wrote:
> 
> On 02/01/2013 04:50 PM, Jack Wang wrote:
>> Hi All,
>>  In our product system, we have several sata disks attached to one 
>> machine. So when one of the disk fails, the jbd2(yes, we use ext4) 
>> will hang forever and we will get something in /var/log/messages like
> below.
>> It seems to me that the io sent to the scsi layer is never returned 
>> back with -EIO which is a little bit surprised for me(It should be a 
>> timeout somewhere, right?). We have tried echo "offline" > 
>> /sys/block/sdl/device/state, but it doesn't work. So is there any way 
>> for us to let the scsi device returns all the io requests back with 
>> EIO so that all the end_io can be called accordingly? Am I missing
> something here?
>>
>> Thanks,
>> Tao
>> [Jack Wang]
>> Hi Tao,
>>
>> Have you tried:
>>  echo 1 > /sys/block/sdv/device/delete
> It will do some IO first so it will hang doing IO.
>>  echo "- - -" > /sys/class/scsi_host/host
> What do you mean for this line?
> 
> [Jack Wang] Sorry I mean to let the driver rescan to get the disk back.
> The line should be :
>  echo "- - -" > /sys/class/scsi_host/hostx/scan.
> 
> Per above delete does not work , so no need to run this.
>>
>> another way is :
>> find out which phy the disk attached to and:
>> echo 1 > /sys/class/sas_phy/phy-x:x:x/link_reset
> sorry, I have done it, but there is no response.
> 
> [Jack Wang] 
> What about
> echo 1 > /sys/class/sas_phy/phy-x:x:x/hard_reset
sorry, no response either.

Thanks,
Tao
> 
> ?
> Thanks,
> Tao
>>
>> Jack
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe 
>> linux-kernel" in the body of a message to majord...@vger.kernel.org 
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at  http://www.tux.org/lkml/
>>
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the
> body of a message to majord...@vger.kernel.org More majordomo info at
> http://vger.kernel.org/majordomo-info.html
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: How to online remove an error scsi disk from the system?

2013-02-01 Thread Tao Ma
On 02/01/2013 05:52 PM, Bryn M. Reeves wrote:
> On 02/01/2013 07:54 AM, Bart Van Assche wrote:
>>   * proc_scsi_write - handle writes to /proc/scsi/scsi
>>   * @file: not used
>>   * @buf: buffer to write
>>   * @length: length of buf, at most PAGE_SIZE
>>   * @ppos: not used
>>   *
>>   * Description: this provides a legacy mechanism to add or remove
>>   * devices by Host, Channel, ID, and Lun.  To use,
>>   * "echo 'scsi add-single-device 0 1 2 3' > /proc/scsi/scsi" or
>>   * "echo 'scsi remove-single-device 0 1 2 3' > /proc/scsi/scsi" with
>>   * "0 1 2 3" replaced by the Host, Channel, Id, and Lun.
> 
> The proc interface is deprecated; this can all be done via sysfs today,
> e.g.:
> 
> echo 1 > /sys/block/sdc/device/delete
> 
> Is equivalent to issuing scsi remove-single-device to proc.
yes, but the result is the same. It will do some IO first which will
cause this command hang.

Thanks,
Tao
> 
> Regards,
> Bryn.
> 
> 
> -- 
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: How to online remove an error scsi disk from the system?

2013-02-01 Thread Bryn M. Reeves

On 02/01/2013 09:59 AM, Tao Ma wrote:

yes, but the result is the same. It will do some IO first which will
cause this command hang.


You seem to have a problem with either the device/adapter or in the 
driver. The backtrace you posted shows that jbd2 (ext4) is still waiting 
on IO that's been submitted to an mpt2sas or mpt3sas adapter (I only 
know that because I recognise their log messages - you should try to 
include relevant details like this when seeking assistance).


The adapter/driver hasn't completed the IO and it looks like the SCSI 
layer is trying to abort it. Depending on the state of the driver and 
hardware your only option might be to reboot (or physically hot remove 
the device if your hardware allows it).


You don't mention the versions of the kernel and driver you're using - 
if the system is in production I would suggest contacting who ever 
normally provides support for the kernel and distribution that you are 
running.


Regards,
Bryn.

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: How to online remove an error scsi disk from the system?

2013-02-01 Thread Tao Ma
On 02/01/2013 06:07 PM, Bryn M. Reeves wrote:
> On 02/01/2013 09:59 AM, Tao Ma wrote:
>> yes, but the result is the same. It will do some IO first which will
>> cause this command hang.
> 
> You seem to have a problem with either the device/adapter or in the
> driver. The backtrace you posted shows that jbd2 (ext4) is still waiting
> on IO that's been submitted to an mpt2sas or mpt3sas adapter (I only
> know that because I recognise their log messages - you should try to
> include relevant details like this when seeking assistance).
This should be  a mpt2sas adapter
#lsmod|grep mpt
mptctl 96789  0
mptbase97052  1 mptctl
mpt2sas   164962  18
scsi_transport_sas 35232  3 isci,libsas,mpt2sas
raid_class  4746  1 mpt2sas

The system has 12 sata disks. What else do you need? I am willing to
provide any details you want.

> 
> The adapter/driver hasn't completed the IO and it looks like the SCSI
> layer is trying to abort it. Depending on the state of the driver and
> hardware your only option might be to reboot (or physically hot remove
> the device if your hardware allows it).
OK, so let me describe the situation here. This is one of our storage
system. So 12 2TB sata disk in one box, normally when one disk fails, we
just want to remove it from the system by *software*, and then continue
to use the 11 disks left. We have found that sometimes an unsuccessful
umount or some actions against this disk can lead to some bad
situation(Say some very high load because many processes are 'D'ed). So
ideally if we can remove this device successfully, all the ios to this
disk will fail and there will be no 'D' processes and the loadavg will
also be low.
> 
> You don't mention the versions of the kernel and driver you're using -
> if the system is in production I would suggest contacting who ever
> normally provides support for the kernel and distribution that you are
> running.
We use CentOS6.2 and the kernel version is 2.6.32-220.23.1.

Thanks,
Tao
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: How to online remove an error scsi disk from the system?

2013-02-01 Thread Bryn M. Reeves

On 02/01/2013 11:13 AM, Tao Ma wrote:

You don't mention the versions of the kernel and driver you're using -
if the system is in production I would suggest contacting who ever
normally provides support for the kernel and distribution that you are
running.

We use CentOS6.2 and the kernel version is 2.6.32-220.23.1.


This is ancient, even by CentOS or RHEL standards. There are thousands 
of patches in more recent kernels (either at kernel.org or in the 
updates in CentOS repositories).


Nobody on linux-kernel or the other lists you copied is going to want to 
investigate problems on such an old kernel - you'll need to either 
reproduce with something current or seek assistance from the CentOS 
community (who will probably tell you to update your kernel first anyway).


Regards,
Bryn.


--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[LSF/MM TOPIC] Reducing the SRP initiator failover time

2013-02-01 Thread Bart Van Assche
It is known that it takes about two to three minutes before the upstream 
SRP initiator fails over from a failed path to a working path. This is 
not only considered longer than acceptable but is also longer than other 
Linux SCSI initiators (e.g. iSCSI and FC). Progress so far with 
improving the fail-over SRP initiator has been slow. This is because the 
discussion about candidate patches occurred at two different levels: not 
only the patches itself were discussed but also the approach that should 
be followed. That last aspect is easier to discuss in a meeting than 
over a mailing list. Hence the proposal to discuss SRP initiator 
failover behavior during the LSF/MM summit. The topics that need further 
discussion are:

* If a path fails, remove the entire SCSI host or preserve the SCSI
  host and only remove the SCSI devices associated with that host ?
* Which software component should test the state of a path and should
  reconnect to an SRP target if a path is restored ? Should that be
  done by the user space process srp_daemon or by the SRP initiator
  kernel module ?
* How should the SRP initiator behave after a path failure has been
  detected ? Should the behavior be similar to the FC initiator with
  its fast_io_fail_tmo and dev_loss_tmo parameters ?

Dave, if this topic gets accepted, I really hope you will be able to 
attend the LSF/MM summit.


Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: How to online remove an error scsi disk from the system?

2013-02-01 Thread Hillf Danton
On Fri, Feb 1, 2013 at 2:13 PM, Tao Ma  wrote:
> Hi All,
> In our product system, we have several sata disks attached to one
> machine. So when one of the disk fails, the jbd2(yes, we use ext4) will
> hang forever and we will get something in /var/log/messages like below.
> It seems to me that the io sent to the scsi layer is never returned back
> with -EIO which is a little bit surprised for me(It should be a timeout
> somewhere, right?). We have tried echo "offline" >
> /sys/block/sdl/device/state, but it doesn't work. So is there any way
> for us to let the scsi device returns all the io requests back with EIO
> so that all the end_io can be called accordingly? Am I missing something
> here?
>
> Thanks,
> Tao
>
>
> sd 0:0:11:0: attempting task abort! scmd(88180e900580)
> sd 0:0:11:0: [sdl] CDB: Write(10): 2a 00 0d ca e0 3f 00 04 00 00
> target0:0:11: handle(0x0015), sas_address(0x500e004aaa0b), phy(11)
> target0:0:11: enclosure_logical_id(0x500e004aaa00), slot(11)
> INFO: task jbd2/sdl1-8:4629 blocked for more than 120 seconds.
> "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
> jbd2/sdl1-8   D  0  4629  2 0x
>  88180aa79ae0 0046 88180aa79aa8 
>  88007ce0fe40 00015f40 8818102c0638 8818102c0080
>  880a9184a100 8818102c0638 000105006028 0001
> Call Trace:
>  [] ? cpumask_next_and+0x25/0x40
>  [] ? read_tsc+0x16/0x40
>  [] ? ktime_get_ts+0xa9/0xe0
>  [] ? read_tsc+0x16/0x40
>  [] ? ktime_get_ts+0xa9/0xe0
>  [] io_schedule+0x73/0xc0
>  [] sync_page+0x38/0x50
>  [] __wait_on_bit+0x5e/0x90
>  [] ? sync_page+0x0/0x50
>  [] wait_on_page_bit+0x75/0x80
>  [] ? wake_bit_function+0x0/0x40
>  [] ? pagevec_lookup_tag+0x27/0x40
>  [] write_cache_pages+0x1d5/0x440
>  [] ? __writepage+0x0/0x40
>  [] generic_writepages+0x24/0x30
>  [] jbd2_journal_commit_transaction+0x3e9/0x1490 [jbd2]
>  [] ? try_to_del_timer_sync+0x49/0xe0
>  [] kjournald2+0xb4/0x220 [jbd2]
>  [] ? autoremove_wake_function+0x0/0x40
>  [] ? kjournald2+0x0/0x220 [jbd2]
>  [] kthread+0x96/0xa0
>  [] child_rip+0xa/0x20
>  [] ? kthread+0x0/0xa0
>  [] ? child_rip+0x0/0x20
>
Can you try upstream?
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [LSF/MM TOPIC] SCSI Express driver

2013-02-01 Thread Hannes Reinecke

On 01/31/2013 06:23 PM, scame...@beardog.cce.hp.com wrote:


If there is interest, I would like to discuss the SCSI Express driver
Chayan and I have been working on for the last few months.



YES.

Cheers,

Hannes
--
Dr. Hannes Reinecke   zSeries & Storage
h...@suse.de  +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v8 4/4] sd: change to auto suspend mode

2013-02-01 Thread Alan Stern
On Fri, 1 Feb 2013, Aaron Lu wrote:

> On Thu, Jan 31, 2013 at 10:13:05AM -0500, Alan Stern wrote:
> > On Thu, 31 Jan 2013, Aaron Lu wrote:
> > 
> > > > > +static int scsi_blk_runtime_suspend(struct device *dev)
> > > > > +{
> > > > > + struct scsi_device *sdev = to_scsi_device(dev);
> > > > 
> > > > For this routine and the other new ones, it may be slightly more
> > > > efficient to pass both dev and sdev as arguments (this depends on how
> > > > smart the compiler's optimizer is).  The caller already knows both of
> > > > them, after all.
> > > 
> > > What about passing only scsi_device? When device is needed, I can use
> > > &sdev->sdev_gendev. Is this equally efficient?
> > 
> > I don't know...  The difference is very small in any case.  The 
> > routines will probably be inlined automatically.
> 
> Indeed, I just checked the .s output of the three cases, they are all
> the same. So we just need to care about readability and less of code,
> passing only scsi_device seems to be the simplest, are you OK with this?

Yes, that's fine.  Thanks for checking it out.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 0/8] [SCSI] Enhanced sense and Unit Attention handling

2013-02-01 Thread Ewan D. Milne
From: "Ewan D. Milne" 

This patch set adds changes to the SCSI mid-layer, sysfs and scsi_debug
to provide enhanced support for Unit Attention conditions, as well as
detection of reported sense data overflow conditions and some changes
to sense data processing.  It also adds a uevent when the reported
capacity changes on an sd device.

There was some discussion about this a couple of years ago on the linux-scsi
mailing list:  http://marc.info/?l=linux-scsi&m=129702506514742&w=2
Although one approach is to send all SCSI sense data to a userspace daemon
for processing, this patch set does not take that approach due to the
difficulty in reliably delivering all of the data.  An interesting UA
condition might not be delivered due to a flood of media errors, for example.

The mechanism used is to flag when certain UA ASC/ASCQ codes are received
that report asynchronous changes to the storage device configuration.
An appropriate uevent is then generated for the scsi_device or scsi_target
object.  An aggregation mechanism is used to avoid generating uevents at
too high a rate, and to coalesce multiple UAs reported by LUNs on the
same target for a REPORTED LUNS DATA HAS CHANGED sense code.

The changes are (mostly) enabled by a new kernel config option
CONFIG_SCSI_ENHANCED_UA.  If this config option is not used, no new
uevents are generated.  There are some changes to kernel logging messages
if CONFIG_SCSI_ENHANCED_UA is enabled, because the existing messages
explicitly stated that the kernel did not do anything with the information.

Note that checkpatch is reporting errors on patch 6/8 relating to macros
in scsi_sysfs.c -- I believe these errors are incorrect and have sent a
message to the checkpatch maintainer.  The macros were derived from
existing ones already in the file.

Some changes have been made to this patch set since an earlier version
was sent out with RFC:

   - Remove patch 1/9 "Detect overflow of sense data buffer"
 Some scsi_debug changes in this patch were moved to patch 7/8
   - Corrected Kconfig help text
   - Change name of "sdev_evt_thread" to "sdev_evt_work"
   - Change name of "starget_evt_thread" to "starget_evt_work"
   - Pull code out of scsi_check_sense() that handles UAs into
 an exported function so that drivers can report conditions
 received asynchronously

Thanks to everyone for the comments on this patch series.

Ewan D. Milne (8):
  [SCSI] Generate uevent on sd capacity change
  [SCSI] Add a kernel config option for enhanced Unit Attention support
  [SCSI] Rename scsi_evt_xxx to sdev_evt_xxx and scsi_event to
sdev_event
  [SCSI] Add support for scsi_target events
  [SCSI] Generate uevents for certain Unit Attention codes
  [SCSI] Add sysfs support for enhanced Unit Attention handling
  [SCSI] Add sense and Unit Attention generation to scsi_debug
  [SCSI] Streamline detection of FM/EOM/ILI status

 drivers/scsi/Kconfig   |  12 +++
 drivers/scsi/scsi_debug.c  | 138 ++
 drivers/scsi/scsi_error.c  | 203 -
 drivers/scsi/scsi_lib.c| 180 +---
 drivers/scsi/scsi_priv.h   |  10 ++-
 drivers/scsi/scsi_scan.c   |  54 ++--
 drivers/scsi/scsi_sysfs.c  | 148 ++---
 drivers/scsi/sd.c  |   9 ++
 include/scsi/scsi_cmnd.h   |   4 +
 include/scsi/scsi_device.h |  64 +-
 include/scsi/scsi_eh.h |   8 ++
 11 files changed, 750 insertions(+), 80 deletions(-)

-- 
1.7.11.7

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 1/8] [SCSI] Generate uevent on sd capacity change

2013-02-01 Thread Ewan D. Milne
From: "Ewan D. Milne" 

In sd_read_capacity(), detect if the capacity is different from the
previously read value, and generate a uevent if this is the case.

Signed-off-by: Ewan D. Milne 
---
 drivers/scsi/scsi_lib.c| 5 -
 drivers/scsi/scsi_sysfs.c  | 2 ++
 drivers/scsi/sd.c  | 9 +
 include/scsi/scsi_device.h | 3 ++-
 4 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 6dfb978..eba68de 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -2186,7 +2186,9 @@ static void scsi_evt_emit(struct scsi_device *sdev, 
struct scsi_event *evt)
case SDEV_EVT_MEDIA_CHANGE:
envp[idx++] = "SDEV_MEDIA_CHANGE=1";
break;
-
+   case SDEV_EVT_CAPACITY_CHANGE:
+   envp[idx++] = "SDEV_CAPACITY_CHANGE=1";
+   break;
default:
/* do nothing */
break;
@@ -2280,6 +2282,7 @@ struct scsi_event *sdev_evt_alloc(enum scsi_device_event 
evt_type,
/* evt_type-specific initialization, if any */
switch (evt_type) {
case SDEV_EVT_MEDIA_CHANGE:
+   case SDEV_EVT_CAPACITY_CHANGE:
default:
/* do nothing */
break;
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 04c2a27..ba7da3b 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -712,6 +712,7 @@ sdev_store_evt_##name(struct device *dev, struct 
device_attribute *attr,\
 #define REF_EVT(name) &dev_attr_evt_##name.attr
 
 DECLARE_EVT(media_change, MEDIA_CHANGE)
+DECLARE_EVT(capacity_change, CAPACITY_CHANGE)
 
 /* Default template for device attributes.  May NOT be modified */
 static struct attribute *scsi_sdev_attrs[] = {
@@ -731,6 +732,7 @@ static struct attribute *scsi_sdev_attrs[] = {
&dev_attr_ioerr_cnt.attr,
&dev_attr_modalias.attr,
REF_EVT(media_change),
+   REF_EVT(capacity_change),
NULL
 };
 
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 6f0a4c6..9f2d00a 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2017,6 +2017,15 @@ got_data:
  "%u-byte physical blocks\n",
  sdkp->physical_block_size);
}
+
+   /*
+* Don't report a capacity change event unless we have a
+* valid "old" value.
+*/
+   if (!sdkp->first_scan && (old_capacity != 0) &&
+   (old_capacity != sdkp->capacity))
+   sdev_evt_send_simple(sdp, SDEV_EVT_CAPACITY_CHANGE,
+GFP_KERNEL);
}
 
/* Rescale capacity to 512-byte units */
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index 6efb2e1..e4c964e 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -51,8 +51,9 @@ enum scsi_device_state {
 
 enum scsi_device_event {
SDEV_EVT_MEDIA_CHANGE   = 1,/* media has changed */
+   SDEV_EVT_CAPACITY_CHANGE= 2,/* capacity has changed */
 
-   SDEV_EVT_LAST   = SDEV_EVT_MEDIA_CHANGE,
+   SDEV_EVT_LAST   = SDEV_EVT_CAPACITY_CHANGE,
SDEV_EVT_MAXBITS= SDEV_EVT_LAST + 1
 };
 
-- 
1.7.11.7

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 2/8] [SCSI] Add a kernel config option for enhanced Unit Attention support

2013-02-01 Thread Ewan D. Milne
From: "Ewan D. Milne" 

Added CONFIG_SCSI_ENHANCED_UA kernel config option to enable changes
in the SCSI mid-layer which detect and report certain Unit Attention
conditions reported by devices.  These changes are primarily useful
when storage arrays that can be reconfigured are being used, so the
config option would normally not be used unless it was needed.

Signed-off-by: Ewan D. Milne 
---
 drivers/scsi/Kconfig | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index e955978..5d1e614 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -280,6 +280,18 @@ config SCSI_WAIT_SCAN
 # disabling it, whereas people who accidentally switch it off may wonder why
 # their mkinitrd gets into trouble.
 
+config SCSI_ENHANCED_UA
+   bool "Enhanced SCSI Unit Attention handling"
+   depends on SCSI
+   help
+Certain SCSI devices report changes via a UNIT ATTENTION code.
+(For example, the addition or removal of LUNs from a target, or
+changing the number of logical blocks on a LUN.)  This option
+enables reporting of these changes via udev events, so that the
+device can be rescanned to find out what has changed.  This is
+primarily useful when storage arrays that can be reconfigured
+are attached to the system, otherwise you can say N here.
+
 menu "SCSI Transports"
depends on SCSI
 
-- 
1.7.11.7

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 3/8] [SCSI] Rename scsi_evt_xxx to sdev_evt_xxx and scsi_event to sdev_event

2013-02-01 Thread Ewan D. Milne
From: "Ewan D. Milne" 

The names of the struct and some of the functions for scsi_device
events are too generic and do not match the comments in the source.
Changed all of the names to begin with sdev_ in order to avoid
naming issues and confusion with scsi_target events to be added.
Also changed name of sdev_evt_thread() to sdev_evt_work().

Signed-off-by: Ewan D. Milne 
---
 drivers/scsi/scsi_lib.c| 24 
 drivers/scsi/scsi_priv.h   |  1 +
 drivers/scsi/scsi_scan.c   |  3 +--
 drivers/scsi/scsi_sysfs.c  |  4 ++--
 include/scsi/scsi_device.h |  6 +++---
 5 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index eba68de..75b7cad 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -2175,9 +2175,9 @@ EXPORT_SYMBOL(scsi_device_set_state);
  * @sdev: associated SCSI device
  * @evt: event to emit
  *
- * Send a single uevent (scsi_event) to the associated scsi_device.
+ * Send a single uevent (sdev_event) to the associated scsi_device.
  */
-static void scsi_evt_emit(struct scsi_device *sdev, struct scsi_event *evt)
+static void sdev_evt_emit(struct scsi_device *sdev, struct sdev_event *evt)
 {
int idx = 0;
char *envp[3];
@@ -2200,13 +2200,13 @@ static void scsi_evt_emit(struct scsi_device *sdev, 
struct scsi_event *evt)
 }
 
 /**
- * sdev_evt_thread - send a uevent for each scsi event
+ * sdev_evt_work - send a uevent for each scsi event
  * @work: work struct for scsi_device
  *
  * Dispatch queued events to their associated scsi_device kobjects
  * as uevents.
  */
-void scsi_evt_thread(struct work_struct *work)
+void sdev_evt_work(struct work_struct *work)
 {
struct scsi_device *sdev;
LIST_HEAD(event_list);
@@ -2214,7 +2214,7 @@ void scsi_evt_thread(struct work_struct *work)
sdev = container_of(work, struct scsi_device, event_work);
 
while (1) {
-   struct scsi_event *evt;
+   struct sdev_event *evt;
struct list_head *this, *tmp;
unsigned long flags;
 
@@ -2226,9 +2226,9 @@ void scsi_evt_thread(struct work_struct *work)
break;
 
list_for_each_safe(this, tmp, &event_list) {
-   evt = list_entry(this, struct scsi_event, node);
+   evt = list_entry(this, struct sdev_event, node);
list_del(&evt->node);
-   scsi_evt_emit(sdev, evt);
+   sdev_evt_emit(sdev, evt);
kfree(evt);
}
}
@@ -2241,7 +2241,7 @@ void scsi_evt_thread(struct work_struct *work)
  *
  * Assert scsi device event asynchronously.
  */
-void sdev_evt_send(struct scsi_device *sdev, struct scsi_event *evt)
+void sdev_evt_send(struct scsi_device *sdev, struct sdev_event *evt)
 {
unsigned long flags;
 
@@ -2267,12 +2267,12 @@ EXPORT_SYMBOL_GPL(sdev_evt_send);
  * @evt_type: type of event to allocate
  * @gfpflags: GFP flags for allocation
  *
- * Allocates and returns a new scsi_event.
+ * Allocates and returns a new sdev_event.
  */
-struct scsi_event *sdev_evt_alloc(enum scsi_device_event evt_type,
+struct sdev_event *sdev_evt_alloc(enum scsi_device_event evt_type,
  gfp_t gfpflags)
 {
-   struct scsi_event *evt = kzalloc(sizeof(struct scsi_event), gfpflags);
+   struct sdev_event *evt = kzalloc(sizeof(struct sdev_event), gfpflags);
if (!evt)
return NULL;
 
@@ -2303,7 +2303,7 @@ EXPORT_SYMBOL_GPL(sdev_evt_alloc);
 void sdev_evt_send_simple(struct scsi_device *sdev,
  enum scsi_device_event evt_type, gfp_t gfpflags)
 {
-   struct scsi_event *evt = sdev_evt_alloc(evt_type, gfpflags);
+   struct sdev_event *evt = sdev_evt_alloc(evt_type, gfpflags);
if (!evt) {
sdev_printk(KERN_ERR, sdev, "event %d eaten due to OOM\n",
evt_type);
diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h
index 07ce3f5..7f00813 100644
--- a/drivers/scsi/scsi_priv.h
+++ b/drivers/scsi/scsi_priv.h
@@ -90,6 +90,7 @@ extern void scsi_exit_queue(void);
 struct request_queue;
 struct request;
 extern struct kmem_cache *scsi_sdb_cache;
+extern void sdev_evt_work(struct work_struct *work);
 
 /* scsi_proc.c */
 #ifdef CONFIG_SCSI_PROC_FS
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 2e5fe58..47348ed 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -244,7 +244,6 @@ static struct scsi_device *scsi_alloc_sdev(struct 
scsi_target *starget,
struct scsi_device *sdev;
int display_failure_msg = 1, ret;
struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
-   extern void scsi_evt_thread(struct work_struct *work);
extern void scsi_requeue_run_queue(struct work_struct *work);
 
sde

[PATCH v2 4/8] [SCSI] Add support for scsi_target events

2013-02-01 Thread Ewan D. Milne
From: "Ewan D. Milne" 

Added capability to generate uevents on scsi_target objects.

Signed-off-by: Ewan D. Milne 
---
 drivers/scsi/scsi_lib.c| 135 +
 drivers/scsi/scsi_priv.h   |   3 +
 drivers/scsi/scsi_scan.c   |  17 ++
 include/scsi/scsi_device.h |  34 
 4 files changed, 189 insertions(+)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 75b7cad..b815666 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -2393,6 +2393,141 @@ scsi_target_resume(struct scsi_target *starget)
 }
 EXPORT_SYMBOL(scsi_target_resume);
 
+#ifdef CONFIG_SCSI_ENHANCED_UA
+/**
+ * starget_evt_emit - emit a single SCSI target uevent
+ * @starget: associated SCSI target
+ * @evt: event to emit
+ *
+ * Send a single uevent (starget_event) to the associated scsi_target.
+ */
+static void starget_evt_emit(struct scsi_target *starget,
+struct starget_event *evt)
+{
+   int idx = 0;
+   char *envp[3];
+
+   switch (evt->evt_type) {
+   case STARGET_EVT_LUN_CHANGE_REPORTED:
+   envp[idx++] = "STARGET_LUN_CHANGE_REPORTED=1";
+   break;
+   default:
+   /* do nothing */
+   break;
+   }
+
+   envp[idx++] = NULL;
+
+   kobject_uevent_env(&starget->dev.kobj, KOBJ_CHANGE, envp);
+}
+
+/**
+ * starget_evt_work - send a uevent for each scsi event
+ * @work: work struct for scsi_target
+ *
+ * Dispatch queued events to their associated scsi_target kobjects
+ * as uevents.
+ */
+void starget_evt_work(struct work_struct *work)
+{
+   struct scsi_target *starget;
+   LIST_HEAD(event_list);
+
+   starget = container_of(work, struct scsi_target, event_work);
+
+   while (1) {
+   struct starget_event *evt;
+   struct list_head *this, *tmp;
+   unsigned long flags;
+
+   spin_lock_irqsave(&starget->list_lock, flags);
+   list_splice_init(&starget->event_list, &event_list);
+   spin_unlock_irqrestore(&starget->list_lock, flags);
+
+   if (list_empty(&event_list))
+   break;
+
+   list_for_each_safe(this, tmp, &event_list) {
+   evt = list_entry(this, struct starget_event, node);
+   list_del(&evt->node);
+   starget_evt_emit(starget, evt);
+   kfree(evt);
+   }
+   }
+}
+
+/**
+ * starget_evt_send - send asserted event to uevent thread
+ * @starget: scsi_target event occurred on
+ * @evt: event to send
+ *
+ * Assert scsi target event asynchronously.
+ */
+void starget_evt_send(struct scsi_target *starget, struct starget_event *evt)
+{
+   unsigned long flags;
+
+   spin_lock_irqsave(&starget->list_lock, flags);
+   list_add_tail(&evt->node, &starget->event_list);
+   schedule_work(&starget->event_work);
+   spin_unlock_irqrestore(&starget->list_lock, flags);
+}
+EXPORT_SYMBOL_GPL(starget_evt_send);
+
+/**
+ * starget_evt_alloc - allocate a new scsi_target event
+ * @evt_type: type of event to allocate
+ * @gfpflags: GFP flags for allocation
+ *
+ * Allocates and returns a new starget_event.
+ */
+struct starget_event *starget_evt_alloc(enum scsi_target_event evt_type,
+   gfp_t gfpflags)
+{
+   struct starget_event *evt = kzalloc(sizeof(struct starget_event),
+   gfpflags);
+   if (!evt)
+   return NULL;
+
+   evt->evt_type = evt_type;
+   INIT_LIST_HEAD(&evt->node);
+
+   /* evt_type-specific initialization, if any */
+   switch (evt_type) {
+   case STARGET_EVT_LUN_CHANGE_REPORTED:
+   default:
+   /* do nothing */
+   break;
+   }
+
+   return evt;
+}
+EXPORT_SYMBOL_GPL(starget_evt_alloc);
+
+/**
+ * starget_evt_send_simple - send asserted event to uevent thread
+ * @starget: scsi_target event occurred on
+ * @evt_type: type of event to send
+ * @gfpflags: GFP flags for allocation
+ *
+ * Assert scsi target event asynchronously, given an event type.
+ */
+void starget_evt_send_simple(struct scsi_target *starget,
+enum scsi_target_event evt_type, gfp_t gfpflags)
+{
+   struct starget_event *evt = starget_evt_alloc(evt_type, gfpflags);
+   if (!evt) {
+   starget_printk(KERN_ERR, starget, "event %d eaten due to OOM\n",
+  evt_type);
+   return;
+   }
+
+   starget_evt_send(starget, evt);
+}
+EXPORT_SYMBOL_GPL(starget_evt_send_simple);
+
+#endif
+
 /**
  * scsi_internal_device_block - internal function to put a device temporarily 
into the SDEV_BLOCK state
  * @sdev:  device to block
diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h
index 7f00813..5da5466 

[PATCH v2 8/8] [SCSI] Streamline detection of FM/EOM/ILI status

2013-02-01 Thread Ewan D. Milne
From: "Ewan D. Milne" 

Avoid duplicate tests when examining sense data for FM/EOM/ILI
bits.  Moved extraction of status to scsi_normalize_sense() if
the config option CONFIG_SCSI_ENHANCED_UA is used, because
descriptor format sense data is already being parsed there.

Signed-off-by: Ewan D. Milne 
---
 drivers/scsi/scsi_error.c | 16 +++-
 include/scsi/scsi_eh.h|  3 +++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index d0b5a26..3ad001e 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -340,6 +340,10 @@ static int scsi_check_sense(struct scsi_cmnd *scmd)
 * Previous logic looked for FILEMARK, EOM or ILI which are
 * mainly associated with tapes and returned SUCCESS.
 */
+#ifdef CONFIG_SCSI_ENHANCED_UA
+   if (sshdr.fm_eom_ili)
+   return SUCCESS;
+#else
if (sshdr.response_code == 0x70) {
/* fixed format */
if (scmd->sense_buffer[2] & 0xe0)
@@ -355,6 +359,7 @@ static int scsi_check_sense(struct scsi_cmnd *scmd)
(scmd->sense_buffer[11] & 0xe0))
return SUCCESS;
}
+#endif
 
switch (sshdr.sense_key) {
case NO_SENSE:
@@ -2198,6 +2203,11 @@ int scsi_normalize_sense(const u8 *sense_buffer, int 
sb_len,
((sense_buffer[desc_pos + 4] & 0x01) != 0))
sshdr->ua_queue_overflow = 1;
 
+   if ((desc_type == 0x04) && (desc_len >= 4) &&
+   (addl_len >= 2) &&
+   ((sense_buffer[desc_pos + 3] & 0xe0) != 0))
+   sshdr->fm_eom_ili = 1;
+
if (addl_len > (desc_len - 2))
addl_len = desc_len - 2;
 
@@ -2210,8 +2220,12 @@ int scsi_normalize_sense(const u8 *sense_buffer, int 
sb_len,
/*
 * fixed format
 */
-   if (sb_len > 2)
+   if (sb_len > 2) {
+#ifdef CONFIG_SCSI_ENHANCED_UA
+   sshdr->fm_eom_ili = ((sense_buffer[2] & 0xe0) != 0);
+#endif
sshdr->sense_key = (sense_buffer[2] & 0xf);
+   }
if (sb_len > 7) {
sb_len = (sb_len < (sense_buffer[7] + 8)) ?
 sb_len : (sense_buffer[7] + 8);
diff --git a/include/scsi/scsi_eh.h b/include/scsi/scsi_eh.h
index b6c4d3d..d53a1d2 100644
--- a/include/scsi/scsi_eh.h
+++ b/include/scsi/scsi_eh.h
@@ -27,6 +27,9 @@ struct scsi_sense_hdr {   /* See SPC-3 section 
4.5 */
u8 additional_length;   /* always 0 for fixed sense format */
 #ifdef CONFIG_SCSI_ENHANCED_UA
unsigned int ua_queue_overflow:1;   /* UA info lost by device */
+
+   unsigned int fm_eom_ili:1;  /* filemark, end of medium, or
+  incorrect length indicator set */
 #endif
 };
 
-- 
1.7.11.7

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 7/8] [SCSI] Add sense and Unit Attention generation to scsi_debug

2013-02-01 Thread Ewan D. Milne
From: "Ewan D. Milne" 

Added capability to scsi_debug to generate sense and Unit Attention
conditions to exercise the enhanced sense and Unit Attention handling.

Signed-off-by: Ewan D. Milne 
---
 drivers/scsi/scsi_debug.c | 138 ++
 1 file changed, 138 insertions(+)

diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 182d5a5..8a6bf31 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -230,6 +230,7 @@ struct sdebug_dev_info {
char reset;
char stopped;
char used;
+   char sense_pending;
 };
 
 struct sdebug_host_info {
@@ -3050,10 +3051,27 @@ static ssize_t sdebug_max_luns_store(struct 
device_driver * ddp,
 const char * buf, size_t count)
 {
 int n;
+#ifdef CONFIG_SCSI_ENHANCED_UA
+   struct sdebug_host_info *sdbg_host;
+   struct sdebug_dev_info *devip;
+#endif
 
if ((count > 0) && (1 == sscanf(buf, "%d", &n)) && (n >= 0)) {
scsi_debug_max_luns = n;
sdebug_max_tgts_luns();
+
+#ifdef CONFIG_SCSI_ENHANCED_UA
+   spin_lock(&sdebug_host_list_lock);
+   list_for_each_entry(sdbg_host, &sdebug_host_list, host_list) {
+   list_for_each_entry(devip, &sdbg_host->dev_info_list,
+   dev_list) {
+   mk_sense_buffer(devip, UNIT_ATTENTION,
+   0x3f, 0x0e);
+   devip->sense_pending = 1;
+   }
+   }
+   spin_unlock(&sdebug_host_list_lock);
+#endif
return count;
}
return -EINVAL;
@@ -3100,12 +3118,28 @@ static ssize_t sdebug_virtual_gb_store(struct 
device_driver * ddp,
   const char * buf, size_t count)
 {
 int n;
+#ifdef CONFIG_SCSI_ENHANCED_UA
+   struct sdebug_host_info *sdbg_host;
+   struct sdebug_dev_info *devip;
+#endif
 
if ((count > 0) && (1 == sscanf(buf, "%d", &n)) && (n >= 0)) {
scsi_debug_virtual_gb = n;
 
sdebug_capacity = get_sdebug_capacity();
 
+#ifdef CONFIG_SCSI_ENHANCED_UA
+   spin_lock(&sdebug_host_list_lock);
+   list_for_each_entry(sdbg_host, &sdebug_host_list, host_list) {
+   list_for_each_entry(devip, &sdbg_host->dev_info_list,
+   dev_list) {
+   mk_sense_buffer(devip, UNIT_ATTENTION,
+   0x2a, 0x09);
+   devip->sense_pending = 1;
+   }
+   }
+   spin_unlock(&sdebug_host_list_lock);
+#endif
return count;
}
return -EINVAL;
@@ -3206,6 +3240,90 @@ static ssize_t sdebug_map_show(struct device_driver 
*ddp, char *buf)
 DRIVER_ATTR(map, S_IRUGO, sdebug_map_show, NULL);
 
 
+#ifdef CONFIG_SCSI_ENHANCED_UA
+static ssize_t sdebug_ua_overflow_store(struct device_driver *ddp,
+   const char *buf, size_t count)
+{
+   int n;
+   struct sdebug_host_info *sdbg_host;
+   struct sdebug_dev_info *devip;
+
+   if ((count > 0) && (1 == sscanf(buf, "%d", &n)) && (n >= 0)) {
+   spin_lock(&sdebug_host_list_lock);
+   list_for_each_entry(sdbg_host, &sdebug_host_list, host_list) {
+   list_for_each_entry(devip, &sdbg_host->dev_info_list,
+   dev_list) {
+   if (scsi_debug_dsense) {
+   mk_sense_buffer(devip, UNIT_ATTENTION,
+   0, 0);
+   devip->sense_buff[7] = 8;
+   devip->sense_buff[8] = 0x02;
+   devip->sense_buff[9] = 0x06;
+   devip->sense_buff[12] = 0x01;
+   }
+   devip->sense_pending = 1;
+   }
+   }
+   spin_unlock(&sdebug_host_list_lock);
+   return count;
+   }
+   return -EINVAL;
+}
+DRIVER_ATTR(ua_overflow, S_IWUSR, NULL, sdebug_ua_overflow_store);
+
+static ssize_t sdebug_soft_threshold_reached_store(struct device_driver *ddp,
+  const char *buf,
+  size_t count)
+{
+   int n;
+   struct sdebug_host_info *sdbg_host;
+   struct sdebug_dev_info *devip;
+
+   if ((count > 0) && (1 == sscanf(buf, "%d", &n)) && (n >= 0)) {
+   spin_lock(&sdebug_host_list_lock);
+   list_for_each_entry(sdbg_host, &sdebug_host_list, host_list) {
+   list_for_eac

[PATCH v2 6/8] [SCSI] Add sysfs support for enhanced Unit Attention handling

2013-02-01 Thread Ewan D. Milne
From: "Ewan D. Milne" 

Added support for additional scsi_device events in sysfs, as
well as support for scsi_target events.  Also added "rescan"
node in scsi_target sysfs to permit targets to be rescanned
from udev rules in a more straightforward way.

Signed-off-by: Ewan D. Milne 
---
 drivers/scsi/scsi_priv.h  |   4 +-
 drivers/scsi/scsi_scan.c  |  29 +-
 drivers/scsi/scsi_sysfs.c | 141 ++
 3 files changed, 136 insertions(+), 38 deletions(-)

diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h
index b237c8e..fa3366a97 100644
--- a/drivers/scsi/scsi_priv.h
+++ b/drivers/scsi/scsi_priv.h
@@ -136,7 +136,9 @@ extern int scsi_sysfs_add_host(struct Scsi_Host *);
 extern int scsi_sysfs_register(void);
 extern void scsi_sysfs_unregister(void);
 extern void scsi_sysfs_device_initialize(struct scsi_device *);
-extern int scsi_sysfs_target_initialize(struct scsi_device *);
+extern void scsi_sysfs_target_initialize(struct scsi_target *,
+struct Scsi_Host *,
+struct device *parent);
 extern struct scsi_transport_template blank_transport_template;
 extern void __scsi_remove_device(struct scsi_device *);
 
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 1ad4287..1bbbc43 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -346,25 +346,6 @@ static void scsi_target_destroy(struct scsi_target 
*starget)
put_device(dev);
 }
 
-static void scsi_target_dev_release(struct device *dev)
-{
-   struct device *parent = dev->parent;
-   struct scsi_target *starget = to_scsi_target(dev);
-
-   kfree(starget);
-   put_device(parent);
-}
-
-static struct device_type scsi_target_type = {
-   .name = "scsi_target",
-   .release =  scsi_target_dev_release,
-};
-
-int scsi_is_target_device(const struct device *dev)
-{
-   return dev->type == &scsi_target_type;
-}
-EXPORT_SYMBOL(scsi_is_target_device);
 
 static struct scsi_target *__scsi_find_target(struct device *parent,
  int channel, uint id)
@@ -416,15 +397,11 @@ static struct scsi_target *scsi_alloc_target(struct 
device *parent,
printk(KERN_ERR "%s: allocation failure\n", __func__);
return NULL;
}
-   dev = &starget->dev;
-   device_initialize(dev);
-   starget->reap_ref = 1;
-   dev->parent = get_device(parent);
-   dev_set_name(dev, "target%d:%d:%d", shost->host_no, channel, id);
-   dev->bus = &scsi_bus_type;
-   dev->type = &scsi_target_type;
starget->id = id;
starget->channel = channel;
+   scsi_sysfs_target_initialize(starget, shost, parent);
+   dev = &starget->dev;
+   starget->reap_ref = 1;
starget->can_queue = 0;
INIT_LIST_HEAD(&starget->siblings);
INIT_LIST_HEAD(&starget->devices);
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index aff1e29..363e29f 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -502,7 +502,7 @@ sdev_store_##field (struct device *dev, struct 
device_attribute *attr,  \
 {  \
int ret;\
struct scsi_device *sdev;   \
-   ret = scsi_sdev_check_buf_bit(buf); \
+   ret = scsi_sysfs_check_buf_bit(buf);\
if (ret >= 0)   {   \
sdev = to_scsi_device(dev); \
sdev->field = ret;  \
@@ -513,10 +513,10 @@ sdev_store_##field (struct device *dev, struct 
device_attribute *attr,\
 static DEVICE_ATTR(field, S_IRUGO | S_IWUSR, sdev_show_##field, 
sdev_store_##field);
 
 /*
- * scsi_sdev_check_buf_bit: return 0 if buf is "0", return 1 if buf is "1",
+ * scsi_sysfs_check_buf_bit: return 0 if buf is "0", return 1 if buf is "1",
  * else return -EINVAL.
  */
-static int scsi_sdev_check_buf_bit(const char *buf)
+static int scsi_sysfs_check_buf_bit(const char *buf)
 {
if ((buf[1] == '\0') || ((buf[1] == '\n') && (buf[2] == '\0'))) {
if (buf[0] == '1')
@@ -650,7 +650,8 @@ show_queue_type_field(struct device *dev, struct 
device_attribute *attr,
 static DEVICE_ATTR(queue_type, S_IRUGO, show_queue_type_field, NULL);
 
 static ssize_t
-show_iostat_counterbits(struct device *dev, struct device_attribute *attr, 
char *buf)
+show_iostat_counterbits(struct device *dev, struct device_attribute *attr,
+   char *buf)
 {
return snprintf(buf, 20, "%d\n", (int)sizeof(atomic_t) * 8);
 }
@@ -681,7 +682,7 @@ sdev_show_modalias(struct device *dev, struct 
device_attribute *attr, char *buf)
 

[PATCH v2 5/8] [SCSI] Generate uevents for certain Unit Attention codes

2013-02-01 Thread Ewan D. Milne
From: "Ewan D. Milne" 

Generate a uevent on the scsi_target object when the following
Unit Attention ASC/ASCQ code is received:

3F/0E  REPORTED LUNS DATA HAS CHANGED

Generate a uevent on the scsi_device object when the following
Unit Attention ASC/ASCQ codes are received:

2A/01  MODE PARAMETERS CHANGED
2A/09  CAPACITY DATA HAS CHANGED
38/07  THIN PROVISIONING SOFT THRESHOLD REACHED

All uevent generation is aggregated and rate-limited so that any
individual event is delivered no more than once every 2 seconds.

Log kernel messages when the following Unit Attention ASC/ASCQ
codes are received:

2A/xx  PARAMETERS CHANGED
3F/03  INQUIRY DATA HAS CHANGED
3F/xx  TARGET OPERATING CONDITIONS HAVE CHANGED

Also changed the kernel log messages on existing Unit Attention
codes, to remove text that indicates that the conditions were not
handled in any way (since they are now handled in some way) and
reflect the wording used in SPC-4.

Also log a kernel message when the a scsi device reports a Unit
Attention queue overflow, indicating that status has been lost.

These changes are only enabled when the kernel config option
CONFIG_SCSI_ENHANCED_UA is set.  Otherwise, the behavior is the
same as before, including the existing kernel log messages.
However, the detection of these conditions was moved to be earlier
in scsi_check_sense(), because the code was not always reached.

Added a new exported function scsi_report_sense() to allow drivers
to report sense data that is not associated with a SCSI command.

Signed-off-by: Ewan D. Milne 
---
 drivers/scsi/scsi_error.c  | 187 -
 drivers/scsi/scsi_lib.c|  16 
 drivers/scsi/scsi_priv.h   |   2 +
 drivers/scsi/scsi_scan.c   |   5 ++
 drivers/scsi/scsi_sysfs.c  |   3 +
 include/scsi/scsi_cmnd.h   |   4 +
 include/scsi/scsi_device.h |  21 +
 include/scsi/scsi_eh.h |   5 ++
 8 files changed, 222 insertions(+), 21 deletions(-)

diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index d0f71e5..d0b5a26 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -223,6 +223,86 @@ static inline void scsi_eh_prt_fail_stats(struct Scsi_Host 
*shost,
 #endif
 
 /**
+ * scsi_report_sense - Examine scsi sense information and log messages for
+ *certain conditions, also issue uevents if so configured.
+ * @sshdr: sshdr to be examined
+ */
+void scsi_report_sense(struct scsi_device *sdev, struct scsi_sense_hdr *sshdr)
+{
+#ifdef CONFIG_SCSI_ENHANCED_UA
+   if (sshdr->ua_queue_overflow)
+   sdev_printk(KERN_WARNING, sdev,
+   "Unit Attention queue overflow");
+#endif
+
+   if (sshdr->sense_key == UNIT_ATTENTION) {
+   if (sshdr->asc == 0x3f && sshdr->ascq == 0x03)
+   sdev_printk(KERN_WARNING, sdev,
+   "Inquiry data has changed");
+   else if (sshdr->asc == 0x3f && sshdr->ascq == 0x0e) {
+#ifdef CONFIG_SCSI_ENHANCED_UA
+   struct scsi_target *starget = scsi_target(sdev);
+   if (atomic_xchg(&starget->lun_change_reported, 1) == 0)
+   schedule_delayed_work(&starget->ua_dwork, 2*HZ);
+   sdev_printk(KERN_WARNING, sdev,
+   "Reported LUNs data has changed");
+#else
+   sdev_printk(KERN_WARNING, sdev,
+   "Warning! Received an indication that the "
+   "LUN assignments on this target have "
+   "changed. The Linux SCSI layer does not "
+   "automatically remap LUN assignments.\n");
+#endif
+   } else if (sshdr->asc == 0x3f)
+#ifdef CONFIG_SCSI_ENHANCED_UA
+   sdev_printk(KERN_WARNING, sdev,
+   "Target operating conditions have changed");
+#else
+   sdev_printk(KERN_WARNING, sdev,
+   "Warning! Received an indication that the "
+   "operating parameters on this target have "
+   "changed. The Linux SCSI layer does not "
+   "automatically adjust these parameters.\n");
+#endif
+
+   if (sshdr->asc == 0x38 && sshdr->ascq == 0x07) {
+#ifdef CONFIG_SCSI_ENHANCED_UA
+   if (atomic_xchg(&sdev->soft_threshold_reached, 1) == 0)
+   schedule_delayed_work(&sdev->ua_dwork, 2 * HZ);
+   sdev_printk(KERN_WARNING, sdev,
+   "Thin provisioning soft threshold reached");
+#else
+   sdev_printk(KERN_WARNING, sdev,
+   "Warning! Received an indication that the "
+   "LUN reached a thin prov

[GIT PULL] target fixes for v3.8-rc7

2013-02-01 Thread Nicholas A. Bellinger
Hi Linus,

Here's the current set of v3.8-rc fixes in the target-pending.git queue.
Apologies in advance for these missing the -rc6 release, and having to
be destined for -rc7 code.

Please go ahead and pull from:

  git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending.git master

The majority of these patches are regression bugfixes specific to
v3.8-rc code changes, namely the zero-length CDB handling breakage after
the sense_reason_t conversion, and preventing configfs port linking for
unconfigured devices after the recent struct se_subsystem_dev removal.  
These is also one (the divide by zero bug for unconfigured devices) that
is CC'ed to stable.

Thank you,

--nab

Michael S. Tsirkin (1):
  tcm_vhost: fix pr_err on early kick

Nicholas Bellinger (5):
  target: Fix zero-length INQUIRY additional sense code regression
  target: Fix zero-length MODE_SENSE regression
  target: Fix zero-length READ_CAPACITY_16 regression
  target: Fix regression allowing unconfigured devices to fabric port
link
  target: Fix divide by zero bug in fabric_max_sectors for unconfigured
devices

 drivers/target/target_core_device.c  |8 -
 drivers/target/target_core_fabric_configfs.c |5 +++
 drivers/target/target_core_sbc.c |   18 +--
 drivers/target/target_core_spc.c |   44 ++---
 drivers/vhost/tcm_vhost.c|4 +--
 5 files changed, 32 insertions(+), 47 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html