LSF/MM 2014 Call For Proposals

2013-12-20 Thread Mel Gorman
The annual Linux Storage, Filesystem and Memory Management Summit for
2014 will be held on March 24th and 25th before the Linux Foundation
Collaboration summit at The Meritage Resort, Napa Valley, CA.


http://events.linuxfoundation.org/events/linux-storage-filesystem-and-mm-summit
http://events.linuxfoundation.org/events/collaboration-summit

Note that we are running LSF/MM a little earlier in 2014 than in previous
years.

On behalf of the committee I would like to issue a call for agenda proposals
that are suitable for cross-track discussion as well as more technical
subjects for discussion in the breakout sessions.

1) Suggestions for agenda topics should be sent before January 31st
2014 to:

lsf...@lists.linux-foundation.org

and cc the Linux list or lists that are most interested in it:

ATA: linux-...@vger.kernel.org
FS: linux-fsde...@vger.kernel.org
MM: linux...@kvack.org
SCSI: linux-scsi@vger.kernel.org

People who need more time for visa applications should send proposals before
January 15th. The committee will complete the first round of selections
on that date to accommodate applications.

Please remember to tag your subject with [LSF/MM TOPIC] to make it
easier to track. Agenda topics and attendees will be selected by the
program committee, but the final agenda will be formed by consensus of
the attendees on the day.

We will try to cap attendance at around 25-30 per track to facilitate
discussions although the final numbers will depend on the room sizes at
the venue.

2) Requests to attend the summit should be sent to:

lsf...@lists.linux-foundation.org

Please summarize what expertise you will bring to the meeting, and what
you would like to discuss. Please also tag your email with [LSF/MM ATTEND]
so there is less chance of it getting lost in the large mail pile.

Presentations are allowed to guide discussion, but are strongly
discouraged. There will be no recording or audio bridge. However, we expect
that written minutes will be published as we did in previous years

2013:
http://lwn.net/Articles/548089/

2012:
http://lwn.net/Articles/490114/
http://lwn.net/Articles/490501/

2011:
http://lwn.net/Articles/436871/
http://lwn.net/Articles/437066/

3) If you have feedback on last year's meeting that we can use to
improve this year's, please also send that to:

lsf...@lists.linux-foundation.org

Thank you on behalf of the program committee:

Storage:
James Bottomley
Martin K. Petersen

Filesystems:
Trond Myklebust
Jeff Layton
Dave Chinner
Jan Kara
Ted Ts'o

MM:
Rik van Riel
Michel Lespinasse

-- 
Mel Gorman
SUSE Labs
--
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 0/2] pm80xx: Fix ATTO pm8001 based HBA support

2013-12-20 Thread Jack Wang
On 12/19/2013 04:50 PM, Bradley Grove wrote:
 Addresses issues that we uncovered during testing with our HBAs.
 For the most part, we just enabled code that was already being used 
 for other vendor's HBAs.
 
 Bradley Grove (2):
   pm80xx: Read saved WWN from NVMD for ATTO pm8001 based HBAs.
   pm80xx: Enable BAR shift to avoid BIOS conflict with MPI space for
 ATTO pm8001 based HBAs.
 
  drivers/scsi/pm8001/pm8001_hwi.c  |  6 +++---
  drivers/scsi/pm8001/pm8001_init.c | 10 +-
  2 files changed, 8 insertions(+), 8 deletions(-)
 
Looks fine, thanks
 Acked-by: Jack Wang xjtu...@gmail.com
--
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 00/16] scsi_dh_alua updates

2013-12-20 Thread Hannes Reinecke
Hi James,

here's an update for the ALUA device handler I've been hoarding
for quite some time. The major bit here is the asynchronous
RTPG handling. With the original design we would treat every
LUN independently, despite the fact that several LUNs might
in fact belong to the same target port group. So any
change on one LUN will affect the others, too.
And we now can treat LUNs in 'transitioning' ALUA mode
correctly, as now we'll be blocking any I/O in the prep_fn()
until the controller is in a working state again.

Hannes Reinecke (16):
  scsi_dh_alua: Improve error handling
  scsi_dh_alua: use flag for RTPG extended header
  scsi_dh_alua: Pass buffer as function argument
  scsi_dh_alua: Make stpg synchronous
  scsi_dh_alua: put sense buffer on stack
  scsi_dh_alua: use local buffer for VPD inquiry
  scsi_dh_alua: Use separate alua_port_group structure
  scsi_dh_alua: parse target device id
  scsi_dh_alua: simplify sense code handling
  scsi_dh_alua: Do not attach to management devices
  scsi_dh_alua: multipath failover fails with error 15
  scsi_dh: return individual errors in scsi_dh_activate()
  scsi_dh_alua: Clarify logging message
  scsi_dh: invoke callback if -activate is not present
  scsi_dh_alua: revert commit a8e5a2d593cbfccf530c3382c2c328d2edaa7b66
  scsi_dh_alua: Use workqueue for RTPG

 drivers/scsi/device_handler/scsi_dh.c  |   18 +-
 drivers/scsi/device_handler/scsi_dh_alua.c | 1045 
 2 files changed, 750 insertions(+), 313 deletions(-)

-- 
1.7.12.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


[PATCH 06/16] scsi_dh_alua: use local buffer for VPD inquiry

2013-12-20 Thread Hannes Reinecke
VPD inquiry need to be done only once, so we can be using
a local buffer here.

Signed-off-by: Hannes Reinecke h...@suse.de
---
 drivers/scsi/device_handler/scsi_dh_alua.c | 45 ++
 1 file changed, 27 insertions(+), 18 deletions(-)

diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c 
b/drivers/scsi/device_handler/scsi_dh_alua.c
index adc77ef..49952f4 100644
--- a/drivers/scsi/device_handler/scsi_dh_alua.c
+++ b/drivers/scsi/device_handler/scsi_dh_alua.c
@@ -322,16 +322,27 @@ static int alua_check_tpgs(struct scsi_device *sdev, 
struct alua_dh_data *h)
  */
 static int alua_vpd_inquiry(struct scsi_device *sdev, struct alua_dh_data *h)
 {
+   unsigned char *buff;
+   unsigned char bufflen = 36;
int len, timeout = ALUA_FAILOVER_TIMEOUT;
unsigned char sense[SCSI_SENSE_BUFFERSIZE];
struct scsi_sense_hdr sense_hdr;
unsigned retval;
unsigned char *d;
unsigned long expiry;
+   int err;
 
expiry = round_jiffies_up(jiffies + timeout);
  retry:
-   retval = submit_vpd_inquiry(sdev, h-buff, h-bufflen, sense);
+   buff = kmalloc(bufflen, GFP_ATOMIC);
+   if (!buff) {
+   sdev_printk(KERN_WARNING, sdev,
+   %s: kmalloc buffer failed\n,
+   ALUA_DH_NAME);
+   /* Temporary failure, bypass */
+   return SCSI_DH_DEV_TEMP_BUSY;
+   }
+   retval = submit_vpd_inquiry(sdev, buff, bufflen, sense);
if (retval) {
unsigned err;
 
@@ -345,6 +356,7 @@ static int alua_vpd_inquiry(struct scsi_device *sdev, 
struct alua_dh_data *h)
err = SCSI_DH_DEV_TEMP_BUSY;
else
err = SCSI_DH_IO;
+   kfree(buff);
return err;
}
err = alua_check_sense(sdev, sense_hdr);
@@ -362,24 +374,19 @@ static int alua_vpd_inquiry(struct scsi_device *sdev, 
struct alua_dh_data *h)
}
 
