Re: Sparc ESP problem with blk-mq

2014-10-16 Thread mroos
  Christoph, any idea on this? The command just times out, for some reason.
  Only thing I could think of was related to perhaps missing bouncing or
  similar, but I don't think that's the case. But the hba must not like the
  request somehow. Or perhaps it sets up the wrong number of segments.
  
  Seems like this is the first command we send.  I don't really have an
  idea at the moment, but it would be good to increase the scsi_logging
  level to the maximum and/or add some traces to the esp driver to figure
  out where the command gets lost.
 
 I'll set aside some time to see if I can find anything obvious.
 
 The ESP driver already has a deep, extensive, debug logging facility.
 Just set the esp_debug=xxx option to something.  You can turn
 everything on just by using something like esp_debug=0x7ff

I booted with esp_scsi.esp_debug=0x7ff and here is the dmesg:

boot: test esp_scsi.esp_debug=0x7ff scsi_mod.use_blk_mq=1
Allocated 64 Megs of memory at 0x4000 for kernel
Uncompressing image...
Loaded kernel version 3.17.0

[0.00] PROMLIB: Sun IEEE Boot Prom 'OBP 3.35.0 2004/04/19 12:15'
[0.00] PROMLIB: Root node compatible: 
[0.00] Initializing cgroup subsys cpu
[0.00] Linux version 3.17.0-07613-gca32188-dirty (mroos@melon) (gcc 
version 4.9.1 (Debian 4.9.1-16) ) #56 Mon Oct 13 19:17:41 EEST 2014
[0.00] bootconsole [earlyprom0] enabled
[0.00] ARCH: SUN4U
[0.00] Ethernet address: 08:00:20:9f:6b:e4
[0.00] MM: PAGE_OFFSET is 0xf800 (max_phys_bits == 40)
[0.00] MM: VMALLOC [0x0001 -- 0x0600]
[0.00] MM: VMEMMAP [0x0600 -- 0x0c00]
[0.00] Kernel: Using 2 locked TLB entries for main kernel image.
[0.00] Remapping the kernel... done.
[0.00] OF stdout device is: /sbus@1f,0/zs@f,110:a
[0.00] PROM: Built device tree with 52656 bytes of memory.
[0.00] Top of RAM: 0x33f5, Total RAM: 0x33f3e000
[0.00] Memory hole size: 0MB
[0.00] Allocated 16384 bytes for kernel page tables.
[0.00] Zone ranges:
[0.00]   Normal   [mem 0x-0x33f4]
[0.00] Movable zone start for each node
[0.00] Early memory node ranges
[0.00]   node   0: [mem 0x-0x33efdfff]
[0.00]   node   0: [mem 0x33f0-0x33f2bfff]
[0.00]   node   0: [mem 0x33f3c000-0x33f4]
[0.00] Booting Linux...
[0.00] CPU CAPS: [flush,stbar,swap,muldiv,v9,mul32,div32,v8plus]
[0.00] CPU CAPS: [vis]
[0.00] Built 1 zonelists in Zone order, mobility grouping on.  Total 
pages: 105567
[0.00] Kernel command line: root=/dev/sda2 ro scsi_mod.use_blk_mq=0 
esp_scsi.esp_debug=0x7ff scsi_mod.use_blk_mq=1
[0.00] PID hash table entries: 4096 (order: 2, 32768 bytes)
[0.00] Dentry cache hash table entries: 131072 (order: 7, 1048576 bytes)
[0.00] Inode-cache hash table entries: 65536 (order: 6, 524288 bytes)
[0.00] Sorting __ex_table...
[0.00] Memory: 836032K/851192K available (3453K kernel code, 260K 
rwdata, 824K rodata, 152K init, 399K bss, 15160K reserved)
[0.00] NR_IRQS:2048 nr_irqs:2048 1
[   65.975922] clocksource: mult[6fe6fda] shift[24]
[   66.030682] clockevent: mult[249a7588] shift[32]
[   66.086598] Console: colour dummy device 80x25
[   66.139102] console [tty0] enabled
[   66.179682] bootconsole [earlyprom0] disabled
[0.00] PROMLIB: Sun IEEE Boot Prom 'OBP 3.35.0 2004/04/19 12:15'
[0.00] PROMLIB: Root node compatible: 
[0.00] Initializing cgroup subsys cpu
[0.00] Linux version 3.17.0-07613-gca32188-dirty (mroos@melon) (gcc 
version 4.9.1 (Debian 4.9.1-16) ) #56 Mon Oct 13 19:17:41 EEST 2014
[0.00] bootconsole [earlyprom0] enabled
[0.00] ARCH: SUN4U
[0.00] Ethernet address: 08:00:20:9f:6b:e4
[0.00] MM: PAGE_OFFSET is 0xf800 (max_phys_bits == 40)
[0.00] MM: VMALLOC [0x0001 -- 0x0600]
[0.00] MM: VMEMMAP [0x0600 -- 0x0c00]
[0.00] Kernel: Using 2 locked TLB entries for main kernel image.
[0.00] Remapping the kernel... done.
[0.00] OF stdout device is: /sbus@1f,0/zs@f,110:a
[0.00] PROM: Built device tree with 52656 bytes of memory.
[0.00] Top of RAM: 0x33f5, Total RAM: 0x33f3e000
[0.00] Memory hole size: 0MB
[0.00] Allocated 16384 bytes for kernel page tables.
[0.00] Zone ranges:
[0.00]   Normal   [mem 0x-0x33f4]
[0.00] Movable zone start for each node
[0.00] Early memory node ranges
[0.00]   node   0: [mem 0x-0x33efdfff]
[0.00]   node   0: [mem 0x33f0-0x33f2bfff]
[0.00]   node   0: [mem 0x33f3c000-0x33f4]
[0.00] Booting Linux...
[0.00] CPU CAPS: [flush,stbar,swap,muldiv,v9,mul32,div32,v8plus]
[0.00] CPU CAPS: [vis]

