Re: [PATCH v8 0/10] More device removal fixes

2013-02-09 Thread Bart Van Assche

On 02/09/13 00:29, Joe Lawrence wrote:

I haven't had time to rerun the test without the two patches that wait in
scsi_remove_host(), however I did rerun the test and verify the same
behavior as in my earlier mail.  I didn't see any __scsi_remove_device()
instances running.

Some more investigation revealed that MD RAID was holding a reference to
the removed device.  (In short, mdadm --remove had failed and left the
device as a faulty member of the array.)  When I did finally manage to
kick that disk from the MD device, scsi host/device removal continued to
completion as expected.

There's a bit more context to the MD situation that I'll post to the raid
list once I get the details together for Neil.  I will CC you if you are
interested in following.


The loop in scsi_remove_host() waits too long. It should stop waiting as 
soon as the blk_cleanup_queue() calls for all sdev's have finished 
instead of waiting until all sdev users have closed these sdev's. I will 
repost patches 07/10 and 08/10.


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: [PATCH 2/3] target: Fix error checking for UNMAP commands

2013-02-09 Thread Chris Boot

On 08/02/2013 23:18, Roland Dreier wrote:

diff --git a/drivers/target/target_core_iblock.c 
b/drivers/target/target_core_iblock.c
index b526d23..b72ca5b 100644
--- a/drivers/target/target_core_iblock.c
+++ b/drivers/target/target_core_iblock.c
@@ -2674,6 +2675,15 @@ transport_send_check_condition_and_sense(struct se_cmd 
*cmd,
/* INVALID FIELD IN PARAMETER LIST */
buffer[SPC_ASC_KEY_OFFSET] = 0x26;
break;
+   case TCM_PARAMETER_LIST_LENGTH_ERROR:
+   /* CURRENT ERROR */
+   buffer[0] = 0x70;
+   buffer[SPC_ADD_SENSE_LEN_OFFSET] = 10;
+   /* ILLEGAL REQUEST */
+   buffer[SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST;
+   /* INVALID FIELD IN PARAMETER LIST */
+   buffer[SPC_ASC_KEY_OFFSET] = 0x1a;
+   break;
case TCM_UNEXPECTED_UNSOLICITED_DATA:
/* CURRENT ERROR */
buffer[0] = 0x70;


Nitpick: I suspect a simple copy  paste error; INVALID FIELD IN 
PARAMETER LIST in your comment should probably read PARAMETER LIST 
LENGTH ERROR instead.


HTH,
Chris

--
Chris Boot
bo...@bootc.net

--
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 v7 1/9] Fix race between starved list processing and device removal

2013-02-09 Thread Bart Van Assche

Hello James,

Please consider this patch for inclusion in kernel 3.9.

Thanks,

Bart.

On 01/09/13 02:25, Chanho Min wrote:

Is there any progress in this patch?
Oops is still occurred from a torn down device due to this cause.
We look forward to this patch is applied to mainline ASAP.

Thanks
Chanho Min


-Original Message-
From: Bart Van Assche [mailto:bvanass...@acm.org]
Sent: Friday, December 07, 2012 12:53 AM
To: undisclosed-recipients:
Cc: linux-scsi; James Bottomley; Mike Christie; Tejun Heo; Chanho Min; Jens 
Axboe
Subject: [PATCH v7 1/9] Fix race between starved list processing and device 
removal

Avoid that the sdev reference count can drop to zero before
a queue is run by scsi_run_queue().

Signed-off-by: Bart Van Assche bvanass...@acm.org
Reported-and-tested-by: Chanho Min chanho@lge.com
Reference: http://lkml.org/lkml/2012/8/2/96
Acked-by: Tejun Heo t...@kernel.org
Reviewed-by: Mike Christie micha...@cs.wisc.edu
Cc: Jens Axboe ax...@kernel.dk
Cc: sta...@vger.kernel.org
---
drivers/scsi/scsi_lib.c   |   16 +++-
drivers/scsi/scsi_sysfs.c |   14 +-
2 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index f1bf5af..5c67339 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -452,11 +452,17 @@ static void scsi_run_queue(struct request_queue *q)
continue;
}

