aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/scsi_debug.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2015-02-13scsi: use %*pb[l] to print bitmaps including cpumasks and nodemasksTejun Heo1-3/+3
printk and friends can now format bitmaps using '%*pb[l]'. cpumask and nodemask also provide cpumask_pr_args() and nodemask_pr_args() respectively which can be used to generate the two printf arguments necessary to format the specified cpu/nodemask. * map_show()'s return value is too high by one and the function could modify beyond the end of the buffer when the formatted text is long enough. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-02-11Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsiLinus Torvalds1-3/+125
Pull first round of SCSI updates from James Bottomley: "This is the usual grab bag of driver updates (hpsa, storvsc, mp2sas, megaraid_sas, ses) plus an assortment of minor updates. There's also an update to ufs which adds new phy drivers and finally a new logging infrastructure for SCSI" * tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: (114 commits) scsi_logging: return void for dev_printk() functions scsi: print single-character strings with seq_putc scsi: merge consecutive seq_puts calls scsi: replace seq_printf with seq_puts aha152x: replace seq_printf with seq_puts advansys: replace seq_printf with seq_puts scsi: remove SPRINTF macro sg: remove an unused variable hpsa: Use local workqueues instead of system workqueues hpsa: add in P840ar controller model name hpsa: add in gen9 controller model names hpsa: detect and report failures changing controller transport modes hpsa: shorten the wait for the CISS doorbell mode change ack hpsa: refactor duplicated scan completion code into a new routine hpsa: move SG descriptor set-up out of hpsa_scatter_gather() hpsa: do not use function pointers in fast path command submission hpsa: print CDBs instead of kernel virtual addresses for uncommon errors hpsa: do not use a void pointer for scsi_cmd field of struct CommandList hpsa: return failed from device reset/abort handlers hpsa: check for ctlr lockup after command allocation in main io path ...
2015-01-22scsi_debug: test always evaluates to false, || should be used insteadColin Ian King1-1/+1
cppcheck found the following issue: (warning) Logical conjunction always evaluates to false: alloc_len < 4 && alloc_len > 65535. ..the test should be instead: if (alloc_len < 4 || alloc_len > 65536) This error was introduced by recent commit 38d5c8336e60bf6e53a1da9 ("scsi_debug: add Report supported opcodes+tmfs; Compare and write") Signed-off-by: Colin Ian King <colin.king@canonical.com> Acked-by: Douglas Gilbert <dgilbert@interlog.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
2015-01-20scsi_debug: use atomic allocation in resp_rsup_opcodesSasha Levin1-1/+1
resp_rsup_opcodes() may get called from atomic context and would need to use GFP_ATOMIC for allocations: [ 1237.913419] BUG: sleeping function called from invalid context at mm/slub.c:1262 [ 1237.914865] in_atomic(): 1, irqs_disabled(): 0, pid: 7556, name: trinity-c311 [ 1237.916142] 3 locks held by trinity-c311/7556: [ 1237.916981] #0: (sb_writers#5){.+.+.+}, at: do_readv_writev (include/linux/fs.h:2346 fs/read_write.c:844) [ 1237.919713] #1: (&of->mutex){+.+.+.}, at: kernfs_fop_write (fs/kernfs/file.c:297) [ 1237.922626] Mutex: counter: -1 owner: trinity-c311 [ 1237.924044] #2: (s_active#51){.+.+.+}, at: kernfs_fop_write (fs/kernfs/file.c:297) [ 1237.925960] Preemption disabled blk_execute_rq_nowait (block/blk-exec.c:95) [ 1237.927416] [ 1237.927680] CPU: 24 PID: 7556 Comm: trinity-c311 Not tainted 3.19.0-rc4-next-20150116-sasha-00054-g4ad498c-dirty #1744 [ 1237.929603] ffff8804fc9d8000 ffff8804d9bc3548 ffffffff9d439fb2 0000000000000000 [ 1237.931097] 0000000000000000 ffff8804d9bc3588 ffffffff9a18389a ffff8804d9bc3598 [ 1237.932466] ffffffff9a1b1715 ffffffffa15935d8 ffffffff9e6f8cb1 00000000000004ee [ 1237.933984] Call Trace: [ 1237.934434] dump_stack (lib/dump_stack.c:52) [ 1237.935323] ___might_sleep (kernel/sched/core.c:7339) [ 1237.936259] ? mark_held_locks (kernel/locking/lockdep.c:2549) [ 1237.937293] __might_sleep (kernel/sched/core.c:7305) [ 1237.938272] __kmalloc (mm/slub.c:1262 mm/slub.c:2419 mm/slub.c:2491 mm/slub.c:3291) [ 1237.939137] ? resp_rsup_opcodes (include/linux/slab.h:435 drivers/scsi/scsi_debug.c:1689) [ 1237.940173] resp_rsup_opcodes (include/linux/slab.h:435 drivers/scsi/scsi_debug.c:1689) [ 1237.941211] ? add_host_store (drivers/scsi/scsi_debug.c:1584) [ 1237.942261] scsi_debug_queuecommand (drivers/scsi/scsi_debug.c:5276) [ 1237.943404] ? blk_rq_map_sg (block/blk-merge.c:254) [ 1237.944398] ? scsi_init_sgtable (drivers/scsi/scsi_lib.c:1095) [ 1237.945402] sdebug_queuecommand_lock_or_not (drivers/scsi/scsi_debug.c:5300) [ 1237.946735] scsi_dispatch_cmd (drivers/scsi/scsi_lib.c:1706) [ 1237.947720] scsi_queue_rq (drivers/scsi/scsi_lib.c:1996) [ 1237.948687] __blk_mq_run_hw_queue (block/blk-mq.c:816) [ 1237.949796] blk_mq_run_hw_queue (block/blk-mq.c:896) [ 1237.950903] ? _raw_spin_unlock (./arch/x86/include/asm/preempt.h:95 include/linux/spinlock_api_smp.h:154 kernel/locking/spinlock.c:183) [ 1237.951862] blk_mq_insert_request (block/blk-mq.c:1037) [ 1237.952876] blk_execute_rq_nowait (block/blk-exec.c:95) [ 1237.953981] ? lockdep_init_map (kernel/locking/lockdep.c:3034) [ 1237.954967] blk_execute_rq (block/blk-exec.c:131) [ 1237.955929] ? blk_rq_bio_prep (block/blk-core.c:2835) [ 1237.956913] scsi_execute (drivers/scsi/scsi_lib.c:252) [ 1237.957821] scsi_execute_req_flags (drivers/scsi/scsi_lib.c:281) [ 1237.958968] scsi_report_opcode (drivers/scsi/scsi.c:956) [ 1237.960009] sd_revalidate_disk (drivers/scsi/sd.c:2707 drivers/scsi/sd.c:2792) [ 1237.961139] revalidate_disk (fs/block_dev.c:1081) [ 1237.962223] sd_rescan (drivers/scsi/sd.c:1532) [ 1237.963142] scsi_rescan_device (drivers/scsi/scsi_scan.c:1579) [ 1237.964165] store_rescan_field (drivers/scsi/scsi_sysfs.c:672) [ 1237.965254] dev_attr_store (drivers/base/core.c:138) [ 1237.966319] sysfs_kf_write (fs/sysfs/file.c:131) [ 1237.967289] kernfs_fop_write (fs/kernfs/file.c:311) [ 1237.968274] do_readv_writev (fs/read_write.c:722 fs/read_write.c:854) [ 1237.969295] ? __acct_update_integrals (kernel/tsacct.c:145) [ 1237.970452] ? kernfs_fop_open (fs/kernfs/file.c:271) [ 1237.971505] ? _raw_spin_unlock (./arch/x86/include/asm/preempt.h:95 include/linux/spinlock_api_smp.h:154 kernel/locking/spinlock.c:183) [ 1237.972512] ? context_tracking_user_exit (include/linux/vtime.h:89 include/linux/jump_label.h:114 include/trace/events/context_tracking.h:47 kernel/context_tracking.c:140) [ 1237.973668] ? trace_hardirqs_on_caller (kernel/locking/lockdep.c:2578 kernel/locking/lockdep.c:2625) [ 1237.974882] ? trace_hardirqs_on (kernel/locking/lockdep.c:2633) [ 1237.975850] vfs_writev (fs/read_write.c:893) [ 1237.976691] SyS_writev (fs/read_write.c:926 fs/read_write.c:917) [ 1237.977538] system_call_fastpath (arch/x86/kernel/entry_64.S:423) Signed-off-by: Sasha Levin <sasha.levin@oracle.com> Acked-by: Douglas Gilbert <dgilbert@interlog.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
2015-01-09scsi_debug: Implement WRITE BUFFER commandEwan D. Milne1-3/+71
Accept the WRITE BUFFER command and do nothing other than set the appropriate "microcode has been changed" UA on the LU. >From an earlier patch by Doug Gilbert. Signed-off-by: Ewan D. Milne <emilne@redhat.com> Acked-by: Douglas Gilbert <dgilbert@interlog.com> Tested-by: Douglas Gilbert <dgilbert@interlog.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
2015-01-09scsi_debug: Add REPORTED LUNS DATA HAS CHANGED Unit AttentionEwan D. Milne1-1/+55
Generate a REPORTED LUNS DATA HAS CHANGED Unit Attention if sysfs "max_luns" is used to change the number of scsi_debug LUNs. This is only done if scsi_debug_scsi_level is SPC-3 or above. Additionally, implement SPC-4 behavior which only generates this Unit Attention on the first LUN on the target to receive a command after the change. This condition is cleared when a REPORT LUNS command is received. Signed-off-by: Ewan D. Milne <emilne@redhat.com> Acked-by: Douglas Gilbert <dgilbert@interlog.com> Tested-by: Douglas Gilbert <dgilbert@interlog.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-12-15scsi_debug: fix missing "break;" in SDEBUG_UA_CAPACITY_CHANGED caseEwan D. Milne1-0/+1
This eliminates a superfluous log message when the capacity is changed: "check_readiness: unexpected unit attention code=3" Signed-off-by: Ewan D. Milne <emilne@redhat.com> Acked-by: Douglas Gilbert <dgilbert@interlog.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-12-15scsi_debug: take sdebug_host_list_lock when changing capacityEwan D. Milne1-0/+2
All other traversals of the sdebug_host_list take the lock. Signed-off-by: Ewan D. Milne <emilne@redhat.com> Acked-by: Douglas Gilbert <dgilbert@interlog.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-12-15scsi_debug: fix compare and write errorsDouglas Gilbert1-15/+16
Kernel build tools pointed out a memory leak so that has been fixed and its error paths strengthened with a goto. Testing showed compare and write was only working for lba=0; correcting the length of the LBA field fixed that. Signed-off-by: Douglas Gilbert <dgilbert@interlog.com> Reviewed-by: Ewan D. Milne <emilne@redhat.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-12-04scsi: remove MSG_*_TAG definesChristoph Hellwig1-1/+0
For SPI drivers use the message definitions from scsi.h, and for target drivers introduce a new TCM_*_TAG namespace. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com
2014-12-04scsi: remove ->change_queue_type methodChristoph Hellwig1-27/+0
Since we got rid of ordered tag support in 2010 the prime use case of switching on and off ordered tags has been obsolete. The other function of enabling/disabling tagging entirely has only been correctly implemented by the 53c700 driver and isn't generally useful. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com Reviewed-by: Hannes Reinecke <hare@suse.de>
2014-11-25scsi_debug: add Report supported opcodes+tmfs; Compare and writeDouglas Gilbert1-19/+307
The Report supported operation codes command is very closely integrated into the table driven parser and very useful for testing it. Its cdb masks form the basis of the 'strict' parameter's checks. The Report supported TMFs command is a simple extension. The Compare and write command may even be useful, as it should be atomic due to the read-write lock that the driver uses on its backing store (ram). Signed-off-by: Douglas Gilbert <dgilbert@interlog.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-11-25scsi_debug: change SCSI command parser to table drivenDouglas Gilbert1-558/+833
The existing 'big switch' parser in queuecommand() is changed to a table driven parser. The old and new queuecommand() were moved in the source so diff would not shuffle them. Apart from the new tables most other changes are refactoring existing response code to be more easily called out of the table parser. The 'strict' parameter is added so that cdb_s can be checked for non-zero values in parts of the cdb that are reserved. Some other changes include: tweak request sense response when D_SENSE differs; support NDOB in Write Same(16); and fix crash in Get LBA Status when LBP was inactive. Signed-off-by: Douglas Gilbert <dgilbert@interlog.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-11-25scsi_debug: add Capacity Changed Unit AttentionDouglas Gilbert1-4/+24
Via sysfs the virtual_gb scsi_debug parameter can be changed while LUs are in use. If that changes, the 'Capacity data has changed' Unit Attention is queued on all LUs. Signed-off-by: Douglas Gilbert <dgilbert@interlog.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-11-25scsi_debug: append inject error flags onto scsi_cmnd objectDouglas Gilbert1-0/+68
The way the existing scsi_debug command parser associated various inject error flags to a command was difficult to replicate in the table driven parser. This patch adds infrastructure to append those flags to the end of a scsi_cmnd object with the cmd_size host template option. Signed-off-by: Douglas Gilbert <dgilbert@interlog.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-11-25scsi_debug: pinpoint invalid field in sense dataDouglas Gilbert1-50/+88
Use Sense Key Specific field in the sense data of an ILLEGAL REQUEST to optionally pinpoint the location of the problem field. This may be either in the cdb or the associated parameter list. Signed-off-by: Douglas Gilbert <dgilbert@interlog.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-11-24scsi: drop reason argument from ->change_queue_depthChristoph Hellwig1-2/+2
Drop the now unused reason argument from the ->change_queue_depth method. Also add a return value to scsi_adjust_queue_depth, and rename it to scsi_change_queue_depth now that it can be used as the default ->change_queue_depth implementation. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Mike Christie <michaelc@cs.wisc.edu> Reviewed-by: Hannes Reinecke <hare@suse.de>
2014-11-24scsi: avoid ->change_queue_depth indirection for queue full trackingChristoph Hellwig1-37/+12
All drivers use the implementation for ramping the queue up and down, so instead of overloading the change_queue_depth method call the implementation diretly if the driver opts into it by setting the track_queue_depth flag in the host template. Note that a few drivers validated the new queue depth in their change_queue_depth method, but as we never go over the queue depth set during slave_configure or the sysfs file this isn't nessecary and can safely be removed. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Mike Christie <michaelc@cs.wisc.edu> Reviewed-by: Hannes Reinecke <hare@suse.de> Reviewed-by: Venkatesh Srinivas <venkateshs@google.com>
2014-11-12scsi_debug: error message should say scsi_host_alloc not scsi_registerFinn Thain1-1/+1
Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Acked-by: Douglas Gilbert <dgilbert@interlog.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-11-12scsi: don't force tagged_supported in driversChristoph Hellwig1-1/+0
Now that we also get proper values in cmd->request->tag for untagged commands, there is no need to force tagged_supported to on in drivers that need host-wide tags. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Mike Christie <michaelc@cs.wisc.edu> Reviewed-by: Hannes Reinecke <hare@suse.de>
2014-11-12scsi: don't set tagging state from scsi_adjust_queue_depthChristoph Hellwig1-5/+2
Remove the tagged argument from scsi_adjust_queue_depth, and just let it handle the queue depth. For most drivers those two are fairly separate, given that most modern drivers don't care about the SCSI "tagged" status of a command at all, and many old drivers allow queuing of multiple untagged commands in the driver. Instead we start out with the ->simple_tags flag set before calling ->slave_configure, which is how all drivers actually looking at ->simple_tags except for one worke anyway. The one other case looks broken, but I've kept the behavior as-is for now. Except for that we only change ->simple_tags from the ->change_queue_type, and when rejecting a tag message in a single driver, so keeping this churn out of scsi_adjust_queue_depth is a clear win. Now that the usage of scsi_adjust_queue_depth is more obvious we can also remove all the trivial instances in ->slave_alloc or ->slave_configure that just set it to the cmd_per_lun default. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Mike Christie <michaelc@cs.wisc.edu> Reviewed-by: Hannes Reinecke <hare@suse.de> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
2014-11-12scsi: provide a generic change_queue_type methodChristoph Hellwig1-8/+1
Most drivers use exactly the same implementation, so provide it as a library function. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Mike Christie <michaelc@cs.wisc.edu> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Reviewed-by: Hannes Reinecke <hare@suse.de>
2014-10-14scsi: replace strnicmp with strncasecmpRasmus Villemoes1-1/+1
The kernel used to contain two functions for length-delimited, case-insensitive string comparison, strnicmp with correct semantics and a slightly buggy strncasecmp. The latter is the POSIX name, so strnicmp was renamed to strncasecmp, and strnicmp made into a wrapper for the new strncasecmp to avoid breaking existing users. To allow the compat wrapper strnicmp to be removed at some point in the future, and to avoid the extra indirection cost, do s/strnicmp/strncasecmp/g. Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> Cc: James Bottomley <James.Bottomley@HansenPartnership.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2014-09-30scsi_debug: deadlock between completions and surprise module removalDouglas Gilbert1-14/+19
A deadlock has been reported when the completion of SCSI commands (simulated by a timer) was surprised by a module removal. This patch removes one half of the offending locks around timer deletions. This fix is applied both to stop_all_queued() which is were the deadlock was discovered and stop_queued_cmnd() which has very similar logic. This patch should be applied both to the lk 3.17 tree and Christoph's drivers-for-3.18 tree. Tested-and-reported-by: Milan Broz <gmazyland@gmail.com> Signed-off-by: Douglas Gilbert <dgilbert@interlog.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-09-16scsi_debug: bump inquiry version to SPC-4, update version descriptorsDouglas Gilbert1-7/+7
Since a lot of functionality from SPC-4 is supported by this driver (e.g. LBP and PI) then bump the default INQUIRY version from SPC-3 to SPC-4. Also update the INQUIRY version descriptors. Signed-off-by: Douglas Gilbert <dgilbert@interlog.com> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-09-16scsi_debug: give unit attention and other errors precedence over TSFDouglas Gilbert1-34/+33
Give existing errors priority over the generation of Task Set Full (TSF) errors. So that max_queue is not exceeded, existing errors may be sent back in the invocation thread. This is done so errors like Unit Attentions are not hidden and lost by either max_queue exceeded or real/injected TSFs. Signed-off-by: Douglas Gilbert <dgilbert@interlog.com> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-09-16scsi_debug: scsi_cmnd->cmnd check and casts unnecessaryDouglas Gilbert1-11/+11
This patch removes a NULL check for the scsi_cmnd::cmnd pointer since many other instances in this driver and elsewhere assume it is valid. Also redundant casts to 'unsigned char *' are removed as the pointer has that type. Signed-off-by: Douglas Gilbert <dgilbert@interlog.com> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-07-26scsi_debug: support scsi-mq, queues and locksDouglas Gilbert1-417/+1047
- add host_lock option whose default value is 0 which removes the host_lock around all queued commands - accept delay=-1 (_hi_) or -2 which use a tasklet to invoke the scsi_done callback into the mid-layer. The default is still delay=1 which uses a timer to delay 1 jiffy - wire .change_queue_depth and .change_queue_type functions to better simulate queueing in a modern LLD - add SCSI_DEBUG_OPT_Q_NOISE (0x200) mask to only produce debug output associated with queue full, plus from .change_queue_depth and .change_queue_type functions - add SCSI_DEBUG_OPT_ALL_TSF (0x400) mask which reports all queued_arr fulls at TASK_SET_FULL, otherwise SCSI_MLQUEUE_HOST_BUSY is returned - add SCSI_DEBUG_OPT_RARE_TSF (0x800) mask which works together with the every_nth option (> 0) to count occurrences of num_in_q==queue_depth. When every_nth is reached the victim (a command) yields TASK SET FULL - clean up many debug messages. - add ndelay=<nanosecs> option that uses high resolution timers; active if > 0 and then overrides delay= option - expand Unit Attention handling: POR, BUS_RESET and MODE PARAMETERS CHANGED - support .eh_target_reset_handler and drop .bios_param - add OPT_N_WCE mask so caching page yields WCE=0 - add OPT_RESET_NOISE mask to log aborts and resets - add OPT_NO_CDB_NOISE mask to not log each cdb - MODE SELECT support for changing caching page's WCE - name common ioctls in log - when fake_rw=1, do not vmalloc fake store; make UNMAP and WRITE SAME obey fake_rw - more logging and code improvements including better sense buffer handling With fio and four (pseudo) devices I have observed 1.2 M IOPS on my equipment. Rob Elliott who has done much testing and made numerous suggestions, has better IOPS results than mine. Signed-off-by: Douglas Gilbert <dgilbert@interlog.com> Reviewed-by: Robert Elliott <elliott@hp.com> Tested-by: Robert Elliott <elliott@hp.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-07-17scsi: use 64-bit LUNsHannes Reinecke1-7/+8
The SCSI standard defines 64-bit values for LUNs, and large arrays employing large or hierarchical LUN numbers become more and more common. So update the linux SCSI stack to use 64-bit LUN numbers. Signed-off-by: Hannes Reinecke <hare@suse.de> Reviewed-by: Christoph Hellwig <hch@infradead.org> Reviewed-by: Ewan Milne <emilne@redhat.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-07-17scsi_debug: allow huge transfer length for read/write commandsAkinobu Mita1-3/+3
This change enables to test read/write commands with huge transfer length such as 1GB. For example: # modprobe scsi_debug dev_size_mb=1024 clustering=1 opts=1 # cat /sys/block/$DEV/queue/max_hw_sectors_kb > \ /sys/block/$DEV/queue/max_sectors_kb # fio --name=test --rw=write --bs=1g --size=1g --filename=/dev/$DEV \ --mem=mmaphuge --direct=1 The data type of max_sectors in scsi_host_template has been extended to unsigned int by the previous change. So we can increase it from 0xffff to 0xffffffff to allow such huge transfer length. Also, this increases sg_tablesize and max_segment_size, otherwise the maximum transfer length is limited to 64MB. (sg_tablesize * max_segment_size = 256 * 256KB) Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Acked by: Douglas Gilbert <dgilbert@interlog.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
2014-05-19scsi_debug: simple short transfer injectionChristoph Hellwig1-0/+8
Add an option to only transfer half the data for every n-th command. Signed-off-by: Christoph Hellwig <hch@lst.de> Acked-by: Douglas Gilbert <dgilbert@interlog.com> Reviewed-by: Nicholas Bellinger <nab@linux-iscsi.org>
2014-03-19[SCSI] scsi_debug: add ability to enable clusteringAkinobu Mita1-0/+5
This adds a module parameter to enable clustering. Without enabling clustering support, the transfer length for read and write scsi commands is limited upto 8MB when page size is 4KB and sg_tablesize is 2048 (= SCSI_MAX_SG_CHAIN_SEGMENTS). I would like to test commands with more than that transfer length. Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Reviewed-by: Douglas Gilbert <dgilbert@interlog.com> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2014-03-19[SCSI] scsi_debug: protect device access with atomic_rw lockAkinobu Mita1-2/+10
This change ensures that concurrent device access including ramdisk storage, protection info, and provisioning map by read, write, and unmap commands are protected with atomic_rw spinlock. Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Reviewed-by: Douglas Gilbert <dgilbert@interlog.com> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2014-03-19[SCSI] scsi_debug: prepare to enable clusteringAkinobu Mita1-50/+59
Currently, clustering support for scsi_debug is disabled. This is because there are for_each_sg() loops which assume that each sg list element is consisted with a single page. But enabling clustering support, each sg list element for scsi commands can be consisted with multiple pages. This replaces these for_each_sg() loops with sg mapping iterator which is capable of handling each sg list element is consisted with multiple pages. Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Reviewed-by: Douglas Gilbert <dgilbert@interlog.com> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2014-03-19[SCSI] scsi_debug: fix resp_xdwriteread() return value when running out of memoryAkinobu Mita1-2/+6
When resp_xdwriteread() can't allocate temporary buffer, it returns -1. But the return value is used as scsi status code and -1 is not interpreted as correct code. target_core_mod has similar xdwriteread emulation code. So this mimics what target_core_mod does for xdwriteread when running out of memory. Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Reviewed-by: Douglas Gilbert <dgilbert@interlog.com> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2014-03-19[SCSI] scsi_debug: fix duplicate dif_errors incrementAkinobu Mita1-1/+0
It is unnecessary to increase dif_errors in dif_verify(), because the caller will increment it when dif_verify() detects failure. This bug was introduced by commit beb40ea42bd6 ("[SCSI] scsi_debug: reduce duplication between prot_verify_read and prot_verify_write") Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Acked-by: Martin K. Petersen <martin.petersen@oracle.com> Reviewed-by: Douglas Gilbert <dgilbert@interlog.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2014-03-19[SCSI] scsi_debug: make pseudo_primary staticAkinobu Mita1-1/+1
As pseudo_primary is only used in scsi_debug.c, it should be static. Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Reviewed-by: Douglas Gilbert <dgilbert@interlog.com> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2014-03-19[SCSI] scsi_debug: fix false positive logical block reference tag check failAkinobu Mita1-3/+1
Reading partially unwritten sectors generates a false positive logical block reference tag check failure when DIF is enabled. This bug is caused by missing ei_lba increment in loop of dif_verify() when unwritten sector is skipped. Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Acked-by: Martin K. Petersen <martin.petersen@oracle.com> Reviewed-by: Douglas Gilbert <dgilbert@interlog.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2013-12-16[SCSI] scsi_debug: simplify creation and destruction of driver attribute filesAkinobu Mita1-160/+106
Instead of repeatedly calling driver_create_file() to create driver attribute files, This achieves the same thing by constructing an array of driver_attribute and setting it to bus_type->drv_groups. This change simplifies both creation and destruction of the attribute files, and also removes sparse warning caused by driver_attributes which are unnecessarily declared as global. Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Acked-by: Douglas Gilbert <dgilbert@interlog.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2013-10-25[SCSI] scsi_debug: fix sparse warnings related to data integrity fieldAkinobu Mita1-11/+8
Each member in data integrity field tuple is big-endian. But the endianness of the values being compared with these members are not annotated. So this fixes these sparse warnings. Reported-by: kbuild test robot <fengguang.wu@intel.com> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Acked-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2013-10-25[SCSI] scsi_debug: fix invalid value check for guard module parameterAkinobu Mita1-3/+3
In the module initialization, invalid value for guard module parameter is detected by the following check: if (scsi_debug_guard > 1) { printk(KERN_ERR "scsi_debug_init: guard must be 0 or 1\n"); return -EINVAL; } But this check isn't enough, because the type of scsi_debug_guard is 'int' and scsi_debug_guard could be a negative value. This fixes it by changing the type of scsi_debug_guard to 'unsigned int' instead of adding extra check for a negative value. Reported-by: Joe Perches <joe@perches.com> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Acked-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2013-10-25[SCSI] scsi_debug: avoid partial copying PI from prot_sglist to dif_storepAkinobu Mita1-23/+17
If data integrity support is enabled, prot_verify_write() is called in response to WRITE commands and it verifies protection info from prot_sglist by comparing against data sglist, and copies protection info to dif_storep. When multiple blocks are transfered by a WRITE command, it verifies and copies these blocks one by one. So if it fails to verify protection info in the middle of blocks, the actual data transfer to fake_storep isn't proceeded at all although protection info for some blocks are already copied to dif_storep. Therefore, it breaks the data integrity between fake_storep and dif_storep. This fixes it by ensuring that copying protection info to dif_storep is done after all blocks are successfully verified. Reusing dif_copy_prot() with supporting the opposite direction simplifies this fix. Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Acked-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2013-10-25[SCSI] scsi_debug: factor out copying PI from dif_storep to prot_sglistAkinobu Mita1-23/+29
If data integrity support is enabled, prot_verify_read() is called in response to READ commands and it verifies protection info from dif_storep by comparing against fake_storep, and copies protection info to prot_sglist. This factors out the portion of copying protection info into a separate function. It will also be reused in the next change after supporting the opposite direction (copying prot_sglist to dif_storep). Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Acked-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2013-10-25[SCSI] scsi_debug: fix buffer overrun when DIF/DIX is enabled and virtual_gb > 0Akinobu Mita1-18/+30
If the module parameter virtual_gb is greater than 0, the READ command may request the blocks which exceed actual ramdisk storage (fake_storep). prot_verify_read() should treat those blocks as wrap around the end of fake_storep. But it actually causes fake_storep and dif_storep buffer overruns. This fixes these buffer overruns. In order to simplify the fix, this also introduces fake_store() and dif_store() which return corresponding wrap around addresses. Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Acked-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2013-09-03[SCSI] scsi_debug: fix logical block provisioning support when unmap_alignment != 0Akinobu Mita1-2/+8
Commit b90ebc3d5c41c9164ae04efd2e4f8204c2a186f1 ("[SCSI] scsi_debug: fix logical block provisioning support") fixed several issues with logical block provisioning support, but it still doesn't properly fix the cases when unmap_alignment > 0. For example, load scsi_debug module with the following module parameters and make all blocks mapped by filling the storage with zero. # modprobe scsi_debug lbpu=1 unmap_alignment=1 unmap_granularity=4 # dd if=/dev/zero of=$DEV Then, try to unmap the first unmappable blocks at lba=1, but GET LBA STATUS unexpectedly reports that the last UNMAP has done nothing. # sg_unmap --lba=1 --num=4 $DEV # sg_get_lba_status --lba=1 $DEV descriptor LBA: 0x0000000000000001 blocks: 16383 mapped The problem is in map_index_to_lba(), which should return the first LBA which is corresponding to a given index of provisioning map (map_storep). Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Acked-by: "Martin K. Petersen" <martin.petersen@oracle.com> Acked-by: Douglas Gilbert <dgilbert@interlog.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2013-09-03[SCSI] scsi_debug: fix endianness bug in sdebug_build_parts()Akinobu Mita1-2/+2
With module parameter num_parts > 0, partition table is built on the ramdisk storage when loading the driver. Unfortunately, there is an endianness bug in sdebug_build_parts(). So the partition table is not correctly initialized on big-endian systems. Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Tested-by: Martin Peschke <mpeschke@linux.vnet.ibm.com> Acked-by: Douglas Gilbert <dgilbert@interlog.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2013-07-13Merge tag 'scsi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsiLinus Torvalds1-104/+70
Pull final round of SCSI updates from James Bottomley: "This is the remaining set of SCSI patches for the merge window. It's mostly driver updates (scsi_debug, qla2xxx, storvsc, mp3sas). There are also several bug fixes in fcoe, libfc, and megaraid_sas. We also have a couple of core changes to try to make device destruction more deterministic" * tag 'scsi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: (46 commits) [SCSI] scsi constants: command, sense key + additional sense strings fcoe: Reduce number of sparse warnings fcoe: Stop fc_rport_priv structure leak libfcoe: Fix meaningless log statement libfc: Differentiate echange timer cancellation debug statements libfc: Remove extra space in fc_exch_timer_cancel definition fcoe: fix the link error status block sparse warnings fcoe: Fix smatch warning in fcoe_fdmi_info function libfc: Reject PLOGI from nodes with incompatible role [SCSI] enable destruction of blocked devices which fail LUN scanning [SCSI] Fix race between starved list and device removal [SCSI] megaraid_sas: fix a bug for 64 bit arches [SCSI] scsi_debug: reduce duplication between prot_verify_read and prot_verify_write [SCSI] scsi_debug: simplify offset calculation for dif_storep [SCSI] scsi_debug: invalidate protection info for unmapped region [SCSI] scsi_debug: fix NULL pointer dereference with parameters dif=0 dix=1 [SCSI] scsi_debug: fix incorrectly nested kmap_atomic() [SCSI] scsi_debug: fix invalid address passed to kunmap_atomic() [SCSI] mpt3sas: Bump driver version to v02.100.00.00 [SCSI] mpt3sas: when async scanning is enabled then while scanning, devices are removed but their transport layer entries are not removed ...
2013-07-09scsi_debug: fix do_device_access() with wrap around rangeAkinobu Mita1-11/+37
do_device_access() is a function that abstracts copying SG list from/to ramdisk storage (fake_storep). It must deal with the ranges exceeding actual fake_storep size, because such ranges are valid if virtual_gb is set greater than zero, and they should be treated as fake_storep is repeatedly mirrored up to virtual size. Unfortunately, it can't deal with the range which wraps around the end of fake_storep. A wrap around range is copied by two sg_copy_{from,to}_buffer() calls, but sg_copy_{from,to}_buffer() can't copy from/to in the middle of SG list, therefore the second call can't copy correctly. This fixes it by using sg_pcopy_{from,to}_buffer() that can copy from/to the middle of SG list. This also simplifies the assignment of sdb->resid in fill_from_dev_buffer(). Because fill_from_dev_buffer() is now only called once per command execution cycle. So it is not necessary to take care to decrease sdb->resid if fill_from_dev_buffer() is called more than once. Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Cc: "David S. Miller" <davem@davemloft.net> Cc: "James E.J. Bottomley" <JBottomley@parallels.com> Cc: Douglas Gilbert <dgilbert@interlog.com> Cc: Herbert Xu <herbert@gondor.apana.org.au> Cc: Horia Geanta <horia.geanta@freescale.com> Cc: Imre Deak <imre.deak@intel.com> Cc: Tejun Heo <tj@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-07-09[SCSI] scsi_debug: reduce duplication between prot_verify_read and prot_verify_writeAkinobu Mita1-85/+52
In order to reduce code duplication between prot_verify_read() and prot_verify_write(), this moves common code into the new functions. [jejb: fix unitialised variable warning] Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Acked-by: Douglas Gilbert <dgilbert@interlog.com> Acked-by: "Martin K. Petersen" <martin.petersen@oracle.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2013-07-09[SCSI] scsi_debug: simplify offset calculation for dif_storepAkinobu Mita1-11/+7
dif_storep is declared as pointer to unsigned char type. But it is actually used to store vmalloced array of struct sd_dif_tuple. This changes the type of dif_storep to the pointer to struct sd_dif_tuple. It simplifies offset calculation for dif_storep and enables to remove hardcoded size of struct sd_dif_tuple. Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Acked-by: Douglas Gilbert <dgilbert@interlog.com> Acked-by: "Martin K. Petersen" <martin.petersen@oracle.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>