Re: Another (ESP?) scsi blk-mq problem on sparc64

2015-01-29 Thread Jens Axboe

On 01/28/2015 11:53 PM, Meelis Roos wrote:

On Mon, 24 Nov 2014, David Miller wrote:


From: mr...@linux.ee
Date: Tue, 25 Nov 2014 00:23:20 +0200 (EET)


Yes, that does look like the case.  Do you have a good trick on how
to allocate a map for the highest possible cpu number without first
iterating the cpu map?  I couldn't find something that looks like a
highest_possible_cpu() helper.


Honestly I think that num_posible_cpus() should return the max of
number of CPUs (weigt), and the highest numbered CPU. It's a pain in
the butt to handle this otherwise.


Hear, hear!!!  That would make my life easier, and would make this sort
of problem much less likely to occur!


How about this one?


It make the machine work.


Thanks for testing!



What's the status of this fix? It is still not applied on yesterdays
3.19.0-rc6-00105-gc59c961 git...


Hmm, I thought commit a33c1ba29138 took care of it... Does the attached 
work?


--
Jens Axboe

diff --git a/block/blk-mq-cpumap.c b/block/blk-mq-cpumap.c
index 5f13f4d0bcce..527d315dc1a5 100644
--- a/block/blk-mq-cpumap.c
+++ b/block/blk-mq-cpumap.c
@@ -88,10 +88,11 @@ int blk_mq_update_queue_map(unsigned int *map, unsigned int nr_queues)
 unsigned int *blk_mq_make_queue_map(struct blk_mq_tag_set *set)
 {
 	unsigned int *map;
+	size_t sz;
 
 	/* If cpus are offline, map them to first hctx */
-	map = kzalloc_node(sizeof(*map) * nr_cpu_ids, GFP_KERNEL,
-set-numa_node);
+	sz = max_t(unsigned int, nr_cpu_ids, num_possible_cpus());
+	map = kzalloc_node(sizeof(*map) * sz, GFP_KERNEL, set-numa_node);
 	if (!map)
 		return NULL;
 


Re: usb-storage URB use-after-free

2015-01-29 Thread Alan Stern
On Wed, 28 Jan 2015, Joe Lawrence wrote:

 This one should have gone over to linux-usb.
 
 -- Joe
 
 On 01/28/2015 05:04 PM, Joe Lawrence wrote:
  Hello linux-usb,
  
  We've hit a USB use-after-free on Stratus HW during device removal tests.
  We're running fio disk I/O to a scsi disk hanging off USB when the USB
  controller is hotplug removed.  This crash is very consistent (usually the
  first device pull during testing).  Without I/O, it may take days to
  encounter.
  
  general protection fault:  [#1] SMP
  ...
  CPU: 35 PID: 19626 Comm: kworker/u97:0 Tainted: PF   W  O-- 
3.10.0-210.el7.dev02.x86_64 #1
  Hardware name: Stratus ftServer 6800/G7LYY, BIOS BIOS Version 8.0:30 
  11/12/2014
  Workqueue: scsi_tmf_872 scmd_eh_abort_handler
  task: 88031bd91960 ti: 880981318000 task.ti: 880981318000
  RIP: 0010:[812d5e2d]  [812d5e2d] kobject_put+0xd/0x60
  RSP: 0018:88098131bd28  EFLAGS: 00010002
  RAX:  RBX: 6b6b6b6b6b6b6c0b RCX: 0001002f0009
  RDX: 002f RSI: ea0015719800 RDI: 6b6b6b6b6b6b6c0b
  RBP: 88098131bd30 R08: 88055c6622f0 R09: 0001002f0008
  R10: 88085f407a80 R11: 81450503 R12: 8804bab6d248
  R13: ff98 R14: 0086 R15: 0c20
  FS:  () GS:88085fce() knlGS:
  CS:  0010 DS:  ES:  CR0: 80050033
  CR2: 7f2ebb5d6008 CR3: 001038dc5000 CR4: 001407e0
  DR0:  DR1:  DR2: 
  DR3:  DR6: 0ff0 DR7: 0400
  Stack:
    88098131bd40 813cd327 88098131bd50
   8140a65a 88098131bd78 81416795 
   880414791968 880414791978 88098131bd88 814175f6
  Call Trace:
   [813cd327] put_device+0x17/0x20
   [8140a65a] usb_put_dev+0x1a/0x20
   [81416795] usb_hcd_unlink_urb+0x65/0xe0
   [814175f6] usb_unlink_urb+0x26/0x50
   [81418e92] usb_sg_cancel+0x82/0xe0
   [a0074e71] usb_stor_stop_transport+0x31/0x50 [usb_storage]
   [a0073b8d] command_abort+0xcd/0xe0 [usb_storage]
   [813f51ef] scmd_eh_abort_handler+0xbf/0x480
   [8108f06b] process_one_work+0x17b/0x470
   [8108fe4b] worker_thread+0x11b/0x400
   [8108fd30] ? rescuer_thread+0x400/0x400
   [8109722f] kthread+0xcf/0xe0
   [81097160] ? kthread_create_on_node+0x140/0x140
   [8161387c] ret_from_fork+0x7c/0xb0
   [81097160] ? kthread_create_on_node+0x140/0x140
  
  from another crash, we know that the URB itself has been freed:

  but the underlying usb_device-device is still present:

  It looks like usb_hcd_unlink_urb takes a reference out on the underlying
  device but not the URB, which in our test case consistently gets freed
  just before usb_hcd_unlink_urb tries to return a reference on urb-device. 

The analysis looks correct.

  Maybe the URB is a reference count short when usb_hcd_unlink_urb calls
  unlink1?  Somewhere usb-storage missed taking out a ref?

No; it's a simple use-after-free error.

  A tourniquet hack-patch follows (probably inside out, as the URB should stay
  intact while usb_hcd_unlink_urb does its thing) and has been running a
  little over 30 surprise device removals under I/O without incident.
  
  Any better suggestions?

Please try this instead.

Alan Stern



Index: usb-3.19/drivers/usb/core/hcd.c
===
--- usb-3.19.orig/drivers/usb/core/hcd.c
+++ usb-3.19/drivers/usb/core/hcd.c
@@ -1618,6 +1618,7 @@ static int unlink1(struct usb_hcd *hcd,
 int usb_hcd_unlink_urb (struct urb *urb, int status)
 {
struct usb_hcd  *hcd;
+   struct usb_device   *udev = urb-dev;
int retval = -EIDRM;
unsigned long   flags;
 
@@ -1629,20 +1630,19 @@ int usb_hcd_unlink_urb (struct urb *urb,
spin_lock_irqsave(hcd_urb_unlink_lock, flags);
if (atomic_read(urb-use_count)  0) {
retval = 0;
-   usb_get_dev(urb-dev);
+   usb_get_dev(udev);
}
spin_unlock_irqrestore(hcd_urb_unlink_lock, flags);
if (retval == 0) {
hcd = bus_to_hcd(urb-dev-bus);
retval = unlink1(hcd, urb, status);
-   usb_put_dev(urb-dev);
+   if (retval == 0)
+   retval = -EINPROGRESS;
+   else if (retval != -EIDRM  retval != -EBUSY)
+   dev_dbg(udev-dev, hcd_unlink_urb %p fail %d\n,
+   urb, retval);
+   usb_put_dev(udev);
}
-
-   if (retval == 0)
-   retval = -EINPROGRESS;
-   else if (retval != -EIDRM  retval != -EBUSY)
-   dev_dbg(urb-dev-dev, hcd_unlink_urb %p fail %d\n,
-  

Re: [PATCH 0/17] Clear up bidi command confusion

2015-01-29 Thread Boaz Harrosh
On 01/29/2015 04:41 PM, James Bottomley wrote:
 On Thu, 2015-01-29 at 15:00 +0200, Boaz Harrosh wrote:
 On 01/23/2015 03:12 PM, Christoph Hellwig wrote:
 On Fri, Jan 23, 2015 at 01:05:30PM +0100, Bart Van Assche wrote:
 There is some confusion in the SCSI core and in SCSI LLDs around the
 meaning of sc_data_direction and whether or not this member can have the
 value DMA_BIDIRECTIONAL. Clear up this confusion. The patches in this
 series are:

 I wonder if we should change the code to set DMA_BIDIRECTIONAL for
 bidi commands.  That seems a lot more logical than the current
 version.


 You cannot do this. Because a Bidi Command is actually two commands
 one for the WRITE side (DMA_TO_DEVICE) which is this one, and another
 command for the READ side (DMA_FROM_DEVICE).
 
 You're not thinking about this the correct way.  DMA_BIDIRECTIONAL is a
 DMA engine flag.  We use it in SCSI for historical reasons (mainly to
 prevent a translation from the SCSI version).  Since it was never used,
 most SCSI drivers have code to check and reject commands with it set.
 For actual bidirectional commands, you have to check scsi_bidi_command()
 and programme the DMA engine separately for both phases, so the flag is
 useless in this case.
 

This is what I meant how is above different from what I said?

 The proposal is to make it the signal for bidirectional commands

This I disagree, and would be a very bad idea and will take us back, to
hacking time. As you noted, please let us leave DMA_BIDIRECTIONAL to the
DMA engines. Let us just stir away from the DMA_XXX flags altogether and
move back to block layer flags. 

 (in which case most HBAs would make it do the right thing; i.e. reject) 

This is not necessary, (the check and rejection), commands will not be issued
to LLDs that did not mark support for BiDi. So they will never receive
such commands and it is added dead code.

 but
 it still wouldn't be how you'd program the DMA enigne; that still would
 have to be done in two phases as it is today.
 

Exactly my point. Only one small correction, these are not two phases, as in
phases-1 then phases-2. These are two memory buffers independently programmed
for DMA transfer. The actual transfer occurs simultaneously, on both buffers.

 James
 
 

Thanks
Boaz

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


kobject (00000000008e10d8): tried to init an initialized object, something is seriously wrong.

2015-01-29 Thread Meelis Roos
Tried 3.19.0-rc6-00105-gc59c961-dirty (first kernel after 3.18) on Sun 
E3000 (spoarc64), got a bunch on warnings in blk_mq_register_disk. After 
that, it seems to work fine.

-dirty means the following patch to fix the warnings in Another (ESP?) 
scsi blk-mq problem on sparc64 thread from Nov 14 2014.

diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 0a9a6da..db21f68 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -83,7 +83,13 @@ extern const struct cpumask *const cpu_active_mask;
 
 #if NR_CPUS  1
 #define num_online_cpus()  cpumask_weight(cpu_online_mask)
-#define num_possible_cpus()cpumask_weight(cpu_possible_mask)
+/*
+ * For platforms with discontig CPU numbering, the weight of the possible
+ * bitmask may be less than the highest numbered CPU. Return the max of
+ * the two, to prevent accidentical bugs.
+ */
+#define num_possible_cpus()\
+   max_t(unsigned int, cpumask_weight(cpu_possible_mask), nr_cpu_ids)
 #define num_present_cpus() cpumask_weight(cpu_present_mask)
 #define num_active_cpus()  cpumask_weight(cpu_active_mask)
 #define cpu_online(cpu)cpumask_test_cpu((cpu), cpu_online_mask)



Full dmesg:

[0.00] PROMLIB: Sun IEEE Boot Prom 'OBP 3.2.29 2001/06/18 17:28'
[0.00] PROMLIB: Root node compatible: 
[0.00] Linux version 3.19.0-rc6-00105-gc59c961-dirty (mroos@mandel) 
(gcc version 4.9.2 (Debian 4.9.2-1) ) #31 SMP Wed Jan 28 16:40:28 EET 2015
[0.00] debug: ignoring loglevel setting.
[0.00] bootconsole [earlyprom0] enabled
[0.00] ARCH: SUN4U
[0.00] Ethernet address: 00:03:ba:12:70:5c
[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: /central@1f,0/fhc@0,f880/zs@0,902000:a
[0.00] PROM: Built device tree with 95892 bytes of memory.
[0.00] Top of RAM: 0xffd16000, Total RAM: 0xff954000
[0.00] Memory hole size: 3MB
[0.00] Allocated 16384 bytes for kernel page tables.
[0.00] Zone ranges:
[0.00]   Normal   [mem 0x-0xffd15fff]
[0.00] Movable zone start for each node
[0.00] Early memory node ranges
[0.00]   node   0: [mem 0x-0xff84dfff]
[0.00]   node   0: [mem 0xffc0-0xffce]
[0.00]   node   0: [mem 0xffd0-0xffd15fff]
[0.00] Initmem setup node 0 [mem 0x-0xffd15fff]
[0.00] On node 0 totalpages: 523434
[0.00]   Normal zone: 4094 pages used for memmap
[0.00]   Normal zone: 0 pages reserved
[0.00]   Normal zone: 523434 pages, LIFO batch:15
[0.00] Booting Linux...
[0.00] CPU CAPS: [flush,stbar,swap,muldiv,v9,mul32,div32,v8plus]
[0.00] CPU CAPS: [vis]
[0.00] PERCPU: Embedded 7 pages/cpu @f800ff40 s13888 r8192 
d35264 u1048576
[0.00] pcpu-alloc: s13888 r8192 d35264 u1048576 alloc=1*4194304
[0.00] pcpu-alloc: [0] 10 11 14 15 
[0.00] Built 1 zonelists in Zone order, mobility grouping on.  Total 
pages: 519340
[0.00] Kernel command line: root=/dev/sda2 ro ignore_loglevel
[0.00] PID hash table entries: 4096 (order: 2, 32768 bytes)
[0.00] Dentry cache hash table entries: 524288 (order: 9, 4194304 bytes)
[0.00] Inode-cache hash table entries: 262144 (order: 8, 2097152 bytes)
[0.00] Sorting __ex_table...
[0.00] Memory: 4142456K/4187472K available (3684K kernel code, 242K 
rwdata, 808K rodata, 184K init, 413K bss, 45016K reserved, 0K cma-reserved)
[0.00] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=16, Nodes=1
[0.00] Hierarchical RCU implementation.
[0.00]  Additional per-CPU info printed with stalls.
[0.00] NR_IRQS:2048 nr_irqs:2048 1
[  138.460070] clocksource: mult[2042108] shift[23]
[  138.514676] clockevent: mult[3f7ced91] shift[32]
[  138.570180] Console: colour dummy device 80x25
[  138.623106] console [tty0] enabled
[  138.663685] bootconsole [earlyprom0] disabled
[  138.865946] Calibrating delay using timer specific routine.. 497.37 BogoMIPS 
(lpj=2486892)
[  138.866023] pid_max: default: 32768 minimum: 301
[  138.866453] Mount-cache hash table entries: 8192 (order: 3, 65536 bytes)
[  138.866515] Mountpoint-cache hash table entries: 8192 (order: 3, 65536 bytes)
[  138.877710] CPU 11: synchronized TICK with master CPU (last diff -1 cycles, 
maxerr 517 cycles)
[  138.882148] CPU 14: synchronized TICK with master CPU (last diff -4 cycles, 
maxerr 529 cycles)
[  138.886557] CPU 15: synchronized TICK with master CPU (last diff -4 cycles, 
maxerr 529 cycles)
[  138.886777] Brought up 4 CPUs
[  138.888914] devtmpfs: initialized
[  138.963355] device-tree: 

Re: [PATCH 1/1] [PATCH REGRESSION] alua: fix bus detach oops

2015-01-29 Thread Hannes Reinecke
On 01/28/2015 10:46 AM, micha...@cs.wisc.edu wrote:
 From: Mike Christie micha...@cs.wisc.edu
 
 This fixes a regression caused by commit
 1d5203284d8acbdfdf9b478d434450b34f338f28
 
 The bug is that the alua detach() callout will try to access the
 sddev-scsi_dh_data, but we have already set it to NULL. This patch
 moves the clearing of that field to after detach() is called.
 
 It looks like the regression was added during 3.19 development,
 so it has not been in a released kernel, and so I did not cc
 stable.
 
 Signed-off-by: Mike Christie micha...@cs.wisc.edu
 
 ---
  drivers/scsi/device_handler/scsi_dh.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
 
 diff --git a/drivers/scsi/device_handler/scsi_dh.c 
 b/drivers/scsi/device_handler/scsi_dh.c
 index 1dba62c..1efebc9 100644
 --- a/drivers/scsi/device_handler/scsi_dh.c
 +++ b/drivers/scsi/device_handler/scsi_dh.c
 @@ -136,11 +136,12 @@ static void __detach_handler (struct kref *kref)
   struct scsi_device_handler *scsi_dh = scsi_dh_data-scsi_dh;
   struct scsi_device *sdev = scsi_dh_data-sdev;
  
 + scsi_dh-detach(sdev);
 +
   spin_lock_irq(sdev-request_queue-queue_lock);
   sdev-scsi_dh_data = NULL;
   spin_unlock_irq(sdev-request_queue-queue_lock);
  
 - scsi_dh-detach(sdev);
   sdev_printk(KERN_NOTICE, sdev, %s: Detached\n, scsi_dh-name);
   module_put(scsi_dh-module);
  }
 
Errm.

We save the contents first:

   struct scsi_device_handler *scsi_dh = scsi_dh_data-scsi_dh;

Then set the pointer to NULL:

   sdev-scsi_dh_data = NULL;

and then call 'detach':

   scsi_dh-detach(sdev);

So scsi_dh is _not_ NULL, hence it shouldn't oops.

NACK.

Cheers,

Hannes
-- 
Dr. Hannes ReineckezSeries  Storage
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (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


raid1 narrow_write_error with 4K disks, sd bad block number requested messages

2015-01-29 Thread Nate Dailey
I'm writing about something that appears to be an issue with raid1's 
narrow_write_error, particular to non-512-byte-sector disks. Here's what 
I'm doing:


- 2 disk raid1, 4K disks, each connected to a different SAS HBA
- mount a filesystem on the raid1, run a test that writes to it
- remove one of the SAS HBAs (echo 1  
/sys/bus/pci/devices/\:45\:00.0/remove)


At this point, writes fail and narrow_write_error breaks them up and 
retries, one sector at a time. But these are 512-byte sectors, and sd 
doesn't like it:


[ 2645.310517] sd 3:0:1:0: [sde] Bad block number requested
[ 2645.310610] sd 3:0:1:0: [sde] Bad block number requested
[ 2645.310690] sd 3:0:1:0: [sde] Bad block number requested
...

There appears to be no real harm done, but there can be a huge number of 
these messages in the log.


I can avoid this by disabling bad block tracking, but it looks like 
maybe the superblock's bblog_shift is intended to address this exact 
issue. However, I don't see a way to change it. Presumably this is 
something mdadm should be setting up? I don't see bblog_shift ever set 
to anything other than 0.


This is on a RHEL 7.1 kernel, version 3.10.0-221.el7. I took a look at 
upstream sd and md changes and nothing jumps out at me that would have 
affected this (but I have not tested to see if the bad block messages do 
or do not happen on an upstream kernel).


I'd appreciate any advice re: how to handle this. Thanks!

Nate Dailey
Stratus Technologies

--
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 1/1] [PATCH REGRESSION] alua: fix bus detach oops

2015-01-29 Thread Mike Christie
On 01/29/2015 02:45 AM, Hannes Reinecke wrote:
 On 01/28/2015 10:46 AM, micha...@cs.wisc.edu wrote:
 From: Mike Christie micha...@cs.wisc.edu

 This fixes a regression caused by commit
 1d5203284d8acbdfdf9b478d434450b34f338f28

 The bug is that the alua detach() callout will try to access the
 sddev-scsi_dh_data, but we have already set it to NULL. This patch
 moves the clearing of that field to after detach() is called.

 It looks like the regression was added during 3.19 development,
 so it has not been in a released kernel, and so I did not cc
 stable.

 Signed-off-by: Mike Christie micha...@cs.wisc.edu

 ---
  drivers/scsi/device_handler/scsi_dh.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

 diff --git a/drivers/scsi/device_handler/scsi_dh.c 
 b/drivers/scsi/device_handler/scsi_dh.c
 index 1dba62c..1efebc9 100644
 --- a/drivers/scsi/device_handler/scsi_dh.c
 +++ b/drivers/scsi/device_handler/scsi_dh.c
 @@ -136,11 +136,12 @@ static void __detach_handler (struct kref *kref)
  struct scsi_device_handler *scsi_dh = scsi_dh_data-scsi_dh;
  struct scsi_device *sdev = scsi_dh_data-sdev;
  
 +scsi_dh-detach(sdev);
 +
  spin_lock_irq(sdev-request_queue-queue_lock);
  sdev-scsi_dh_data = NULL;
  spin_unlock_irq(sdev-request_queue-queue_lock);
  
 -scsi_dh-detach(sdev);
  sdev_printk(KERN_NOTICE, sdev, %s: Detached\n, scsi_dh-name);
  module_put(scsi_dh-module);
  }

 Errm.
 
 We save the contents first:
 
  struct scsi_device_handler *scsi_dh = scsi_dh_data-scsi_dh;
 
 Then set the pointer to NULL:
 
  sdev-scsi_dh_data = NULL;
 
 and then call 'detach':
 
  scsi_dh-detach(sdev);
 
 So scsi_dh is _not_ NULL, hence it shouldn't oops.
 

The problem is the actual detach() functions are the ones that are
accessing the NULL'd scsi_dh_data-scsi_dh pointer.

So above we have set sdev-scsi_dh_data to NULL and then are calling
detach(). In scsi_dh_alua.c, get_alua_data() we will then access the
NULL'd pointer.

static void alua_bus_detach(struct scsi_device *sdev)
{
struct alua_dh_data *h = get_alua_data(sdev);

if (h-buff  h-inq != h-buff)
kfree(h-buff);
kfree(h);

--
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 1/1] [PATCH REGRESSION] alua: fix bus detach oops

2015-01-29 Thread Christoph Hellwig
On Thu, Jan 29, 2015 at 09:45:24AM +0100, Hannes Reinecke wrote:
 Errm.
 
 We save the contents first:
 
  struct scsi_device_handler *scsi_dh = scsi_dh_data-scsi_dh;
 
 Then set the pointer to NULL:
 
  sdev-scsi_dh_data = NULL;
 
 and then call 'detach':
 
  scsi_dh-detach(sdev);
 
 So scsi_dh is _not_ NULL, hence it shouldn't oops.

The actual -detach method can, and usually does access it.
--
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 v2 0/6] scsi: Some seq_file cleanups/optimizations

2015-01-29 Thread Rasmus Villemoes
On Thu, Jan 29 2015, Finn Thain fth...@telegraphics.com.au wrote:

 I have one reservation about this patch series.

 For example, the changes,

 - seq_printf(m, %s, p);
 + seq_puts(m, p);

 These calls are not equivalent because the bounds check is not the same. 
 seq_puts will fail when m-count + strlen(p) == m-size.


So will seq_printf:

int seq_vprintf(struct seq_file *m, const char *f, va_list args)
{
int len;

if (m-count  m-size) {
len = vsnprintf(m-buf + m-count, m-size - m-count, f, args);
if (m-count + len  m-size) {
m-count += len;
return 0;
}
}
seq_set_overflow(m);
return -1;
}

The return value from vsnprintf(%s, p) is by definition the length of
the string p. Yes, vsnprintf may write some of the bytes from the
string to the buffer, but those are effectively discarded if they don't
all fit, since m-count is not updated.

 There's a similar situation with the changes,

 - seq_puts(m, x);
 + seq_putc(m, 'x');

It's true that this may cause 'x' to be printed which it might not have
been before. I think this is a bug in seq_puts - it should use = for
its bounds check. OTOH, seq_printf probably needs to continue using ,
because if the return value is == m-size-m-count, vsnprintf will have
truncated the output, overwriting the last byte with a '\0'.

 Have you considered what the implications might be? Are there any?

I must admit I hadn't thought that deeply about it before, but now it
seems that my patches can only end up utilizing m-buf a bit better
(well, 8 bits, to be precise). If I understand the whole seq_*
interface, overflow will just cause a larger buffer to be allocated and
all the print functions to be called again.

Steven, you've been doing some cleanup in this area, among other things
trying to make all the seq_* functions return void. Could you fill me in
on the status of that?

Rasmus
--
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/4] Update driver version to 3.2.25.0

2015-01-29 Thread anil.gurumurthy
From: Anil Gurumurthy anil.gurumur...@qlogic.com

Signed-off-by: Sudarsana Kalluru sudarsana.kall...@qlogic.com
Signed-off-by: Anil Gurumurthy anil.gurumur...@qlogic.com
---
 drivers/scsi/bfa/bfad_drv.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/bfa/bfad_drv.h b/drivers/scsi/bfa/bfad_drv.h
index 8001459..f9e8620 100644
--- a/drivers/scsi/bfa/bfad_drv.h
+++ b/drivers/scsi/bfa/bfad_drv.h
@@ -58,7 +58,7 @@
 #ifdef BFA_DRIVER_VERSION
 #define BFAD_DRIVER_VERSIONBFA_DRIVER_VERSION
 #else
-#define BFAD_DRIVER_VERSION3.2.23.0
+#define BFAD_DRIVER_VERSION3.2.25.0
 #endif
 
 #define BFAD_PROTO_NAME FCPI_NAME
-- 
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/4] File header and user visible string changes

2015-01-29 Thread anil.gurumurthy
From: Anil Gurumurthy anil.gurumur...@qlogic.com

Signed-off-by: Sudarsana Kalluru sudarsana.kall...@qlogic.com
Signed-off-by: Anil Gurumurthy anil.gurumur...@qlogic.com
---
 drivers/scsi/bfa/bfa.h   |2 +-
 drivers/scsi/bfa/bfa_core.c  |2 +-
 drivers/scsi/bfa/bfa_cs.h|2 +-
 drivers/scsi/bfa/bfa_defs.h  |2 +-
 drivers/scsi/bfa/bfa_defs_fcs.h  |2 +-
 drivers/scsi/bfa/bfa_defs_svc.h  |2 +-
 drivers/scsi/bfa/bfa_fc.h|2 +-
 drivers/scsi/bfa/bfa_fcbuild.c   |2 +-
 drivers/scsi/bfa/bfa_fcbuild.h   |2 +-
 drivers/scsi/bfa/bfa_fcpim.c |2 +-
 drivers/scsi/bfa/bfa_fcpim.h |2 +-
 drivers/scsi/bfa/bfa_fcs.c   |2 +-
 drivers/scsi/bfa/bfa_fcs.h   |4 +-
 drivers/scsi/bfa/bfa_fcs_fcpim.c |2 +-
 drivers/scsi/bfa/bfa_fcs_lport.c |2 +-
 drivers/scsi/bfa/bfa_fcs_rport.c |2 +-
 drivers/scsi/bfa/bfa_hw_cb.c |2 +-
 drivers/scsi/bfa/bfa_hw_ct.c |2 +-
 drivers/scsi/bfa/bfa_ioc.c   |4 +-
 drivers/scsi/bfa/bfa_ioc.h   |2 +-
 drivers/scsi/bfa/bfa_ioc_cb.c|2 +-
 drivers/scsi/bfa/bfa_ioc_ct.c|2 +-
 drivers/scsi/bfa/bfa_modules.h   |2 +-
 drivers/scsi/bfa/bfa_plog.h  |2 +-
 drivers/scsi/bfa/bfa_port.c  |2 +-
 drivers/scsi/bfa/bfa_port.h  |2 +-
 drivers/scsi/bfa/bfa_svc.c   |2 +-
 drivers/scsi/bfa/bfa_svc.h   |2 +-
 drivers/scsi/bfa/bfad.c  |   19 --
 drivers/scsi/bfa/bfad_attr.c |   70 +++---
 drivers/scsi/bfa/bfad_bsg.c  |2 +-
 drivers/scsi/bfa/bfad_bsg.h  |2 +-
 drivers/scsi/bfa/bfad_debugfs.c  |2 +-
 drivers/scsi/bfa/bfad_drv.h  |2 +-
 drivers/scsi/bfa/bfad_im.c   |4 +-
 drivers/scsi/bfa/bfad_im.h   |2 +-
 drivers/scsi/bfa/bfi.h   |2 +-
 drivers/scsi/bfa/bfi_ms.h|2 +-
 drivers/scsi/bfa/bfi_reg.h   |4 +-
 39 files changed, 83 insertions(+), 88 deletions(-)

diff --git a/drivers/scsi/bfa/bfa.h b/drivers/scsi/bfa/bfa.h
index 7d0337b..0e119d8 100644
--- a/drivers/scsi/bfa/bfa.h
+++ b/drivers/scsi/bfa/bfa.h
@@ -4,7 +4,7 @@
  * All rights reserved
  * www.qlogic.com
  *
- * Linux driver for Brocade Fibre Channel Host Bus Adapter.
+ * Linux driver for QLogic BR-series Fibre Channel Host Bus Adapter.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License (GPL) Version 2 as
diff --git a/drivers/scsi/bfa/bfa_core.c b/drivers/scsi/bfa/bfa_core.c
index f157a37..2ea0db4 100644
--- a/drivers/scsi/bfa/bfa_core.c
+++ b/drivers/scsi/bfa/bfa_core.c
@@ -4,7 +4,7 @@
  * All rights reserved
  * www.qlogic.com
  *
- * Linux driver for Brocade Fibre Channel Host Bus Adapter.
+ * Linux driver for QLogic BR-series Fibre Channel Host Bus Adapter.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License (GPL) Version 2 as
diff --git a/drivers/scsi/bfa/bfa_cs.h b/drivers/scsi/bfa/bfa_cs.h
index c8bb20a..da9cf65 100644
--- a/drivers/scsi/bfa/bfa_cs.h
+++ b/drivers/scsi/bfa/bfa_cs.h
@@ -4,7 +4,7 @@
  * All rights reserved
  * www.qlogic.com
  *
- * Linux driver for Brocade Fibre Channel Host Bus Adapter.
+ * Linux driver for QLogic BR-series Fibre Channel Host Bus Adapter.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License (GPL) Version 2 as
diff --git a/drivers/scsi/bfa/bfa_defs.h b/drivers/scsi/bfa/bfa_defs.h
index da4f705..5dc3782 100644
--- a/drivers/scsi/bfa/bfa_defs.h
+++ b/drivers/scsi/bfa/bfa_defs.h
@@ -4,7 +4,7 @@
  * All rights reserved
  * www.qlogic.com
  *
- * Linux driver for Brocade Fibre Channel Host Bus Adapter.
+ * Linux driver for QLogic BR-series Fibre Channel Host Bus Adapter.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License (GPL) Version 2 as
diff --git a/drivers/scsi/bfa/bfa_defs_fcs.h b/drivers/scsi/bfa/bfa_defs_fcs.h
index 5185ae3..5815a90 100644
--- a/drivers/scsi/bfa/bfa_defs_fcs.h
+++ b/drivers/scsi/bfa/bfa_defs_fcs.h
@@ -4,7 +4,7 @@
  * All rights reserved
  * www.qlogic.com
  *
- * Linux driver for Brocade Fibre Channel Host Bus Adapter.
+ * Linux driver for QLogic BR-series Fibre Channel Host Bus Adapter.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License (GPL) Version 2 as
diff --git a/drivers/scsi/bfa/bfa_defs_svc.h b/drivers/scsi/bfa/bfa_defs_svc.h
index fd2fa24..e81707f 100644
--- a/drivers/scsi/bfa/bfa_defs_svc.h
+++ b/drivers/scsi/bfa/bfa_defs_svc.h
@@ -4,7 +4,7 @@
  * All rights reserved
  * www.qlogic.com
  *
- * Linux driver for Brocade Fibre Channel Host Bus Adapter.
+ * Linux driver for QLogic BR-series Fibre Channel Host Bus Adapter.
  *
  * This program is free software; you can redistribute it 

[PATCH 1/4] Updating copyright messages

2015-01-29 Thread anil.gurumurthy
From: Anil Gurumurthy anil.gurumur...@qlogic.com

Signed-off-by: Sudarsana Kalluru sudarsana.kall...@qlogic.com
Signed-off-by: Anil Gurumurthy anil.gurumur...@qlogic.com
---
 drivers/scsi/bfa/bfa.h   |5 +++--
 drivers/scsi/bfa/bfa_core.c  |5 +++--
 drivers/scsi/bfa/bfa_cs.h|5 +++--
 drivers/scsi/bfa/bfa_defs.h  |5 +++--
 drivers/scsi/bfa/bfa_defs_fcs.h  |5 +++--
 drivers/scsi/bfa/bfa_defs_svc.h  |5 +++--
 drivers/scsi/bfa/bfa_fc.h|5 +++--
 drivers/scsi/bfa/bfa_fcbuild.c   |5 +++--
 drivers/scsi/bfa/bfa_fcbuild.h   |5 +++--
 drivers/scsi/bfa/bfa_fcpim.c |5 +++--
 drivers/scsi/bfa/bfa_fcpim.h |5 +++--
 drivers/scsi/bfa/bfa_fcs.c   |5 +++--
 drivers/scsi/bfa/bfa_fcs.h   |5 +++--
 drivers/scsi/bfa/bfa_fcs_fcpim.c |5 +++--
 drivers/scsi/bfa/bfa_fcs_lport.c |5 +++--
 drivers/scsi/bfa/bfa_fcs_rport.c |5 +++--
 drivers/scsi/bfa/bfa_hw_cb.c |5 +++--
 drivers/scsi/bfa/bfa_hw_ct.c |5 +++--
 drivers/scsi/bfa/bfa_ioc.c   |5 +++--
 drivers/scsi/bfa/bfa_ioc.h   |5 +++--
 drivers/scsi/bfa/bfa_ioc_cb.c|5 +++--
 drivers/scsi/bfa/bfa_ioc_ct.c|5 +++--
 drivers/scsi/bfa/bfa_modules.h   |5 +++--
 drivers/scsi/bfa/bfa_plog.h  |5 +++--
 drivers/scsi/bfa/bfa_port.c  |5 +++--
 drivers/scsi/bfa/bfa_port.h  |5 +++--
 drivers/scsi/bfa/bfa_svc.c   |5 +++--
 drivers/scsi/bfa/bfa_svc.h   |5 +++--
 drivers/scsi/bfa/bfad.c  |5 +++--
 drivers/scsi/bfa/bfad_attr.c |5 +++--
 drivers/scsi/bfa/bfad_bsg.c  |5 +++--
 drivers/scsi/bfa/bfad_bsg.h  |5 +++--
 drivers/scsi/bfa/bfad_debugfs.c  |5 +++--
 drivers/scsi/bfa/bfad_drv.h  |5 +++--
 drivers/scsi/bfa/bfad_im.c   |5 +++--
 drivers/scsi/bfa/bfad_im.h   |5 +++--
 drivers/scsi/bfa/bfi.h   |5 +++--
 drivers/scsi/bfa/bfi_ms.h|5 +++--
 drivers/scsi/bfa/bfi_reg.h   |5 +++--
 39 files changed, 117 insertions(+), 78 deletions(-)

diff --git a/drivers/scsi/bfa/bfa.h b/drivers/scsi/bfa/bfa.h
index 4ad7e36..7d0337b 100644
--- a/drivers/scsi/bfa/bfa.h
+++ b/drivers/scsi/bfa/bfa.h
@@ -1,7 +1,8 @@
 /*
- * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
+ * Copyright (c) 2005-2014 Brocade Communications Systems, Inc.
+ * Copyright (c) 2014- QLogic Corporation.
  * All rights reserved
- * www.brocade.com
+ * www.qlogic.com
  *
  * Linux driver for Brocade Fibre Channel Host Bus Adapter.
  *
diff --git a/drivers/scsi/bfa/bfa_core.c b/drivers/scsi/bfa/bfa_core.c
index e3f67b0..f157a37 100644
--- a/drivers/scsi/bfa/bfa_core.c
+++ b/drivers/scsi/bfa/bfa_core.c
@@ -1,7 +1,8 @@
 /*
- * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
+ * Copyright (c) 2005-2014 Brocade Communications Systems, Inc.
+ * Copyright (c) 2014- QLogic Corporation.
  * All rights reserved
- * www.brocade.com
+ * www.qlogic.com
  *
  * Linux driver for Brocade Fibre Channel Host Bus Adapter.
  *
diff --git a/drivers/scsi/bfa/bfa_cs.h b/drivers/scsi/bfa/bfa_cs.h
index 91a8aa3..c8bb20a 100644
--- a/drivers/scsi/bfa/bfa_cs.h
+++ b/drivers/scsi/bfa/bfa_cs.h
@@ -1,7 +1,8 @@
 /*
- * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
+ * Copyright (c) 2005-2014 Brocade Communications Systems, Inc.
+ * Copyright (c) 2014- QLogic Corporation.
  * All rights reserved
- * www.brocade.com
+ * www.qlogic.com
  *
  * Linux driver for Brocade Fibre Channel Host Bus Adapter.
  *
diff --git a/drivers/scsi/bfa/bfa_defs.h b/drivers/scsi/bfa/bfa_defs.h
index 877b86d..da4f705 100644
--- a/drivers/scsi/bfa/bfa_defs.h
+++ b/drivers/scsi/bfa/bfa_defs.h
@@ -1,7 +1,8 @@
 /*
- * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
+ * Copyright (c) 2005-2014 Brocade Communications Systems, Inc.
+ * Copyright (c) 2014- QLogic Corporation.
  * All rights reserved
- * www.brocade.com
+ * www.qlogic.com
  *
  * Linux driver for Brocade Fibre Channel Host Bus Adapter.
  *
diff --git a/drivers/scsi/bfa/bfa_defs_fcs.h b/drivers/scsi/bfa/bfa_defs_fcs.h
index 06f0a16..5185ae3 100644
--- a/drivers/scsi/bfa/bfa_defs_fcs.h
+++ b/drivers/scsi/bfa/bfa_defs_fcs.h
@@ -1,7 +1,8 @@
 /*
- * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
+ * Copyright (c) 2005-2014 Brocade Communications Systems, Inc.
+ * Copyright (c) 2014- QLogic Corporation.
  * All rights reserved
- * www.brocade.com
+ * www.qlogic.com
  *
  * Linux driver for Brocade Fibre Channel Host Bus Adapter.
  *
diff --git a/drivers/scsi/bfa/bfa_defs_svc.h b/drivers/scsi/bfa/bfa_defs_svc.h
index 638f441..fd2fa24 100644
--- a/drivers/scsi/bfa/bfa_defs_svc.h
+++ b/drivers/scsi/bfa/bfa_defs_svc.h
@@ -1,7 +1,8 @@
 /*
- * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
+ * Copyright (c) 2005-2014 Brocade Communications Systems, Inc.
+ * Copyright (c) 2014- QLogic Corporation.
  * All rights reserved
- * www.brocade.com
+ * www.qlogic.com
  *
  * Linux driver for 

[PATCH 0/4] bfa: Patches for scsi misc branch

2015-01-29 Thread anil.gurumurthy
Hi James, Christoph,

Please apply the following patches to the scsi tree, misc branch  at your
earliest convenience.

Thanks,
Anil

Anil Gurumurthy (4):
  Updating copyright messages
  Fix for crash when bfa_itnim is NULL
  File header and user visible string changes
  Update driver version to 3.2.25.0

 drivers/scsi/bfa/bfa.h   |7 ++--
 drivers/scsi/bfa/bfa_core.c  |7 ++--
 drivers/scsi/bfa/bfa_cs.h|7 ++--
 drivers/scsi/bfa/bfa_defs.h  |7 ++--
 drivers/scsi/bfa/bfa_defs_fcs.h  |7 ++--
 drivers/scsi/bfa/bfa_defs_svc.h  |7 ++--
 drivers/scsi/bfa/bfa_fc.h|7 ++--
 drivers/scsi/bfa/bfa_fcbuild.c   |7 ++--
 drivers/scsi/bfa/bfa_fcbuild.h   |7 ++--
 drivers/scsi/bfa/bfa_fcpim.c |7 ++--
 drivers/scsi/bfa/bfa_fcpim.h |7 ++--
 drivers/scsi/bfa/bfa_fcs.c   |7 ++--
 drivers/scsi/bfa/bfa_fcs.h   |9 +++--
 drivers/scsi/bfa/bfa_fcs_fcpim.c |7 ++--
 drivers/scsi/bfa/bfa_fcs_lport.c |9 +++--
 drivers/scsi/bfa/bfa_fcs_rport.c |7 ++--
 drivers/scsi/bfa/bfa_hw_cb.c |7 ++--
 drivers/scsi/bfa/bfa_hw_ct.c |7 ++--
 drivers/scsi/bfa/bfa_ioc.c   |9 +++--
 drivers/scsi/bfa/bfa_ioc.h   |7 ++--
 drivers/scsi/bfa/bfa_ioc_cb.c|7 ++--
 drivers/scsi/bfa/bfa_ioc_ct.c|7 ++--
 drivers/scsi/bfa/bfa_modules.h   |7 ++--
 drivers/scsi/bfa/bfa_plog.h  |7 ++--
 drivers/scsi/bfa/bfa_port.c  |7 ++--
 drivers/scsi/bfa/bfa_port.h  |7 ++--
 drivers/scsi/bfa/bfa_svc.c   |7 ++--
 drivers/scsi/bfa/bfa_svc.h   |7 ++--
 drivers/scsi/bfa/bfad.c  |   24 +---
 drivers/scsi/bfa/bfad_attr.c |   75 +++---
 drivers/scsi/bfa/bfad_bsg.c  |7 ++--
 drivers/scsi/bfa/bfad_bsg.h  |7 ++--
 drivers/scsi/bfa/bfad_debugfs.c  |7 ++--
 drivers/scsi/bfa/bfad_drv.h  |9 +++--
 drivers/scsi/bfa/bfad_im.c   |   35 --
 drivers/scsi/bfa/bfad_im.h   |7 ++--
 drivers/scsi/bfa/bfi.h   |7 ++--
 drivers/scsi/bfa/bfi_ms.h|7 ++--
 drivers/scsi/bfa/bfi_reg.h   |9 +++--
 39 files changed, 228 insertions(+), 168 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


[PATCH 2/4] Fix for crash when bfa_itnim is NULL

2015-01-29 Thread anil.gurumurthy
From: Anil Gurumurthy anil.gurumur...@qlogic.com

Signed-off-by: Sudarsana Kalluru sudarsana.kall...@qlogic.com
Signed-off-by: Anil Gurumurthy anil.gurumur...@qlogic.com
---
 drivers/scsi/bfa/bfa_fcs_lport.c |2 +-
 drivers/scsi/bfa/bfad_im.c   |   26 ++
 2 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/bfa/bfa_fcs_lport.c b/drivers/scsi/bfa/bfa_fcs_lport.c
index d823792..4631630 100644
--- a/drivers/scsi/bfa/bfa_fcs_lport.c
+++ b/drivers/scsi/bfa/bfa_fcs_lport.c
@@ -2654,7 +2654,7 @@ bfa_fcs_fdmi_get_hbaattr(struct bfa_fcs_lport_fdmi_s 
*fdmi,
 
strncpy(hba_attr-node_sym_name.symname,
port-port_cfg.node_sym_name.symname, BFA_SYMNAME_MAXLEN);
-   strcpy(hba_attr-vendor_info, BROCADE);
+   strcpy(hba_attr-vendor_info, QLogic);
hba_attr-num_ports =
cpu_to_be32(bfa_ioc_get_nports(port-fcs-bfa-ioc));
hba_attr-fabric_name = port-fabric-lps-pr_nwwn;
diff --git a/drivers/scsi/bfa/bfad_im.c b/drivers/scsi/bfa/bfad_im.c
index 575efdc..3e4dce7 100644
--- a/drivers/scsi/bfa/bfad_im.c
+++ b/drivers/scsi/bfa/bfad_im.c
@@ -272,6 +272,19 @@ bfad_im_target_reset_send(struct bfad_s *bfad, struct 
scsi_cmnd *cmnd,
cmnd-host_scribble = NULL;
cmnd-SCp.Status = 0;
bfa_itnim = bfa_fcs_itnim_get_halitn(itnim-fcs_itnim);
+   /*
+* bfa_itnim can be NULL if the port gets disconnected and the bfa
+* and fcs layers have cleaned up their nexus with the targets and
+* the same has not been cleaned up by the shim
+*/
+   if (bfa_itnim == NULL) {
+   bfa_tskim_free(tskim);
+   BFA_LOG(KERN_ERR, bfad, bfa_log_level,
+   target reset, bfa_itnim is NULL\n);
+   rc = BFA_STATUS_FAILED;
+   goto out;
+   }
+
memset(scsilun, 0, sizeof(scsilun));
bfa_tskim_start(tskim, bfa_itnim, scsilun,
FCP_TM_TARGET_RESET, BFAD_TARGET_RESET_TMO);
@@ -327,6 +340,19 @@ bfad_im_reset_lun_handler(struct scsi_cmnd *cmnd)
cmnd-SCp.ptr = (char *)wq;
cmnd-SCp.Status = 0;
bfa_itnim = bfa_fcs_itnim_get_halitn(itnim-fcs_itnim);
+   /*
+* bfa_itnim can be NULL if the port gets disconnected and the bfa
+* and fcs layers have cleaned up their nexus with the targets and
+* the same has not been cleaned up by the shim
+*/
+   if (bfa_itnim == NULL) {
+   bfa_tskim_free(tskim);
+   BFA_LOG(KERN_ERR, bfad, bfa_log_level,
+   lun reset, bfa_itnim is NULL\n);
+   spin_unlock_irqrestore(bfad-bfad_lock, flags);
+   rc = FAILED;
+   goto out;
+   }
int_to_scsilun(cmnd-device-lun, scsilun);
bfa_tskim_start(tskim, bfa_itnim, scsilun,
FCP_TM_LUN_RESET, BFAD_LUN_RESET_TMO);
-- 
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: Another (ESP?) scsi blk-mq problem on sparc64

2015-01-29 Thread Meelis Roos
On Mon, 24 Nov 2014, David Miller wrote:

 From: mr...@linux.ee
 Date: Tue, 25 Nov 2014 00:23:20 +0200 (EET)
 
 Yes, that does look like the case.  Do you have a good trick on how
 to allocate a map for the highest possible cpu number without first
 iterating the cpu map?  I couldn't find something that looks like a
 highest_possible_cpu() helper.
   
Honestly I think that num_posible_cpus() should return the max of
number of CPUs (weigt), and the highest numbered CPU. It's a pain in
the butt to handle this otherwise.
  
   Hear, hear!!!  That would make my life easier, and would make this sort
   of problem much less likely to occur!
  
  How about this one?
  
  It make the machine work.
 
 Thanks for testing!
 

What's the status of this fix? It is still not applied on yesterdays 
3.19.0-rc6-00105-gc59c961 git...

-- 
Meelis Roos (mr...@linux.ee)
--
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: module: fix module_refcount() return when running in a module exit routine

2015-01-29 Thread Bart Van Assche
On 01/28/15 22:45, James Bottomley wrote:
 On Wed, 2015-01-28 at 10:23 +0100, Bart Van Assche wrote:
 Is this the latest version of this patch that is available ? I have
 tried to test the above patch. However, I couldn't test the impact of
 this patch on the SRP initiator driver since my test system didn't boot
 anymore with the above patch applied. That test system boots from an ATA
 disk managed by the SCSI subsystem:
 $ lsscsi | head -n1
 [0:0:0:0]diskATA  KINGSTON SH103S3 BBF0  /dev/sda
 
 Not yet, since I knew it would need a bit of testing to identify all the
 potential in_exit acquisitions.  However, you could help me by
 diagnosing the current failure.

Hello James,

I have done the following:
- Read over your patch but didn't spot anything obvious.
- Added printk() statements in the modified functions in an attempt to
  determine where in the boot process the hang occurs. Apparently none
  of the functions touched by this patch got called before the hang
  occurred.
- Uploaded a screenshot of the boot messages
(https://drive.google.com/file/d/0B1YQOreL3_FxN1pPMnZrSDdLYTQ/view?usp=sharing).
The most remarkable message is SATA link down. This message does not
appear when booting e.g. kernel version v3.16.
- Left the system alone for a few minutes after the boot process
  stopped making progress. The message boot drive not found appeared.

So this is probably an issue in another component than the SCSI
subsystem. What's not clear to me is why every time I tried to boot
without this patch that booting succeeded and every time I tried to boot
with this patch applied that booting did not succeed ... I have not yet
had the time to run a bisect.

Note: the tests I ran today were performed with kernel v3.19-rc6 with
patch https://lkml.org/lkml/2015/1/28/334 applied. However, that last
patch shouldn't have any impact on the boot process since
CONFIG_SCSI_MQ_DEFAULT was not set.

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] IB/srp: Process REQ_PREEMPT requests correctly

2015-01-29 Thread Sagi Grimberg

On 1/29/2015 3:02 PM, Bart Van Assche wrote:

Delay REQ_PREEMPT requests submitted against a blocked device
until the device is unblocked by returning SCSI_MLQUEUE_HOST_BUSY
to the SCSI mid-layer. This avoids that a rescan shortly after a
cable pull sporadically triggers the following kernel oops:

BUG: unable to handle kernel paging request at c9001a6bc084
IP: [a04e08f2] mlx4_ib_post_send+0xd2/0xb30 [mlx4_ib]
Process rescan-scsi-bus (pid: 9241, threadinfo 88053484a000, task 
880534aae100)
Call Trace:
  [a0718135] srp_post_send+0x65/0x70 [ib_srp]
  [a071b9df] srp_queuecommand+0x1cf/0x3e0 [ib_srp]
  [a0001ff1] scsi_dispatch_cmd+0x101/0x280 [scsi_mod]
  [a0009ad1] scsi_request_fn+0x411/0x4d0 [scsi_mod]
  [81223b37] __blk_run_queue+0x27/0x30
  [8122a8d2] blk_execute_rq_nowait+0x82/0x110
  [8122a9c2] blk_execute_rq+0x62/0xf0
  [a000b0e8] scsi_execute+0xe8/0x190 [scsi_mod]
  [a000b2f3] scsi_execute_req+0xa3/0x130 [scsi_mod]
  [a000c1aa] scsi_probe_lun+0x17a/0x450 [scsi_mod]
  [a000ce86] scsi_probe_and_add_lun+0x156/0x480 [scsi_mod]
  [a000dc2f] __scsi_scan_target+0xdf/0x1f0 [scsi_mod]
  [a000dfa3] scsi_scan_host_selected+0x183/0x1c0 [scsi_mod]
  [a000edfb] scsi_scan+0xdb/0xe0 [scsi_mod]
  [a000ee13] store_scan+0x13/0x20 [scsi_mod]
  [811c8d9b] sysfs_write_file+0xcb/0x160
  [811589de] vfs_write+0xce/0x140
  [81158b53] sys_write+0x53/0xa0
  [81464592] system_call_fastpath+0x16/0x1b
  [7f611c9d9300] 0x7f611c9d92ff

Reported-by: Max Gurtuvoy m...@mellanox.com
Signed-off-by: Bart Van Assche bart.vanass...@sandisk.com
Cc: Sagi Grimberg sa...@mellanox.com
Cc: sta...@vger.kernel.org
---
  drivers/infiniband/ulp/srp/ib_srp.c | 7 ++-
  1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/ulp/srp/ib_srp.c 
b/drivers/infiniband/ulp/srp/ib_srp.c
index 0747c05..77a7a2f 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -2003,8 +2003,13 @@ static int srp_queuecommand(struct Scsi_Host *shost, 
struct scsi_cmnd *scmnd)
if (in_scsi_eh)
mutex_lock(rport-mutex);

+   /*
+* The blocked state of SCSI devices is ignored by the SCSI core for
+* REQ_PREEMPT requests. Hence the explicit check below for the SCSI
+* device state.
+*/
scmnd-result = srp_chkready(target-rport);
-   if (unlikely(scmnd-result))
+   if (unlikely(scmnd-result != 0 || scsi_device_blocked(scmnd-device)))
goto err;

WARN_ON_ONCE(scmnd-request-tag  0);




Yep...

Reviewed-by: Sagi Grimberg sa...@mellanox.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


Re: [PATCH] scsi, be2iscsi, LLVMLinux: Add missing MODULE_DEVICE_TABLE()

2015-01-29 Thread Arnd Bergmann
On Wednesday 28 January 2015 17:37:02 Behan Webster wrote:
 Missing MODULE_DEVICE_TABLE for pci ids from be2iscsi driver found by clang.
 
 Signed-off-by: Behan Webster beh...@converseincode.com
 Reviewed-by: Mark Charlebois charl...@gmail.com
 Suggested-by: Arnd Bergmann a...@arndb.de
 Cc: Arnd Bergmann a...@arndb.de
 ---

Like one previous patch, the change is good, the description is wrong.
This patch removes a duplicate MODULE_DEVICE_TABLE entry.

Arnd
--
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/17] Clear up bidi command confusion

2015-01-29 Thread Boaz Harrosh
On 01/23/2015 03:12 PM, Christoph Hellwig wrote:
 On Fri, Jan 23, 2015 at 01:05:30PM +0100, Bart Van Assche wrote:
 There is some confusion in the SCSI core and in SCSI LLDs around the
 meaning of sc_data_direction and whether or not this member can have the
 value DMA_BIDIRECTIONAL. Clear up this confusion. The patches in this
 series are:
 
 I wonder if we should change the code to set DMA_BIDIRECTIONAL for
 bidi commands.  That seems a lot more logical than the current
 version.
 

You cannot do this. Because a Bidi Command is actually two commands
one for the WRITE side (DMA_TO_DEVICE) which is this one, and another
command for the READ side (DMA_FROM_DEVICE).

The DMA_XXX_ enum must not to be confused with the t10-scsi Bidi commands.
In DMA world the enum means: What are the allowed access on the memory buffer,
is Device allowed to read-from-memory-only or write-to-memory-only or both
simultaneously on the same buffer.
It is a flag to the IO-mmu on the direction of its mappings.

A t10-scsi bidi command is two buffers. The command caries two distinct
buffers one is only-written-to 2nd only-read-from. But these are two distinct
buffers each his proper direction.

If you ask me you need to remove sc_data_direction all together and just
go directly to the READ/WRITE flag at request level. SCSI has no business
duplicating the same information in another member another way.

In any way t10-scsi has no use in the entire of its STD of the DMA_BIDIRECTIONAL
sense. ie. same buffer, two directional access. So DMA_BIDIRECTIONAL is just
dead code for sc_data_direction. It could be imagined but t10-scsi does not
have a use for it.

Again Not to be confused with one-command two buffers, which is exactly the 
opposite.

 Also I don't think all the debug checks for bidi commands that you
 change should stay at all - driver need to set the QUEUE_FLAG_BIDI to
 ever see a bidi command.
 

Exactly just remove the all checks.

 It would also nice to add a host template flag for bidi support instead
 of having to poke into the block layer request_queue while we're at it.

Cheers
Boaz


--
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] IB/srp: Process REQ_PREEMPT requests correctly