-   spin_unlock(shost-host_lock);
-   spin_lock(sdev-request_queue-queue_lock);
-   __blk_run_queue(sdev-request_queue);
-   spin_unlock(sdev-request_queue-queue_lock);
-   spin_lock(shost-host_lock);
+   /*
+* Obtain a reference before unlocking the host_lock such that
+* the sdev can't disappear before blk_run_queue() is invoked.
+*/
+   get_device(sdev-sdev_gendev);
+   spin_unlock_irqrestore(shost-host_lock, flags);
+
+   blk_run_queue(sdev-request_queue);
+   put_device(sdev-sdev_gendev);
+
+   spin_lock_irqsave(shost-host_lock, flags);
}
/* put any unprocessed entries back */
list_splice(starved_list, shost-starved_list);
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index ce5224c..2ff7ba5 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -348,7 +348,6 @@ static void scsi_device_dev_release_usercontext(struct 
work_struct *work)
starget-reap_ref++;
list_del(sdev-siblings);
list_del(sdev-same_target_siblings);
-   list_del(sdev-starved_entry);
spin_unlock_irqrestore(sdev-host-host_lock, flags);

cancel_work_sync(sdev-event_work);
@@ -956,6 +955,8 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)
void __scsi_remove_device(struct scsi_device *sdev)
{
struct device *dev = sdev-sdev_gendev;
+   struct Scsi_Host *shost = sdev-host;
+   unsigned long flags;

if (sdev-is_visible) {
if (scsi_device_set_state(sdev, SDEV_CANCEL) != 0)
@@ -977,6 +978,17 @@ void __scsi_remove_device(struct scsi_device *sdev)
blk_cleanup_queue(sdev-request_queue);
cancel_work_sync(sdev-requeue_work);

+   /*
+* Remove a SCSI device from the starved list after blk_cleanup_queue()
+* finished such that scsi_request_fn() can't add it back to that list.
+* Also remove an sdev from the starved list before invoking
+* put_device() such that get_device() is guaranteed to succeed for an
+* sdev present on the starved list.
+*/
+   spin_lock_irqsave(shost-host_lock, flags);
+   list_del(sdev-starved_entry);
+   spin_unlock_irqrestore(shost-host_lock, flags);
+
if (sdev-host-hostt-slave_destroy)
sdev-host-hostt-slave_destroy(sdev);
transport_destroy_device(dev);
--
1.7.10.4





--
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 2/3] target: Fix error checking for UNMAP commands

2013-02-09 Thread Roland Dreier
On Sat, Feb 9, 2013 at 1:23 AM, Chris Boot bo...@bootc.net wrote:
 +   case TCM_PARAMETER_LIST_LENGTH_ERROR:
 +   /* CURRENT ERROR */
 +   buffer[0] = 0x70;
 +   buffer[SPC_ADD_SENSE_LEN_OFFSET] = 10;
 +   /* ILLEGAL REQUEST */
 +   buffer[SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST;
 +   /* INVALID FIELD IN PARAMETER LIST */
 +   buffer[SPC_ASC_KEY_OFFSET] = 0x1a;
 +   break;
 case TCM_UNEXPECTED_UNSOLICITED_DATA:
 /* CURRENT ERROR */
 buffer[0] = 0x70;


 Nitpick: I suspect a simple copy  paste error; INVALID FIELD IN PARAMETER
 LIST in your comment should probably read PARAMETER LIST LENGTH ERROR
 instead.

Yes, the comment is a copy and paste error.  The ASC of 1Ah is correct for
PARAMETER LIST LENGTH ERROR.  Thanks  good catch.

Nic, want me to resend?

 - R.
--
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] [SCSI] aacraid: silence two GCC warnings

2013-02-09 Thread Paul Bolle
Compiling src.o for a 32 bit system triggers two GCC warnings:
drivers/scsi/aacraid/src.c: In function ‘aac_src_deliver_message’:
drivers/scsi/aacraid/src.c:410:3: warning: right shift count = width of 
type [enabled by default]
drivers/scsi/aacraid/src.c:434:2: warning: right shift count = width of 
type [enabled by default]

Silence these warnings by casting the 'address' variable (of type
dma_addr_t) to u64 on those two lines.

Signed-off-by: Paul Bolle pebo...@tiscali.nl
---
0) Compile tested only.