Re: [PATCH 0/5] block/scsi/lio support for COMPARE_AND_WRITE

2014-10-16 Thread Douglas Gilbert

On 14-10-16 07:37 AM, micha...@cs.wisc.edu wrote:

The following patches implement the SCSI command COMPARE_AND_WRITE as a new
bio/request type REQ_CMP_AND_WRITE. COMPARE_AND_WRITE is defined in the
SCSI SBC (SCSI block command) specs as:

The COMPARE AND WRITE command requests that the device server perform the
following as an uninterrupted series of actions:

1) perform the following operations:
 A) read the specified logical blocks; and
 B) transfer the specified number of logical blocks from the Data-Out
 Buffer (i.e., the verify instance of the data is transferred from the
 Data-Out Buffer);

2) compare the data read from the specified logical blocks with the verify
instance of the data; and
3) If the compared data matches, then perform the following operations:
 1) transfer the specified number of logical blocks from the Data-Out
 Buffer (i.e., the write instance of the data transferred from the
 Data-Out Buffer); and
 2) write those logical blocks.

The most command use of this command today is in VMware ESX where it is used
for locking. See
http://blogs.vmware.com/vsphere/2012/05/vmfs-locking-uncovered.html
[in ESX is it is called ATS (atomic test and set)] for more VMware info.
Linux fits into this use, because its SCSI target layer (LIO) is commonly
used as storage for ESX VMs.

Currently, to support this command in LIO we emulate it by taking a lock,
doing a read, comparing it, then doing a write. The problem this patchset
tries to solve is that in many cases it is more efficient to pass the one
COMPARE_AND_REQUEST request directly to the device where it might have
optimized locking and also will require fewer requests to/from the target
and backing storage device.