2015-01-29 Thread Bart Van Assche
Delay REQ_PREEMPT requests submitted against a blocked device
until the device is unblocked by returning SCSI_MLQUEUE_HOST_BUSY
to the SCSI mid-layer. This avoids that a rescan shortly after a
cable pull sporadically triggers the following kernel oops:

BUG: unable to handle kernel paging request at c9001a6bc084
IP: [a04e08f2] mlx4_ib_post_send+0xd2/0xb30 [mlx4_ib]
Process rescan-scsi-bus (pid: 9241, threadinfo 88053484a000, task 
880534aae100)
Call Trace:
 [a0718135] srp_post_send+0x65/0x70 [ib_srp]
 [a071b9df] srp_queuecommand+0x1cf/0x3e0 [ib_srp]
 [a0001ff1] scsi_dispatch_cmd+0x101/0x280 [scsi_mod]
 [a0009ad1] scsi_request_fn+0x411/0x4d0 [scsi_mod]
 [81223b37] __blk_run_queue+0x27/0x30
 [8122a8d2] blk_execute_rq_nowait+0x82/0x110
 [8122a9c2] blk_execute_rq+0x62/0xf0
 [a000b0e8] scsi_execute+0xe8/0x190 [scsi_mod]
 [a000b2f3] scsi_execute_req+0xa3/0x130 [scsi_mod]
 [a000c1aa] scsi_probe_lun+0x17a/0x450 [scsi_mod]
 [a000ce86] scsi_probe_and_add_lun+0x156/0x480 [scsi_mod]
 [a000dc2f] __scsi_scan_target+0xdf/0x1f0 [scsi_mod]
 [a000dfa3] scsi_scan_host_selected+0x183/0x1c0 [scsi_mod]
 [a000edfb] scsi_scan+0xdb/0xe0 [scsi_mod]
 [a000ee13] store_scan+0x13/0x20 [scsi_mod]
 [811c8d9b] sysfs_write_file+0xcb/0x160
 [811589de] vfs_write+0xce/0x140
 [81158b53] sys_write+0x53/0xa0
 [81464592] system_call_fastpath+0x16/0x1b
 [7f611c9d9300] 0x7f611c9d92ff