1) Changing '0L' to 'OUL' might be a bit of cargo cult programming. I
doubt it's necessary. Members of that cult might also change
'0x' to '0xUL', but I didn't.

 drivers/scsi/aacraid/src.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/aacraid/src.c b/drivers/scsi/aacraid/src.c
index 3b021ec..dfa8a37 100644
--- a/drivers/scsi/aacraid/src.c
+++ b/drivers/scsi/aacraid/src.c
@@ -407,7 +407,7 @@ static int aac_src_deliver_message(struct fib *fib)
fib-hw_fib_va-header.StructType = FIB_MAGIC2;
fib-hw_fib_va-header.SenderFibAddress = (u32)address;
fib-hw_fib_va-header.u.TimeStamp = 0;
-   BUG_ON((u32)(address  32) != 0L);
+   BUG_ON(((u64)address  32) != 0UL);
address |= fibsize;
} else {
/* Calculate the amount to the fibsize bits */
@@ -431,7 +431,7 @@ static int aac_src_deliver_message(struct fib *fib)
address |= fibsize;
}
 
-   src_writel(dev, MUnit.IQ_H, (address  32)  0x);
+   src_writel(dev, MUnit.IQ_H, ((u64)address  32)  0x);
src_writel(dev, MUnit.IQ_L, address  0x);
 
return 0;
-- 
1.8.1.2

--
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 0/3] megaraid_sas: Updates for scsi-misc

2013-02-09 Thread adam radford
James/linux-scsi,

The following small patch series for megaraid_sas brings the driver up
to v06.506.00.00-rc1:

1. Add 4k FastPath DIF support.
2. Dont load DevHandle unless FastPath enabled.
3. Version and Changelog update.

-Adam
--
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 1/3] megaraid_sas: Add 4k FastPath DIF support

2013-02-09 Thread adam radford
James/linux-scsi,

The following patch for megaraid_sas will allow Fastpath T10PI/DIF
frame builds to work with 4k sector size.

Signed-off-by: Adam Radford aradf...@gmail.com