I am also bugging the ceph-devel list, because I am working on LIO + ceph
support. I am interested in using ceph's rbd device for the backing
storage for LIO, and I was thinking this request could be implemented similar
to how REQ_DISCARD (unmap/trim) is going to be, and I wanted to get some early
feedback. I know the scsi layer better, so I have only added support in sd in
this patchset.

The following patches were made over the target-pending for-next branch but
also apply to Linus's tree.


As I found when I implemented this command in sg3_utils,
my library's support for handling and reporting the
MISCOMPARE sense key needed to be strengthened. [A sense
buffer with a MISCOMPARE sense key is what results when
the compare in step 2) is unequal.]

Since it was relatively rare prior to VMWare's use of
the COMPARE AND WRITE command, MISCOMPARE is often forgotten
in sense key handling. Also it should not be considered
as an error and definitely should not lead to the command
being retried.

The COMPARE AND WRITE command may fail for other reasons
such as a transport problem or a Unit Attention, so the
SCSI eh logic may need to know about it.

Doug Gilbert

--
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] tmscim: Remove unused SCSI_IRQ_NONE macro definition

2014-10-16 Thread Guennadi Liakhovetski
On Fri, 3 Oct 2014, Finn Thain wrote:

 
 Signed-off-by: Finn Thain fth...@telegraphics.com.au

Acked-by: Guennadi Liakhovetski g.liakhovet...@gmx.de

Thanks
Guennadi

 
 ---
 
 This macro is only used in the NCR5380 drivers and they don't include
 this header.
 
 ---
  drivers/scsi/tmscsim.h |2 --
  1 file changed, 2 deletions(-)
 
 Index: linux/drivers/scsi/tmscsim.h
 ===
 --- linux.orig/drivers/scsi/tmscsim.h 2014-09-29 10:55:44.0 +1000
 +++ linux/drivers/scsi/tmscsim.h  2014-10-01 16:33:25.0 +1000
 @@ -10,8 +10,6 @@
  
  #include linux/types.h
  
 -#define SCSI_IRQ_NONE 255
 -
  #define MAX_ADAPTER_NUM  4
  #define MAX_SG_LIST_BUF  16  /* Not used */
  #define MAX_SCSI_ID  8
 
--
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] aic7xxx: replace kmalloc/memset by kzalloc

2014-10-16 Thread Michael Opdenacker
This replaces kmalloc + memset by a call to kzalloc.

This also fixes one checkpatch.pl issue in the process.

This improvement was suggested by make coccicheck

Signed-off-by: Michael Opdenacker michael.opdenac...@free-electrons.com
---
 drivers/scsi/aic7xxx/aic79xx_core.c |  3 +--
 drivers/scsi/aic7xxx/aic79xx_osm.c  |  3 +--
 drivers/scsi/aic7xxx/aic7xxx_core.c | 10 --
 drivers/scsi/aic7xxx/aic7xxx_osm.c  |  3 +--
 4 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/drivers/scsi/aic7xxx/aic79xx_core.c 