Reported-by: Max Gurtuvoy m...@mellanox.com
Signed-off-by: Bart Van Assche bart.vanass...@sandisk.com
Cc: Sagi Grimberg sa...@mellanox.com
Cc: sta...@vger.kernel.org
---
 drivers/infiniband/ulp/srp/ib_srp.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/ulp/srp/ib_srp.c 
b/drivers/infiniband/ulp/srp/ib_srp.c
index 0747c05..77a7a2f 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -2003,8 +2003,13 @@ static int srp_queuecommand(struct Scsi_Host *shost, 
struct scsi_cmnd *scmnd)
if (in_scsi_eh)
mutex_lock(rport-mutex);
 
+   /*
+* The blocked state of SCSI devices is ignored by the SCSI core for
+* REQ_PREEMPT requests. Hence the explicit check below for the SCSI
+* device state.
+*/
scmnd-result = srp_chkready(target-rport);
-   if (unlikely(scmnd-result))
+   if (unlikely(scmnd-result != 0 || scsi_device_blocked(scmnd-device)))
goto err;
 
WARN_ON_ONCE(scmnd-request-tag  0);
-- 
2.1.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 0/17] Clear up bidi command confusion

2015-01-29 Thread Boaz Harrosh
On 01/26/2015 11:58 AM, Bart Van Assche wrote:

 Hello Christoph,
 
 This makes sense to me. I will rework this patch series as you proposed.
 

