From 624f28be81097d06796e12c4c10aa7611305b334 Mon Sep 17 00:00:00 2001 From: Chad Dupuis Date: Wed, 26 Feb 2014 04:15:05 -0500 Subject: [SCSI] scsi_transport_fc: Add 32Gbps speed definition. Signed-off-by: Chad Dupuis Signed-off-by: Saurav Kashyap Signed-off-by: James Bottomley --- include/scsi/scsi_transport_fc.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/scsi') diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h index b797e8fad669..8c79980dc8f2 100644 --- a/include/scsi/scsi_transport_fc.h +++ b/include/scsi/scsi_transport_fc.h @@ -130,6 +130,7 @@ enum fc_vport_state { #define FC_PORTSPEED_4GBIT 8 #define FC_PORTSPEED_8GBIT 0x10 #define FC_PORTSPEED_16GBIT 0x20 +#define FC_PORTSPEED_32GBIT 0x40 #define FC_PORTSPEED_NOT_NEGOTIATED (1 << 15) /* Speed not established */ /* -- cgit v1.2.3 From 3af74a3c07d93e34fce3d6c6dcd73676d8381d21 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 6 Feb 2014 12:23:07 -0800 Subject: [SCSI] libsas: introduce scmd_dbg() to quiet false positive "timeout" messages libsas sometimes short circuits timeouts to force commands into error recovery. It is misleading to log that the command timed-out in sas_scsi_timed_out() when in fact it was just queued for error handling. It's also redundant in the case of a true timeout as libata eh will detect and report timeouts via it's AC_ERR_TIMEOUT facility. Given that some environments consider "timeout" errors to be indicative of impending device failure demote the sas_scsi_timed_out() timeout message to be disabled by default. This parallels ata_scsi_timed_out(). [jejb: checkpatch fix] Reported-by: Xun Ni Tested-by: Nelson Cheng Acked-by: Lukasz Dorau Signed-off-by: Dan Williams Signed-off-by: James Bottomley --- include/scsi/scsi_device.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include/scsi') diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index d65fbec2533d..622e100561d2 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -235,12 +235,24 @@ struct scsi_dh_data { #define sdev_printk(prefix, sdev, fmt, a...) \ dev_printk(prefix, &(sdev)->sdev_gendev, fmt, ##a) +#define sdev_dbg(sdev, fmt, a...) \ + dev_dbg(&(sdev)->sdev_gendev, fmt, ##a) + #define scmd_printk(prefix, scmd, fmt, a...) \ (scmd)->request->rq_disk ? \ sdev_printk(prefix, (scmd)->device, "[%s] " fmt, \ (scmd)->request->rq_disk->disk_name, ##a) : \ sdev_printk(prefix, (scmd)->device, fmt, ##a) +#define scmd_dbg(scmd, fmt, a...) \ + do { \ + if ((scmd)->request->rq_disk) \ + sdev_dbg((scmd)->device, "[%s] " fmt, \ + (scmd)->request->rq_disk->disk_name, ##a);\ + else \ + sdev_dbg((scmd)->device, fmt, ##a); \ + } while (0) + enum scsi_target_state { STARGET_CREATED = 1, STARGET_RUNNING, -- cgit v1.2.3 From e63ed0d7a98014fdfc2cfeb3f6dada313dcabb59 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Tue, 21 Jan 2014 07:00:50 -0800 Subject: [SCSI] fix our current target reap infrastructure This patch eliminates the reap_ref and replaces it with a proper kref. On last put of this kref, the target is removed from visibility in sysfs. The final call to scsi_target_reap() for the device is done from __scsi_remove_device() and only if the device was made visible. This ensures that the target disappears as soon as the last device is gone rather than waiting until final release of the device (which is often too long). Reviewed-by: Alan Stern Tested-by: Sarah Sharp Cc: stable@vger.kernel.org # delay backport by 2 months for field testing Signed-off-by: James Bottomley --- include/scsi/scsi_device.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'include/scsi') diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index 622e100561d2..ccabdc1c27ca 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -269,7 +269,7 @@ struct scsi_target { struct list_head siblings; struct list_head devices; struct device dev; - unsigned int reap_ref; /* protected by the host lock */ + struct kref reap_ref; /* last put renders target invisible */ unsigned int channel; unsigned int id; /* target id ... replace * scsi_device.id eventually */ @@ -296,7 +296,6 @@ struct scsi_target { #define SCSI_DEFAULT_TARGET_BLOCKED 3 char scsi_level; - struct execute_work ew; enum scsi_target_state state; void *hostdata; /* available to low-level driver */ unsigned long starget_data[0]; /* for the transport */ -- cgit v1.2.3 From 659743b02c411075b26601725947b21df0bb29c8 Mon Sep 17 00:00:00 2001 From: Shlomo Pongratz Date: Fri, 7 Feb 2014 00:41:38 -0600 Subject: [SCSI] libiscsi: Reduce locking contention in fast path Replace the session lock with two locks, a forward lock and a backwards lock named frwd_lock and back_lock respectively. The forward lock protects resources that change while sending a request to the target, such as cmdsn, queued_cmdsn, and allocating task from the commands' pool with kfifo_out. The backward lock protects resources that change while processing a response or in error path, such as cmdsn_exp, cmdsn_max, and returning tasks to the commands' pool with kfifo_in. Under a steady state fast-path situation, that is when one or more processes/threads submit IO to an iscsi device and a single kernel upcall (e.g softirq) is dealing with processing of responses without errors, this patch eliminates the contention between the queuecommand()/request response/scsi_done() flows associated with iscsi sessions. Between the forward and the backward locks exists a strict locking hierarchy. The mutual exclusion zone protected by the forward lock can enclose the mutual exclusion zone protected by the backward lock but not vice versa. For example, in iscsi_conn_teardown or in iscsi_xmit_data when there is a failure and __iscsi_put_task is called, the backward lock is taken while the forward lock is still taken. On the other hand, if in the RX path a nop is to be sent, for example in iscsi_handle_reject or __iscsi_complete_pdu than the forward lock is released and the backward lock is taken for the duration of iscsi_send_nopout, later the backward lock is released and the forward lock is retaken. libiscsi_tcp uses two kernel fifos the r2t pool and the r2t queue. The insertion and deletion from these queues didn't corespond to the assumption taken by the new forward/backwards session locking paradigm. That is, in iscsi_tcp_clenup_task which belongs to the RX (backwards) path, r2t is taken out from r2t queue and inserted to the r2t pool. In iscsi_tcp_get_curr_r2t which belong to the TX (forward) path, r2t is also inserted to the r2t pool and another r2t is pulled from r2t queue. Only in iscsi_tcp_r2t_rsp which is called in the RX path but can requeue to the TX path, r2t is taken from the r2t pool and inserted to the r2t queue. In order to cope with this situation, two spin locks were added, pool2queue and queue2pool. The former protects extracting from the r2t pool and inserting to the r2t queue, and the later protects the extracing from the r2t queue and inserting to the r2t pool. Signed-off-by: Shlomo Pongratz Signed-off-by: Or Gerlitz [minor fix up to apply cleanly and compile fix] Signed-off-by: Mike Christie Signed-off-by: James Bottomley --- include/scsi/libiscsi.h | 17 ++++++++++++----- include/scsi/libiscsi_tcp.h | 2 ++ 2 files changed, 14 insertions(+), 5 deletions(-) (limited to 'include/scsi') diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h index 309f51336fb9..7221a24e821b 100644 --- a/include/scsi/libiscsi.h +++ b/include/scsi/libiscsi.h @@ -327,12 +327,19 @@ struct iscsi_session { struct iscsi_transport *tt; struct Scsi_Host *host; struct iscsi_conn *leadconn; /* leading connection */ - spinlock_t lock; /* protects session state, * - * sequence numbers, * + /* Between the forward and the backward locks exists a strict locking + * hierarchy. The mutual exclusion zone protected by the forward lock + * can enclose the mutual exclusion zone protected by the backward lock + * but not vice versa. + */ + spinlock_t frwd_lock; /* protects session state, * + * cmdsn, queued_cmdsn * * session resources: * - * - cmdpool, * - * - mgmtpool, * - * - r2tpool */ + * - cmdpool kfifo_out , * + * - mgmtpool, */ + spinlock_t back_lock; /* protects cmdsn_exp * + * cmdsn_max, * + * cmdpool kfifo_in */ int state; /* session state */ int age; /* counts session re-opens */ diff --git a/include/scsi/libiscsi_tcp.h b/include/scsi/libiscsi_tcp.h index 215469a9b801..2a7aa75dd009 100644 --- a/include/scsi/libiscsi_tcp.h +++ b/include/scsi/libiscsi_tcp.h @@ -83,6 +83,8 @@ struct iscsi_tcp_task { struct iscsi_pool r2tpool; struct kfifo r2tqueue; void *dd_data; + spinlock_t pool2queue; + spinlock_t queue2pool; }; enum { -- cgit v1.2.3 From 0479633686d370303e3430256ace4bd5f7f138dc Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Thu, 20 Feb 2014 14:20:55 -0800 Subject: [SCSI] do not manipulate device reference counts in scsi_get/put_command Many callers won't need this and we can optimize them away. In addition the handling in the __-prefixed variants was inconsistant to start with. Based on an earlier patch from Bart Van Assche. [jejb: fix kerneldoc probelm picked up by Fengguang Wu] Signed-off-by: Christoph Hellwig Reviewed-by: Hannes Reinecke Signed-off-by: James Bottomley --- include/scsi/scsi_cmnd.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'include/scsi') diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h index 91558a1f97f4..414edf9b1272 100644 --- a/include/scsi/scsi_cmnd.h +++ b/include/scsi/scsi_cmnd.h @@ -142,8 +142,7 @@ static inline struct scsi_driver *scsi_cmd_to_driver(struct scsi_cmnd *cmd) extern struct scsi_cmnd *scsi_get_command(struct scsi_device *, gfp_t); extern struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *, gfp_t); extern void scsi_put_command(struct scsi_cmnd *); -extern void __scsi_put_command(struct Scsi_Host *, struct scsi_cmnd *, - struct device *); +extern void __scsi_put_command(struct Scsi_Host *, struct scsi_cmnd *); extern void scsi_finish_command(struct scsi_cmnd *cmd); extern void *scsi_kmap_atomic_sg(struct scatterlist *sg, int sg_count, -- cgit v1.2.3 From b3ae8780b42918111387240762f470d5c1e269d6 Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Sat, 15 Mar 2014 09:51:49 +0100 Subject: [SCSI] Add EVPD page 0x83 and 0x80 to sysfs EVPD page 0x83 is used to uniquely identify the device. So instead of having each and every program issue a separate SG_IO call to retrieve this information it does make far more sense to display it in sysfs. Some older devices (most notably tapes) will only report reliable information in page 0x80 (Unit Serial Number). So export this in the sysfs attribute 'vpd_pg80'. [jejb: checkpatch fix] [hare: attach after transport configure] [fengguang.wu@intel.com: spotted problems with the original now fixed] Signed-off-by: Hannes Reinecke Signed-off-by: James Bottomley --- include/scsi/scsi_device.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include/scsi') diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index ccabdc1c27ca..4e845b80efd3 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -113,6 +113,12 @@ struct scsi_device { const char * vendor; /* [back_compat] point into 'inquiry' ... */ const char * model; /* ... after scan; point to static string */ const char * rev; /* ... "nullnullnullnull" before scan */ + +#define SCSI_VPD_PG_LEN 255 + int vpd_pg83_len; + unsigned char *vpd_pg83; + int vpd_pg80_len; + unsigned char *vpd_pg80; unsigned char current_tag; /* current tag */ struct scsi_target *sdev_target; /* used only for single_lun */ @@ -320,6 +326,7 @@ extern int scsi_add_device(struct Scsi_Host *host, uint channel, extern int scsi_register_device_handler(struct scsi_device_handler *scsi_dh); extern void scsi_remove_device(struct scsi_device *); extern int scsi_unregister_device_handler(struct scsi_device_handler *scsi_dh); +void scsi_attach_vpd(struct scsi_device *sdev); extern int scsi_device_get(struct scsi_device *); extern void scsi_device_put(struct scsi_device *); -- cgit v1.2.3 From 0f2bb84d2a68448c29d46f9f77a78bb4ed0218db Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Thu, 20 Feb 2014 14:20:59 -0800 Subject: [SCSI] megaraid: simplify internal command handling We don't use the passed in scsi command for anything, so just add a adapter- wide internal status to go along with the internal scb that is used unter int_mtx to pass back the return value and get rid of all the complexities and abuse of the scsi_cmnd structure. This gets rid of the only user of scsi_allocate_command/scsi_free_command, which can now be removed. [jejb: checkpatch fixes] Signed-off-by: Christoph Hellwig Acked-by: Adam Radford Signed-off-by: James Bottomley --- include/scsi/scsi_cmnd.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'include/scsi') diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h index 414edf9b1272..dd7c998221b3 100644 --- a/include/scsi/scsi_cmnd.h +++ b/include/scsi/scsi_cmnd.h @@ -155,9 +155,6 @@ extern void scsi_release_buffers(struct scsi_cmnd *cmd); extern int scsi_dma_map(struct scsi_cmnd *cmd); extern void scsi_dma_unmap(struct scsi_cmnd *cmd); -struct scsi_cmnd *scsi_allocate_command(gfp_t gfp_mask); -void scsi_free_command(gfp_t gfp_mask, struct scsi_cmnd *cmd); - static inline unsigned scsi_sg_count(struct scsi_cmnd *cmd) { return cmd->sdb.table.nents; -- cgit v1.2.3 From 89d9a567952baec13e26ada3e438f1b642d66b6e Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Thu, 20 Feb 2014 14:21:01 -0800 Subject: [SCSI] add support for per-host cmd pools This allows drivers to specify the size of their per-command private data in the host template and then get extra memory allocated for each command instead of needing another allocation in ->queuecommand. With the current SCSI code that already does multiple allocations for each command this probably doesn't make a big performance impact, but it allows to clean up the drivers, and prepare them for using the blk-mq infrastructure where the common allocation will make a difference. Signed-off-by: Christoph Hellwig Reviewed-by: Paolo Bonzini Signed-off-by: James Bottomley --- include/scsi/scsi_host.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include/scsi') diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 53075e5039e6..94844fc77b97 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -15,6 +15,7 @@ struct completion; struct module; struct scsi_cmnd; struct scsi_device; +struct scsi_host_cmd_pool; struct scsi_target; struct Scsi_Host; struct scsi_host_cmd_pool; @@ -524,6 +525,12 @@ struct scsi_host_template { * scsi_netlink.h */ u64 vendor_id; + + /* + * Additional per-command data allocated for the driver. + */ + unsigned int cmd_size; + struct scsi_host_cmd_pool *cmd_pool; }; /* -- cgit v1.2.3