b/drivers/scsi/aic7xxx/aic79xx_core.c
index 0bcacf71aef8..9ce383c884c0 100644
--- a/drivers/scsi/aic7xxx/aic79xx_core.c
+++ b/drivers/scsi/aic7xxx/aic79xx_core.c
@@ -10437,14 +10437,13 @@ ahd_handle_en_lun(struct ahd_softc *ahd, struct 
cam_sim *sim, union ccb *ccb)
return;
}
}
-   lstate = kmalloc(sizeof(*lstate), GFP_ATOMIC);
+   lstate = kzalloc(sizeof(*lstate), GFP_ATOMIC);
if (lstate == NULL) {
xpt_print_path(ccb-ccb_h.path);
printk(Couldn't allocate lstate\n);
ccb-ccb_h.status = CAM_RESRC_UNAVAIL;
return;
}
-   memset(lstate, 0, sizeof(*lstate));
status = xpt_create_path(lstate-path, /*periph*/NULL,
 xpt_path_path_id(ccb-ccb_h.path),
 xpt_path_target_id(ccb-ccb_h.path),
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c 
b/drivers/scsi/aic7xxx/aic79xx_osm.c
index ed333669a7dc..67a01e804195 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm.c
+++ b/drivers/scsi/aic7xxx/aic79xx_osm.c
@@ -1325,10 +1325,9 @@ int
 ahd_platform_alloc(struct ahd_softc *ahd, void *platform_arg)
 {
ahd-platform_data =
-   kmalloc(sizeof(struct ahd_platform_data), GFP_ATOMIC);
+   kzalloc(sizeof(struct ahd_platform_data), GFP_ATOMIC);
if (ahd-platform_data == NULL)
return (ENOMEM);
-   memset(ahd-platform_data, 0, sizeof(struct ahd_platform_data));
ahd-platform_data-irq = AHD_LINUX_NOIRQ;
ahd_lockinit(ahd);
ahd-seltime = (aic79xx_seltime  0x3)  4;
diff --git a/drivers/scsi/aic7xxx/aic7xxx_core.c 
b/drivers/scsi/aic7xxx/aic7xxx_core.c
index 10172a3af1b9..c4829d84b335 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_core.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_core.c
@@ -4464,10 +4464,9 @@ ahc_softc_init(struct ahc_softc *ahc)
ahc-pause = ahc-unpause | PAUSE; 
/* XXX The shared scb data stuff should be deprecated */
if (ahc-scb_data == NULL) {
-   ahc-scb_data = kmalloc(sizeof(*ahc-scb_data), GFP_ATOMIC);
+   ahc-scb_data = kzalloc(sizeof(*ahc-scb_data), GFP_ATOMIC);
if (ahc-scb_data == NULL)
return (ENOMEM);
-   memset(ahc-scb_data, 0, sizeof(*ahc-scb_data));
}
 
return (0);
@@ -4780,10 +4779,10 @@ ahc_init_scbdata(struct ahc_softc *ahc)
SLIST_INIT(scb_data-sg_maps);
 
/* Allocate SCB resources */
-   scb_data-scbarray = kmalloc(sizeof(struct scb) * AHC_SCB_MAX_ALLOC, 
GFP_ATOMIC);
+   scb_data-scbarray = kzalloc(sizeof(struct scb) * AHC_SCB_MAX_ALLOC,
+   GFP_ATOMIC);
if (scb_data-scbarray == NULL)
return (ENOMEM);
-   memset(scb_data-scbarray, 0, sizeof(struct scb) * AHC_SCB_MAX_ALLOC);
 
/* Determine the number of hardware SCBs and initialize them */
 
@@ -7558,14 +7557,13 @@ ahc_handle_en_lun(struct ahc_softc *ahc, struct cam_sim 
*sim, union ccb *ccb)
return;
}
}
-   lstate = kmalloc(sizeof(*lstate), GFP_ATOMIC);
+   lstate = kzalloc(sizeof(*lstate), GFP_ATOMIC);
if (lstate == NULL) {
xpt_print_path(ccb-ccb_h.path);
printk(Couldn't allocate lstate\n);
ccb-ccb_h.status = CAM_RESRC_UNAVAIL;
return;
}
-   memset(lstate, 0, sizeof(*lstate));
status = xpt_create_path(lstate-path, /*periph*/NULL,
 xpt_path_path_id(ccb-ccb_h.path),
 xpt_path_target_id(ccb-ccb_h.path),
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c 
b/drivers/scsi/aic7xxx/aic7xxx_osm.c
index d2c9bf39033d..350701407ecd 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c
@@ -1213,10 +1213,9 @@ ahc_platform_alloc(struct ahc_softc *ahc, void 
*platform_arg)
 {
 
ahc-platform_data =
-   kmalloc(sizeof(struct ahc_platform_data), GFP_ATOMIC);
+   kzalloc(sizeof(struct ahc_platform_data), GFP_ATOMIC);
if (ahc-platform_data == NULL)
return (ENOMEM);
-   

Re: [PATCH] aic7xxx: replace kmalloc/memset by kzalloc

2014-10-16 Thread Joe Perches
On Thu, 2014-10-16 at 21:14 +0200, Michael Opdenacker wrote:
 This replaces kmalloc + memset by a call to kzalloc.
[]
 diff --git a/drivers/scsi/aic7xxx/aic7xxx_core.c 
 b/drivers/scsi/aic7xxx/aic7xxx_core.c
[]
 @@ -4780,10 +4779,10 @@ ahc_init_scbdata(struct ahc_softc *ahc)
   SLIST_INIT(scb_data-sg_maps);
  
   /* Allocate SCB resources */
 - scb_data-scbarray = kmalloc(sizeof(struct scb) * AHC_SCB_MAX_ALLOC, 
 GFP_ATOMIC);
 + scb_data-scbarray = kzalloc(sizeof(struct scb) * AHC_SCB_MAX_ALLOC,
 + GFP_ATOMIC);
   if (scb_data-scbarray == NULL)
   return (ENOMEM);
 - memset(scb_data-scbarray, 0, sizeof(struct scb) * AHC_SCB_MAX_ALLOC);
  
   /* Determine the number of hardware SCBs and initialize them */
  

Probably better as kcalloc.

--
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] aic7xxx: replace kmalloc/memset by kzalloc

2014-10-16 Thread Michael Opdenacker
Hi Joe,

On 10/16/2014 09:28 PM, Joe Perches wrote:
 On Thu, 2014-10-16 at 21:14 +0200, Michael Opdenacker wrote:

  
   /* Allocate SCB resources */
 - scb_data-scbarray = kmalloc(sizeof(struct scb) * AHC_SCB_MAX_ALLOC, 
 GFP_ATOMIC);
 + scb_data-scbarray = kzalloc(sizeof(struct scb) * AHC_SCB_MAX_ALLOC,
 + GFP_ATOMIC);
   if (scb_data-scbarray == NULL)
   return (ENOMEM);
 - memset(scb_data-scbarray, 0, sizeof(struct scb) * AHC_SCB_MAX_ALLOC);
  
   /* Determine the number of hardware SCBs and initialize them */
  
 Probably better as kcalloc.

Hey, well spotted! Thanks for your review. I will post a new version soon.

Cheers,

Michael.




-- 
Michael Opdenacker, CEO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
+33 484 258 098

--
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/5] block/scsi/lio support for COMPARE_AND_WRITE

2014-10-16 Thread Douglas Gilbert

On 14-10-16 12:39 PM, Douglas Gilbert wrote:

On 14-10-16 07:37 AM, micha...@cs.wisc.edu wrote:

The following patches implement the SCSI command COMPARE_AND_WRITE as a new
bio/request type REQ_CMP_AND_WRITE. COMPARE_AND_WRITE is defined in the
SCSI SBC (SCSI block command) specs as:

The COMPARE AND WRITE command requests that the device server perform the
following as an uninterrupted series of actions:

1) perform the following operations:
 A) read the specified logical blocks; and
 B) transfer the specified number of logical blocks from the Data-Out
 Buffer (i.e., the verify instance of the data is transferred from the
 Data-Out Buffer);