Do you have a bidi setup to test against?

Sending xor command to scsi_dbg is only half the test for me because, yes
there are two buffers, but they are of same size so bugs might be masked.
(From experience)

Thanks
Boaz

 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 0/17] Clear up bidi command confusion

2015-01-29 Thread Bart Van Assche
On 01/29/15 14:07, Boaz Harrosh wrote:
 On 01/26/2015 11:58 AM, Bart Van Assche wrote:
 
 Hello Christoph,

 This makes sense to me. I will rework this patch series as you proposed.
 
 Do you have a bidi setup to test against?
 
 Sending xor command to scsi_dbg is only half the test for me because, yes
 there are two buffers, but they are of same size so bugs might be masked.
 (From experience)

Hello Boaz,

If anyone would like to submit a scsi_debug patch that adds support to
that kernel driver for a bidi command for which the input and output
buffers have different sizes I think that would be helpful.

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 v2 0/6] scsi: Some seq_file cleanups/optimizations

2015-01-29 Thread Steven Rostedt
On Thu, 29 Jan 2015 10:16:16 +0100
Rasmus Villemoes li...@rasmusvillemoes.dk wrote:

 Steven, you've been doing some cleanup in this area, among other things
 trying to make all the seq_* functions return void. Could you fill me in
 on the status of that?

Yes, the entire seq_*() operations are ambiguous in how they handle
filling the buffers. Don't worry about side effects of using one seq
operation over another (I highly doubt anyone will notice).

I had to stop doing the cleanups to work on other things, but I have
patches to make all seq operations perform the same (and also use the
new seq_buf infrastructure).

And, please ignore any return value from the seq operations. If you
want to know if the buffer is full use seq_has_overflowed() to find out.

I'll try to continue this clean up as a side project.

-- Steve

--
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/17] Clear up bidi command confusion

2015-01-29 Thread Boaz Harrosh
On 01/29/2015 03:20 PM, Bart Van Assche wrote:
 On 01/29/15 14:07, Boaz Harrosh wrote:
 On 01/26/2015 11:58 AM, Bart Van Assche wrote:

 Hello Christoph,

 This makes sense to me. I will rework this patch series as you proposed.

 Do you have a bidi setup to test against?

 Sending xor command to scsi_dbg is only half the test for me because, yes
 there are two buffers, but they are of same size so bugs might be masked.
 (From experience)
 
 Hello Boaz,
 
 If anyone would like to submit a scsi_debug patch that adds support to
 that kernel driver for a bidi command for which the input and output
 buffers have different sizes I think that would be helpful.
 

Hi Bart.

scsi_dbg is a scsi-blk-device type device (forgot the exact name).
I do not think there is such a command defined by the STD for this command
set.

its only for other device types like osd, printer and so on.

But sending XOR commands to scsi_dbg is a good start.

 Bart.
 

Please Note: I do not agree for the use of the constant DMA_BIDIRECTIONAL
to denote scsi_bidi_cmnd(cmd). This is wrong and takes us back not
forward.

If anything at all is done, cmd-sc_data_direction should be just removed
all together. It is not needed and denotes nothing more than what is already
available at the request level. Please do not add any more new code on top
of cmd-sc_data_direction. (At minimum just remove the all DMA_BIDIRECTIONAL
checks and you are done)

Cheers
Boaz

--
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/17] Clear up bidi command confusion

2015-01-29 Thread James Bottomley
On Thu, 2015-01-29 at 15:00 +0200, Boaz Harrosh wrote:
 On 01/23/2015 03:12 PM, Christoph Hellwig wrote:
  On Fri, Jan 23, 2015 at 01:05:30PM +0100, Bart Van Assche wrote:
  There is some confusion in the SCSI core and in SCSI LLDs around the
  meaning of sc_data_direction and whether or not this member can have the
  value DMA_BIDIRECTIONAL. Clear up this confusion. The patches in this
  series are:
  
  I wonder if we should change the code to set DMA_BIDIRECTIONAL for
  bidi commands.  That seems a lot more logical than the current
  version.
  
 
 You cannot do this. Because a Bidi Command is actually two commands
 one for the WRITE side (DMA_TO_DEVICE) which is this one, and another
 command for the READ side (DMA_FROM_DEVICE).

You're not thinking about this the correct way.  DMA_BIDIRECTIONAL is a
DMA engine flag.  We use it in SCSI for historical reasons (mainly to
prevent a translation from the SCSI version).  Since it was never used,
most SCSI drivers have code to check and reject commands with it set.
For actual bidirectional commands, you have to check scsi_bidi_command()
and programme the DMA engine separately for both phases, so the flag is
useless in this case.

The proposal is to make it the signal for bidirectional commands (in
which case most HBAs would make it do the right thing; i.e. reject) but
it still wouldn't be how you'd program the DMA enigne; that still would
have to be done in two phases as it is today.

James


--
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 3/3] scsi: proper state checking and module refcount handling in scsi_device_get

2015-01-29 Thread James Bottomley
On Thu, 2015-01-29 at 00:00 +0100, Christoph Hellwig wrote:
 This effectively reverts commits 85b6c7 ([SCSI] sd: fix cache flushing on
 module removal (and individual device removal) and dc4515ea (scsi: always
 increment reference count).
 
 We now never call scsi_device_get from the shutdown path, and the fact
 that we started grabbing reference there in commit 85b6c7 turned out
 turned out to create more problems than it solves, and required
 workarounds for workarounds for workarounds. Move back to properly checking
 the device state and carefully handle module refcounting.
 
 Signed-off-by: Christoph Hellwig h...@lst.de
 ---
  drivers/scsi/scsi.c | 17 ++---
  1 file changed, 10 insertions(+), 7 deletions(-)
 
 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
 index 9b38299..95f0293 100644
 --- a/drivers/scsi/scsi.c
 +++ b/drivers/scsi/scsi.c
 @@ -982,15 +982,18 @@ EXPORT_SYMBOL(scsi_report_opcode);
   */
  int scsi_device_get(struct scsi_device *sdev)
  {
 - if (sdev-sdev_state == SDEV_DEL)
 - return -ENXIO;
 + if (sdev-sdev_state == SDEV_DEL || sdev-sdev_state == SDEV_CANCEL)
 + goto fail;
   if (!get_device(sdev-sdev_gendev))
 - return -ENXIO;
 - /* We can fail try_module_get if we're doing SCSI operations
 -  * from module exit (like cache flush) */
 - __module_get(sdev-host-hostt-module);
 -
 + goto fail;
 + if (!try_module_get(sdev-host-hostt-module))
 + goto fail_put_device;
   return 0;
 +
 +fail_put_device:
 + put_device(sdev-sdev_gendev);
 +fail:
 + return -ENXIO;
  }
  EXPORT_SYMBOL(scsi_device_get);

If we can get away with this, I'm all for this approach.  However, you
need to document in a comment or above the function that it may not be
called in module exit functions and why.

Other than the comment issue, the series looks good,

Thanks,

James



Re: [PATCH] IB/srp: Process REQ_PREEMPT requests correctly

2015-01-29 Thread Mike Christie

On 1/29/15, 7:02 AM, Bart Van Assche wrote:

Delay REQ_PREEMPT requests submitted against a blocked device
until the device is unblocked by returning SCSI_MLQUEUE_HOST_BUSY
to the SCSI mid-layer. This avoids that a rescan shortly after a
cable pull sporadically triggers the following kernel oops:

BUG: unable to handle kernel paging request at c9001a6bc084
IP: [a04e08f2] mlx4_ib_post_send+0xd2/0xb30 [mlx4_ib]
Process rescan-scsi-bus (pid: 9241, threadinfo 88053484a000, task 
880534aae100)
Call Trace:
  [a0718135] srp_post_send+0x65/0x70 [ib_srp]
  [a071b9df] srp_queuecommand+0x1cf/0x3e0 [ib_srp]
  [a0001ff1] scsi_dispatch_cmd+0x101/0x280 [scsi_mod]
  [a0009ad1] scsi_request_fn+0x411/0x4d0 [scsi_mod]
  [81223b37] __blk_run_queue+0x27/0x30
  [8122a8d2] blk_execute_rq_nowait+0x82/0x110
  [8122a9c2] blk_execute_rq+0x62/0xf0
  [a000b0e8] scsi_execute+0xe8/0x190 [scsi_mod]
  [a000b2f3] scsi_execute_req+0xa3/0x130 [scsi_mod]
  [a000c1aa] scsi_probe_lun+0x17a/0x450 [scsi_mod]
  [a000ce86] scsi_probe_and_add_lun+0x156/0x480 [scsi_mod]
  [a000dc2f] __scsi_scan_target+0xdf/0x1f0 [scsi_mod]
  [a000dfa3] scsi_scan_host_selected+0x183/0x1c0 [scsi_mod]
  [a000edfb] scsi_scan+0xdb/0xe0 [scsi_mod]
  [a000ee13] store_scan+0x13/0x20 [scsi_mod]
  [811c8d9b] sysfs_write_file+0xcb/0x160
  [811589de] vfs_write+0xce/0x140
  [81158b53] sys_write+0x53/0xa0
  [81464592] system_call_fastpath+0x16/0x1b
  [7f611c9d9300] 0x7f611c9d92ff

Reported-by: Max Gurtuvoy m...@mellanox.com
Signed-off-by: Bart Van Assche bart.vanass...@sandisk.com
Cc: Sagi Grimberg sa...@mellanox.com
Cc: sta...@vger.kernel.org
---
  drivers/infiniband/ulp/srp/ib_srp.c | 7 ++-
  1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/ulp/srp/ib_srp.c 
b/drivers/infiniband/ulp/srp/ib_srp.c
index 0747c05..77a7a2f 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -2003,8 +2003,13 @@ static int srp_queuecommand(struct Scsi_Host *shost, 
struct scsi_cmnd *scmnd)
if (in_scsi_eh)
mutex_lock(rport-mutex);

+   /*
+* The blocked state of SCSI devices is ignored by the SCSI core for
+* REQ_PREEMPT requests. Hence the explicit check below for the SCSI
+* device state.
+*/
scmnd-result = srp_chkready(target-rport);
-   if (unlikely(scmnd-result))
+   if (unlikely(scmnd-result != 0 || scsi_device_blocked(scmnd-device)))
goto err;

WARN_ON_ONCE(scmnd-request-tag  0);



What is the case where a driver blocks the device and can handle or 
wants commands? iSCSI and FC also do not want commands, even PREEMPT 
ones, at this time. It looks like they have been hitting internal checks 
to prevent hitting similar issues.

--
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 1/3] scsi: serialize -rescan against -remove

2015-01-29 Thread Alan Stern
On Thu, 29 Jan 2015, Christoph Hellwig wrote:

 Lock the device embedded in the scsi_device to protect against
 concurrent calls to -remove.
 
 Signed-off-by: Christoph Hellwig h...@lst.de
 ---
  drivers/scsi/scsi_scan.c | 7 +++
  1 file changed, 3 insertions(+), 4 deletions(-)
 
 diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
 index 983aed1..523faee 100644
 --- a/drivers/scsi/scsi_scan.c
 +++ b/drivers/scsi/scsi_scan.c
 @@ -1593,16 +1593,15 @@ EXPORT_SYMBOL(scsi_add_device);
  
  void scsi_rescan_device(struct device *dev)
  {
 - if (!dev-driver)
 - return;
 -
 - if (try_module_get(dev-driver-owner)) {
 + device_lock(dev);
 + if (dev-driver  try_module_get(dev-driver-owner)) {
   struct scsi_driver *drv = to_scsi_driver(dev-driver);
  
   if (drv-rescan)
   drv-rescan(dev);
   module_put(dev-driver-owner);
   }
 + device_unlock(dev);
  }
  EXPORT_SYMBOL(scsi_rescan_device);

Acked-by: Alan Stern st...@rowland.harvard.edu

--
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/1] scsi: Fix max transfer length for 4k disks

2015-01-29 Thread Brian King

The following patch fixes an issue observed with 4k sector disks
where the max_hw_sectors attribute was getting set too large in
sd_revalidate_disk. Since sdkp-max_xfer_blocks is in units
of SCSI logical blocks and queue_max_hw_sectors is in units of
512 byte blocks, on a 4k sector disk, every time we went through
sd_revalidate_disk, we were taking the current value of
queue_max_hw_sectors and increasing it by a factor of 8. Fix
this by only shifting sdkp-max_xfer_blocks.

Cc: stablesta...@vger.kernel.org
Signed-off-by: Brian King brk...@linux.vnet.ibm.com
---

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

diff -puN drivers/scsi/sd.c~sd_revalidate_4k drivers/scsi/sd.c
--- linux/drivers/scsi/sd.c~sd_revalidate_4k2015-01-29 14:44:23.316171187 
-0600
+++ linux-bjking1/drivers/scsi/sd.c 2015-01-29 14:51:05.846126392 -0600
@@ -2800,9 +2800,11 @@ static int sd_revalidate_disk(struct gen
 */
sd_set_flush_flag(sdkp);
 
-   max_xfer = min_not_zero(queue_max_hw_sectors(sdkp-disk-queue),
-   sdkp-max_xfer_blocks);
+   max_xfer = sdkp-max_xfer_blocks;
max_xfer = ilog2(sdp-sector_size) - 9;
+
+   max_xfer = min_not_zero(queue_max_hw_sectors(sdkp-disk-queue),
+   max_xfer);
blk_queue_max_hw_sectors(sdkp-disk-queue, max_xfer);
set_capacity(disk, sdkp-capacity);
sd_config_write_same(sdkp);
_

--
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 1/1] scsi: Fix max transfer length for 4k disks

2015-01-29 Thread Martin K. Petersen
 Brian == Brian King brk...@linux.vnet.ibm.com writes:

Brian on a 4k sector disk, every time we went through
Brian sd_revalidate_disk, we were taking the current value of
Brian queue_max_hw_sectors and increasing it by a factor of 8. Fix this
Brian by only shifting sdkp-max_xfer_blocks.

*blush*

Reviewed-by: Martin K. Petersen martin.peter...@oracle.com

-- 
Martin K. Petersen  Oracle Linux Engineering
--
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 v2 2/6] scsi/advansys: Replace seq_printf with seq_puts

2015-01-29 Thread Finn Thain

Reviewed-by: Finn Thain fth...@telegraphics.com.au