/* Check if vpd page exceeds initial buffer */
-   len = (h-buff[2]  8) + h-buff[3] + 4;
-   if (len  h-bufflen) {
+   len = (buff[2]  8) + buff[3] + 4;
+   if (len  bufflen) {
/* Resubmit with the correct length */
-   if (realloc_buffer(h, len)) {
-   sdev_printk(KERN_WARNING, sdev,
-   %s: kmalloc buffer failed\n,
-   ALUA_DH_NAME);
-   /* Temporary failure, bypass */
-   return SCSI_DH_DEV_TEMP_BUSY;
-   }
+   kfree(buff);
+   bufflen = len;
goto retry;
}
 
/*
 * Now look for the correct descriptor.
 */
-   d = h-buff + 4;
-   while (d  h-buff + len) {
+   d = buff + 4;
+   while (d  buff + len) {
switch (d[1]  0xf) {
case 0x4:
/* Relative target port */
@@ -406,13 +413,15 @@ static int alua_vpd_inquiry(struct scsi_device *sdev, 
struct alua_dh_data *h)
ALUA_DH_NAME);
h-state = TPGS_STATE_OPTIMIZED;
h-tpgs = TPGS_MODE_NONE;
-   return SCSI_DH_DEV_UNSUPP;
+   err = SCSI_DH_DEV_UNSUPP;
+   } else {
+   sdev_printk(KERN_INFO, sdev,
+   %s: port group %02x rel port %02x\n,
+   ALUA_DH_NAME, h-group_id, h-rel_port);
+   err = SCSI_DH_OK;
}
-   sdev_printk(KERN_INFO, sdev,
-   %s: port group %02x rel port %02x\n,
-   ALUA_DH_NAME, h-group_id, h-rel_port);
-
-   return SCSI_DH_OK;
+   kfree(buff);
+   return err;
 }
 
 static char print_alua_state(int state)
-- 
1.7.12.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


[PATCH 07/16] scsi_dh_alua: Use separate alua_port_group structure

2013-12-20 Thread Hannes Reinecke
The port group needs to be a separate structure as several
LUNs might belong to the same group.

Signed-off-by: Hannes Reinecke h...@suse.de
---
 drivers/scsi/device_handler/scsi_dh_alua.c | 220 ++---
 1 file changed, 139 insertions(+), 81 deletions(-)

diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c 
b/drivers/scsi/device_handler/scsi_dh_alua.c
index 49952f4..6f1d19c 100644
--- a/drivers/scsi/device_handler/scsi_dh_alua.c
+++ b/drivers/scsi/device_handler/scsi_dh_alua.c
@@ -63,9 +63,13 @@
 #define ALUA_OPTIMIZE_STPG 1
 #define ALUA_RTPG_EXT_HDR_UNSUPP   2
 
-struct alua_dh_data {
+static LIST_HEAD(port_group_list);
+static DEFINE_SPINLOCK(port_group_lock);
+
+struct alua_port_group {
+   struct kref kref;
+   struct list_headnode;
int group_id;
-   int rel_port;
int tpgs;
int state;
int pref;
@@ -74,6 +78,13 @@ struct alua_dh_data {
unsigned char   *buff;
int bufflen;
unsigned char   transition_tmo;
+};
+
+struct alua_dh_data {
+   struct alua_port_group  *pg;
+   int rel_port;
+   int tpgs;
+   unsignedflags; /* used for optimizing STPG */
struct scsi_device  *sdev;
activate_complete   callback_fn;
void*callback_data;
@@ -92,18 +103,18 @@ static inline struct alua_dh_data *get_alua_data(struct 
scsi_device *sdev)
return ((struct alua_dh_data *) scsi_dh_data-buf);
 }
 
-static int realloc_buffer(struct alua_dh_data *h, unsigned len)
+static int realloc_buffer(struct alua_port_group *pg, unsigned len)
 {
-   if (h-buff  h-buff != h-inq)
-   kfree(h-buff);
+   if (pg-buff  pg-buff != pg-inq)
+   kfree(pg-buff);
 
-   h-buff = kmalloc(len, GFP_NOIO);
-   if (!h-buff) {
-   h-buff = h-inq;
-   h-bufflen = ALUA_INQUIRY_SIZE;
+   pg-buff = kmalloc(len, GFP_NOIO);
+   if (!pg-buff) {
+   pg-buff = pg-inq;
+   pg-bufflen = ALUA_INQUIRY_SIZE;
return 1;
}
-   h-bufflen = len;
+   pg-bufflen = len;
return 0;
 }
 
@@ -137,6 +148,20 @@ static struct request *get_alua_req(struct scsi_device 
*sdev,
return rq;
 }
 
+static void release_port_group(struct kref *kref)
+{
+   struct alua_port_group *pg;
+
+   pg = container_of(kref, struct alua_port_group, kref);
+   printk(KERN_WARNING alua: release port group %d\n, pg-group_id);
+   spin_lock(port_group_lock);
+   list_del(pg-node);
+   spin_unlock(port_group_lock);
+   if (pg-buff  pg-inq != pg-buff)
+   kfree(pg-buff);
+   kfree(pg);
+}
+
 /*
  * submit_vpd_inquiry - Issue an INQUIRY VPD page 0x83 command
  * @sdev: sdev the command should be sent to
@@ -327,10 +352,11 @@ static int alua_vpd_inquiry(struct scsi_device *sdev, 
struct alua_dh_data *h)
int len, timeout = ALUA_FAILOVER_TIMEOUT;
unsigned char sense[SCSI_SENSE_BUFFERSIZE];
struct scsi_sense_hdr sense_hdr;
-   unsigned retval;
+   unsigned retval, err;
+   int group_id = -1;
unsigned char *d;
unsigned long expiry;
-   int err;
+   struct alua_port_group *pg = NULL;
 
expiry = round_jiffies_up(jiffies + timeout);
  retry:
@@ -344,8 +370,6 @@ static int alua_vpd_inquiry(struct scsi_device *sdev, 
struct alua_dh_data *h)
}
retval = submit_vpd_inquiry(sdev, buff, bufflen, sense);
if (retval) {
-   unsigned err;
-
if (!(driver_byte(retval)  DRIVER_SENSE) ||
!scsi_normalize_sense(sense, SCSI_SENSE_BUFFERSIZE,
  sense_hdr)) {
@@ -356,8 +380,7 @@ static int alua_vpd_inquiry(struct scsi_device *sdev, 
struct alua_dh_data *h)
err = SCSI_DH_DEV_TEMP_BUSY;
else
err = SCSI_DH_IO;
-   kfree(buff);
-   return err;
+   goto out;
}
err = alua_check_sense(sdev, sense_hdr);
if (err == ADD_TO_MLQUEUE  time_before(jiffies, expiry))
@@ -369,7 +392,8 @@ static int alua_vpd_inquiry(struct scsi_device *sdev, 
struct alua_dh_data *h)
sdev_printk(KERN_INFO, sdev,
%s: evpd inquiry failed, , ALUA_DH_NAME);
scsi_show_extd_sense(sense_hdr.asc, sense_hdr.ascq);
-   return SCSI_DH_IO;
+   err = SCSI_DH_IO;
+   goto out;
}
}
 
@@ -394,7 +418,7 @@ static int alua_vpd_inquiry(struct scsi_device *sdev, 
struct alua_dh_data *h)
 

[PATCH 02/16] scsi_dh_alua: use flag for RTPG extended header

2013-12-20 Thread Hannes Reinecke
We should be using a flag when RTPG extended header is not
supported, that saves us sending RTPG twice for older arrays.

Signed-off-by: Hannes Reinecke h...@suse.de
---
 drivers/scsi/device_handler/scsi_dh_alua.c | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c 
b/drivers/scsi/device_handler/scsi_dh_alua.c
index e4e5497..ece2255 100644
--- a/drivers/scsi/device_handler/scsi_dh_alua.c
+++ b/drivers/scsi/device_handler/scsi_dh_alua.c
@@ -61,6 +61,7 @@
 
 /* flags passed from user level */
 #define ALUA_OPTIMIZE_STPG 1
+#define ALUA_RTPG_EXT_HDR_UNSUPP   2
 
 struct alua_dh_data {
int group_id;
@@ -181,8 +182,7 @@ done:
  * submit_rtpg - Issue a REPORT TARGET GROUP STATES command
  * @sdev: sdev the command should be sent to
  */
-static unsigned submit_rtpg(struct scsi_device *sdev, struct alua_dh_data *h,
-   bool rtpg_ext_hdr_req)
+static unsigned submit_rtpg(struct scsi_device *sdev, struct alua_dh_data *h)
 {
struct request *rq;
int err;
@@ -195,7 +195,7 @@ static unsigned submit_rtpg(struct scsi_device *sdev, 
struct alua_dh_data *h,
 
/* Prepare the command. */
rq-cmd[0] = MAINTENANCE_IN;
-   if (rtpg_ext_hdr_req)
+   if (!(h-flags  ALUA_RTPG_EXT_HDR_UNSUPP))
rq-cmd[1] = MI_REPORT_TARGET_PGS | MI_EXT_HDR_PARAM_FMT;
else
rq-cmd[1] = MI_REPORT_TARGET_PGS;
@@ -565,7 +565,6 @@ static int alua_rtpg(struct scsi_device *sdev, struct 
alua_dh_data *h, int wait_
int len, k, off, valid_states = 0;
unsigned char *ucp;
unsigned err, retval;
-   bool rtpg_ext_hdr_req = 1;
unsigned long expiry, interval = 0;
unsigned int tpg_desc_tbl_off;
unsigned char orig_transition_tmo;
@@ -576,7 +575,7 @@ static int alua_rtpg(struct scsi_device *sdev, struct 
alua_dh_data *h, int wait_
expiry = round_jiffies_up(jiffies + h-transition_tmo * HZ);
 
  retry:
-   retval = submit_rtpg(sdev, h, rtpg_ext_hdr_req);
+   retval = submit_rtpg(sdev, h);
 
if (retval) {
if (h-senselen == 0 ||
@@ -600,10 +599,10 @@ static int alua_rtpg(struct scsi_device *sdev, struct 
alua_dh_data *h, int wait_
 * The retry without rtpg_ext_hdr_req set
 * handles this.
 */
-   if (rtpg_ext_hdr_req == 1 
+   if (!(h-flags  ALUA_RTPG_EXT_HDR_UNSUPP) 
sense_hdr.sense_key == ILLEGAL_REQUEST 
sense_hdr.asc == 0x24  sense_hdr.ascq == 0) {
-   rtpg_ext_hdr_req = 0;
+   h-flags |= ALUA_RTPG_EXT_HDR_UNSUPP;
goto retry;
}
 
-- 
1.7.12.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


[PATCH 08/16] scsi_dh_alua: parse target device id

2013-12-20 Thread Hannes Reinecke
VPD descriptor association 0x2 in VPD page 0x83 identification
descrioptors can be used to identify the array / target device.
Some tricks need to be taken for EMC and HP, which put the
array identification into the standard inquiry.

Signed-off-by: Hannes Reinecke h...@suse.de
---
 drivers/scsi/device_handler/scsi_dh_alua.c | 123 -
 1 file changed, 119 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c 
b/drivers/scsi/device_handler/scsi_dh_alua.c
index 6f1d19c..9d712be 100644
--- a/drivers/scsi/device_handler/scsi_dh_alua.c
+++ b/drivers/scsi/device_handler/scsi_dh_alua.c
@@ -69,6 +69,9 @@ static DEFINE_SPINLOCK(port_group_lock);
 struct alua_port_group {
struct kref kref;
struct list_headnode;
+   unsigned char   target_id[256];
+   unsigned char   target_id_str[256];
+   int target_id_size;
int group_id;
int tpgs;
int state;
@@ -351,12 +354,14 @@ static int alua_vpd_inquiry(struct scsi_device *sdev, 
struct alua_dh_data *h)
unsigned char bufflen = 36;
int len, timeout = ALUA_FAILOVER_TIMEOUT;
unsigned char sense[SCSI_SENSE_BUFFERSIZE];
+   char target_id_str[256], *target_id = NULL;
+   int target_id_size;
struct scsi_sense_hdr sense_hdr;
unsigned retval, err;
int group_id = -1;
unsigned char *d;
unsigned long expiry;
-   struct alua_port_group *pg = NULL;
+   struct alua_port_group *tmp_pg, *pg = NULL;
 
expiry = round_jiffies_up(jiffies + timeout);
  retry:
@@ -409,9 +414,54 @@ static int alua_vpd_inquiry(struct scsi_device *sdev, 
struct alua_dh_data *h)
/*
 * Now look for the correct descriptor.
 */
+   memset(target_id_str, 0, 256);
+   target_id_size = 0;
d = buff + 4;
while (d  buff + len) {
switch (d[1]  0xf) {
+   case 0x2:
+   /* EUI-64 */
+   if ((d[1]  0x30) == 0x20) {
+   target_id_size = d[3];
+   target_id = d + 4;
+   switch (target_id_size) {
+   case 8:
+   sprintf(target_id_str,
+   eui.%8phN, d + 4);
+   break;
+   case 12:
+   sprintf(target_id_str,
+   eui.%12phN, d + 4);
+   break;
+   case 16:
+   sprintf(target_id_str,
+   eui.%16phN, d + 4);
+   break;
+   default:
+   target_id_size = 0;
+   break;
+   }
+   }
+   break;
+   case 0x3:
+   /* NAA */
+   if ((d[1]  0x30) == 0x20) {
+   target_id_size = d[3];
+   target_id = d + 4;
+   switch (target_id_size) {
+   case 8:
+   sprintf(target_id_str,
+   naa.%8phN, d + 4);
+   break;
+   case 16:
+   sprintf(target_id_str,
+   naa.%16phN, d + 4);
+   break;
+   default:
+   target_id_size = 0;
+   break;
+   }
+   }
case 0x4:
/* Relative target port */
h-rel_port = (d[6]  8) + d[7];
@@ -420,6 +470,18 @@ static int alua_vpd_inquiry(struct scsi_device *sdev, 
struct alua_dh_data *h)
/* Target port group */
group_id = (d[6]  8) + d[7];
break;
+   case 0x8:
+   /* SCSI name string */
+   if ((d[1]  0x30) == 0x20) {
+   /* SCSI name */
+   target_id_size = d[3];
+   target_id = d + 4;
+   strncpy(target_id_str, d + 4, 256);
+   if (target_id_size  255)
+   target_id_size = 255;
+   

[PATCH 13/16] scsi_dh_alua: Clarify logging message

2013-12-20 Thread Hannes Reinecke
We should be diffentiating between an invalid TPGS setting
and unsupported.

Signed-off-by: Hannes Reinecke h...@suse.de
---
 drivers/scsi/device_handler/scsi_dh_alua.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c 
b/drivers/scsi/device_handler/scsi_dh_alua.c
index dc77ce4..baaae3f 100644
--- a/drivers/scsi/device_handler/scsi_dh_alua.c
+++ b/drivers/scsi/device_handler/scsi_dh_alua.c
@@ -347,12 +347,18 @@ static int alua_check_tpgs(struct scsi_device *sdev, 
struct alua_dh_data *h)
sdev_printk(KERN_INFO, sdev, %s: supports implicit TPGS\n,
ALUA_DH_NAME);
break;
-   default:
-   h-tpgs = TPGS_MODE_NONE;
+   case 0:
sdev_printk(KERN_INFO, sdev, %s: not supported\n,
ALUA_DH_NAME);
err = SCSI_DH_DEV_UNSUPP;
break;
+   default:
+   sdev_printk(KERN_INFO, sdev,
+   %s: unsupported TPGS setting %d\n,
+   ALUA_DH_NAME, h-tpgs);
+   h-tpgs = TPGS_MODE_NONE;
+   err = SCSI_DH_DEV_UNSUPP;
+   break;
}
 
return err;
-- 
1.7.12.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


[PATCH 14/16] scsi_dh: invoke callback if -activate is not present

2013-12-20 Thread Hannes Reinecke
When -activate isn't present we still need to invoke the
callbacks, otherwise the system might stall.

Signed-off-by: Hannes Reinecke h...@suse.de
---
 drivers/scsi/device_handler/scsi_dh.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/device_handler/scsi_dh.c 
b/drivers/scsi/device_handler/scsi_dh.c
index ae7f399..a90380f 100644
--- a/drivers/scsi/device_handler/scsi_dh.c
+++ b/drivers/scsi/device_handler/scsi_dh.c
@@ -411,7 +411,7 @@ int scsi_dh_activate(struct request_queue *q, 
activate_complete fn, void *data)
err = SCSI_DH_DEV_OFFLINED;
spin_unlock_irqrestore(q-queue_lock, flags);
 
-   if (err != SCSI_DH_OK) {
+   if (err != SCSI_DH_OK || !scsi_dh-activate) {
if (fn)
fn(data, err);
goto out;
-- 
1.7.12.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


[PATCH 04/16] scsi_dh_alua: Make stpg synchronous

2013-12-20 Thread Hannes Reinecke
We should be issuing STPG synchronously as we need to
evaluate the return code on failure.

Signed-off-by: Hannes Reinecke h...@suse.de
---
 drivers/scsi/device_handler/scsi_dh_alua.c | 192 +
 1 file changed, 89 insertions(+), 103 deletions(-)

diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c 
b/drivers/scsi/device_handler/scsi_dh_alua.c
index 5358c2f..ef92008 100644
--- a/drivers/scsi/device_handler/scsi_dh_alua.c
+++ b/drivers/scsi/device_handler/scsi_dh_alua.c
@@ -227,82 +227,27 @@ done:
 }
 
 /*
- * stpg_endio - Evaluate SET TARGET GROUP STATES
- * @sdev: the device to be evaluated
- * @state: the new target group state
- *
- * Evaluate a SET TARGET GROUP STATES command response.
- */
-static void stpg_endio(struct request *req, int error)
-{
-   struct alua_dh_data *h = req-end_io_data;
-   struct scsi_sense_hdr sense_hdr;
-   unsigned err = SCSI_DH_OK;
-
-   if (host_byte(req-errors) != DID_OK ||
-   msg_byte(req-errors) != COMMAND_COMPLETE) {
-   err = SCSI_DH_IO;
-   goto done;
-   }
-
-   if (req-sense_len  0) {
-   if (!scsi_normalize_sense(h-sense, SCSI_SENSE_BUFFERSIZE,
- sense_hdr)) {
-   err = SCSI_DH_IO;
-   goto done;
-   }
-   err = alua_check_sense(h-sdev, sense_hdr);
-   if (err == ADD_TO_MLQUEUE) {
-   err = SCSI_DH_RETRY;
-   goto done;
-   }
-   sdev_printk(KERN_INFO, h-sdev, %s: stpg failed, ,
-   ALUA_DH_NAME);
-   scsi_show_sense_hdr(sense_hdr);
-   sdev_printk(KERN_INFO, h-sdev, %s: stpg failed, ,
-   ALUA_DH_NAME);
-   scsi_show_extd_sense(sense_hdr.asc, sense_hdr.ascq);
-   err = SCSI_DH_IO;
-   } else if (error)
-   err = SCSI_DH_IO;
-
-   if (err == SCSI_DH_OK) {
-   h-state = TPGS_STATE_OPTIMIZED;
-   sdev_printk(KERN_INFO, h-sdev,
-   %s: port group %02x switched to state %c\n,
-   ALUA_DH_NAME, h-group_id,
-   print_alua_state(h-state));
-   }
-done:
-   req-end_io_data = NULL;
-   __blk_put_request(req-q, req);
-   if (h-callback_fn) {
-   h-callback_fn(h-callback_data, err);
-   h-callback_fn = h-callback_data = NULL;
-   }
-   return;
-}
-
-/*
  * submit_stpg - Issue a SET TARGET GROUP STATES command
  *
  * Currently we're only setting the current target port group state
  * to 'active/optimized' and let the array firmware figure out
  * the states of the remaining groups.
  */
-static unsigned submit_stpg(struct alua_dh_data *h)
+static unsigned submit_stpg(struct scsi_device *sdev, int group_id,
+   unsigned char *sense)
 {
struct request *rq;
+   unsigned char stpg_data[8];
int stpg_len = 8;
-   struct scsi_device *sdev = h-sdev;
+   int err;
 
/* Prepare the data buffer */
-   memset(h-buff, 0, stpg_len);
-   h-buff[4] = TPGS_STATE_OPTIMIZED  0x0f;
-   h-buff[6] = (h-group_id  8)  0xff;
-   h-buff[7] = h-group_id  0xff;
+   memset(stpg_data, 0, stpg_len);
+   stpg_data[4] = TPGS_STATE_OPTIMIZED  0x0f;
+   stpg_data[6] = (group_id  8)  0xff;
+   stpg_data[7] = group_id  0xff;
 
-   rq = get_alua_req(sdev, h-buff, stpg_len, WRITE);
+   rq = get_alua_req(sdev, stpg_data, stpg_len, WRITE);
if (!rq)
return SCSI_DH_RES_TEMP_UNAVAIL;
 
@@ -315,13 +260,22 @@ static unsigned submit_stpg(struct alua_dh_data *h)
rq-cmd[9] = stpg_len  0xff;
rq-cmd_len = COMMAND_SIZE(MAINTENANCE_OUT);
 
-   rq-sense = h-sense;
+   rq-sense = sense;
memset(rq-sense, 0, SCSI_SENSE_BUFFERSIZE);
-   rq-sense_len = h-senselen = 0;
-   rq-end_io_data = h;
+   rq-sense_len = 0;
 
-   blk_execute_rq_nowait(rq-q, NULL, rq, 1, stpg_endio);
-   return SCSI_DH_OK;
+   err = blk_execute_rq(rq-q, NULL, rq, 1);
+   if (err  0) {
+   if (!rq-errors)
+   err = DID_ERROR  16;
+   else
+   err = rq-errors;
+   if (rq-sense_len)
+   err |= (DRIVER_SENSE  24);
+   }
+   blk_put_request(rq);
+
+   return err;
 }
 
 /*
@@ -715,6 +669,69 @@ static int alua_rtpg(struct scsi_device *sdev, struct 
alua_dh_data *h, int wait_
 }
 
 /*
+ * alua_stpg - Issue a SET TARGET GROUP STATES command
+ *
+ * Issue a SET TARGET GROUP STATES command and evaluate the
+ * response. Returns SCSI_DH_RETRY per default to trigger
+ * a re-evaluation of the target group state.
+ */
+static unsigned alua_stpg(struct scsi_device *sdev, struct alua_dh_data *h)
+{
+   int retval, err = SCSI_DH_RETRY;
+   unsigned char 

[PATCH 16/16] scsi_dh_alua: Use workqueue for RTPG

2013-12-20 Thread Hannes Reinecke
The current ALUA device_handler has two drawbacks:
- We're sending a 'SET TARGET PORT GROUP' command to every LUN,
  disregarding the fact that several LUNs might be in a port group
  and will be automatically switched whenever _any_ LUN within
  that port group receives the command.
- Whenever a LUN is in 'transitioning' mode we cannot block I/O
  to that LUN, instead the controller has to abort the command.
  This leads to increased traffic across the wire and heavy load
  on the controller during switchover.

With this patch the RTPG handling is moved to a workqueue, which
is being run once per port group. This reduces the number of
'REPORT TARGET PORT GROUP' and 'SET TARGET PORT GROUPS' which
will be send to the controller. It also allows us to block
I/O to any LUN / port group found to be in 'transitioning' ALUA
mode, as the workqueue item will be requeued until the controller
moves out of transitioning.

Signed-off-by: Hannes Reinecke h...@suse.de
---
 drivers/scsi/device_handler/scsi_dh_alua.c | 389 ++---
 1 file changed, 304 insertions(+), 85 deletions(-)

diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c 
b/drivers/scsi/device_handler/scsi_dh_alua.c
index e6b2565..1493291 100644
--- a/drivers/scsi/device_handler/scsi_dh_alua.c
+++ b/drivers/scsi/device_handler/scsi_dh_alua.c
@@ -22,6 +22,8 @@
 #include linux/slab.h
 #include linux/delay.h
 #include linux/module.h
+#include linux/workqueue.h
+#include linux/rcupdate.h
 #include scsi/scsi.h
 #include scsi/scsi_dbg.h
 #include scsi/scsi_eh.h
@@ -58,13 +60,20 @@
 #define ALUA_INQUIRY_SIZE  36
 #define ALUA_FAILOVER_TIMEOUT  60
 #define ALUA_FAILOVER_RETRIES  5
+#define ALUA_RTPG_DELAY_MSECS  5
 
 /* flags passed from user level */
-#define ALUA_OPTIMIZE_STPG 1
-#define ALUA_RTPG_EXT_HDR_UNSUPP   2
+#define ALUA_OPTIMIZE_STPG 0x01
+#define ALUA_RTPG_EXT_HDR_UNSUPP   0x02
+/* State machine flags */
+#define ALUA_PG_RUN_RTPG   0x10
+#define ALUA_PG_RUN_STPG   0x20
+#define ALUA_PG_STPG_DONE  0x40
+
 
 static LIST_HEAD(port_group_list);
 static DEFINE_SPINLOCK(port_group_lock);
+static struct workqueue_struct *kmpath_aluad;
 
 struct alua_port_group {
struct kref kref;
@@ -81,14 +90,26 @@ struct alua_port_group {
unsigned char   *buff;
int bufflen;
unsigned char   transition_tmo;
+   unsigned long   expiry;
+   unsigned long   interval;
+   struct delayed_work rtpg_work;
+   spinlock_t  rtpg_lock;
+   struct list_headrtpg_list;
+   struct scsi_device  *rtpg_sdev;
 };
 
 struct alua_dh_data {
struct alua_port_group  *pg;
+   spinlock_t  pg_lock;
int rel_port;
int tpgs;
+   int error;
unsignedflags; /* used for optimizing STPG */
-   struct scsi_device  *sdev;
+   struct completion   init_complete;
+};
+
+struct alua_queue_data {
+   struct list_headentry;
activate_complete   callback_fn;
void*callback_data;
 };
@@ -98,11 +119,13 @@ struct alua_dh_data {
 
 static char print_alua_state(int);
 static int alua_check_sense(struct scsi_device *, struct scsi_sense_hdr *);
+static void alua_rtpg_work(struct work_struct *work);
+static void alua_check(struct scsi_device *sdev);
 
 static inline struct alua_dh_data *get_alua_data(struct scsi_device *sdev)
 {
struct scsi_dh_data *scsi_dh_data = sdev-scsi_dh_data;
-   BUG_ON(scsi_dh_data == NULL);
+
return ((struct alua_dh_data *) scsi_dh_data-buf);
 }
 
@@ -570,9 +593,12 @@ static int alua_vpd_inquiry(struct scsi_device *sdev, 
struct alua_dh_data *h)
ALUA_DH_NAME, group_id, h-rel_port);
}
if (pg) {
-   h-pg = pg;
kref_get(pg-kref);
spin_unlock(port_group_lock);
+   spin_lock(h-pg_lock);
+   rcu_assign_pointer(h-pg, pg);
+   spin_unlock(h-pg_lock);
+   synchronize_rcu();
err = SCSI_DH_OK;
goto out;
}
@@ -601,9 +627,17 @@ static int alua_vpd_inquiry(struct scsi_device *sdev, 
struct alua_dh_data *h)
pg-state = TPGS_STATE_OPTIMIZED;
pg-flags = h-flags;
kref_init(pg-kref);
+   INIT_DELAYED_WORK(pg-rtpg_work, alua_rtpg_work);
+   INIT_LIST_HEAD(pg-rtpg_list);
+   spin_lock_init(pg-rtpg_lock);
list_add(pg-node, port_group_list);
-   h-pg = pg;
+   kref_get(pg-kref);
spin_unlock(port_group_lock);
+   spin_lock(h-pg_lock);
+   rcu_assign_pointer(h-pg, pg);
+   spin_unlock(h-pg_lock);
+   kref_put(pg-kref, release_port_group);
+   synchronize_rcu();
err = SCSI_DH_OK;
 out:
   

[PATCH 10/16] scsi_dh_alua: Do not attach to management devices

2013-12-20 Thread Hannes Reinecke
Management devices should be ignored when
detecting ALUA capabilites.

Signed-off-by: Hannes Reinecke h...@suse.de
---
 drivers/scsi/device_handler/scsi_dh_alua.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c 
b/drivers/scsi/device_handler/scsi_dh_alua.c
index e297851..51f4a31 100644
--- a/drivers/scsi/device_handler/scsi_dh_alua.c
+++ b/drivers/scsi/device_handler/scsi_dh_alua.c
@@ -315,6 +315,23 @@ static int alua_check_tpgs(struct scsi_device *sdev, 
struct alua_dh_data *h)
 {
int err = SCSI_DH_OK;
 
+   if (scsi_is_wlun(sdev-lun)) {
+   h-tpgs = TPGS_MODE_NONE;
+   sdev_printk(KERN_INFO, sdev,
+   %s: disable for WLUN\n,
+   ALUA_DH_NAME);
+   return SCSI_DH_DEV_UNSUPP;
+   }
+   if (sdev-type == TYPE_RAID ||
+   sdev-type == TYPE_ENCLOSURE ||
+   sdev-type == 0x1F) {
+   h-tpgs = TPGS_MODE_NONE;
+   sdev_printk(KERN_INFO, sdev,
+   %s: disable for enclosure devices\n,
+   ALUA_DH_NAME);
+   return SCSI_DH_DEV_UNSUPP;
+   }
+
h-tpgs = scsi_device_tpgs(sdev);
switch (h-tpgs) {
case TPGS_MODE_EXPLICIT|TPGS_MODE_IMPLICIT:
-- 
1.7.12.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


[PATCH 11/16] scsi_dh_alua: multipath failover fails with error 15

2013-12-20 Thread Hannes Reinecke
When a path is already optimized multipath failover will fail
with the message
Could not failover device X:Y: Handler scsi_dh_alua Error 15

Signed-off-by: Hannes Reinecke h...@suse.de
---
 drivers/scsi/device_handler/scsi_dh_alua.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c 
b/drivers/scsi/device_handler/scsi_dh_alua.c
index 51f4a31..dc77ce4 100644
--- a/drivers/scsi/device_handler/scsi_dh_alua.c
+++ b/drivers/scsi/device_handler/scsi_dh_alua.c
@@ -851,6 +851,8 @@ static unsigned alua_stpg(struct scsi_device *sdev, struct 
alua_port_group *pg)
return SCSI_DH_RETRY;
}
switch (pg-state) {
+   case TPGS_STATE_OPTIMIZED:
+   return SCSI_DH_OK;
case TPGS_STATE_NONOPTIMIZED:
if ((pg-flags  ALUA_OPTIMIZE_STPG) 
(!pg-pref) 
@@ -865,10 +867,11 @@ static unsigned alua_stpg(struct scsi_device *sdev, 
struct alua_port_group *pg)
break;
case TPGS_STATE_TRANSITIONING:
return SCSI_DH_RETRY;
-   break;
default:
+   sdev_printk(KERN_INFO, sdev,
+   %s: stpg failed, unhandled TPGS state %d,
+   ALUA_DH_NAME, pg-state);
return SCSI_DH_NOSYS;
-   break;
}
/* Set state to transitioning */
pg-state = TPGS_STATE_TRANSITIONING;
-- 
1.7.12.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


[PATCH 03/16] scsi_dh_alua: Pass buffer as function argument

2013-12-20 Thread Hannes Reinecke
Pass in the buffer as a function argument for submit_vpd() and
submit_rtpg().

Signed-off-by: Hannes Reinecke h...@suse.de
---
 drivers/scsi/device_handler/scsi_dh_alua.c | 44 --
 1 file changed, 24 insertions(+), 20 deletions(-)

diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c 
b/drivers/scsi/device_handler/scsi_dh_alua.c
index ece2255..5358c2f 100644
--- a/drivers/scsi/device_handler/scsi_dh_alua.c
+++ b/drivers/scsi/device_handler/scsi_dh_alua.c
@@ -143,12 +143,13 @@ static struct request *get_alua_req(struct scsi_device 
*sdev,
  * submit_vpd_inquiry - Issue an INQUIRY VPD page 0x83 command
  * @sdev: sdev the command should be sent to
  */
-static int submit_vpd_inquiry(struct scsi_device *sdev, struct alua_dh_data *h)
+static int submit_vpd_inquiry(struct scsi_device *sdev, unsigned char *buff,
+ int bufflen, unsigned char *sense)
 {
struct request *rq;
int err;
 
-   rq = get_alua_req(sdev, h-buff, h-bufflen, READ);
+   rq = get_alua_req(sdev, buff, bufflen, READ);
if (!rq) {
err = DRIVER_BUSY  24;
goto done;
@@ -158,12 +159,12 @@ static int submit_vpd_inquiry(struct scsi_device *sdev, 
struct alua_dh_data *h)
rq-cmd[0] = INQUIRY;
rq-cmd[1] = 1;
rq-cmd[2] = 0x83;
-   rq-cmd[4] = h-bufflen;
+   rq-cmd[4] = bufflen;
rq-cmd_len = COMMAND_SIZE(INQUIRY);
 
-   rq-sense = h-sense;
+   rq-sense = sense;
memset(rq-sense, 0, SCSI_SENSE_BUFFERSIZE);
-   rq-sense_len = h-senselen = 0;
+   rq-sense_len = 0;
 
err = blk_execute_rq(rq-q, NULL, rq, 1);
if (err  0) {
@@ -171,7 +172,8 @@ static int submit_vpd_inquiry(struct scsi_device *sdev, 
struct alua_dh_data *h)
err = DID_ERROR  16;
else
err = rq-errors;
-   h-senselen = rq-sense_len;
+   if (rq-sense_len)
+   err |= (DRIVER_SENSE  24);
}
blk_put_request(rq);
 done:
@@ -182,12 +184,13 @@ done:
  * submit_rtpg - Issue a REPORT TARGET GROUP STATES command
  * @sdev: sdev the command should be sent to
  */
-static unsigned submit_rtpg(struct scsi_device *sdev, struct alua_dh_data *h)
+static unsigned submit_rtpg(struct scsi_device *sdev, unsigned char *buff,
+   int bufflen, unsigned char *sense, int flags)
 {
struct request *rq;
int err;
 
-   rq = get_alua_req(sdev, h-buff, h-bufflen, READ);
+   rq = get_alua_req(sdev, buff, bufflen, READ);
if (!rq) {
err = DRIVER_BUSY  24;
goto done;
@@ -195,19 +198,19 @@ static unsigned submit_rtpg(struct scsi_device *sdev, 
struct alua_dh_data *h)
 
/* Prepare the command. */
rq-cmd[0] = MAINTENANCE_IN;
-   if (!(h-flags  ALUA_RTPG_EXT_HDR_UNSUPP))
+   if (!(flags  ALUA_RTPG_EXT_HDR_UNSUPP))
rq-cmd[1] = MI_REPORT_TARGET_PGS | MI_EXT_HDR_PARAM_FMT;
else
rq-cmd[1] = MI_REPORT_TARGET_PGS;
-   rq-cmd[6] = (h-bufflen  24)  0xff;
-   rq-cmd[7] = (h-bufflen  16)  0xff;
-   rq-cmd[8] = (h-bufflen   8)  0xff;
-   rq-cmd[9] = h-bufflen  0xff;
+   rq-cmd[6] = (bufflen  24)  0xff;
+   rq-cmd[7] = (bufflen  16)  0xff;
+   rq-cmd[8] = (bufflen   8)  0xff;
+   rq-cmd[9] = bufflen  0xff;
rq-cmd_len = COMMAND_SIZE(MAINTENANCE_IN);
 
-   rq-sense = h-sense;
+   rq-sense = sense;
memset(rq-sense, 0, SCSI_SENSE_BUFFERSIZE);
-   rq-sense_len = h-senselen = 0;
+   rq-sense_len = 0;
 
err = blk_execute_rq(rq-q, NULL, rq, 1);
if (err  0) {
@@ -215,7 +218,8 @@ static unsigned submit_rtpg(struct scsi_device *sdev, 
struct alua_dh_data *h)
err = DID_ERROR  16;
else
err = rq-errors;
-   h-senselen = rq-sense_len;
+   if (rq-sense_len)
+   err |= (DRIVER_SENSE  24);
}
blk_put_request(rq);
 done:
@@ -374,11 +378,11 @@ static int alua_vpd_inquiry(struct scsi_device *sdev, 
struct alua_dh_data *h)
 
expiry = round_jiffies_up(jiffies + timeout);
  retry:
-   retval = submit_vpd_inquiry(sdev, h);
+   retval = submit_vpd_inquiry(sdev, h-buff, h-bufflen, h-sense);
if (retval) {
unsigned err;
 
-   if (h-senselen == 0 ||
+   if (!(driver_byte(retval)  DRIVER_SENSE) ||
!scsi_normalize_sense(h-sense, SCSI_SENSE_BUFFERSIZE,
  sense_hdr)) {
sdev_printk(KERN_INFO, sdev,
@@ -575,10 +579,10 @@ static int alua_rtpg(struct scsi_device *sdev, struct 
alua_dh_data *h, int wait_
expiry = round_jiffies_up(jiffies + h-transition_tmo * HZ);
 
  retry:
-   retval = submit_rtpg(sdev, h);
+   retval = submit_rtpg(sdev, h-buff, 

[PATCH 12/16] scsi_dh: return individual errors in scsi_dh_activate()

2013-12-20 Thread Hannes Reinecke
When calling scsi_dh_activate() we should be returning
individual errors and not lumping all into one.

Signed-off-by: Hannes Reinecke h...@suse.de
---
 drivers/scsi/device_handler/scsi_dh.c | 18 +++---
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/device_handler/scsi_dh.c 
b/drivers/scsi/device_handler/scsi_dh.c
index 33e422e..ae7f399 100644
--- a/drivers/scsi/device_handler/scsi_dh.c
+++ b/drivers/scsi/device_handler/scsi_dh.c
@@ -381,7 +381,7 @@ EXPORT_SYMBOL_GPL(scsi_unregister_device_handler);
  */
 int scsi_dh_activate(struct request_queue *q, activate_complete fn, void *data)
 {
-   int err = 0;
+   int err = SCSI_DH_OK;
unsigned long flags;
struct scsi_device *sdev;
struct scsi_device_handler *scsi_dh = NULL;
@@ -400,15 +400,18 @@ int scsi_dh_activate(struct request_queue *q, 
activate_complete fn, void *data)
if (sdev-scsi_dh_data)
scsi_dh = sdev-scsi_dh_data-scsi_dh;
dev = get_device(sdev-sdev_gendev);
-   if (!scsi_dh || !dev ||
-   sdev-sdev_state == SDEV_CANCEL ||
-   sdev-sdev_state == SDEV_DEL)
+   if (!scsi_dh)
err = SCSI_DH_NOSYS;
-   if (sdev-sdev_state == SDEV_OFFLINE)
+   else if (!dev)
+   err = SCSI_DH_DEV_OFFLINED;
+   else if (sdev-sdev_state == SDEV_CANCEL ||
+sdev-sdev_state == SDEV_DEL)
+   err = SCSI_DH_NOTCONN;
+   else if (sdev-sdev_state == SDEV_OFFLINE)
err = SCSI_DH_DEV_OFFLINED;
spin_unlock_irqrestore(q-queue_lock, flags);
 
-   if (err) {
+   if (err != SCSI_DH_OK) {
if (fn)
fn(data, err);
goto out;
@@ -417,7 +420,8 @@ int scsi_dh_activate(struct request_queue *q, 
activate_complete fn, void *data)
if (scsi_dh-activate)
err = scsi_dh-activate(sdev, fn, data);
 out:
-   put_device(dev);
+   if (dev)
+   put_device(dev);
return err;
 }
 EXPORT_SYMBOL_GPL(scsi_dh_activate);
-- 
1.7.12.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


[PATCH 05/16] scsi_dh_alua: put sense buffer on stack

2013-12-20 Thread Hannes Reinecke
There is no need to have the sense buffer as part of the per-device
structure, we can put the sense buffer on the stack.

Signed-off-by: Hannes Reinecke h...@suse.de
---
 drivers/scsi/device_handler/scsi_dh_alua.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c 
b/drivers/scsi/device_handler/scsi_dh_alua.c
index ef92008..adc77ef 100644
--- a/drivers/scsi/device_handler/scsi_dh_alua.c
+++ b/drivers/scsi/device_handler/scsi_dh_alua.c
@@ -74,8 +74,6 @@ struct alua_dh_data {
unsigned char   *buff;
int bufflen;
unsigned char   transition_tmo;
-   unsigned char   sense[SCSI_SENSE_BUFFERSIZE];
-   int senselen;
struct scsi_device  *sdev;
activate_complete   callback_fn;
void*callback_data;
@@ -325,6 +323,7 @@ static int alua_check_tpgs(struct scsi_device *sdev, struct 
alua_dh_data *h)
 static int alua_vpd_inquiry(struct scsi_device *sdev, struct alua_dh_data *h)
 {
int len, timeout = ALUA_FAILOVER_TIMEOUT;
+   unsigned char sense[SCSI_SENSE_BUFFERSIZE];
struct scsi_sense_hdr sense_hdr;
unsigned retval;
unsigned char *d;
@@ -332,12 +331,12 @@ static int alua_vpd_inquiry(struct scsi_device *sdev, 
struct alua_dh_data *h)
 
expiry = round_jiffies_up(jiffies + timeout);
  retry:
-   retval = submit_vpd_inquiry(sdev, h-buff, h-bufflen, h-sense);
+   retval = submit_vpd_inquiry(sdev, h-buff, h-bufflen, sense);
if (retval) {
unsigned err;
 
if (!(driver_byte(retval)  DRIVER_SENSE) ||
-   !scsi_normalize_sense(h-sense, SCSI_SENSE_BUFFERSIZE,
+   !scsi_normalize_sense(sense, SCSI_SENSE_BUFFERSIZE,
  sense_hdr)) {
sdev_printk(KERN_INFO, sdev,
%s: evpd inquiry failed, , ALUA_DH_NAME);
@@ -519,6 +518,7 @@ static int alua_check_sense(struct scsi_device *sdev,
  */
 static int alua_rtpg(struct scsi_device *sdev, struct alua_dh_data *h, int 
wait_for_transition)
 {
+   unsigned char sense[SCSI_SENSE_BUFFERSIZE];
struct scsi_sense_hdr sense_hdr;
int len, k, off, valid_states = 0;
unsigned char *ucp;
@@ -533,11 +533,11 @@ static int alua_rtpg(struct scsi_device *sdev, struct 
alua_dh_data *h, int wait_
expiry = round_jiffies_up(jiffies + h-transition_tmo * HZ);
 
  retry:
-   retval = submit_rtpg(sdev, h-buff, h-bufflen, h-sense, h-flags);
+   retval = submit_rtpg(sdev, h-buff, h-bufflen, sense, h-flags);
 
if (retval) {
if (!(driver_byte(retval)  DRIVER_SENSE) ||
-   !scsi_normalize_sense(h-sense, SCSI_SENSE_BUFFERSIZE,
+   !scsi_normalize_sense(sense, SCSI_SENSE_BUFFERSIZE,
  sense_hdr)) {
sdev_printk(KERN_INFO, sdev, %s: rtpg failed, ,
ALUA_DH_NAME);
-- 
1.7.12.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


[PATCH 09/16] scsi_dh_alua: simplify sense code handling

2013-12-20 Thread Hannes Reinecke
Most sense code is already handled in the generic
code, so we shouldn't be adding special cases here.
However, when doing so we need to check for
unit attention whenever we're sending an internal
command.

Signed-off-by: Hannes Reinecke h...@suse.de
---
 drivers/scsi/device_handler/scsi_dh_alua.c | 33 +-
 1 file changed, 5 insertions(+), 28 deletions(-)

diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c 
b/drivers/scsi/device_handler/scsi_dh_alua.c
index 9d712be..e297851 100644
--- a/drivers/scsi/device_handler/scsi_dh_alua.c
+++ b/drivers/scsi/device_handler/scsi_dh_alua.c
@@ -388,6 +388,8 @@ static int alua_vpd_inquiry(struct scsi_device *sdev, 
struct alua_dh_data *h)
goto out;
}
err = alua_check_sense(sdev, sense_hdr);
+   if (sense_hdr.sense_key == UNIT_ATTENTION)
+   err = ADD_TO_MLQUEUE;
if (err == ADD_TO_MLQUEUE  time_before(jiffies, expiry))
goto retry;
if (err != SUCCESS) {
@@ -617,21 +619,6 @@ static int alua_check_sense(struct scsi_device *sdev,
 * LUN Not Accessible - ALUA state transition
 */
return ADD_TO_MLQUEUE;
-   if (sense_hdr-asc == 0x04  sense_hdr-ascq == 0x0b)
-   /*
-* LUN Not Accessible -- Target port in standby state
-*/
-   return SUCCESS;
-   if (sense_hdr-asc == 0x04  sense_hdr-ascq == 0x0c)
-   /*
-* LUN Not Accessible -- Target port in unavailable 
state
-*/
-   return SUCCESS;
-   if (sense_hdr-asc == 0x04  sense_hdr-ascq == 0x12)
-   /*
-* LUN Not Ready -- Offline
-*/
-   return SUCCESS;
break;
case UNIT_ATTENTION:
if (sense_hdr-asc == 0x29  sense_hdr-ascq == 0x00)
@@ -646,7 +633,7 @@ static int alua_check_sense(struct scsi_device *sdev,
return ADD_TO_MLQUEUE;
if (sense_hdr-asc == 0x2a  sense_hdr-ascq == 0x01)
/*
-* Mode Parameters Changed
+* Mode parameter changed
 */
return ADD_TO_MLQUEUE;
if (sense_hdr-asc == 0x2a  sense_hdr-ascq == 0x06)
@@ -659,18 +646,6 @@ static int alua_check_sense(struct scsi_device *sdev,
 * Implicit ALUA state transition failed
 */
return ADD_TO_MLQUEUE;
-   if (sense_hdr-asc == 0x3f  sense_hdr-ascq == 0x03)
-   /*
-* Inquiry data has changed
-*/
-   return ADD_TO_MLQUEUE;
-   if (sense_hdr-asc == 0x3f  sense_hdr-ascq == 0x0e)
-   /*
-* REPORTED_LUNS_DATA_HAS_CHANGED is reported
-* when switching controllers on targets like
-* Intel Multi-Flex. We can just retry.
-*/
-   return ADD_TO_MLQUEUE;
break;
}
 
@@ -735,6 +710,8 @@ static int alua_rtpg(struct scsi_device *sdev, struct 
alua_port_group *pg, int w
}
 
err = alua_check_sense(sdev, sense_hdr);
+   if (sense_hdr.sense_key == UNIT_ATTENTION)
+   err = ADD_TO_MLQUEUE;
if (err == ADD_TO_MLQUEUE  time_before(jiffies, expiry)) {
sdev_printk(KERN_ERR, sdev, %s: rtpg retry, ,
ALUA_DH_NAME);
-- 
1.7.12.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 00/10] scsi: avoid linebreaks in syslog output

2013-12-20 Thread Tomas Henzl
Hi Hannes, James,

I'm wondering what happened to this patch-set? I think it could
make parsing of the output for userspace programs much easier.
Are there some problems still to solve or is this just forgotten?

Thanks,
Tomas

On 10/12/2012 10:33 AM, Hannes Reinecke wrote:

 This patchset updates the SCSI midlayer to use dev_printk() instead
 of the simple printk(). The main objective here is to avoid line-breaks
 in syslog output; with the current state it's nearly impossible to match
 the output to the occurring device; under high load even the CDB will
 be split off into individual bytes, spread randomly across the lines.
 Which makes debugging via scsi_logging_level _really_ hard.
 In addition we'll be getting the syslog messages nicely prefixed with
 the device, which will make userspace logging daemons happy.

 Before:
 [  297.300605] sd 2:0:3:2: Send: 
 [  297.300607] 0x8802348b0980 
 [  297.300610] sd 2:0:3:2: CDB: 
 [  297.300615] Test Unit Ready: 00 00 00 00 00 00
 [  297.300747] sd 2:0:3:2: Done: 
 [  297.300750] 0x8802348b0980 SUCCESS
 [  297.300753] sd 2:0:3:2:  
 [  297.300755] Result: hostbyte=DID_OK driverbyte=DRIVER_OK
 [  297.300758] sd 2:0:3:2: CDB: 
 [  297.300764] Test Unit Ready: 00 00 00 00 00 00
 [  297.300766] sd 2:0:3:2:  
 [  297.300769] Sense Key : Unit Attention [current] 
 [  297.300771] Info fld=0x0
 [  297.300772] sd 2:0:3:2:  
 [  297.300776] Add. Sense: Capacity data has changed

 After:
 [  636.683556] sd 2:0:3:2: Send: 0x88043145eec0
 [  636.727856] sd 2:0:3:2: CDB: Test Unit Ready: 00 00 00 00 00 00
 [  636.785330] sd 2:0:3:2: Done: 0x88043145eec0 SUCCESS
 [  636.838228] sd 2:0:3:2: Result: hostbyte=DID_OK driverbyte=DRIVER_OK
 [  636.899099] sd 2:0:3:2: CDB: Test Unit Ready: 00 00 00 00 00 00
 [  636.955905] sd 2:0:3:2: Sense Key : Unit Attention [current] 
 [  637.069179] sd 2:0:3:2: Add. Sense: Capacity data has changed


 Hannes Reinecke (10):
   sg: Use dev_printk
   sr: Use dev_printk()
   scsi: Avoid linebreaks in syslog output
   scsi: Use sdev_printk() for logging
   scsi: use buffer for print_opcode_name()
   scsi: use single printk call in scsi_print_command()
   scsi: use buffer for scsi_show_result()
   scsi: open-code scsi_decode_sense_buffer()
   scsi: decode descriptor sense
   scsi: use local buffer for decoding sense data

  drivers/scsi/constants.c  |  406 
 +
  drivers/scsi/scsi.c   |   54 ---
  drivers/scsi/scsi_error.c |  190 ++---
  drivers/scsi/scsi_lib.c   |   13 +-
  drivers/scsi/scsi_scan.c  |   68 
  drivers/scsi/sd.c |   16 +-
  drivers/scsi/sg.c |  187 -
  drivers/scsi/sr.c |   47 +++---
  drivers/scsi/sr.h |4 +
  include/scsi/scsi_dbg.h   |6 +-
  include/scsi/scsi_eh.h|8 +-
  11 files changed, 588 insertions(+), 411 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


Re: [PATCH 00/10] scsi: avoid linebreaks in syslog output

2013-12-20 Thread Hannes Reinecke
On 12/20/2013 02:25 PM, Tomas Henzl wrote:
 Hi Hannes, James,
 
 I'm wondering what happened to this patch-set? I think it could
 make parsing of the output for userspace programs much easier.
 Are there some problems still to solve or is this just forgotten?
 
Oh, no. Quite the contrary.
As James has now merged my previous patchsets I'm in the process of
updating this one, too.

It'll be part of a larger patchset having a per-device
scsi_logging_level; something I was wanting to have for a _LONG_
time now.

Currently I'm fiddling with sense code printing, so I won't be able
to send anything this year. But early next year I should have
something presentable.

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 00/10] scsi: avoid linebreaks in syslog output

2013-12-20 Thread Tomas Henzl
On 12/20/2013 02:31 PM, Hannes Reinecke wrote:
 On 12/20/2013 02:25 PM, Tomas Henzl wrote:
 Hi Hannes, James,

 I'm wondering what happened to this patch-set? I think it could
 make parsing of the output for userspace programs much easier.
 Are there some problems still to solve or is this just forgotten?

 Oh, no. Quite the contrary.
 As James has now merged my previous patchsets I'm in the process of
 updating this one, too.

 It'll be part of a larger patchset having a per-device
 scsi_logging_level; something I was wanting to have for a _LONG_
 time now.

 Currently I'm fiddling with sense code printing, so I won't be able
 to send anything this year. But early next year I should have
 something presentable.

Great news! thanks.


 Cheers,

 Hannes

--
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] [ATTEND] scsi_eh updates

2013-12-20 Thread Hannes Reinecke
Hi all,

(before leaving for holiday ...)

I'd like to attend LSF 2014.

During that I'd like to discuss the current status of the SCSI EH
and the future planned updates.

As discussed during last year's LSF the SCSI error handler should be
updated to handle modern SCSI transports better.
While some patchsets are already merged, there are some issues which
are still open:
- Handling of requests during host reset:
  Do we need to keep hold of outstanding requests during host reset?
  Or is it save to return them prior to host reset?
- Check for transport status prior to sending TMFs.
  Task management functions typically need a working I_T nexus,
  so it does make sense to first check the transport status
  prior to attempting any TMFs
- Further steps for updating SCSI EH
As these are tricky issues which have possible repercussions on the
entire subsystem and LLDDs it'd be good to have a broader discussion
here.

Happy X-mas,

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


[PATCH 0/6] iscsi changes for scsi-misc

2013-12-20 Thread michaelc
The following patches are some features and fixes for scsi-misc.

James, if you were going to merge the libiscsi locking changes here
http://www.spinics.net/lists/linux-scsi/msg69903.html
do not bother. The qlogic patches that were just merged had a conflict.
The patches in the following emails should apply cleanly to misc.


--
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 2/6] SCSI/libiscsi: Reduce locking contention in fast path

2013-12-20 Thread michaelc
From: Shlomo Pongratz shlo...@mellanox.com

Replace the session lock with two locks, a forward lock and
a backwards lock named frwd_lock and back_lock respectively.

The forward lock protects resources that change while sending a
request to the target, such as cmdsn, queued_cmdsn, and allocating
task from the commands' pool with kfifo_out.

The backward lock protects resources that change while processing
a response or in error path, such as cmdsn_exp, cmdsn_max, and
returning tasks to the commands' pool with kfifo_in.

Under a steady state fast-path situation, that is when one
or more processes/threads submit IO to an iscsi device and
a single kernel upcall (e.g softirq) is dealing with processing
of responses without errors, this patch eliminates the contention
between the queuecommand()/request response/scsi_done() flows
associated with iscsi sessions.

Between the forward and the backward locks exists a strict locking
hierarchy.
The mutual exclusion zone protected by the forward lock can enclose the
mutual exclusion zone protected by the backward lock but not vice versa.

For example, in iscsi_conn_teardown or in iscsi_xmit_data when there is
a
failure and __iscsi_put_task is called, the backward lock is taken while
the
forward lock is still taken. On the other hand, if in the RX path a nop
is
to be sent, for example in iscsi_handle_reject or __iscsi_complete_pdu
than
the forward lock is released and the backward lock is taken for the
duration
of iscsi_send_nopout, later the backward lock is released and the
forward
lock is retaken.

libiscsi_tcp uses two kernel fifos the r2t pool and the r2t queue.

The insertion and deletion from these queues didn't corespond to the
assumption taken by the new forward/backwards session locking paradigm.

That is, in iscsi_tcp_clenup_task which belongs to the RX (backwards)
path, r2t is taken out from r2t queue and inserted to the r2t pool.
In iscsi_tcp_get_curr_r2t which belong to the TX (forward) path, r2t
is also inserted to the r2t pool and another r2t is pulled from r2t
queue.

Only in iscsi_tcp_r2t_rsp which is called in the RX path but can requeue
to the TX path, r2t is taken from the r2t pool and inserted to the r2t
queue.

In order to cope with this situation, two spin locks were added,
pool2queue and queue2pool. The former protects extracting from the
r2t pool and inserting to the r2t queue, and the later protects the
extracing from the r2t queue and inserting to the r2t pool.

Signed-off-by: Shlomo Pongratz shlo...@mellanox.com
Signed-off-by: Or Gerlitz ogerl...@mellanox.com
[minor fix up to apply cleanly]
Signed-off-by: Mike Christie micha...@cs.wisc.edu
---
 drivers/scsi/be2iscsi/be_main.c  |   26 +++---
 drivers/scsi/bnx2i/bnx2i_hwi.c   |   46 +-
 drivers/scsi/bnx2i/bnx2i_iscsi.c |8 +-
 drivers/scsi/iscsi_tcp.c |   22 ++--
 drivers/scsi/libiscsi.c  |  192 ++
 drivers/scsi/libiscsi_tcp.c  |   28 --
 drivers/scsi/qla4xxx/ql4_isr.c   |4 +-
 include/scsi/libiscsi.h  |   17 +++-
 include/scsi/libiscsi_tcp.h  |2 +
 9 files changed, 195 insertions(+), 150 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 1f37505..1fb16b1 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -232,20 +232,20 @@ static int beiscsi_eh_abort(struct scsi_cmnd *sc)
cls_session = starget_to_session(scsi_target(sc-device));
session = cls_session-dd_data;
 
-   spin_lock_bh(session-lock);
+   spin_lock_bh(session-frwd_lock);
if (!aborted_task || !aborted_task-sc) {
/* we raced */
-   spin_unlock_bh(session-lock);
+   spin_unlock_bh(session-fwrd_lock);
return SUCCESS;
}
 
aborted_io_task = aborted_task-dd_data;
if (!aborted_io_task-scsi_cmnd) {
/* raced or invalid command */
-   spin_unlock_bh(session-lock);
+   spin_unlock_bh(session-fwrd_lock);
return SUCCESS;
}
-   spin_unlock_bh(session-lock);
+   spin_unlock_bh(session-fwrd_lock);
/* Invalidate WRB Posted for this Task */
AMAP_SET_BITS(struct amap_iscsi_wrb, invld,
  aborted_io_task-pwrb_handle-pwrb,
@@ -307,9 +307,9 @@ static int beiscsi_eh_device_reset(struct scsi_cmnd *sc)
/* invalidate iocbs */
cls_session = starget_to_session(scsi_target(sc-device));
session = cls_session-dd_data;
-   spin_lock_bh(session-lock);
+   spin_lock_bh(session-frwd_lock);
if (!session-leadconn || session-state != ISCSI_STATE_LOGGED_IN) {
-   spin_unlock_bh(session-lock);
+   spin_unlock_bh(session-frwd_lock);
return FAILED;
}
conn = session-leadconn;
@@ -338,7 +338,7 @@ static int beiscsi_eh_device_reset(struct scsi_cmnd *sc)
num_invalidate++;
 

[PATCH 1/6] SCSI/libiscsi: Restructure iscsi_tcp r2t response logic

2013-12-20 Thread michaelc
From: Shlomo Pongratz shlo...@mellanox.com

Restructure the iscsi_tcp_r2t_rsp routine in order to avoid allocating
r2t from r2tpool.queue and returning it back in case the parameters
rhdr-data_length and or rhdr-data_offset prohibit the requing.

Since the values of these parameters are known prior to the allocation,
we can pre-check and thus avoid futile allocations.

Signed-off-by: Shlomo Pongratz shlo...@mellanox.com
Signed-off-by: Or Gerlitz ogerl...@mellanox.com
Signed-off-by: Mike Christie micha...@cs.wisc.edu
---
 drivers/scsi/libiscsi_tcp.c |   43 ++-
 1 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/drivers/scsi/libiscsi_tcp.c b/drivers/scsi/libiscsi_tcp.c
index 1d58d53..7f59073 100644
--- a/drivers/scsi/libiscsi_tcp.c
+++ b/drivers/scsi/libiscsi_tcp.c
@@ -529,6 +529,8 @@ static int iscsi_tcp_r2t_rsp(struct iscsi_conn *conn, 
struct iscsi_task *task)
struct iscsi_r2t_rsp *rhdr = (struct iscsi_r2t_rsp *)tcp_conn-in.hdr;
struct iscsi_r2t_info *r2t;
int r2tsn = be32_to_cpu(rhdr-r2tsn);
+   u32 data_length;
+   u32 data_offset;
int rc;
 
if (tcp_conn-in.datalen) {
@@ -554,40 +556,39 @@ static int iscsi_tcp_r2t_rsp(struct iscsi_conn *conn, 
struct iscsi_task *task)
return 0;
}
 
-   rc = kfifo_out(tcp_task-r2tpool.queue, (void*)r2t, sizeof(void*));
-   if (!rc) {
-   iscsi_conn_printk(KERN_ERR, conn, Could not allocate R2T. 
- Target has sent more R2Ts than it 
- negotiated for or driver has leaked.\n);
-   return ISCSI_ERR_PROTO;
-   }
-
-   r2t-exp_statsn = rhdr-statsn;
-   r2t-data_length = be32_to_cpu(rhdr-data_length);
-   if (r2t-data_length == 0) {
+   data_length = be32_to_cpu(rhdr-data_length);
+   if (data_length == 0) {
iscsi_conn_printk(KERN_ERR, conn,
  invalid R2T with zero data len\n);
-   kfifo_in(tcp_task-r2tpool.queue, (void*)r2t,
-   sizeof(void*));
return ISCSI_ERR_DATALEN;
}
 
-   if (r2t-data_length  session-max_burst)
+   if (data_length  session-max_burst)
ISCSI_DBG_TCP(conn, invalid R2T with data len %u and max 
  burst %u. Attempting to execute request.\n,
- r2t-data_length, session-max_burst);
+ data_length, session-max_burst);
 
-   r2t-data_offset = be32_to_cpu(rhdr-data_offset);
-   if (r2t-data_offset + r2t-data_length  scsi_out(task-sc)-length) {
+   data_offset = be32_to_cpu(rhdr-data_offset);
+   if (data_offset + data_length  scsi_out(task-sc)-length) {
iscsi_conn_printk(KERN_ERR, conn,
  invalid R2T with data len %u at offset %u 
- and total length %d\n, r2t-data_length,
- r2t-data_offset, scsi_out(task-sc)-length);
-   kfifo_in(tcp_task-r2tpool.queue, (void*)r2t,
-   sizeof(void*));
+ and total length %d\n, data_length,
+ data_offset, scsi_out(task-sc)-length);
return ISCSI_ERR_DATALEN;
}
 
+   rc = kfifo_out(tcp_task-r2tpool.queue, (void*)r2t, sizeof(void*));
+   if (!rc) {
+   iscsi_conn_printk(KERN_ERR, conn, Could not allocate R2T. 
+ Target has sent more R2Ts than it 
+ negotiated for or driver has leaked.\n);
+   return ISCSI_ERR_PROTO;
+   }
+
+   r2t-exp_statsn = rhdr-statsn;
+   r2t-data_length = data_length;
+   r2t-data_offset = data_offset;
+
r2t-ttt = rhdr-ttt; /* no flip */
r2t-datasn = 0;
r2t-sent = 0;
-- 
1.7.1

--
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 6/6] iscsi_tcp: check for valid session before accessing

2013-12-20 Thread michaelc
From: Mike Christie micha...@cs.wisc.edu

Check that the session is setup before accessing its
connection. This fixes a oops where userspace tries
to get the ip address before the session is bound to
a host.

Signed-off-by: Mike Christie micha...@cs.wisc.edu
---
 drivers/scsi/iscsi_tcp.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index 12b3512..bfb6d07 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -759,6 +759,9 @@ static int iscsi_sw_tcp_host_get_param(struct Scsi_Host 
*shost,
 
switch (param) {
case ISCSI_HOST_PARAM_IPADDRESS:
+   if (!session)
+   return -ENOTCONN;
+
spin_lock_bh(session-frwd_lock);
conn = session-leadconn;
if (!conn) {
-- 
1.7.1

--
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 3/6] SCSI/libiscsi: Remove unneeded code

2013-12-20 Thread michaelc
From: Shlomo Pongratz shlo...@mellanox.com

We never will have a closed window and something on one of those lists.

Signed-off-by: Mike Christie micha...@cs.wisc.edu
Signed-off-by: Shlomo Pongratz shlo...@mellanox.com
---
 drivers/scsi/libiscsi.c |   12 
 1 files changed, 0 insertions(+), 12 deletions(-)

diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index e77c41f..cc19cc2 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -108,18 +108,6 @@ static void __iscsi_update_cmdsn(struct iscsi_session 
*session,
if (exp_cmdsn != session-exp_cmdsn 
!iscsi_sna_lt(exp_cmdsn, session-exp_cmdsn))
session-exp_cmdsn = exp_cmdsn;
-
-   if (max_cmdsn != session-max_cmdsn 
-   !iscsi_sna_lt(max_cmdsn, session-max_cmdsn)) {
-   session-max_cmdsn = max_cmdsn;
-   /*
-* if the window closed with IO queued, then kick the
-* xmit thread
-*/
-   if (!list_empty(session-leadconn-cmdqueue) ||
-   !list_empty(session-leadconn-mgmtqueue))
-   iscsi_conn_queue_work(session-leadconn);
-   }
 }
 
 void iscsi_update_cmdsn(struct iscsi_session *session, struct iscsi_nopin *hdr)
-- 
1.7.1

--
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 4/6] be2iscsi: fix lun test in device reset callout

2013-12-20 Thread michaelc
From: Mike Christie micha...@cs.wisc.edu

We want to be checking the scsi_cmnd's lun against
the possible tasks in the driver. Current check tests
task against itself which was useless.

Signed-off-by: Mike Christie micha...@cs.wisc.edu
---
 drivers/scsi/be2iscsi/be_main.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 1fb16b1..3ffe8ca 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -325,7 +325,7 @@ static int beiscsi_eh_device_reset(struct scsi_cmnd *sc)
if (!abrt_task-sc || abrt_task-state == ISCSI_TASK_FREE)
continue;
 
-   if (abrt_task-sc-device-lun != abrt_task-sc-device-lun)
+   if (sc-device-lun != abrt_task-sc-device-lun)
continue;
 
/* Invalidate WRB Posted for this Task */
-- 
1.7.1

--
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 5/6] iscsi_boot_sysfs: Fix a memory leak in iscsi_boot_destroy_kset()

2013-12-20 Thread michaelc
From: Ethan Zhao ethan.ker...@gmail.com

Load and unload iscsi_ibft module will cause kernel memory leak, fix it
in scsi/iscsi_boot_sysfs.c iscsi_boot_destroy_kset().

Signed-off-by: Ethan Zhao ethan.ker...@gmail.com
Signed-off-by: Mike Christie micha...@cs.wisc.edu
---
 drivers/scsi/iscsi_boot_sysfs.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/iscsi_boot_sysfs.c b/drivers/scsi/iscsi_boot_sysfs.c
index 14c1c8f..680bf6f 100644
--- a/drivers/scsi/iscsi_boot_sysfs.c
+++ b/drivers/scsi/iscsi_boot_sysfs.c
@@ -490,5 +490,6 @@ void iscsi_boot_destroy_kset(struct iscsi_boot_kset 
*boot_kset)
iscsi_boot_remove_kobj(boot_kobj);
 
kset_unregister(boot_kset-kset);
+   kfree(boot_kset);
 }
 EXPORT_SYMBOL_GPL(iscsi_boot_destroy_kset);
-- 
1.7.1

--
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/2] target_core_spc: bounds check for spc_emulate_inquiry()

2013-12-20 Thread Paolo Bonzini
Il 20/12/2013 07:47, Hannes Reinecke ha scritto:
  
  How about changing the local buffer to heap memory instead, and bumping
  SE_INQUIRY_BUF to 1024 bytes..?
  
 Ok. But then we should have a quick check at the start
 
 if (cmd-data_length  SE_INQUIRY_BUF)
   len = cmd-data_length
 else
   len = SE_INQUIRY_BUF
 
 to catch oversized requests.

Why do you need it?  If inquiry data is always 1K,  when
cmd-data_length is large you can just need to write zeroes to the
buffer after the first SE_INQUIRY_BUF bytes.

Paolo
--
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] drivers: target: target_core_mod: use div64_u64_rem() instead of operator '%' for u64

2013-12-20 Thread Chen Gang
In kernel, need use div64_u64_rem() instead of operator '%' for u64, or
can not pass compiling (with allmodconfig under metag):

MODPOST 2909 modules
  ERROR: __umoddi3 [drivers/target/target_core_mod.ko] undefined!

Also need u64 type cast for u32 variable multiply u32 variable, or will
cause type overflow issue.


Signed-off-by: Chen Gang gang.chen.5...@gmail.com
---
 drivers/target/target_core_alua.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/target/target_core_alua.c 
b/drivers/target/target_core_alua.c
index dc0d399..ff2aadc 100644
--- a/drivers/target/target_core_alua.c
+++ b/drivers/target/target_core_alua.c
@@ -489,7 +489,8 @@ static inline int core_alua_state_lba_dependent(
u64 first_lba = map-lba_map_first_lba;
 
if (segment_mult) {
-   start_lba = lba % (segment_size * segment_mult);
+   u64 tmp = (u64)segment_size * segment_mult;
+   div64_u64_rem(lba, tmp, start_lba);
last_lba = first_lba + segment_size - 1;
if (start_lba = first_lba 
start_lba = last_lba) {
-- 
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