2) compare the data read from the specified logical blocks with the verify
instance of the data; and
3) If the compared data matches, then perform the following operations:
 1) transfer the specified number of logical blocks from the Data-Out
 Buffer (i.e., the write instance of the data transferred from the
 Data-Out Buffer); and
 2) write those logical blocks.

The most command use of this command today is in VMware ESX where it is used
for locking. See
http://blogs.vmware.com/vsphere/2012/05/vmfs-locking-uncovered.html
[in ESX is it is called ATS (atomic test and set)] for more VMware info.
Linux fits into this use, because its SCSI target layer (LIO) is commonly
used as storage for ESX VMs.

Currently, to support this command in LIO we emulate it by taking a lock,
doing a read, comparing it, then doing a write. The problem this patchset
tries to solve is that in many cases it is more efficient to pass the one
COMPARE_AND_REQUEST request directly to the device where it might have
optimized locking and also will require fewer requests to/from the target
and backing storage device.

I am also bugging the ceph-devel list, because I am working on LIO + ceph
support. I am interested in using ceph's rbd device for the backing
storage for LIO, and I was thinking this request could be implemented similar
to how REQ_DISCARD (unmap/trim) is going to be, and I wanted to get some early
feedback. I know the scsi layer better, so I have only added support in sd in
this patchset.