On Wed, 3 Dec 2014, Rasmus Villemoes wrote:

 Using seq_printf to print a simple string is a lot more expensive than
 it needs to be, since seq_puts exists. Replace seq_printf with
 seq_puts when possible.
 
 Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk
 ---
  drivers/scsi/advansys.c | 155 
 +++-
  1 file changed, 75 insertions(+), 80 deletions(-)
 
 diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
 index 6719a33..d31fc6d 100644
 --- a/drivers/scsi/advansys.c
 +++ b/drivers/scsi/advansys.c
 @@ -2880,7 +2880,7 @@ static void asc_prt_board_devices(struct seq_file *m, 
 struct Scsi_Host *shost)
   chip_scsi_id = boardp-dvc_var.adv_dvc_var.chip_scsi_id;
   }
  
 - seq_printf(m, Target IDs Detected:);
 + seq_puts(m, Target IDs Detected:);
   for (i = 0; i = ADV_MAX_TID; i++) {
   if (boardp-init_tidmask  ADV_TID_TO_TIDMASK(i))
   seq_printf(m,  %X,, i);
 @@ -2896,18 +2896,18 @@ static void asc_prt_adv_bios(struct seq_file *m, 
 struct Scsi_Host *shost)
   struct asc_board *boardp = shost_priv(shost);
   ushort major, minor, letter;
  
 - seq_printf(m, \nROM BIOS Version: );
 + seq_puts(m, \nROM BIOS Version: );
  
   /*
* If the BIOS saved a valid signature, then fill in
* the BIOS code segment base address.
*/
   if (boardp-bios_signature != 0x55AA) {
 - seq_printf(m, Disabled or Pre-3.1\n);
 - seq_printf(m,
 -   BIOS either disabled or Pre-3.1. If it is pre-3.1, 
 then a newer version\n);
 - seq_printf(m,
 -   can be found at the ConnectCom FTP site: 
 ftp://ftp.connectcom.net/pub\n;);
 + seq_puts(m, Disabled or Pre-3.1\n);
 + seq_puts(m,
 +  BIOS either disabled or Pre-3.1. If it is pre-3.1, 
 then a newer version\n);
 + seq_puts(m,
 +  can be found at the ConnectCom FTP site: 
 ftp://ftp.connectcom.net/pub\n;);
   } else {
   major = (boardp-bios_version  12)  0xF;
   minor = (boardp-bios_version  8)  0xF;
 @@ -2923,10 +2923,9 @@ static void asc_prt_adv_bios(struct seq_file *m, 
 struct Scsi_Host *shost)
*/
   if (major  3 || (major = 3  minor  1) ||
   (major = 3  minor = 1  letter  ('I' - 'A'))) {
 - seq_printf(m,
 -Newer version of ROM BIOS is available at 
 the ConnectCom FTP site:\n);
 - seq_printf(m,
 -ftp://ftp.connectcom.net/pub\n;);
 + seq_puts(m,
 +  Newer version of ROM BIOS is available at the 
 ConnectCom FTP site:\n);
 + seq_puts(m, ftp://ftp.connectcom.net/pub\n;);
   }
   }
  }
 @@ -3056,11 +3055,10 @@ static void asc_prt_asc_board_eeprom(struct seq_file 
 *m, struct Scsi_Host *shost
   == ASC_TRUE)
   seq_printf(m,  Serial Number: %s\n, serialstr);
   else if (ep-adapter_info[5] == 0xBB)
 - seq_printf(m,
 - Default Settings Used for EEPROM-less Adapter.\n);
 + seq_puts(m,
 +   Default Settings Used for EEPROM-less Adapter.\n);
   else
 - seq_printf(m,
 - Serial Number Signature Not Present.\n);
 + seq_puts(m,  Serial Number Signature Not Present.\n);
  
   seq_printf(m,
   Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: 
 %u\n,
 @@ -3070,34 +3068,34 @@ static void asc_prt_asc_board_eeprom(struct seq_file 
 *m, struct Scsi_Host *shost
   seq_printf(m,
   cntl 0x%x, no_scam 0x%x\n, ep-cntl, ep-no_scam);
  
 - seq_printf(m,  Target ID:   );
 + seq_puts(m,  Target ID:   );
   for (i = 0; i = ASC_MAX_TID; i++)
   seq_printf(m,  %d, i);
 - seq_printf(m, \n);
 + seq_puts(m, \n);
  
 - seq_printf(m,  Disconnects: );
 + seq_puts(m,  Disconnects: );
   for (i = 0; i = ASC_MAX_TID; i++)
   seq_printf(m,  %c,
  (ep-disc_enable  ADV_TID_TO_TIDMASK(i)) ? 'Y' : 
 'N');
 - seq_printf(m, \n);
 + seq_puts(m, \n);
  
 - seq_printf(m,  Command Queuing: );
 + seq_puts(m,  Command Queuing: );
   for (i = 0; i = ASC_MAX_TID; i++)
   seq_printf(m,  %c,
  (ep-use_cmd_qng  ADV_TID_TO_TIDMASK(i)) ? 'Y' : 
 'N');
 - seq_printf(m, \n);
 + seq_puts(m, \n);
  
 - seq_printf(m,  Start Motor: );
 + seq_puts(m,  Start Motor: );
   for (i = 0; i = ASC_MAX_TID; i++)
   seq_printf(m,  %c,
  (ep-start_motor  ADV_TID_TO_TIDMASK(i)) ? 'Y' : 
 'N');
 - 

Re: [PATCH] IB/srp: Process REQ_PREEMPT requests correctly

2015-01-29 Thread Mike Christie

On 1/29/15, 1:38 PM, Mike Christie wrote:

On 1/29/15, 7:02 AM, Bart Van Assche wrote:

Delay REQ_PREEMPT requests submitted against a blocked device
until the device is unblocked by returning SCSI_MLQUEUE_HOST_BUSY
to the SCSI mid-layer. This avoids that a rescan shortly after a
cable pull sporadically triggers the following kernel oops:

BUG: unable to handle kernel paging request at c9001a6bc084
IP: [a04e08f2] mlx4_ib_post_send+0xd2/0xb30 [mlx4_ib]
Process rescan-scsi-bus (pid: 9241, threadinfo 88053484a000, task
880534aae100)
Call Trace:
  [a0718135] srp_post_send+0x65/0x70 [ib_srp]
  [a071b9df] srp_queuecommand+0x1cf/0x3e0 [ib_srp]
  [a0001ff1] scsi_dispatch_cmd+0x101/0x280 [scsi_mod]
  [a0009ad1] scsi_request_fn+0x411/0x4d0 [scsi_mod]
  [81223b37] __blk_run_queue+0x27/0x30
  [8122a8d2] blk_execute_rq_nowait+0x82/0x110
  [8122a9c2] blk_execute_rq+0x62/0xf0
  [a000b0e8] scsi_execute+0xe8/0x190 [scsi_mod]
  [a000b2f3] scsi_execute_req+0xa3/0x130 [scsi_mod]
  [a000c1aa] scsi_probe_lun+0x17a/0x450 [scsi_mod]
  [a000ce86] scsi_probe_and_add_lun+0x156/0x480 [scsi_mod]
  [a000dc2f] __scsi_scan_target+0xdf/0x1f0 [scsi_mod]
  [a000dfa3] scsi_scan_host_selected+0x183/0x1c0 [scsi_mod]
  [a000edfb] scsi_scan+0xdb/0xe0 [scsi_mod]
  [a000ee13] store_scan+0x13/0x20 [scsi_mod]
  [811c8d9b] sysfs_write_file+0xcb/0x160
  [811589de] vfs_write+0xce/0x140
  [81158b53] sys_write+0x53/0xa0
  [81464592] system_call_fastpath+0x16/0x1b
  [7f611c9d9300] 0x7f611c9d92ff

Reported-by: Max Gurtuvoy m...@mellanox.com
Signed-off-by: Bart Van Assche bart.vanass...@sandisk.com
Cc: Sagi Grimberg sa...@mellanox.com
Cc: sta...@vger.kernel.org
---
  drivers/infiniband/ulp/srp/ib_srp.c | 7 ++-
  1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/ulp/srp/ib_srp.c
b/drivers/infiniband/ulp/srp/ib_srp.c
index 0747c05..77a7a2f 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -2003,8 +2003,13 @@ static int srp_queuecommand(struct Scsi_Host
*shost, struct scsi_cmnd *scmnd)
  if (in_scsi_eh)
  mutex_lock(rport-mutex);

+/*
+ * The blocked state of SCSI devices is ignored by the SCSI
core for
+ * REQ_PREEMPT requests. Hence the explicit check below for the SCSI
+ * device state.
+ */
  scmnd-result = srp_chkready(target-rport);
-if (unlikely(scmnd-result))
+if (unlikely(scmnd-result != 0 ||
scsi_device_blocked(scmnd-device)))
  goto err;

  WARN_ON_ONCE(scmnd-request-tag  0);



What is the case where a driver blocks the device and can handle or
wants commands? iSCSI and FC also do not want commands, even PREEMPT
ones, at this time. It looks like they have been hitting internal checks
to prevent hitting similar issues.


I think I figured this out. I think we want to change the 
scsi_prep_state_check check instead of each driver/class.


It looks like for the SDEV_QUIESCE state we want to allow REQ_PREEMPT 
commands. James would know best, but I think SPI needs that ability.


For SDEV_BLOCK/SDEV_CREATED_BLOCK, it looks like drivers/classes that 
use that state do not want any commands to be queued at that time, 
because the transport is normally down.

--
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 1/3] scsi: serialize -rescan against -remove

2015-01-29 Thread Paolo Bonzini


On 29/01/2015 00:00, Christoph Hellwig wrote:
 Lock the device embedded in the scsi_device to protect against
 concurrent calls to -remove.
 
 Signed-off-by: Christoph Hellwig h...@lst.de

I wonder if this makes this problem: https://lkml.org/lkml/2015/1/5/9 go
away.

Paolo

 ---
  drivers/scsi/scsi_scan.c | 7 +++
  1 file changed, 3 insertions(+), 4 deletions(-)
 
 diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
 index 983aed1..523faee 100644
 --- a/drivers/scsi/scsi_scan.c
 +++ b/drivers/scsi/scsi_scan.c
 @@ -1593,16 +1593,15 @@ EXPORT_SYMBOL(scsi_add_device);
  
  void scsi_rescan_device(struct device *dev)
  {
 - if (!dev-driver)
 - return;
 -
 - if (try_module_get(dev-driver-owner)) {
 + device_lock(dev);
 + if (dev-driver  try_module_get(dev-driver-owner)) {
   struct scsi_driver *drv = to_scsi_driver(dev-driver);
  
   if (drv-rescan)
   drv-rescan(dev);
   module_put(dev-driver-owner);
   }
 + device_unlock(dev);
  }
  EXPORT_SYMBOL(scsi_rescan_device);
  
 
--
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


[PATCHv2 5/5] scsi: move scsi/sg.h to uapi/linux/sg.h

2015-01-29 Thread Andy Grover
This will enable user programs to have access to the most current
definitions.

Modify include sites for new path.

Signed-off-by: Andy Grover agro...@redhat.com
---
 block/bio.c|   2 +-
 block/blk-map.c|   2 +-
 block/bsg.c|   2 +-
 block/scsi_ioctl.c |   2 +-
 drivers/block/aoe/aoeblk.c |   2 +-
 drivers/block/cciss.c  |   2 +-
 drivers/block/nvme-core.c  |   2 +-
 drivers/block/nvme-scsi.c  |   2 +-
 drivers/block/skd_main.c   |   2 +-
 drivers/message/i2o/i2o_scsi.c |   2 +-
 drivers/scsi/ips.c |   2 +-
 drivers/scsi/scsi_error.c  |   2 +-
 drivers/scsi/scsi_ioctl.c  |   2 +-
 drivers/scsi/sg.c  |   2 +-
 drivers/scsi/st.c  |   2 +-
 fs/compat_ioctl.c  |   2 +-
 include/scsi/sg.h  | 274 -
 include/uapi/linux/Kbuild  |   1 +
 include/uapi/linux/sg.h| 274 +
 kernel/sysctl.c|   2 +-
 20 files changed, 292 insertions(+), 291 deletions(-)
 delete mode 100644 include/scsi/sg.h
 create mode 100644 include/uapi/linux/sg.h

diff --git a/block/bio.c b/block/bio.c
index 471d738..ca072bb 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -28,7 +28,7 @@
 #include linux/mempool.h
 #include linux/workqueue.h
 #include linux/cgroup.h
-#include scsi/sg.h   /* for struct sg_iovec */
+#include uapi/linux/sg.h /* for struct sg_iovec */
 
 #include trace/events/block.h
 
diff --git a/block/blk-map.c b/block/blk-map.c
index f890d43..e29be04 100644
--- a/block/blk-map.c
+++ b/block/blk-map.c
@@ -5,7 +5,7 @@
 #include linux/module.h
 #include linux/bio.h
 #include linux/blkdev.h
-#include scsi/sg.h   /* for struct sg_iovec */
+#include uapi/linux/sg.h /* for struct sg_iovec */
 
 #include blk.h
 
diff --git a/block/bsg.c b/block/bsg.c
index f5796993..8f4d4d6 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -27,7 +27,7 @@
 #include scsi/scsi_cmnd.h
 #include scsi/scsi_device.h
 #include scsi/scsi_driver.h
-#include scsi/sg.h
+#include uapi/linux/sg.h
 
 #define BSG_DESCRIPTIONBlock layer SCSI generic (bsg) driver
 #define BSG_VERSION0.4
diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
index 7bf22f2..061b40c 100644
--- a/block/scsi_ioctl.c
+++ b/block/scsi_ioctl.c
@@ -49,7 +49,7 @@ const unsigned char scsi_command_size_tbl[8] =
 };
 EXPORT_SYMBOL(scsi_command_size_tbl);
 
-#include scsi/sg.h
+#include uapi/linux/sg.h
 
 static int sg_get_version(int __user *p)
 {
diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c
index 46c282f..9f966c0 100644
--- a/drivers/block/aoe/aoeblk.c
+++ b/drivers/block/aoe/aoeblk.c
@@ -18,7 +18,7 @@
 #include linux/export.h
 #include linux/moduleparam.h
 #include linux/debugfs.h
-#include scsi/sg.h
+#include uapi/linux/sg.h
 #include aoe.h
 
 static DEFINE_MUTEX(aoeblk_mutex);
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 8c79ac0..d477f63 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -50,7 +50,7 @@
 #include linux/genhd.h
 #include linux/completion.h
 #include scsi/scsi.h
-#include scsi/sg.h
+#include uapi/linux/sg.h
 #include uapi/linux/scsi_ioctl.h
 #include linux/cdrom.h
 #include linux/scatterlist.h
diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c
index b1d5d87..5aa0035 100644
--- a/drivers/block/nvme-core.c
+++ b/drivers/block/nvme-core.c
@@ -38,7 +38,7 @@
 #include linux/sched.h
 #include linux/slab.h
 #include linux/types.h
-#include scsi/sg.h
+#include uapi/linux/sg.h
 #include asm-generic/io-64-nonatomic-lo-hi.h
 
 #define NVME_Q_DEPTH   1024
diff --git a/drivers/block/nvme-scsi.c b/drivers/block/nvme-scsi.c
index 5e78568..30edac8 100644
--- a/drivers/block/nvme-scsi.c
+++ b/drivers/block/nvme-scsi.c
@@ -41,7 +41,7 @@
 #include linux/sched.h
 #include linux/slab.h
 #include linux/types.h
-#include scsi/sg.h
+#include uapi/linux/sg.h
 #include scsi/scsi.h
 
 
diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c
index 1e46eb2..51d1bd5 100644
--- a/drivers/block/skd_main.c
+++ b/drivers/block/skd_main.c
@@ -42,7 +42,7 @@
 #include linux/wait.h
 #include linux/uio.h
 #include scsi/scsi.h
-#include scsi/sg.h
+#include uapi/linux/sg.h
 #include linux/io.h
 #include linux/uaccess.h
 #include asm/unaligned.h
diff --git a/drivers/message/i2o/i2o_scsi.c b/drivers/message/i2o/i2o_scsi.c
index 8152e9fa..debc9b5 100644
--- a/drivers/message/i2o/i2o_scsi.c
+++ b/drivers/message/i2o/i2o_scsi.c
@@ -64,7 +64,7 @@
 #include scsi/scsi_host.h
 #include scsi/scsi_device.h
 #include scsi/scsi_cmnd.h
-#include scsi/sg.h
+#include uapi/linux/sg.h
 
 #define OSM_NAME   scsi-osm
 #define OSM_VERSION1.316
diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c
index e5c2843..3346ec2 100644
--- a/drivers/scsi/ips.c
+++ b/drivers/scsi/ips.c
@@ -180,7 +180,7 @@
 #include linux/types.h
 #include linux/dma-mapping.h

[PATCHv2 0/5] Move headers to uapi/linux

2015-01-29 Thread Andy Grover
Hi James and hch, here's v2 with the headers exported in uapi/linux/*
instead of uapi/scsi/*, based upon your feedback. v2 also additionally
moves sg.h.

Also, you mentioned dropping obsolete SPC-2 opcodes from these
headers, but I wasn't sure what was safe to drop. Candidates?

Against scsi/for-next.

Summary:

Moving SCSI opcodes and other useful defines into user-available
headers should help projects like tgt and glibc that have copied
these opcode definitions, and then fall out of date. Unfortunately we
cannot move them to scsi/* because of conflicts with glibc.

The first patch adds a missing opcode.

Builds with allmodconfig. Thanks for taking a look, and any
suggestions for further improvement.

Regards -- Andy

Andy Grover (5):
  scsi: add WRITE_VERIFY_16 to scsi.h
  scsi: Move ioctl defs from scsi/scsi.h to scsi/scsi_ioctl.h
  scsi: Move user-shareable stuff in scsi/scsi.h to uapi/linux/scsi.h
  scsi: Move scsi/scsi_ioctl.h to uapi/linux/scsi_ioctl.h
  scsi: move scsi/sg.h to uapi/linux/sg.h

 block/bio.c|   2 +-
 block/blk-map.c|   2 +-
 block/bsg.c|   4 +-
 block/scsi_ioctl.c |   4 +-
 drivers/block/aoe/aoeblk.c |   2 +-
 drivers/block/cciss.c  |   4 +-
 drivers/block/nvme-core.c  |   2 +-
 drivers/block/nvme-scsi.c  |   2 +-
 drivers/block/pktcdvd.c|   2 +-
 drivers/block/skd_main.c   |   2 +-
 drivers/ide/ide-floppy.c   |   2 +-
 drivers/ide/ide-floppy_ioctl.c |   2 +-
 drivers/message/i2o/i2o_scsi.c |   2 +-
 drivers/scsi/ch.c  |   2 +-
 drivers/scsi/fdomain.c |   2 +-
 drivers/scsi/ips.c |   2 +-
 drivers/scsi/nsp32.c   |   2 +-
 drivers/scsi/osd/osd_uld.c |   2 +-
 drivers/scsi/osst.c|   2 +-
 drivers/scsi/pcmcia/aha152x_stub.c |   2 +-
 drivers/scsi/pcmcia/fdomain_stub.c |   2 +-
 drivers/scsi/pcmcia/nsp_cs.c   |   2 +-
 drivers/scsi/pcmcia/qlogic_stub.c  |   2 +-
 drivers/scsi/pcmcia/sym53c500_cs.c |   2 +-
 drivers/scsi/scsi_error.c  |   4 +-
 drivers/scsi/scsi_ioctl.c  |   4 +-
 drivers/scsi/sd.c  |   2 +-
 drivers/scsi/sd_dif.c  |   2 +-
 drivers/scsi/sg.c  |   4 +-
 drivers/scsi/sr.c  |   2 +-
 drivers/scsi/sr_ioctl.c|   2 +-
 drivers/scsi/sr_vendor.c   |   2 +-
 drivers/scsi/st.c  |   4 +-
 fs/compat_ioctl.c  |   4 +-
 include/scsi/scsi.h| 517 +
 include/scsi/scsi_ioctl.h  |  48 
 include/scsi/sg.h  | 274 
 include/uapi/linux/Kbuild  |   3 +
 include/uapi/linux/scsi.h  | 506 
 include/uapi/linux/scsi_ioctl.h|  72 ++
 include/uapi/linux/sg.h| 274 
 kernel/sysctl.c|   2 +-
 42 files changed, 901 insertions(+), 879 deletions(-)
 delete mode 100644 include/scsi/scsi_ioctl.h
 delete mode 100644 include/scsi/sg.h
 create mode 100644 include/uapi/linux/scsi.h
 create mode 100644 include/uapi/linux/scsi_ioctl.h
 create mode 100644 include/uapi/linux/sg.h

-- 
2.1.0

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


[PATCHv2 3/5] scsi: Move user-shareable stuff in scsi/scsi.h to uapi/linux/scsi.h

2015-01-29 Thread Andy Grover
A great many SCSI codes can be made available to userspace in a uapi
header, while the kernel-only definitions stay in scsi/scsi.h.

This will permit userspace apps to stop using the antiquated definitions
available in glibc's scsi/scsi.h, which are very old and incomplete.

scsi/scsi.h also includes uapi/scsi/scsi.h so kernel code need not update
includes.

Signed-off-by: Andy Grover agro...@redhat.com
---
 include/scsi/scsi.h   | 497 +
 include/uapi/linux/Kbuild |   1 +
 include/uapi/linux/scsi.h | 506 ++
 3 files changed, 510 insertions(+), 494 deletions(-)
 create mode 100644 include/uapi/linux/scsi.h

diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h
index 012f493..9ed33a5 100644
--- a/include/scsi/scsi.h
+++ b/include/scsi/scsi.h
@@ -1,6 +1,5 @@
 /*
- * This header file contains public constants and structures used by
- * the scsi code for linux.
+ * This header file contains kernel-specific definitions for SCSI code.
  *
  * For documentation on the OPCODES, MESSAGES, and SENSE values,
  * please consult the SCSI standard.
@@ -12,6 +11,8 @@
 #include linux/scatterlist.h
 #include linux/kernel.h
 
+#include uapi/linux/scsi.h
+
 struct scsi_cmnd;
 
 enum scsi_timeouts {
@@ -49,178 +50,6 @@ enum scsi_timeouts {
  */
 #define SCAN_WILD_CARD ~0
 
-/*
- *  SCSI opcodes
- */
-
-#define TEST_UNIT_READY   0x00
-#define REZERO_UNIT   0x01
-#define REQUEST_SENSE 0x03
-#define FORMAT_UNIT   0x04
-#define READ_BLOCK_LIMITS 0x05
-#define REASSIGN_BLOCKS   0x07
-#define INITIALIZE_ELEMENT_STATUS 0x07
-#define READ_60x08
-#define WRITE_6   0x0a
-#define SEEK_60x0b
-#define READ_REVERSE  0x0f
-#define WRITE_FILEMARKS   0x10
-#define SPACE 0x11
-#define INQUIRY   0x12
-#define RECOVER_BUFFERED_DATA 0x14
-#define MODE_SELECT   0x15
-#define RESERVE   0x16
-#define RELEASE   0x17
-#define COPY  0x18
-#define ERASE 0x19
-#define MODE_SENSE0x1a
-#define START_STOP0x1b
-#define RECEIVE_DIAGNOSTIC0x1c
-#define SEND_DIAGNOSTIC   0x1d
-#define ALLOW_MEDIUM_REMOVAL  0x1e
-
-#define READ_FORMAT_CAPACITIES 0x23
-#define SET_WINDOW0x24
-#define READ_CAPACITY 0x25
-#define READ_10   0x28
-#define WRITE_10  0x2a
-#define SEEK_10   0x2b
-#define POSITION_TO_ELEMENT   0x2b
-#define WRITE_VERIFY  0x2e
-#define VERIFY0x2f
-#define SEARCH_HIGH   0x30
-#define SEARCH_EQUAL  0x31
-#define SEARCH_LOW0x32
-#define SET_LIMITS0x33
-#define PRE_FETCH 0x34
-#define READ_POSITION 0x34
-#define SYNCHRONIZE_CACHE 0x35
-#define LOCK_UNLOCK_CACHE 0x36
-#define READ_DEFECT_DATA  0x37
-#define MEDIUM_SCAN   0x38
-#define COMPARE   0x39
-#define COPY_VERIFY   0x3a
-#define WRITE_BUFFER  0x3b
-#define READ_BUFFER   0x3c
-#define UPDATE_BLOCK  0x3d
-#define READ_LONG 0x3e
-#define WRITE_LONG0x3f
-#define CHANGE_DEFINITION 0x40
-#define WRITE_SAME0x41
-#define UNMAP0x42
-#define READ_TOC  0x43
-#define READ_HEADER   0x44
-#define GET_EVENT_STATUS_NOTIFICATION 0x4a
-#define LOG_SELECT0x4c
-#define LOG_SENSE 0x4d
-#define XDWRITEREAD_100x53
-#define MODE_SELECT_100x55
-#define RESERVE_100x56
-#define RELEASE_100x57
-#define MODE_SENSE_10 0x5a
-#define PERSISTENT_RESERVE_IN 0x5e
-#define PERSISTENT_RESERVE_OUT 0x5f
-#define VARIABLE_LENGTH_CMD   0x7f
-#define REPORT_LUNS   0xa0
-#define SECURITY_PROTOCOL_IN  0xa2
-#define MAINTENANCE_IN0xa3
-#define MAINTENANCE_OUT   0xa4
-#define MOVE_MEDIUM   0xa5
-#define EXCHANGE_MEDIUM   0xa6
-#define READ_12   0xa8
-#define SERVICE_ACTION_OUT_12 0xa9
-#define WRITE_12  0xaa
-#define READ_MEDIA_SERIAL_NUMBER 0xab /* Obsolete with SPC-2 */
-#define SERVICE_ACTION_IN_12  0xab
-#define WRITE_VERIFY_12   0xae
-#define VERIFY_120xaf
-#define SEARCH_HIGH_120xb0
-#define SEARCH_EQUAL_12   0xb1
-#define SEARCH_LOW_12 0xb2
-#define SECURITY_PROTOCOL_OUT 0xb5
-#define READ_ELEMENT_STATUS   0xb8
-#define SEND_VOLUME_TAG   0xb6
-#define WRITE_LONG_2  0xea
-#define EXTENDED_COPY 0x83
-#define RECEIVE_COPY_RESULTS  0x84
-#define ACCESS_CONTROL_IN 0x86
-#define ACCESS_CONTROL_OUT0x87
-#define READ_16   0x88
-#define COMPARE_AND_WRITE 0x89
-#define WRITE_16  0x8a
-#define READ_ATTRIBUTE0x8c
-#define WRITE_ATTRIBUTE  0x8d
-#define WRITE_VERIFY_16   0x8e
-#define VERIFY_160x8f
-#define 

[PATCHv2 1/5] scsi: add WRITE_VERIFY_16 to scsi.h

2015-01-29 Thread Andy Grover
Signed-off-by: Andy Grover agro...@redhat.com
---
 include/scsi/scsi.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h
index d0a66aa..cf778fe 100644
--- a/include/scsi/scsi.h
+++ b/include/scsi/scsi.h
@@ -150,6 +150,7 @@ enum scsi_timeouts {
 #define WRITE_16  0x8a
 #define READ_ATTRIBUTE0x8c
 #define WRITE_ATTRIBUTE  0x8d
+#define WRITE_VERIFY_16   0x8e
 #define VERIFY_160x8f
 #define SYNCHRONIZE_CACHE_16  0x91
 #define WRITE_SAME_160x93
-- 
2.1.0

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


[PATCHv2 4/5] scsi: Move scsi/scsi_ioctl.h to uapi/linux/scsi_ioctl.h

2015-01-29 Thread Andy Grover
Make all scsi ioctl-related definitions available via a uapi header.

Change files referencing scsi/scsi_ioctl.h to refer to
uapi/linux/scsi_ioctl.h.

Signed-off-by: Andy Grover agro...@redhat.com
---
 block/bsg.c|  2 +-
 block/scsi_ioctl.c |  2 +-
 drivers/block/cciss.c  |  2 +-
 drivers/block/pktcdvd.c|  2 +-
 drivers/ide/ide-floppy.c   |  2 +-
 drivers/ide/ide-floppy_ioctl.c |  2 +-
 drivers/scsi/ch.c  |  2 +-
 drivers/scsi/fdomain.c |  2 +-
 drivers/scsi/nsp32.c   |  2 +-
 drivers/scsi/osd/osd_uld.c |  2 +-
 drivers/scsi/osst.c|  2 +-
 drivers/scsi/pcmcia/aha152x_stub.c |  2 +-
 drivers/scsi/pcmcia/fdomain_stub.c |  2 +-
 drivers/scsi/pcmcia/nsp_cs.c   |  2 +-
 drivers/scsi/pcmcia/qlogic_stub.c  |  2 +-
 drivers/scsi/pcmcia/sym53c500_cs.c |  2 +-
 drivers/scsi/scsi_error.c  |  2 +-
 drivers/scsi/scsi_ioctl.c  |  2 +-
 drivers/scsi/sd.c  |  2 +-
 drivers/scsi/sd_dif.c  |  2 +-
 drivers/scsi/sg.c  |  2 +-
 drivers/scsi/sr.c  |  2 +-
 drivers/scsi/sr_ioctl.c|  2 +-
 drivers/scsi/sr_vendor.c   |  2 +-
 drivers/scsi/st.c  |  2 +-
 fs/compat_ioctl.c  |  2 +-
 include/scsi/scsi_ioctl.h  | 68 ---
 include/uapi/linux/Kbuild  |  1 +
 include/uapi/linux/scsi_ioctl.h| 72 ++
 29 files changed, 99 insertions(+), 94 deletions(-)
 delete mode 100644 include/scsi/scsi_ioctl.h
 create mode 100644 include/uapi/linux/scsi_ioctl.h

diff --git a/block/bsg.c b/block/bsg.c
index 276e869..f5796993 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -23,7 +23,7 @@
 #include linux/slab.h
 
 #include scsi/scsi.h
-#include scsi/scsi_ioctl.h
+#include uapi/linux/scsi_ioctl.h
 #include scsi/scsi_cmnd.h
 #include scsi/scsi_device.h
 #include scsi/scsi_driver.h
diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
index 28163fad..7bf22f2 100644
--- a/block/scsi_ioctl.c
+++ b/block/scsi_ioctl.c
@@ -31,7 +31,7 @@
 #include asm/uaccess.h
 
 #include scsi/scsi.h
-#include scsi/scsi_ioctl.h
+#include uapi/linux/scsi_ioctl.h
 #include scsi/scsi_cmnd.h
 
 struct blk_cmd_filter {
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index ff20f19..8c79ac0 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -51,7 +51,7 @@
 #include linux/completion.h
 #include scsi/scsi.h
 #include scsi/sg.h
-#include scsi/scsi_ioctl.h
+#include uapi/linux/scsi_ioctl.h
 #include linux/cdrom.h
 #include linux/scatterlist.h
 #include linux/kthread.h
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 09e628da..46b7ce4 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -62,7 +62,7 @@
 #include linux/mutex.h
 #include linux/slab.h
 #include scsi/scsi_cmnd.h
-#include scsi/scsi_ioctl.h
+#include uapi/linux/scsi_ioctl.h
 #include scsi/scsi.h
 #include linux/debugfs.h
 #include linux/device.h
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 8c6363c..da947b2 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -32,7 +32,7 @@
 #include linux/mutex.h
 #include linux/scatterlist.h
 
-#include scsi/scsi_ioctl.h
+#include uapi/linux/scsi_ioctl.h
 
 #include asm/byteorder.h
 #include linux/uaccess.h
diff --git a/drivers/ide/ide-floppy_ioctl.c b/drivers/ide/ide-floppy_ioctl.c
index a22ca84..058d802 100644
--- a/drivers/ide/ide-floppy_ioctl.c
+++ b/drivers/ide/ide-floppy_ioctl.c
@@ -9,7 +9,7 @@
 
 #include asm/unaligned.h
 
-#include scsi/scsi_ioctl.h
+#include uapi/linux/scsi_ioctl.h
 
 #include ide-floppy.h
 
diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c
index 0045742..3537519 100644
--- a/drivers/scsi/ch.c
+++ b/drivers/scsi/ch.c
@@ -27,7 +27,7 @@
 #include scsi/scsi.h
 #include scsi/scsi_cmnd.h
 #include scsi/scsi_driver.h
-#include scsi/scsi_ioctl.h
+#include uapi/linux/scsi_ioctl.h
 #include scsi/scsi_host.h
 #include scsi/scsi_device.h
 #include scsi/scsi_eh.h
diff --git a/drivers/scsi/fdomain.c b/drivers/scsi/fdomain.c
index fff6829..fea41e3 100644
--- a/drivers/scsi/fdomain.c
+++ b/drivers/scsi/fdomain.c
@@ -287,7 +287,7 @@
 #include scsi/scsi_cmnd.h
 #include scsi/scsi_device.h
 #include scsi/scsi_host.h
-#include scsi/scsi_ioctl.h
+#include uapi/linux/scsi_ioctl.h
 #include fdomain.h
 
 #ifndef PCMCIA
diff --git a/drivers/scsi/nsp32.c b/drivers/scsi/nsp32.c
index 90abb03..aa7c549 100644
--- a/drivers/scsi/nsp32.c
+++ b/drivers/scsi/nsp32.c
@@ -44,7 +44,7 @@
 #include scsi/scsi_cmnd.h
 #include scsi/scsi_device.h
 #include scsi/scsi_host.h
-#include scsi/scsi_ioctl.h
+#include uapi/linux/scsi_ioctl.h
 
 #include nsp32.h
 
diff --git a/drivers/scsi/osd/osd_uld.c b/drivers/scsi/osd/osd_uld.c
index 243eab3..34f76cd 100644
--- a/drivers/scsi/osd/osd_uld.c
+++ b/drivers/scsi/osd/osd_uld.c
@@ -55,7 +55,7 @@
 #include 

[PATCHv2 2/5] scsi: Move ioctl defs from scsi/scsi.h to scsi/scsi_ioctl.h

2015-01-29 Thread Andy Grover
These can be consolidated into scsi_ioctl.h with the other ones.

Signed-off-by: Andy Grover agro...@redhat.com
---
 include/scsi/scsi.h   | 21 -
 include/scsi/scsi_ioctl.h | 20 
 2 files changed, 20 insertions(+), 21 deletions(-)

diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h
index cf778fe..012f493 100644
--- a/include/scsi/scsi.h
+++ b/include/scsi/scsi.h
@@ -565,27 +565,6 @@ static inline int scsi_is_wlun(u64 lun)
 #define SCSI_INQ_PQ_NOT_CON 0x01
 #define SCSI_INQ_PQ_NOT_CAP 0x03
 
-
-/*
- * Here are some scsi specific ioctl commands which are sometimes useful.
- *
- * Note that include/linux/cdrom.h also defines IOCTL 0x5300 - 0x5395
- */
-
-/* Used to obtain PUN and LUN info.  Conflicts with CDROMAUDIOBUFSIZ */
-#define SCSI_IOCTL_GET_IDLUN   0x5382
-
-/* 0x5383 and 0x5384 were used for SCSI_IOCTL_TAGGED_{ENABLE,DISABLE} */
-
-/* Used to obtain the host number of a device. */
-#define SCSI_IOCTL_PROBE_HOST  0x5385
-
-/* Used to obtain the bus number for a device */
-#define SCSI_IOCTL_GET_BUS_NUMBER  0x5386
-
-/* Used to obtain the PCI location of a device */
-#define SCSI_IOCTL_GET_PCI 0x5387
-
 /* Pull a u32 out of a SCSI message (using BE SCSI conventions) */
 static inline __u32 scsi_to_u32(__u8 *ptr)
 {
diff --git a/include/scsi/scsi_ioctl.h b/include/scsi/scsi_ioctl.h
index 8d19d1d..4d9f71f 100644
--- a/include/scsi/scsi_ioctl.h
+++ b/include/scsi/scsi_ioctl.h
@@ -15,6 +15,26 @@
 #defineSCSI_REMOVAL_PREVENT1
 #defineSCSI_REMOVAL_ALLOW  0
 
+/*
+ * Here are some scsi specific ioctl commands which are sometimes useful.
+ *
+ * Note that include/linux/cdrom.h also defines IOCTL 0x5300 - 0x5395
+ */
+
+/* Used to obtain PUN and LUN info.  Conflicts with CDROMAUDIOBUFSIZ */
+#define SCSI_IOCTL_GET_IDLUN   0x5382
+
+/* 0x5383 and 0x5384 were used for SCSI_IOCTL_TAGGED_{ENABLE,DISABLE} */
+
+/* Used to obtain the host number of a device. */
+#define SCSI_IOCTL_PROBE_HOST  0x5385
+
+/* Used to obtain the bus number for a device */
+#define SCSI_IOCTL_GET_BUS_NUMBER  0x5386
+
+/* Used to obtain the PCI location of a device */
+#define SCSI_IOCTL_GET_PCI 0x5387
+
 #ifdef __KERNEL__
 
 struct scsi_device;
-- 
2.1.0

--
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 v2 6/6] scsi: misc: Print single-character strings with seq_putc

2015-01-29 Thread Finn Thain

Reviewed-by: Finn Thain fth...@telegraphics.com.au

For the NCR5380 bits:

Acked-by: Finn Thain fth...@telegraphics.com.au


On Wed, 3 Dec 2014, Rasmus Villemoes wrote:

 Using seq_putc to print a single character saves at least a strlen()
 call and a memory access, and may also give a small .text reduction.
 
 Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk
 ---
  drivers/scsi/NCR5380.c  |  2 +-
  drivers/scsi/advansys.c | 34 +-
  drivers/scsi/aic7xxx/aic79xx_proc.c | 10 +-
  drivers/scsi/aic7xxx/aic7xxx_proc.c | 10 +-
  drivers/scsi/atari_NCR5380.c|  2 +-
  drivers/scsi/dc395x.c   |  4 ++--
  drivers/scsi/esas2r/esas2r_main.c   |  2 +-
  drivers/scsi/in2000.c   |  2 +-
  drivers/scsi/ips.c  |  2 +-
  drivers/scsi/nsp32.c|  2 +-
  drivers/scsi/pcmcia/nsp_cs.c|  4 ++--
  drivers/scsi/qla2xxx/qla_dfs.c  |  2 +-
  drivers/scsi/scsi_proc.c| 10 +-
  drivers/scsi/scsi_trace.c   |  2 +-
  drivers/scsi/wd33c93.c  |  2 +-
  15 files changed, 45 insertions(+), 45 deletions(-)
 
 diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
 index a30af00..8981701 100644
 --- a/drivers/scsi/NCR5380.c
 +++ b/drivers/scsi/NCR5380.c
 @@ -764,7 +764,7 @@ static void lprint_command(unsigned char *command, struct 
 seq_file *m)
   lprint_opcode(command[0], m);
   for (i = 1, s = COMMAND_SIZE(command[0]); i  s; ++i)
   seq_printf(m, %02x , command[i]);
 - seq_puts(m, \n);
 + seq_putc(m, '\n');
  }
  
  static void lprint_opcode(int opcode, struct seq_file *m)
 diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
 index c4d0910..81ffb0f 100644
 --- a/drivers/scsi/advansys.c
 +++ b/drivers/scsi/advansys.c
 @@ -3088,7 +3088,7 @@ static void asc_prt_asc_board_eeprom(struct seq_file 
 *m, struct Scsi_Host *shost
   for (i = 0; i = ASC_MAX_TID; i++)
   seq_printf(m,  %c,
  (ep-init_sdtr  ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
 - seq_puts(m, \n);
 + seq_putc(m, '\n');
  
  #ifdef CONFIG_ISA
   if (asc_dvc_varp-bus_type  ASC_IS_ISA) {
 @@ -3203,7 +3203,7 @@ static void asc_prt_adv_board_eeprom(struct seq_file 
 *m, struct Scsi_Host *shost
   seq_puts(m,  Target ID:   );
   for (i = 0; i = ADV_MAX_TID; i++)
   seq_printf(m,  %X, i);
 - seq_puts(m, \n);
 + seq_putc(m, '\n');
  
   if (adv_dvc_varp-chip_type == ADV_CHIP_ASC3550) {
   word = ep_3550-disc_enable;
 @@ -3216,7 +3216,7 @@ static void asc_prt_adv_board_eeprom(struct seq_file 
 *m, struct Scsi_Host *shost
   for (i = 0; i = ADV_MAX_TID; i++)
   seq_printf(m,  %c,
  (word  ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
 - seq_puts(m, \n);
 + seq_putc(m, '\n');
  
   if (adv_dvc_varp-chip_type == ADV_CHIP_ASC3550) {
   word = ep_3550-tagqng_able;
 @@ -3229,7 +3229,7 @@ static void asc_prt_adv_board_eeprom(struct seq_file 
 *m, struct Scsi_Host *shost
   for (i = 0; i = ADV_MAX_TID; i++)
   seq_printf(m,  %c,
  (word  ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
 - seq_puts(m, \n);
 + seq_putc(m, '\n');
  
   if (adv_dvc_varp-chip_type == ADV_CHIP_ASC3550) {
   word = ep_3550-start_motor;
 @@ -3242,7 +3242,7 @@ static void asc_prt_adv_board_eeprom(struct seq_file 
 *m, struct Scsi_Host *shost
   for (i = 0; i = ADV_MAX_TID; i++)
   seq_printf(m,  %c,
  (word  ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
 - seq_puts(m, \n);
 + seq_putc(m, '\n');
  
   if (adv_dvc_varp-chip_type == ADV_CHIP_ASC3550) {
   seq_puts(m,  Synchronous Transfer:);
 @@ -3250,7 +3250,7 @@ static void asc_prt_adv_board_eeprom(struct seq_file 
 *m, struct Scsi_Host *shost
   seq_printf(m,  %c,
  (ep_3550-sdtr_able  ADV_TID_TO_TIDMASK(i)) 
 ?
  'Y' : 'N');
 - seq_puts(m, \n);
 + seq_putc(m, '\n');
   }
  
   if (adv_dvc_varp-chip_type == ADV_CHIP_ASC3550) {
 @@ -3259,7 +3259,7 @@ static void asc_prt_adv_board_eeprom(struct seq_file 
 *m, struct Scsi_Host *shost
   seq_printf(m,  %c,
  (ep_3550-ultra_able  ADV_TID_TO_TIDMASK(i))
  ? 'Y' : 'N');
 - seq_puts(m, \n);
 + seq_putc(m, '\n');
   }
  
   if (adv_dvc_varp-chip_type == ADV_CHIP_ASC3550) {
 @@ -3273,7 +3273,7 @@ static void asc_prt_adv_board_eeprom(struct seq_file 
 *m, struct Scsi_Host *shost
   for (i = 0; i = ADV_MAX_TID; i++)
   seq_printf(m,  %c,
  (word  ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
 - seq_puts(m, \n);
 + seq_putc(m, '\n');
  
   if (adv_dvc_varp-chip_type == 

Re: [PATCH 1/3] scsi: serialize -rescan against -remove

2015-01-29 Thread Fam Zheng
On Fri, 01/30 00:11, Paolo Bonzini wrote:
 
 
 On 29/01/2015 00:00, Christoph Hellwig wrote:
  Lock the device embedded in the scsi_device to protect against
  concurrent calls to -remove.
  
  Signed-off-by: Christoph Hellwig h...@lst.de
 
 I wonder if this makes this problem: https://lkml.org/lkml/2015/1/5/9 go
 away.

A quick test says yes.

Fam

 
 Paolo
 
  ---
   drivers/scsi/scsi_scan.c | 7 +++
   1 file changed, 3 insertions(+), 4 deletions(-)
  
  diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
  index 983aed1..523faee 100644
  --- a/drivers/scsi/scsi_scan.c
  +++ b/drivers/scsi/scsi_scan.c
  @@ -1593,16 +1593,15 @@ EXPORT_SYMBOL(scsi_add_device);
   
   void scsi_rescan_device(struct device *dev)
   {
  -   if (!dev-driver)
  -   return;
  -
  -   if (try_module_get(dev-driver-owner)) {
  +   device_lock(dev);
  +   if (dev-driver  try_module_get(dev-driver-owner)) {
  struct scsi_driver *drv = to_scsi_driver(dev-driver);
   
  if (drv-rescan)
  drv-rescan(dev);
  module_put(dev-driver-owner);
  }
  +   device_unlock(dev);
   }
   EXPORT_SYMBOL(scsi_rescan_device);
   
  
 --
 To unsubscribe from this list: send the line unsubscribe linux-scsi in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCHv2 5/5] scsi: move scsi/sg.h to uapi/linux/sg.h

2015-01-29 Thread James Bottomley
On Thu, 2015-01-29 at 16:56 -0800, Andy Grover wrote:
 This will enable user programs to have access to the most current
 definitions.
 
 Modify include sites for new path.
 
 Signed-off-by: Andy Grover agro...@redhat.com
 ---
  block/bio.c|   2 +-
  block/blk-map.c|   2 +-
  block/bsg.c|   2 +-
  block/scsi_ioctl.c |   2 +-
  drivers/block/aoe/aoeblk.c |   2 +-
  drivers/block/cciss.c  |   2 +-
  drivers/block/nvme-core.c  |   2 +-
  drivers/block/nvme-scsi.c  |   2 +-
  drivers/block/skd_main.c   |   2 +-
  drivers/message/i2o/i2o_scsi.c |   2 +-
  drivers/scsi/ips.c |   2 +-
  drivers/scsi/scsi_error.c  |   2 +-
  drivers/scsi/scsi_ioctl.c  |   2 +-
  drivers/scsi/sg.c  |   2 +-
  drivers/scsi/st.c  |   2 +-
  fs/compat_ioctl.c  |   2 +-
  include/scsi/sg.h  | 274 
 -
  include/uapi/linux/Kbuild  |   1 +
  include/uapi/linux/sg.h| 274 
 +
  kernel/sysctl.c|   2 +-
  20 files changed, 292 insertions(+), 291 deletions(-)
  delete mode 100644 include/scsi/sg.h
  create mode 100644 include/uapi/linux/sg.h
 
 diff --git a/block/bio.c b/block/bio.c
 index 471d738..ca072bb 100644
 --- a/block/bio.c
 +++ b/block/bio.c
 @@ -28,7 +28,7 @@
  #include linux/mempool.h
  #include linux/workqueue.h
  #include linux/cgroup.h
 -#include scsi/sg.h /* for struct sg_iovec */
 +#include uapi/linux/sg.h   /* for struct sg_iovec */

Good grief, not like this, please.  uapi/linux/sg.h becomes our public,
or exported set of interfaces, but keep scsi/sg.h as our internal set
but have it include uapi/linux/sg.h (like you did for scsi.h).  That way
if we have any kernel private sg stuff, it stays in scsi/sg.h plus we
don't need to patch the #include path in fifty odd drivers.

Same goes for scsi_ioctl.h

James


--
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 v2 4/6] scsi: misc: Replace seq_printf with seq_puts

2015-01-29 Thread Finn Thain

Reviewed-by: Finn Thain fth...@telegraphics.com.au

For the NCR5380 bits:

Acked-by: Finn Thain fth...@telegraphics.com.au


On Wed, 3 Dec 2014, Rasmus Villemoes wrote:

 Using seq_printf to print a simple string is a lot more expensive than
 it needs to be, since seq_puts exists. Replace seq_printf with
 seq_puts when possible.
 
 Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk
 ---
  drivers/scsi/BusLogic.c | 10 +-
  drivers/scsi/NCR5380.c  |  4 ++--
  drivers/scsi/aic7xxx/aic79xx_proc.c | 38 
 ++---
  drivers/scsi/aic7xxx/aic7xxx_proc.c | 24 +++
  drivers/scsi/arm/fas216.c   |  6 +++---
  drivers/scsi/atari_NCR5380.c|  4 ++--
  drivers/scsi/atp870u.c  |  6 +++---
  drivers/scsi/dc395x.c   | 17 +
  drivers/scsi/dpt_i2o.c  |  2 +-
  drivers/scsi/eata_pio.c |  2 +-
  drivers/scsi/gdth_proc.c| 24 +++
  drivers/scsi/in2000.c   | 18 +-
  drivers/scsi/ips.c  |  7 +++
  drivers/scsi/megaraid.c |  2 +-
  drivers/scsi/nsp32.c| 14 +++---
  drivers/scsi/pcmcia/nsp_cs.c| 30 ++---
  drivers/scsi/qla2xxx/qla_dfs.c  |  8 
  drivers/scsi/scsi_proc.c| 22 ++---
  drivers/scsi/scsi_trace.c   |  6 +++---
  drivers/scsi/wd33c93.c  | 18 +-
  drivers/scsi/wd7000.c   | 12 ++--
  21 files changed, 136 insertions(+), 138 deletions(-)
 
 diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c
 index 8d66a64..c7be7bb 100644
 --- a/drivers/scsi/BusLogic.c
 +++ b/drivers/scsi/BusLogic.c
 @@ -3485,7 +3485,7 @@ static int blogic_show_info(struct seq_file *m, struct 
 Scsi_Host *shost)
   seq_printf(m, \n\
  Current Driver Queue Depth:  %d\n\
  Currently Allocated CCBs:%d\n, adapter-drvr_qdepth, 
 adapter-alloc_ccbs);
 - seq_printf(m, \n\n\
 + seq_puts(m, \n\n\
  DATA TRANSFER STATISTICS\n\
  \n\
  Target   Tagged Queuing  Queue Depth  Active  Attempted  Completed\n\
 @@ -3500,7 +3500,7 @@ Target  Tagged Queuing  Queue Depth  Active  Attempted  
 Completed\n\
   seq_printf(m,
  %3d   %3u%9u%9u\n, 
 adapter-qdepth[tgt], adapter-active_cmds[tgt], tgt_stats[tgt].cmds_tried, 
 tgt_stats[tgt].cmds_complete);
   }
 - seq_printf(m, \n\
 + seq_puts(m, \n\
  Target  Read Commands  Write Commands   Total Bytes ReadTotal Bytes 
 Written\n\
  ==  =  ==  ===  
 ===\n);
   for (tgt = 0; tgt  adapter-maxdev; tgt++) {
 @@ -3517,7 +3517,7 @@ Target  Read Commands  Write Commands   Total Bytes 
 ReadTotal Bytes Written\
   else
   seq_printf(m,   %9u\n, 
 tgt_stats[tgt].byteswritten.units);
   }
 - seq_printf(m, \n\
 + seq_puts(m, \n\
  Target  Command0-1KB  1-2KB  2-4KB  4-8KB 8-16KB\n\
  ==  ===  =  =  =  =  =\n);
   for (tgt = 0; tgt  adapter-maxdev; tgt++) {
 @@ -3533,7 +3533,7 @@ Target  Command0-1KB  1-2KB  2-4KB  
 4-8KB 8-16KB\n\
   tgt_stats[tgt].write_sz_buckets[0],
   tgt_stats[tgt].write_sz_buckets[1], 
 tgt_stats[tgt].write_sz_buckets[2], tgt_stats[tgt].write_sz_buckets[3], 
 tgt_stats[tgt].write_sz_buckets[4]);
   }
 - seq_printf(m, \n\
 + seq_puts(m, \n\
  Target  Command   16-32KB32-64KB   64-128KB   128-256KB   256KB+\n\
  ==  ===  =  =  =  =  =\n);
   for (tgt = 0; tgt  adapter-maxdev; tgt++) {
 @@ -3549,7 +3549,7 @@ Target  Command   16-32KB32-64KB   64-128KB   
 128-256KB   256KB+\n\
   tgt_stats[tgt].write_sz_buckets[5],
   tgt_stats[tgt].write_sz_buckets[6], 
 tgt_stats[tgt].write_sz_buckets[7], tgt_stats[tgt].write_sz_buckets[8], 
 tgt_stats[tgt].write_sz_buckets[9]);
   }
 - seq_printf(m, \n\n\
 + seq_puts(m, \n\n\
  ERROR RECOVERY STATISTICS\n\
  \n\
 Command Aborts  Bus Device Resets   Host Adapter Resets\n\
 diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
 index aca181e..a30af00 100644
 --- a/drivers/scsi/NCR5380.c
 +++ b/drivers/scsi/NCR5380.c
 @@ -754,7 +754,7 @@ static int __maybe_unused NCR5380_show_info(struct 
 seq_file *m,
  static void lprint_Scsi_Cmnd(struct scsi_cmnd *cmd, struct seq_file *m)
  {
   seq_printf(m, scsi%d : destination target %d, lun %llu\n, 
 cmd-device-host-host_no, cmd-device-id, cmd-device-lun);
 - seq_printf(m, command = );
 + seq_puts(m, command = );
   lprint_command(cmd-cmnd, m);
  }
  
 @@ 

Re: [PATCH v2 3/6] scsi/aha152x: Replace seq_printf with seq_puts

2015-01-29 Thread Finn Thain

Reviewed-by: Finn Thain fth...@telegraphics.com.au


On Wed, 3 Dec 2014, Rasmus Villemoes wrote:

 Using seq_printf to print a simple string is a lot more expensive than
 it needs to be, since seq_puts exists. Replace seq_printf with
 seq_puts when possible.
 
 Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk
 ---
  drivers/scsi/aha152x.c | 248 
 -
  1 file changed, 124 insertions(+), 124 deletions(-)
 
 diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c
 index f14ad8a..e31c460 100644
 --- a/drivers/scsi/aha152x.c
 +++ b/drivers/scsi/aha152x.c
 @@ -2505,21 +2505,21 @@ static void get_command(struct seq_file *m, Scsi_Cmnd 
 * ptr)
   ptr-SCp.buffers_residual);
  
   if (ptr-SCp.phase  not_issued)
 - seq_printf(m, not issued|);
 + seq_puts(m, not issued|);
   if (ptr-SCp.phase  selecting)
 - seq_printf(m, selecting|);
 + seq_puts(m, selecting|);
   if (ptr-SCp.phase  disconnected)
 - seq_printf(m, disconnected|);
 + seq_puts(m, disconnected|);
   if (ptr-SCp.phase  aborted)
 - seq_printf(m, aborted|);
 + seq_puts(m, aborted|);
   if (ptr-SCp.phase  identified)
 - seq_printf(m, identified|);
 + seq_puts(m, identified|);
   if (ptr-SCp.phase  completed)
 - seq_printf(m, completed|);
 + seq_puts(m, completed|);
   if (ptr-SCp.phase  spiordy)
 - seq_printf(m, spiordy|);
 + seq_puts(m, spiordy|);
   if (ptr-SCp.phase  syncneg)
 - seq_printf(m, syncneg|);
 + seq_puts(m, syncneg|);
   seq_printf(m, ; next=0x%p\n, SCNEXT(ptr));
  }
  
 @@ -2530,256 +2530,256 @@ static void get_ports(struct seq_file *m, struct 
 Scsi_Host *shpnt)
   seq_printf(m, \n%s: %s(%s) , CURRENT_SC ? on bus : waiting, 
 states[STATE].name, states[PREVSTATE].name);
  
   s = GETPORT(SCSISEQ);
 - seq_printf(m, SCSISEQ( );
 + seq_puts(m, SCSISEQ( );
   if (s  TEMODEO)
 - seq_printf(m, TARGET MODE );
 + seq_puts(m, TARGET MODE );
   if (s  ENSELO)
 - seq_printf(m, SELO );
 + seq_puts(m, SELO );
   if (s  ENSELI)
 - seq_printf(m, SELI );
 + seq_puts(m, SELI );
   if (s  ENRESELI)
 - seq_printf(m, RESELI );
 + seq_puts(m, RESELI );
   if (s  ENAUTOATNO)
 - seq_printf(m, AUTOATNO );
 + seq_puts(m, AUTOATNO );
   if (s  ENAUTOATNI)
 - seq_printf(m, AUTOATNI );
 + seq_puts(m, AUTOATNI );
   if (s  ENAUTOATNP)
 - seq_printf(m, AUTOATNP );
 + seq_puts(m, AUTOATNP );
   if (s  SCSIRSTO)
 - seq_printf(m, SCSIRSTO );
 - seq_printf(m, ););
 + seq_puts(m, SCSIRSTO );
 + seq_puts(m, ););
  
 - seq_printf(m,  SCSISIG();
 + seq_puts(m,  SCSISIG();
   s = GETPORT(SCSISIG);
   switch (s  P_MASK) {
   case P_DATAO:
 - seq_printf(m, DATA OUT);
 + seq_puts(m, DATA OUT);
   break;
   case P_DATAI:
 - seq_printf(m, DATA IN);
 + seq_puts(m, DATA IN);
   break;
   case P_CMD:
 - seq_printf(m, COMMAND);
 + seq_puts(m, COMMAND);
   break;
   case P_STATUS:
 - seq_printf(m, STATUS);
 + seq_puts(m, STATUS);
   break;
   case P_MSGO:
 - seq_printf(m, MESSAGE OUT);
 + seq_puts(m, MESSAGE OUT);
   break;
   case P_MSGI:
 - seq_printf(m, MESSAGE IN);
 + seq_puts(m, MESSAGE IN);
   break;
   default:
 - seq_printf(m, *invalid*);
 + seq_puts(m, *invalid*);
   break;
   }
  
 - seq_printf(m, ); );
 + seq_puts(m, ); );
  
   seq_printf(m, INTSTAT (%s); , TESTHI(DMASTAT, INTSTAT) ? hi : lo);
  
 - seq_printf(m, SSTAT( );
 + seq_puts(m, SSTAT( );
   s = GETPORT(SSTAT0);
   if (s  TARGET)
 - seq_printf(m, TARGET );
 + seq_puts(m, TARGET );
   if (s  SELDO)
 - seq_printf(m, SELDO );
 + seq_puts(m, SELDO );
   if (s  SELDI)
 - seq_printf(m, SELDI );
 + seq_puts(m, SELDI );
   if (s  SELINGO)
 - seq_printf(m, SELINGO );
 + seq_puts(m, SELINGO );
   if (s  SWRAP)
 - seq_printf(m, SWRAP );
 + seq_puts(m, SWRAP );
   if (s  SDONE)
 - seq_printf(m, SDONE );
 + seq_puts(m, SDONE );
   if (s  SPIORDY)
 - seq_printf(m, SPIORDY );
 + seq_puts(m, SPIORDY );
   if (s  DMADONE)
 - seq_printf(m, DMADONE );
 + seq_puts(m, DMADONE );
  
   s = GETPORT(SSTAT1);
   if (s  SELTO)
 - seq_printf(m, SELTO 

Re: [PATCHv2 3/5] scsi: Move user-shareable stuff in scsi/scsi.h to uapi/linux/scsi.h

2015-01-29 Thread James Bottomley
On Thu, 2015-01-29 at 16:56 -0800, Andy Grover wrote:
 A great many SCSI codes can be made available to userspace in a uapi
 header, while the kernel-only definitions stay in scsi/scsi.h.
 
 This will permit userspace apps to stop using the antiquated definitions
 available in glibc's scsi/scsi.h, which are very old and incomplete.
 
 scsi/scsi.h also includes uapi/scsi/scsi.h so kernel code need not update
 includes.
 
 Signed-off-by: Andy Grover agro...@redhat.com
 ---
  include/scsi/scsi.h   | 497 +
  include/uapi/linux/Kbuild |   1 +
  include/uapi/linux/scsi.h | 506 
 ++

I think this is too much: lots of things in scsi.h have no meaning to
the user: our internal definition of scsi_lun for instance, internal
return codes, mid level queue instructions, our internal markers for
SCSI levels ...

What you put in this file becomes a contract for userspace.  The rule
should be don't put anything in unless we want the user to use it (and
we're willing to stick by it).

I really think that nothing that isn't already
in /usr/include/scsi/scsi.h is a great rule to follow and then, if
necessary, justify why any additional stuff.

James


--
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 1/1] scsi: Fix max transfer length for 4k disks

2015-01-29 Thread Paolo Bonzini


On 29/01/2015 22:54, Brian King wrote:
 The following patch fixes an issue observed with 4k sector disks
 where the max_hw_sectors attribute was getting set too large in
 sd_revalidate_disk. Since sdkp-max_xfer_blocks is in units
 of SCSI logical blocks and queue_max_hw_sectors is in units of
 512 byte blocks, on a 4k sector disk, every time we went through
 sd_revalidate_disk, we were taking the current value of
 queue_max_hw_sectors and increasing it by a factor of 8. Fix
 this by only shifting sdkp-max_xfer_blocks.
 
 Cc: stablesta...@vger.kernel.org
 Signed-off-by: Brian King brk...@linux.vnet.ibm.com
 ---
 
  drivers/scsi/sd.c |6 --
  1 file changed, 4 insertions(+), 2 deletions(-)
 
 diff -puN drivers/scsi/sd.c~sd_revalidate_4k drivers/scsi/sd.c
 --- linux/drivers/scsi/sd.c~sd_revalidate_4k  2015-01-29 14:44:23.316171187 
 -0600
 +++ linux-bjking1/drivers/scsi/sd.c   2015-01-29 14:51:05.846126392 -0600
 @@ -2800,9 +2800,11 @@ static int sd_revalidate_disk(struct gen
*/
   sd_set_flush_flag(sdkp);
  
 - max_xfer = min_not_zero(queue_max_hw_sectors(sdkp-disk-queue),
 - sdkp-max_xfer_blocks);
 + max_xfer = sdkp-max_xfer_blocks;
   max_xfer = ilog2(sdp-sector_size) - 9;
 +
 + max_xfer = min_not_zero(queue_max_hw_sectors(sdkp-disk-queue),
 + max_xfer);
   blk_queue_max_hw_sectors(sdkp-disk-queue, max_xfer);
   set_capacity(disk, sdkp-capacity);
   sd_config_write_same(sdkp);
 _
 
 --
 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
 

Reviewed-by: Paolo Bonzini pbonz...@redhat.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


Re: [PATCH v2 1/6] scsi: Remove SPRINTF macro

2015-01-29 Thread Finn Thain

On Wed, 3 Dec 2014, Rasmus Villemoes wrote:

 The macro SPRINTF doesn't save a lot of typing or make the code more
 readable, and depending on a specific identifier (m) in the
 surrounding scope is generally frowned upon. Nuke it.

Yes. I was going to eliminate this macro from NCR5380.c too, for 
consistency with atari_NCR5380.

Reviewed-by: Finn Thain fth...@telegraphics.com.au

For the NCR5380 bits:

Acked-by: Finn Thain fth...@telegraphics.com.au


 
 Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk
 ---
  drivers/scsi/NCR5380.c   |  20 ++-
  drivers/scsi/aha152x.c   | 295 
 +--
  drivers/scsi/dc395x.c|  78 ++--
  drivers/scsi/nsp32.c |  41 +++---
  drivers/scsi/pcmcia/nsp_cs.c |  50 
  drivers/scsi/wd7000.c|  41 +++---
  6 files changed, 252 insertions(+), 273 deletions(-)
 
 diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
 index 36244d6..aca181e 100644
 --- a/drivers/scsi/NCR5380.c
 +++ b/drivers/scsi/NCR5380.c
 @@ -716,8 +716,6 @@ static int __maybe_unused NCR5380_write_info(struct 
 Scsi_Host *instance,
  }
  #endif
  
 -#undef SPRINTF
 -#define SPRINTF(args...) seq_printf(m, ## args)
  static
  void lprint_Scsi_Cmnd(struct scsi_cmnd *cmd, struct seq_file *m);
  static
 @@ -734,19 +732,19 @@ static int __maybe_unused NCR5380_show_info(struct 
 seq_file *m,
   hostdata = (struct NCR5380_hostdata *) instance-hostdata;
  
  #ifdef PSEUDO_DMA
 - SPRINTF(Highwater I/O busy spin counts: write %d, read %d\n,
 + seq_printf(m, Highwater I/O busy spin counts: write %d, read %d\n,
   hostdata-spin_max_w, hostdata-spin_max_r);
  #endif
   spin_lock_irq(instance-host_lock);
   if (!hostdata-connected)
 - SPRINTF(scsi%d: no currently connected command\n, 
 instance-host_no);
 + seq_printf(m, scsi%d: no currently connected command\n, 
 instance-host_no);
   else
   lprint_Scsi_Cmnd((struct scsi_cmnd *) hostdata-connected, m);
 - SPRINTF(scsi%d: issue_queue\n, instance-host_no);
 + seq_printf(m, scsi%d: issue_queue\n, instance-host_no);
   for (ptr = (struct scsi_cmnd *) hostdata-issue_queue; ptr; ptr = 
 (struct scsi_cmnd *) ptr-host_scribble)
   lprint_Scsi_Cmnd(ptr, m);
  
 - SPRINTF(scsi%d: disconnected_queue\n, instance-host_no);
 + seq_printf(m, scsi%d: disconnected_queue\n, instance-host_no);
   for (ptr = (struct scsi_cmnd *) hostdata-disconnected_queue; ptr; ptr 
 = (struct scsi_cmnd *) ptr-host_scribble)
   lprint_Scsi_Cmnd(ptr, m);
   spin_unlock_irq(instance-host_lock);
 @@ -755,8 +753,8 @@ static int __maybe_unused NCR5380_show_info(struct 
 seq_file *m,
  
  static void lprint_Scsi_Cmnd(struct scsi_cmnd *cmd, struct seq_file *m)
  {
 - SPRINTF(scsi%d : destination target %d, lun %llu\n, 
 cmd-device-host-host_no, cmd-device-id, cmd-device-lun);
 - SPRINTF(command = );
 + seq_printf(m, scsi%d : destination target %d, lun %llu\n, 
 cmd-device-host-host_no, cmd-device-id, cmd-device-lun);
 + seq_printf(m, command = );
   lprint_command(cmd-cmnd, m);
  }
  
 @@ -765,13 +763,13 @@ static void lprint_command(unsigned char *command, 
 struct seq_file *m)
   int i, s;
   lprint_opcode(command[0], m);
   for (i = 1, s = COMMAND_SIZE(command[0]); i  s; ++i)
 - SPRINTF(%02x , command[i]);
 - SPRINTF(\n);
 + seq_printf(m, %02x , command[i]);
 + seq_printf(m, \n);
  }
  
  static void lprint_opcode(int opcode, struct seq_file *m)
  {
 - SPRINTF(%2d (0x%02x), opcode, opcode);
 + seq_printf(m, %2d (0x%02x), opcode, opcode);
  }
  
  
 diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c
 index 2b960b3..f14ad8a 100644
 --- a/drivers/scsi/aha152x.c
 +++ b/drivers/scsi/aha152x.c
 @@ -2490,299 +2490,296 @@ static void show_queues(struct Scsi_Host *shpnt)
   disp_enintr(shpnt);
  }
  
 -#undef SPRINTF
 -#define SPRINTF(args...) seq_printf(m, ##args)
 -
  static void get_command(struct seq_file *m, Scsi_Cmnd * ptr)
  {
   int i;
  
 - SPRINTF(%p: target=%d; lun=%d; cmnd=( ,
 + seq_printf(m, %p: target=%d; lun=%d; cmnd=( ,
   ptr, ptr-device-id, (u8)ptr-device-lun);
  
   for (i = 0; i  COMMAND_SIZE(ptr-cmnd[0]); i++)
 - SPRINTF(0x%02x , ptr-cmnd[i]);
 + seq_printf(m, 0x%02x , ptr-cmnd[i]);
  
 - SPRINTF(); resid=%d; residual=%d; buffers=%d; phase |,
 + seq_printf(m, ); resid=%d; residual=%d; buffers=%d; phase |,
   scsi_get_resid(ptr), ptr-SCp.this_residual,
   ptr-SCp.buffers_residual);
  
   if (ptr-SCp.phase  not_issued)
 - SPRINTF(not issued|);
 + seq_printf(m, not issued|);
   if (ptr-SCp.phase  selecting)
 - SPRINTF(selecting|);
 + seq_printf(m, selecting|);
   if (ptr-SCp.phase  disconnected)
 - SPRINTF(disconnected|);
 + 

Re: [PATCH 2/4] Fix for crash when bfa_itnim is NULL

2015-01-29 Thread Julian Calaby
Hi Anil,

On Thu, Jan 29, 2015 at 7:55 PM,  anil.gurumur...@qlogic.com wrote:
 From: Anil Gurumurthy anil.gurumur...@qlogic.com

 Signed-off-by: Sudarsana Kalluru sudarsana.kall...@qlogic.com
 Signed-off-by: Anil Gurumurthy anil.gurumur...@qlogic.com
 ---
  drivers/scsi/bfa/bfa_fcs_lport.c |2 +-
  drivers/scsi/bfa/bfad_im.c   |   26 ++
  2 files changed, 27 insertions(+), 1 deletions(-)

 diff --git a/drivers/scsi/bfa/bfa_fcs_lport.c 
 b/drivers/scsi/bfa/bfa_fcs_lport.c
 index d823792..4631630 100644
 --- a/drivers/scsi/bfa/bfa_fcs_lport.c
 +++ b/drivers/scsi/bfa/bfa_fcs_lport.c
 @@ -2654,7 +2654,7 @@ bfa_fcs_fdmi_get_hbaattr(struct bfa_fcs_lport_fdmi_s 
 *fdmi,

 strncpy(hba_attr-node_sym_name.symname,
 port-port_cfg.node_sym_name.symname, BFA_SYMNAME_MAXLEN);
 -   strcpy(hba_attr-vendor_info, BROCADE);
 +   strcpy(hba_attr-vendor_info, QLogic);

Shouldn't this be in the next patch?

Thanks,

-- 
Julian Calaby

Email: julian.cal...@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/
--
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 v2 5/6] scsi: misc: Merge consecutive seq_puts calls

2015-01-29 Thread Finn Thain

Reviewed-by: Finn Thain fth...@telegraphics.com.au


On Wed, 3 Dec 2014, Rasmus Villemoes wrote:

 Consecutive seq_puts calls with literal strings may be replaced by a
 single call, saving a little .text.
 
 Signed-off-by: Rasmus Villemoes li...@rasmusvillemoes.dk
 ---
  drivers/scsi/advansys.c  | 43 +++
  drivers/scsi/atp870u.c   |  5 ++---
  drivers/scsi/dc395x.c|  4 ++--
  drivers/scsi/pcmcia/nsp_cs.c |  4 ++--
  4 files changed, 21 insertions(+), 35 deletions(-)
 
 diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
 index d31fc6d..c4d0910 100644
 --- a/drivers/scsi/advansys.c
 +++ b/drivers/scsi/advansys.c
 @@ -2903,11 +2903,9 @@ static void asc_prt_adv_bios(struct seq_file *m, 
 struct Scsi_Host *shost)
* the BIOS code segment base address.
*/
   if (boardp-bios_signature != 0x55AA) {
 - seq_puts(m, Disabled or Pre-3.1\n);
 - seq_puts(m,
 -  BIOS either disabled or Pre-3.1. If it is pre-3.1, 
 then a newer version\n);
 - seq_puts(m,
 -  can be found at the ConnectCom FTP site: 
 ftp://ftp.connectcom.net/pub\n;);
 + seq_puts(m, Disabled or Pre-3.1\n
 + BIOS either disabled or Pre-3.1. If it is pre-3.1, 
 then a newer version\n
 + can be found at the ConnectCom FTP site: 
 ftp://ftp.connectcom.net/pub\n;);
   } else {
   major = (boardp-bios_version  12)  0xF;
   minor = (boardp-bios_version  8)  0xF;
 @@ -2923,9 +2921,8 @@ static void asc_prt_adv_bios(struct seq_file *m, struct 
 Scsi_Host *shost)
*/
   if (major  3 || (major = 3  minor  1) ||
   (major = 3  minor = 1  letter  ('I' - 'A'))) {
 - seq_puts(m,
 -  Newer version of ROM BIOS is available at the 
 ConnectCom FTP site:\n);
 - seq_puts(m, ftp://ftp.connectcom.net/pub\n;);
 + seq_puts(m, Newer version of ROM BIOS is available at 
 the ConnectCom FTP site:\n
 + ftp://ftp.connectcom.net/pub\n;);
   }
   }
  }
 @@ -3071,27 +3068,23 @@ static void asc_prt_asc_board_eeprom(struct seq_file 
 *m, struct Scsi_Host *shost
   seq_puts(m,  Target ID:   );
   for (i = 0; i = ASC_MAX_TID; i++)
   seq_printf(m,  %d, i);
 - seq_puts(m, \n);
  
 - seq_puts(m,  Disconnects: );
 + seq_puts(m, \n Disconnects: );
   for (i = 0; i = ASC_MAX_TID; i++)
   seq_printf(m,  %c,
  (ep-disc_enable  ADV_TID_TO_TIDMASK(i)) ? 'Y' : 
 'N');
 - seq_puts(m, \n);
  
 - seq_puts(m,  Command Queuing: );
 + seq_puts(m, \n Command Queuing: );
   for (i = 0; i = ASC_MAX_TID; i++)
   seq_printf(m,  %c,
  (ep-use_cmd_qng  ADV_TID_TO_TIDMASK(i)) ? 'Y' : 
 'N');
 - seq_puts(m, \n);
  
 - seq_puts(m,  Start Motor: );
 + seq_puts(m, \n Start Motor: );
   for (i = 0; i = ASC_MAX_TID; i++)
   seq_printf(m,  %c,
  (ep-start_motor  ADV_TID_TO_TIDMASK(i)) ? 'Y' : 
 'N');
 - seq_puts(m, \n);
  
 - seq_puts(m,  Synchronous Transfer:);
 + seq_puts(m, \n Synchronous Transfer:);
   for (i = 0; i = ASC_MAX_TID; i++)
   seq_printf(m,  %c,
  (ep-init_sdtr  ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
 @@ -3410,10 +3403,9 @@ static void asc_prt_asc_board_info(struct seq_file *m, 
 struct Scsi_Host *shost)
  i,
  (v-use_tagged_qng  ADV_TID_TO_TIDMASK(i)) ? 'Y' : 
 'N');
   }
 - seq_puts(m, \n);
  
   /* Current number of commands waiting for a device. */
 - seq_puts(m,  Command Queue Pending:);
 + seq_puts(m, \n Command Queue Pending:);
   for (i = 0; i = ASC_MAX_TID; i++) {
   if ((chip_scsi_id == i) ||
   ((boardp-init_tidmask  ADV_TID_TO_TIDMASK(i)) == 0)) {
 @@ -3421,10 +3413,9 @@ static void asc_prt_asc_board_info(struct seq_file *m, 
 struct Scsi_Host *shost)
   }
   seq_printf(m,  %X:%u, i, v-cur_dvc_qng[i]);
   }
 - seq_puts(m, \n);
  
   /* Current limit on number of commands that can be sent to a device. */
 - seq_puts(m,  Command Queue Limit:);
 + seq_puts(m, \n Command Queue Limit:);
   for (i = 0; i = ASC_MAX_TID; i++) {
   if ((chip_scsi_id == i) ||
   ((boardp-init_tidmask  ADV_TID_TO_TIDMASK(i)) == 0)) {
 @@ -3432,10 +3423,9 @@ static void asc_prt_asc_board_info(struct seq_file *m, 
 struct Scsi_Host *shost)
   }
   seq_printf(m,  %X:%u, i, v-max_dvc_qng[i]);
   }
 - seq_puts(m, \n);
  
   /* Indicate whether the device has returned queue full status. */
 - seq_puts(m,  Command Queue Full:);
 +