diff -Naur scsi-misc.old/drivers/scsi/megaraid/megaraid_sas_fusion.c
scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_fusion.c
--- scsi-misc.old/drivers/scsi/megaraid/megaraid_sas_fusion.c   2013-02-08
13:20:39.0 -0800
+++ scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_fusion.c   2013-02-09
22:41:23.871865168 -0800
@@ -1206,7 +1206,7 @@
MPI2_SCSIIO_EEDPFLAGS_INSERT_OP;
}
io_request-Control |= (0x4  26);
-   io_request-EEDPBlockSize = MEGASAS_EEDPBLOCKSIZE;
+   io_request-EEDPBlockSize = scp-device-sector_size;
} else {
/* Some drives don't support 16/12 byte CDB's, convert to 10 */
if (((cdb_len == 12) || (cdb_len == 16)) 
diff -Naur scsi-misc.old/drivers/scsi/megaraid/megaraid_sas_fusion.h
scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_fusion.h
--- scsi-misc.old/drivers/scsi/megaraid/megaraid_sas_fusion.h   2013-02-08
13:20:39.0 -0800
+++ scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_fusion.h   2013-02-09
22:41:38.372866533 -0800
@@ -61,7 +61,6 @@
 #define MEGASAS_SCSI_ADDL_CDB_LEN   0x18
 #define MEGASAS_RD_WR_PROTECT_CHECK_ALL0x20
 #define MEGASAS_RD_WR_PROTECT_CHECK_NONE   0x60
-#define MEGASAS_EEDPBLOCKSIZE  512

 /*
  * Raid context flags


megaraid_sas.patch1
Description: Binary data


[PATCH 2/3] megaraid_sas: Dont load DevHandle unless FastPath enabled

2013-02-09 Thread adam radford
James/linux-scsi,

The following patch for megaraid_sas will fix an issue where the
driver should not be loading the DevHandle unless FastPath is enabled.
 If FastPath was not enabled, this means the hardware raid map
validation failed for some reason, or the map was corrupted, which
could mean the DevHandle could be invalid.

Signed-off-by: Adam Radford aradf...@gmail.com

diff -Naur scsi-misc.old/drivers/scsi/megaraid/megaraid_sas_fusion.c
scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_fusion.c
--- scsi-misc.old/drivers/scsi/megaraid/megaraid_sas_fusion.c   2013-02-09
22:44:15.625191018 -0800
+++ scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_fusion.c   2013-02-09
22:46:14.863866082 -0800
@@ -1511,7 +1511,8 @@
if (scmd-device-channel  MEGASAS_MAX_PD_CHANNELS 
instance-pd_list[pd_index].driveState == MR_PD_STATE_SYSTEM) {
io_request-Function = 0;
-   io_request-DevHandle =
+   if (fusion-fast_path_io)
+   io_request-DevHandle =
local_map_ptr-raidMap.devHndlInfo[device_id].curDevHdl;
io_request-RaidContext.timeoutValue =
local_map_ptr-raidMap.fpPdIoTimeoutSec;


megaraid_sas.patch2
Description: Binary data


[PATCH 3/3] megaraid_sas: Version and Changelog update

2013-02-09 Thread adam radford
James/linux-scsi,

This patch updates the megaraid_sas driver version and updates
Documentation/scsi/ChangeLog.megaraid_sas.

Signed-off-by: Adam Radford aradf...@gmail.com

diff -Naur scsi-misc.old/Documentation/scsi/ChangeLog.megaraid_sas
scsi-misc.new/Documentation/scsi/ChangeLog.megaraid_sas
--- scsi-misc.old/Documentation/scsi/ChangeLog.megaraid_sas 2013-02-08
13:20:39.0 -0800
+++ scsi-misc.new/Documentation/scsi/ChangeLog.megaraid_sas 2013-02-09
22:51:59.079867393 -0800
@@ -1,3 +1,12 @@
+Release Date: Sat. Feb 9, 2013 17:00:00 PST 2013 -
+   (emaild-id:megaraidli...@lsi.com)
+   Adam Radford
+Current Version : 06.506.00.00-rc1
+Old Version : 06.504.01.00-rc1
+1. Add 4k FastPath DIF support.
+2. Dont load DevHandle unless FastPath enabled.
+3. Version and Changelog update.
+---
 Release Date: Mon. Oct 1, 2012 17:00:00 PST 2012 -
(emaild-id:megaraidli...@lsi.com)
Adam Radford
diff -Naur scsi-misc.old/drivers/scsi/megaraid/megaraid_sas_base.c
scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_base.c
--- scsi-misc.old/drivers/scsi/megaraid/megaraid_sas_base.c 2013-02-08
13:20:39.0 -0800
+++ scsi-misc.new/drivers/scsi/megaraid/megaraid_sas_base.c 2013-02-09
22:52:28.607810580 -0800
@@ -18,7 +18,7 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  *
  *  FILE: megaraid_sas_base.c
- *  Version : v06.504.01.00-rc1
+ *  Version : v06.506.00.00-rc1
  *
  *  Authors: LSI Corporation
  *   Sreenivas Bagalkote
diff -Naur scsi-misc.old/drivers/scsi/megaraid/megaraid_sas.h
scsi-misc.new/drivers/scsi/megaraid/megaraid_sas.h
--- scsi-misc.old/drivers/scsi/megaraid/megaraid_sas.h  2013-02-08
13:20:39.0 -0800
+++ scsi-misc.new/drivers/scsi/megaraid/megaraid_sas.h  2013-02-09
22:52:53.344866438 -0800
@@ -33,9 +33,9 @@
 /*
  * MegaRAID SAS Driver meta data
  */
-#define MEGASAS_VERSION06.504.01.00-rc1
-#define MEGASAS_RELDATEOct. 1, 2012
-#define MEGASAS_EXT_VERSIONMon. Oct. 1 17:00:00 PDT 2012
+#define MEGASAS_VERSION06.506.00.00-rc1
+#define MEGASAS_RELDATEFeb. 9, 2013
+#define MEGASAS_EXT_VERSIONSat. Feb. 9 17:00:00 PDT 2013

 /*
  * Device IDs


megaraid_sas.patch3
Description: Binary data