The following patches were made over the target-pending for-next branch but
also apply to Linus's tree.


As I found when I implemented this command in sg3_utils,
my library's support for handling and reporting the
MISCOMPARE sense key needed to be strengthened. [A sense
buffer with a MISCOMPARE sense key is what results when
the compare in step 2) is unequal.]

Since it was relatively rare prior to VMWare's use of
the COMPARE AND WRITE command, MISCOMPARE is often forgotten
in sense key handling. Also it should not be considered
as an error and definitely should not lead to the command
being retried.

The COMPARE AND WRITE command may fail for other reasons
such as a transport problem or a Unit Attention, so the
SCSI eh logic may need to know about it.


Elaborating ...

Hannes will enjoy this one: say a COMPARE AND WRITE (CAW) fails
due to a transport error or timeout. What should the EH do *** ?
Answer: read that LBA(s) to see whether the command succeeded
(i.e. wrote the new data)! If it did, do nothing; if it didn't,
repeat the CAW command. And naturally that second CAW may
yield a MISCOMPARE.


Mike proposes using ECANCELED for the errno corresponding to
MISCOMPARE. Not wild about that but can't see anything better,
and it is definitely much better than EIO.

Checked with FreeBSD and this issue has not come up there yet.
If ESX uses a Unix like kernel, it would be interesting to know
which errno (if any) they use.

Doug Gilbert

*** the EH has other options:
- send the transport error or timeout indication back so
  the application is alerted to do a read to check if done.
- if it retries the CAW blindly that might yield a MISCOMPARE
  when it actually succeeded (due to the original CAW command
  being acted on); but then the application needs to be aware
  that ECANCELED may not mean miscompare.

--
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/5] block/scsi/lio support for COMPARE_AND_WRITE

2014-10-16 Thread Elliott, Robert (Server Storage)


 -Original Message-
 From: linux-scsi-ow...@vger.kernel.org [mailto:linux-scsi-
 ow...@vger.kernel.org] On Behalf Of Douglas Gilbert
 Sent: Thursday, 16 October, 2014 3:02 PM
...
 On 14-10-16 12:39 PM, Douglas Gilbert wrote:
...
  The COMPARE AND WRITE command may fail for other reasons
  such as a transport problem or a Unit Attention, so the
  SCSI eh logic may need to know about it.
 
 Elaborating ...
 
 Hannes will enjoy this one: say a COMPARE AND WRITE (CAW) fails
 due to a transport error or timeout. What should the EH do *** ?
 Answer: read that LBA(s) to see whether the command succeeded
 (i.e. wrote the new data)! If it did, do nothing; if it didn't,
 repeat the CAW command. And naturally that second CAW may
 yield a MISCOMPARE.

I don't think that is safe.. detecting the write data is in
place doesn't prove the COMPARE AND WRITE really worked as
a whole.

Example: if two applications do this:
* application 1: COMPARE AND WRITE: change 4 to 6
* application 2: COMPARE AND WRITE: change 5 to 6

and they both run into transport errors, then they'll 
both read back 6 and think their commands worked when
really only one of them worked.

---
Rob ElliottHP Server Storage



--
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] libcxgbi : support ipv6 address host_param

2014-10-16 Thread Anish Bhatt
libcxgbi was always returning an ipv4 address for ISCSI_HOST_PARAM_IPADDRESS,
return appropriate address based on address family

Signed-off-by: Anish Bhatt an...@chelsio.com
Signed-off-by: Karen Xie k...@chelsio.com
---
 drivers/scsi/cxgbi/libcxgbi.c | 42 +-
 drivers/scsi/cxgbi/libcxgbi.h |  5 -
 2 files changed, 37 insertions(+), 10 deletions(-)

diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c
index 6a2001d..403330a 100644
--- a/drivers/scsi/cxgbi/libcxgbi.c
+++ b/drivers/scsi/cxgbi/libcxgbi.c
@@ -397,6 +397,35 @@ EXPORT_SYMBOL_GPL(cxgbi_hbas_add);
  *   If the source port is outside our allocation range, the caller is
  *   responsible for keeping track of their port usage.
  */
+
+static struct cxgbi_sock *find_sock_on_port(struct cxgbi_device *cdev,
+   unsigned char port_id)
+{
+   struct cxgbi_ports_map *pmap = cdev-pmap;
+   unsigned int i;
+   unsigned int used;
+
+   if (!pmap-max_connect || !pmap-used)
+   return NULL;
+
+   spin_lock_bh(pmap-lock);
+   used = pmap-used;
+   for (i = 0; used  i  pmap-max_connect; i++) {
+   struct cxgbi_sock *csk = pmap-port_csk[i];
+
+   if (csk) {
+   if (csk-port_id == port_id) {
+   spin_unlock_bh(pmap-lock);
+   return csk;
+   }
+   used--;
+   }
+   }
+   spin_unlock_bh(pmap-lock);
+
+   return NULL;
+}
+
 static int sock_get_port(struct cxgbi_sock *csk)
 {
struct cxgbi_device *cdev = csk-cdev;
@@ -747,6 +776,7 @@ static struct cxgbi_sock *cxgbi_check_route6(struct 
sockaddr *dst_addr)
csk-daddr6.sin6_addr = daddr6-sin6_addr;
csk-daddr6.sin6_port = daddr6-sin6_port;
csk-daddr6.sin6_family = daddr6-sin6_family;
+   csk-saddr6.sin6_family = daddr6-sin6_family;
csk-saddr6.sin6_addr = pref_saddr;
 
neigh_release(n);
@@ -2645,12 +2675,14 @@ int cxgbi_get_host_param(struct Scsi_Host *shost, enum 
iscsi_host_param param,
break;
case ISCSI_HOST_PARAM_IPADDRESS:
{
-   __be32 addr;
-
-   addr = cxgbi_get_iscsi_ipv4(chba);
-   len = sprintf(buf, %pI4, addr);
+   struct cxgbi_sock *csk = find_sock_on_port(chba-cdev,
+  chba-port_id);
+   if (csk) {
+   len = sprintf(buf, %pIS,
+ (struct sockaddr *)csk-saddr);
+   }
log_debug(1  CXGBI_DBG_ISCSI,
-   hba %s, ipv4 %pI4.\n, chba-ndev-name, addr);
+ hba %s, addr %s.\n, chba-ndev-name, buf);
break;
}
default:
diff --git a/drivers/scsi/cxgbi/libcxgbi.h b/drivers/scsi/cxgbi/libcxgbi.h
index 1d98fad..2c7cb1c 100644
--- a/drivers/scsi/cxgbi/libcxgbi.h
+++ b/drivers/scsi/cxgbi/libcxgbi.h
@@ -700,11 +700,6 @@ static inline void cxgbi_set_iscsi_ipv4(struct cxgbi_hba 
*chba, __be32 ipaddr)
chba-ndev-name);
 }
 
-static inline __be32 cxgbi_get_iscsi_ipv4(struct cxgbi_hba *chba)
-{
-   return chba-ipv4addr;
-}
-
 struct cxgbi_device *cxgbi_device_register(unsigned int, unsigned int);
 void cxgbi_device_unregister(struct cxgbi_device *);
 void cxgbi_device_unregister_all(unsigned int flag);
-- 
2.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