zfcp features and bugfixes for 3.12 merge window
Subsystems (5)
cover zfcp features and bugfixes for 3.12 merge window
James,
here is a series of zfcp features and bugfixes
for the upcoming merge window preparing kernel v3.12.
The patches apply on top of the current misc branch of your scsi.git.
Steffen
Linux on System z Development
IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martin Jetter
Geschaeftsfuehrung: Dirk Wittkopp
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
PATCH 1/8 zfcp: consistently use appropriate SBAL flag definitions
From: Martin Peschke <[email protected]>
minor cleanup for status read request
--- drivers/s390/scsi/zfcp_fsf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/s390/scsi/zfcp_fsf.c +2 -1
@@ -770,7 +770,8 @@ int zfcp_fsf_status_read(struct zfcp_qdiif (zfcp_qdio_sbal_get (qdio)) goto out; - req =zfcp_fsf_req_create (qdio,FSF_QTCB_UNSOLICITED_STATUS ,0 , + req =zfcp_fsf_req_create (qdio,FSF_QTCB_UNSOLICITED_STATUS , +SBAL_SFLAGS0_TYPE_STATUS , adapter->pool.status_read_req);if (IS_ERR (req)) { retval =PTR_ERR (req);
PATCH 2/8 zfcp: cleanup use of obsolete strict_strto* functions
In reply to Steffen MaierFrom: Martin Peschke <[email protected]>
strict_strtoul and friends are obsolete. Use kstrtoul functions instead.
--- drivers/s390/scsi/zfcp_aux.c | 4 ++-- drivers/s390/scsi/zfcp_sysfs.c | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-)
drivers/s390/scsi/zfcp_aux.c +2 -2
@@ -104,11 +104,11 @@ static void __init zfcp_init_device_setustrncpy (busid, token,ZFCP_BUS_ID_SIZE ); token =strsep (&str,"," ); -if (!token ||strict_strtoull (token,0 , (unsigned long long *) &wwpn)) +if (!token ||kstrtoull (token,0 , (unsigned long long *) &wwpn)) goto err_out; token =strsep (&str,"," ); -if (!token ||strict_strtoull (token,0 , (unsigned long long *) &lun)) +if (!token ||kstrtoull (token,0 , (unsigned long long *) &lun)) goto err_out;kfree (str_saved);
drivers/s390/scsi/zfcp_sysfs.c +6 -6
@@ -95,7 +95,7 @@ static ssize_t zfcp_sysfs_port_failed_st struct zfcp_port *port = container_of(dev, struct zfcp_port, dev);unsigned long val; -if (strict_strtoul (buf,0 , &val) || val !=0 ) +if (kstrtoul (buf,0 , &val) || val !=0 )return -EINVAL ;zfcp_erp_set_port_status (port,ZFCP_STATUS_COMMON_RUNNING );
@@ -134,7 +134,7 @@ static ssize_t zfcp_sysfs_unit_failed_stunsigned long val;struct scsi_device *sdev; -if (strict_strtoul (buf,0 , &val) || val !=0 ) +if (kstrtoul (buf,0 , &val) || val !=0 )return -EINVAL ; sdev =zfcp_unit_sdev (unit);
@@ -184,7 +184,7 @@ static ssize_t zfcp_sysfs_adapter_failedif (!adapter)return -ENODEV ; -if (strict_strtoul (buf,0 , &val) || val !=0 ) { +if (kstrtoul (buf,0 , &val) || val !=0 ) { retval = -EINVAL ; goto out; }
@@ -236,7 +236,7 @@ static ssize_t zfcp_sysfs_port_remove_stif (!adapter)return -ENODEV ; -if (strict_strtoull (buf,0 , (unsigned long long *) &wwpn)) +if (kstrtoull (buf,0 , (unsigned long long *) &wwpn)) goto out; port =zfcp_get_port_by_wwpn (adapter, wwpn);
@@ -297,7 +297,7 @@ static ssize_t zfcp_sysfs_unit_add_storeu64 fcp_lun;int retval; -if (strict_strtoull (buf,0 , (unsigned long long *) &fcp_lun)) +if (kstrtoull (buf,0 , (unsigned long long *) &fcp_lun))return -EINVAL ; retval =zfcp_unit_add (port, fcp_lun);
@@ -315,7 +315,7 @@ static ssize_t zfcp_sysfs_unit_remove_st struct zfcp_port *port = container_of(dev, struct zfcp_port, dev);u64 fcp_lun; -if (strict_strtoull (buf,0 , (unsigned long long *) &fcp_lun)) +if (kstrtoull (buf,0 , (unsigned long long *) &fcp_lun))return -EINVAL ;if (zfcp_unit_remove (port, fcp_lun))
Re: [PATCH 2/8] zfcp: cleanup use of obsolete strict_strto* functions
Quoted 8 lines · Steffen Maier
From: Martin Peschke <[email protected]>
strict_strtouland friends are obsolete. Use kstrtoul functions instead.Signed-off-by Martin Peschke <[email protected]>Cc Jingoo Han <[email protected]>
Best regards,
Jingoo Han
Quoted 5 lines
Signed-off-by Steffen Maier <[email protected]>--- drivers/s390/scsi/zfcp_aux.c | 4 ++-- drivers/s390/scsi/zfcp_sysfs.c | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-)
PATCH 3/8 zfcp: dead code removal
In reply to Steffen MaierFrom: Martin Peschke <[email protected]>
Get rid of unused function zfcp_fsf_get_req and corresponding prototype definition.
Commit a54ca0f62f953898b05549391ac2a8a4dad6482b in v2.6.28 "[SCSI] zfcp: Redesign of the debug tracing for HBA records." accidentally introduced this code which was dead in the first place.
--- drivers/s390/scsi/zfcp_ext.h | 2 -- drivers/s390/scsi/zfcp_fsf.c | 9 --------- 2 files changed, 11 deletions(-)
drivers/s390/scsi/zfcp_ext.h +0 -2
@@ -126,8 +126,6 @@ extern int zfcp_qdio_sbals_from_sg(strucextern int zfcp_qdio_open (struct zfcp_qdio *);extern void zfcp_qdio_close (struct zfcp_qdio *);extern void zfcp_qdio_siosl (struct zfcp_adapter *); -extern struct zfcp_fsf_req *zfcp_fsf_get_req (struct zfcp_qdio *, -struct qdio_buffer *);/* zfcp_scsi.c */ extern struct scsi_transport_template *zfcp_scsi_transport_template;
drivers/s390/scsi/zfcp_fsf.c +0 -9
@@ -2388,12 +2388,3 @@ void zfcp_fsf_reqid_check(struct zfcp_qdbreak ; } } - -struct zfcp_fsf_req *zfcp_fsf_get_req (struct zfcp_qdio *qdio, -struct qdio_buffer *sbal) -{ -struct qdio_buffer_element *sbale = &sbal->element[0 ]; -u64 req_id = (unsigned long ) sbale->addr; - -return zfcp_reqlist_find (qdio->adapter->req_list, req_id); -}
PATCH 4/8 zfcp: fix lock imbalance by reworking request queue locking
In reply to Steffen MaierFrom: Martin Peschke <[email protected]>
This patch adds wait_event_interruptible_lock_irq_timeout(), which is a straight-forward descendant of wait_event_interruptible_timeout() and wait_event_interruptible_lock_irq().
The zfcp driver used to call wait_event_interruptible_timeout() in combination with some intricate and error-prone locking. Using wait_event_interruptible_lock_irq_timeout() as a replacement nicely cleans up that locking.
This rework removes a situation that resulted in a locking imbalance in zfcp_qdio_sbal_get():
BUG: workqueue leaked lock or atomic: events/1/0xffffff00/10
last function: zfcp_fc_wka_port_offline+0x0/0xa0 [zfcp]It was introduced by commit c2af7545aaff3495d9bf9a7608c52f0af86fb194 "[SCSI] zfcp: Do not wait for SBALs on stopped queue", which had a new code path related to ZFCP_STATUS_ADAPTER_QDIOUP that took an early exit without a required lock being held. The problem occured when a special, non-SCSI I/O request was being submitted in process context, when the adapter's queues had been torn down. In this case the bug surfaced when the Fibre Channel port connection for a well-known address was closed during a concurrent adapter shut-down procedure, which is a rare constellation.
This patch also fixes these warnings from the sparse tool (make C=1):
drivers/s390/scsi/zfcp_qdio.c:224:12: warning: context imbalance in
'zfcp_qdio_sbal_check' - wrong count at exitdrivers/s390/scsi/zfcp_qdio.c:244:5: warning: context imbalance in
'zfcp_qdio_sbal_get' - unexpected unlock
Last but not least, we get rid of that crappy lock-unlock-lock sequence at the beginning of the critical section.
It is okay to call zfcp_erp_adapter_reopen() with req_q_lock held.
--- drivers/s390/scsi/zfcp_qdio.c | 8 +---- include/linux/wait.h | 57 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 6 deletions(-)
drivers/s390/scsi/zfcp_qdio.c +2 -6
@@ -224,11 +224,9 @@ int zfcp_qdio_sbals_from_sg(struct zfcp_static int zfcp_qdio_sbal_check (struct zfcp_qdio *qdio) { -spin_lock_irq (&qdio->req_q_lock);if (atomic_read (&qdio->req_q_free) || !(atomic_read (&qdio->adapter->status) &ZFCP_STATUS_ADAPTER_QDIOUP ))return 1 ; -spin_unlock_irq (&qdio->req_q_lock);return 0 ; }
@@ -246,9 +244,8 @@ int zfcp_qdio_sbal_get(struct zfcp_qdio {long ret; -spin_unlock_irq (&qdio->req_q_lock); - ret =wait_event_interruptible_timeout (qdio->req_q_wq, -zfcp_qdio_sbal_check (qdio),5 *HZ ); + ret =wait_event_interruptible_lock_irq_timeout (qdio->req_q_wq, +zfcp_qdio_sbal_check (qdio), qdio->req_q_lock,5 *HZ );if (!(atomic_read (&qdio->adapter->status) &ZFCP_STATUS_ADAPTER_QDIOUP ))return -EIO ;
@@ -262,7 +259,6 @@ int zfcp_qdio_sbal_get(struct zfcp_qdiozfcp_erp_adapter_reopen (qdio->adapter,0 ,"qdsbg_1" ); } -spin_lock_irq (&qdio->req_q_lock);return -EIO ; }
include/linux/wait.h +57 -0
63 lines not on this page · raw message
PATCH 5/8 zfcp: fix schedule-inside-lock in scsi_device list loops
In reply to Steffen MaierFrom: Martin Peschke <[email protected]>
BUG: sleeping function called from invalid context at kernel/workqueue.c:2752 in_atomic(): 1, irqs_disabled(): 1, pid: 360, name: zfcperp0.0.1700 CPU: 1 Not tainted 3.9.3+ #69 Process zfcperp0.0.1700 (pid: 360, task: 0000000075b7e080, ksp: 000000007476bc30) <snip> Call Trace: ([<00000000001165de>] show_trace+0x106/0x154) [<00000000001166a0>] show_stack+0x74/0xf4 [<00000000006ff646>] dump_stack+0xc6/0xd4 [<000000000017f3a0>] __might_sleep+0x128/0x148 [<000000000015ece8>] flush_work+0x54/0x1f8 [<00000000001630de>] __cancel_work_timer+0xc6/0x128 [<00000000005067ac>] scsi_device_dev_release_usercontext+0x164/0x23c [<0000000000161816>] execute_in_process_context+0x96/0xa8 [<00000000004d33d8>] device_release+0x60/0xc0 [<000000000048af48>] kobject_release+0xa8/0x1c4 [<00000000004f4bf2>] __scsi_iterate_devices+0xfa/0x130 [<000003ff801b307a>] zfcp_erp_strategy+0x4da/0x1014 [zfcp] [<000003ff801b3caa>] zfcp_erp_thread+0xf6/0x2b0 [zfcp] [<000000000016b75a>] kthread+0xf2/0xfc [<000000000070c9de>] kernel_thread_starter+0x6/0xc [<000000000070c9d8>] kernel_thread_starter+0x0/0xc
Apparently, the ref_count for some scsi_device drops down to zero, triggering device removal through execute_in_process_context(), while the lldd error recovery thread iterates through a scsi device list. Unfortunately, execute_in_process_context() decides to immediately execute that device removal function, instead of scheduling asynchronous execution, since it detects process context and thinks it is safe to do so. But almost all calls to shost_for_each_device() in our lldd are inside spin_lock_irq, even in thread context. Obviously, schedule() inside spin_lock_irq sections is a bad idea.
Change the lldd to use the proper iterator function, __shost_for_each_device(), in combination with required locking.
Occurences that need to be changed include all calls in zfcp_erp.c, since those might be executed in zfcp error recovery thread context with a lock held.
Other occurences of shost_for_each_device() in zfcp_fsf.c do not need to be changed (no process context, no surrounding locking).
The problem was introduced in Linux 2.6.37 by commit b62a8d9b45b971a67a0f8413338c230e3117dff5
"[SCSI] zfcp: Use SCSI device data zfcp_scsi_dev instead of zfcp_unit".
--- drivers/s390/scsi/zfcp_erp.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-)
drivers/s390/scsi/zfcp_erp.c +22 -7
@@ -102,10 +102,13 @@ static void zfcp_erp_action_dismiss_portif (atomic_read (&port->status) &ZFCP_STATUS_COMMON_ERP_INUSE )zfcp_erp_action_dismiss (&port->erp_action); -else -shost_for_each_device (sdev, port->adapter->scsi_host) +else { +spin_lock (port->adapter->scsi_host->host_lock); +__shost_for_each_device (sdev, port->adapter->scsi_host)if (sdev_to_zfcp (sdev)->port == port)zfcp_erp_action_dismiss_lun (sdev); +spin_unlock (port->adapter->scsi_host->host_lock); + } }static void zfcp_erp_action_dismiss_adapter (struct zfcp_adapter *adapter)
@@ -592,9 +595,11 @@ static void _zfcp_erp_lun_reopen_all(str {struct scsi_device *sdev; -shost_for_each_device (sdev, port->adapter->scsi_host) +spin_lock (port->adapter->scsi_host->host_lock); +__shost_for_each_device (sdev, port->adapter->scsi_host)if (sdev_to_zfcp (sdev)->port == port)_zfcp_erp_lun_reopen (sdev, clear, id,0 ); +spin_unlock (port->adapter->scsi_host->host_lock); }static void zfcp_erp_strategy_followup_failed (struct zfcp_erp_action *act)
@@ -1434,8 +1439,10 @@ void zfcp_erp_set_adapter_status(structatomic_set_mask (common_mask, &port->status);read_unlock_irqrestore (&adapter->port_list_lock, flags); -shost_for_each_device (sdev, adapter->scsi_host) +spin_lock_irqsave (adapter->scsi_host->host_lock, flags); +__shost_for_each_device (sdev, adapter->scsi_host)atomic_set_mask (common_mask, &sdev_to_zfcp (sdev)->status); +spin_unlock_irqrestore (adapter->scsi_host->host_lock, flags); }/**
@@ -1469,11 +1476,13 @@ void zfcp_erp_clear_adapter_status(struc }read_unlock_irqrestore (&adapter->port_list_lock, flags); -shost_for_each_device (sdev, adapter->scsi_host) { +spin_lock_irqsave (adapter->scsi_host->host_lock, flags); +__shost_for_each_device (sdev, adapter->scsi_host) {atomic_clear_mask (common_mask, &sdev_to_zfcp (sdev)->status);if (clear_counter)atomic_set (&sdev_to_zfcp (sdev)->erp_counter,0 ); } +spin_unlock_irqrestore (adapter->scsi_host->host_lock, flags); }/**
@@ -1487,16 +1496,19 @@ void zfcp_erp_set_port_status(struct zfc {struct scsi_device *sdev;u32 common_mask = mask &ZFCP_COMMON_FLAGS ; +unsigned long flags;atomic_set_mask (mask, &port->status);if (!common_mask)return ; -shost_for_each_device (sdev, port->adapter->scsi_host) +spin_lock_irqsave (port->adapter->scsi_host->host_lock, flags); +__shost_for_each_device (sdev, port->adapter->scsi_host)if (sdev_to_zfcp (sdev)->port == port)atomic_set_mask (common_mask, &sdev_to_zfcp (sdev)->status); +spin_unlock_irqrestore (port->adapter->scsi_host->host_lock, flags); }/**
@@ -1511,6 +1523,7 @@ void zfcp_erp_clear_port_status(struct zstruct scsi_device *sdev;u32 common_mask = mask &ZFCP_COMMON_FLAGS ;u32 clear_counter = mask &ZFCP_STATUS_COMMON_ERP_FAILED ; +unsigned long flags;atomic_clear_mask (mask, &port->status);
@@ -1520,13 +1533,15 @@ void zfcp_erp_clear_port_status(struct zif (clear_counter)atomic_set (&port->erp_counter,0 ); -shost_for_each_device (sdev, port->adapter->scsi_host) +spin_lock_irqsave (port->adapter->scsi_host->host_lock, flags); +__shost_for_each_device (sdev, port->adapter->scsi_host)if (sdev_to_zfcp (sdev)->port == port) {atomic_clear_mask (common_mask, &sdev_to_zfcp (sdev)->status);if (clear_counter)atomic_set (&sdev_to_zfcp (sdev)->erp_counter,0 ); } +spin_unlock_irqrestore (port->adapter->scsi_host->host_lock, flags); }/**
PATCH 6/8 zfcp: remove access control tables interface (keep sysfs files)
In reply to Steffen MaierFrom: Martin Peschke <[email protected]>
By popular demand, this patch brings back a couple of sysfs attributes removed by commit 663e0890e31cb85f0cca5ac1faaee0d2d52880b5 "[SCSI] zfcp: remove access control tables interface".
The content has been irrelevant for years, but the files must be there forever for whatever user space tools that may rely on them.
Since these files always return a constant value, a new stripped down show-macro was required. Otherwise build warnings would have been introduced.
--- drivers/s390/scsi/zfcp_sysfs.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/s390/scsi/zfcp_sysfs.c +14 -0
@@ -27,6 +27,16 @@ static ssize_t zfcp_sysfs_##_feat##_##_n static ZFCP_DEV_ATTR(_feat, _name, S_IRUGO, \ zfcp_sysfs_##_feat##_##_name##_show, NULL); +#define ZFCP_DEFINE_ATTR_CONST (_feat, _name, _format, _value) \ +static ssize_t zfcp_sysfs_##_feat##_##_name##_show(struct device *dev, \ + struct device_attribute *at,\ + char *buf) \ +{ \ + return sprintf(buf, _format, _value); \ +} \ +static ZFCP_DEV_ATTR(_feat, _name, S_IRUGO, \ + zfcp_sysfs_##_feat##_##_name##_show, NULL); +#define ZFCP_DEFINE_A_ATTR (_name, _format, _value) \ static ssize_t zfcp_sysfs_adapter_##_name##_show(struct device *dev, \ struct device_attribute *at,\
@@ -75,6 +85,8 @@ ZFCP_DEFINE_ATTR(zfcp_unit, unit, in_recZFCP_DEFINE_ATTR (zfcp_unit, unit, access_denied,"%d\n" , (zfcp_unit_sdev_status (unit) &ZFCP_STATUS_COMMON_ACCESS_DENIED ) !=0 ); +ZFCP_DEFINE_ATTR_CONST (unit, access_shared,"%d\n" ,0 ); +ZFCP_DEFINE_ATTR_CONST (unit, access_readonly,"%d\n" ,0 ); static ssize_t zfcp_sysfs_port_failed_show(struct device *dev, struct device_attribute *attr,
@@ -347,6 +359,8 @@ static struct attribute *zfcp_unit_attrs &dev_attr_unit_in_recovery.attr, &dev_attr_unit_status.attr, &dev_attr_unit_access_denied.attr, + &dev_attr_unit_access_shared.attr, + &dev_attr_unit_access_readonly.attr,NULL }; static struct attribute_group zfcp_unit_attr_group = {
PATCH 7/8 zfcp: remove access control tables interface (port leftovers)
In reply to Steffen MaierFrom: Martin Peschke <[email protected]>
This patch removes some leftovers for commit 663e0890e31cb85f0cca5ac1faaee0d2d52880b5 "[SCSI] zfcp: remove access control tables interface".
The "access denied" case for ports is gone, as well. The corresponding flag was cleared, but never set. So clean it up.
Sysfs flag is kept, though, for backward-compatibility. Now it returns always 0.
--- drivers/s390/scsi/zfcp_erp.c | 7 ------- drivers/s390/scsi/zfcp_fsf.c | 3 +-- drivers/s390/scsi/zfcp_sysfs.c | 4 +--- 3 files changed, 2 insertions(+), 12 deletions(-)
drivers/s390/scsi/zfcp_erp.c +0 -7
@@ -821,11 +821,6 @@ static int zfcp_erp_port_forced_strategyreturn ZFCP_ERP_CONTINUES ; } -static void zfcp_erp_port_strategy_clearstati (struct zfcp_port *port) -{ -atomic_clear_mask (ZFCP_STATUS_COMMON_ACCESS_DENIED , &port->status); -} -static int zfcp_erp_port_forced_strategy (struct zfcp_erp_action *erp_action) {struct zfcp_port *port = erp_action->port;
@@ -833,7 +828,6 @@ static int zfcp_erp_port_forced_strategyswitch (erp_action->step) {case ZFCP_ERP_STEP_UNINITIALIZED : -zfcp_erp_port_strategy_clearstati (port);if ((status &ZFCP_STATUS_PORT_PHYS_OPEN ) && (status &ZFCP_STATUS_COMMON_OPEN ))return zfcp_erp_port_forced_strategy_close (erp_action);
@@ -933,7 +927,6 @@ static int zfcp_erp_port_strategy(structswitch (erp_action->step) {case ZFCP_ERP_STEP_UNINITIALIZED : -zfcp_erp_port_strategy_clearstati (port);if (p_status &ZFCP_STATUS_COMMON_OPEN )return zfcp_erp_port_strategy_close (erp_action);break ;
drivers/s390/scsi/zfcp_fsf.c +1 -2
@@ -1396,8 +1396,7 @@ static void zfcp_fsf_open_port_handler(s port->handle = header->port_handle;atomic_set_mask (ZFCP_STATUS_COMMON_OPEN |ZFCP_STATUS_PORT_PHYS_OPEN , &port->status); -atomic_clear_mask (ZFCP_STATUS_COMMON_ACCESS_DENIED | -ZFCP_STATUS_COMMON_ACCESS_BOXED , +atomic_clear_mask (ZFCP_STATUS_COMMON_ACCESS_BOXED , &port->status);/* check whether D_ID has changed during open */ /*
drivers/s390/scsi/zfcp_sysfs.c +1 -3
@@ -73,9 +73,7 @@ ZFCP_DEFINE_ATTR(zfcp_port, port, statusZFCP_DEFINE_ATTR (zfcp_port, port, in_recovery,"%d\n" , (atomic_read (&port->status) &ZFCP_STATUS_COMMON_ERP_INUSE ) !=0 ); -ZFCP_DEFINE_ATTR (zfcp_port, port, access_denied,"%d\n" , - (atomic_read (&port->status) & -ZFCP_STATUS_COMMON_ACCESS_DENIED ) !=0 ); +ZFCP_DEFINE_ATTR_CONST (port, access_denied,"%d\n" ,0 );ZFCP_DEFINE_ATTR (zfcp_unit, unit, status,"0x%08x\n" ,zfcp_unit_sdev_status (unit));
PATCH 8/8 zfcp: enable FCP hardware data router by default
In reply to Steffen MaierEnabling the data router support by default
can increase performance in certain situations.
It is safe to do so and tolerated in LPAR and under z/VM in case there is no data router support in that environment.
--- drivers/s390/scsi/zfcp_qdio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/s390/scsi/zfcp_qdio.c +2 -2
@@ -16,9 +16,9 @@#define QBUFF_PER_PAGE (PAGE_SIZE / sizeof(struct qdio_buffer)) -static bool enable_multibuffer; +static bool enable_multibuffer =1 ;module_param_named (datarouter, enable_multibuffer, bool,0400 ); -MODULE_PARM_DESC (datarouter,"Enable hardware data router support" ); +MODULE_PARM_DESC (datarouter,"Enable hardware data router support (default on)" );static int zfcp_qdio_buffers_enqueue (struct qdio_buffer **sbal) {
James Bottomley
maintainerQuoted 5 lines · Steffen Maier
James,
here is a series of zfcp features and bugfixes
for the upcoming merge window preparing kernel v3.12.
The patches apply on top of the current misc branch of your scsi.git.
OK, so this isn't going to work any more given Greg's recent statements. Patches for stable have to go through the -rc fixes process, so could you redo this as two patch sets: one for fixes with the cc stable tags and the rest for misc?
Thanks,
James
cover zfcp bugfixes for 3.11-rc
James,
as discussed, I split up bugfixes and features in two separate sets. Here is a resend of zfcp bugfixes for 3.11-rc and stable. The patches apply on top of the current fixes branch of your scsi.git.
Steffen
Linux on System z Development
IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martin Jetter
Geschaeftsfuehrung: Dirk Wittkopp
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
PATCH RESEND 1/3 zfcp: fix lock imbalance by reworking request queue locking
From: Martin Peschke <[email protected]>
This patch adds wait_event_interruptible_lock_irq_timeout(), which is a straight-forward descendant of wait_event_interruptible_timeout() and wait_event_interruptible_lock_irq().
The zfcp driver used to call wait_event_interruptible_timeout() in combination with some intricate and error-prone locking. Using wait_event_interruptible_lock_irq_timeout() as a replacement nicely cleans up that locking.
This rework removes a situation that resulted in a locking imbalance in zfcp_qdio_sbal_get():
BUG: workqueue leaked lock or atomic: events/1/0xffffff00/10
last function: zfcp_fc_wka_port_offline+0x0/0xa0 [zfcp]It was introduced by commit c2af7545aaff3495d9bf9a7608c52f0af86fb194 "[SCSI] zfcp: Do not wait for SBALs on stopped queue", which had a new code path related to ZFCP_STATUS_ADAPTER_QDIOUP that took an early exit without a required lock being held. The problem occured when a special, non-SCSI I/O request was being submitted in process context, when the adapter's queues had been torn down. In this case the bug surfaced when the Fibre Channel port connection for a well-known address was closed during a concurrent adapter shut-down procedure, which is a rare constellation.
This patch also fixes these warnings from the sparse tool (make C=1):
drivers/s390/scsi/zfcp_qdio.c:224:12: warning: context imbalance in
'zfcp_qdio_sbal_check' - wrong count at exitdrivers/s390/scsi/zfcp_qdio.c:244:5: warning: context imbalance in
'zfcp_qdio_sbal_get' - unexpected unlock
Last but not least, we get rid of that crappy lock-unlock-lock sequence at the beginning of the critical section.
It is okay to call zfcp_erp_adapter_reopen() with req_q_lock held.
--- drivers/s390/scsi/zfcp_qdio.c | 8 +---- include/linux/wait.h | 57 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 6 deletions(-)
drivers/s390/scsi/zfcp_qdio.c +2 -6
@@ -224,11 +224,9 @@ int zfcp_qdio_sbals_from_sg(struct zfcp_static int zfcp_qdio_sbal_check (struct zfcp_qdio *qdio) { -spin_lock_irq (&qdio->req_q_lock);if (atomic_read (&qdio->req_q_free) || !(atomic_read (&qdio->adapter->status) &ZFCP_STATUS_ADAPTER_QDIOUP ))return 1 ; -spin_unlock_irq (&qdio->req_q_lock);return 0 ; }
@@ -246,9 +244,8 @@ int zfcp_qdio_sbal_get(struct zfcp_qdio {long ret; -spin_unlock_irq (&qdio->req_q_lock); - ret =wait_event_interruptible_timeout (qdio->req_q_wq, -zfcp_qdio_sbal_check (qdio),5 *HZ ); + ret =wait_event_interruptible_lock_irq_timeout (qdio->req_q_wq, +zfcp_qdio_sbal_check (qdio), qdio->req_q_lock,5 *HZ );if (!(atomic_read (&qdio->adapter->status) &ZFCP_STATUS_ADAPTER_QDIOUP ))return -EIO ;
@@ -262,7 +259,6 @@ int zfcp_qdio_sbal_get(struct zfcp_qdiozfcp_erp_adapter_reopen (qdio->adapter,0 ,"qdsbg_1" ); } -spin_lock_irq (&qdio->req_q_lock);return -EIO ; }
include/linux/wait.h +57 -0
63 lines not on this page · raw message
PATCH RESEND 2/3 zfcp: fix schedule-inside-lock in scsi_device list loops
In reply to Steffen MaierFrom: Martin Peschke <[email protected]>
BUG: sleeping function called from invalid context at kernel/workqueue.c:2752 in_atomic(): 1, irqs_disabled(): 1, pid: 360, name: zfcperp0.0.1700 CPU: 1 Not tainted 3.9.3+ #69 Process zfcperp0.0.1700 (pid: 360, task: 0000000075b7e080, ksp: 000000007476bc30) <snip> Call Trace: ([<00000000001165de>] show_trace+0x106/0x154) [<00000000001166a0>] show_stack+0x74/0xf4 [<00000000006ff646>] dump_stack+0xc6/0xd4 [<000000000017f3a0>] __might_sleep+0x128/0x148 [<000000000015ece8>] flush_work+0x54/0x1f8 [<00000000001630de>] __cancel_work_timer+0xc6/0x128 [<00000000005067ac>] scsi_device_dev_release_usercontext+0x164/0x23c [<0000000000161816>] execute_in_process_context+0x96/0xa8 [<00000000004d33d8>] device_release+0x60/0xc0 [<000000000048af48>] kobject_release+0xa8/0x1c4 [<00000000004f4bf2>] __scsi_iterate_devices+0xfa/0x130 [<000003ff801b307a>] zfcp_erp_strategy+0x4da/0x1014 [zfcp] [<000003ff801b3caa>] zfcp_erp_thread+0xf6/0x2b0 [zfcp] [<000000000016b75a>] kthread+0xf2/0xfc [<000000000070c9de>] kernel_thread_starter+0x6/0xc [<000000000070c9d8>] kernel_thread_starter+0x0/0xc
Apparently, the ref_count for some scsi_device drops down to zero, triggering device removal through execute_in_process_context(), while the lldd error recovery thread iterates through a scsi device list. Unfortunately, execute_in_process_context() decides to immediately execute that device removal function, instead of scheduling asynchronous execution, since it detects process context and thinks it is safe to do so. But almost all calls to shost_for_each_device() in our lldd are inside spin_lock_irq, even in thread context. Obviously, schedule() inside spin_lock_irq sections is a bad idea.
Change the lldd to use the proper iterator function, __shost_for_each_device(), in combination with required locking.
Occurences that need to be changed include all calls in zfcp_erp.c, since those might be executed in zfcp error recovery thread context with a lock held.
Other occurences of shost_for_each_device() in zfcp_fsf.c do not need to be changed (no process context, no surrounding locking).
The problem was introduced in Linux 2.6.37 by commit b62a8d9b45b971a67a0f8413338c230e3117dff5
"[SCSI] zfcp: Use SCSI device data zfcp_scsi_dev instead of zfcp_unit".
--- drivers/s390/scsi/zfcp_erp.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-)
drivers/s390/scsi/zfcp_erp.c +22 -7
@@ -102,10 +102,13 @@ static void zfcp_erp_action_dismiss_portif (atomic_read (&port->status) &ZFCP_STATUS_COMMON_ERP_INUSE )zfcp_erp_action_dismiss (&port->erp_action); -else -shost_for_each_device (sdev, port->adapter->scsi_host) +else { +spin_lock (port->adapter->scsi_host->host_lock); +__shost_for_each_device (sdev, port->adapter->scsi_host)if (sdev_to_zfcp (sdev)->port == port)zfcp_erp_action_dismiss_lun (sdev); +spin_unlock (port->adapter->scsi_host->host_lock); + } }static void zfcp_erp_action_dismiss_adapter (struct zfcp_adapter *adapter)
@@ -592,9 +595,11 @@ static void _zfcp_erp_lun_reopen_all(str {struct scsi_device *sdev; -shost_for_each_device (sdev, port->adapter->scsi_host) +spin_lock (port->adapter->scsi_host->host_lock); +__shost_for_each_device (sdev, port->adapter->scsi_host)if (sdev_to_zfcp (sdev)->port == port)_zfcp_erp_lun_reopen (sdev, clear, id,0 ); +spin_unlock (port->adapter->scsi_host->host_lock); }static void zfcp_erp_strategy_followup_failed (struct zfcp_erp_action *act)
@@ -1434,8 +1439,10 @@ void zfcp_erp_set_adapter_status(structatomic_set_mask (common_mask, &port->status);read_unlock_irqrestore (&adapter->port_list_lock, flags); -shost_for_each_device (sdev, adapter->scsi_host) +spin_lock_irqsave (adapter->scsi_host->host_lock, flags); +__shost_for_each_device (sdev, adapter->scsi_host)atomic_set_mask (common_mask, &sdev_to_zfcp (sdev)->status); +spin_unlock_irqrestore (adapter->scsi_host->host_lock, flags); }/**
@@ -1469,11 +1476,13 @@ void zfcp_erp_clear_adapter_status(struc }read_unlock_irqrestore (&adapter->port_list_lock, flags); -shost_for_each_device (sdev, adapter->scsi_host) { +spin_lock_irqsave (adapter->scsi_host->host_lock, flags); +__shost_for_each_device (sdev, adapter->scsi_host) {atomic_clear_mask (common_mask, &sdev_to_zfcp (sdev)->status);if (clear_counter)atomic_set (&sdev_to_zfcp (sdev)->erp_counter,0 ); } +spin_unlock_irqrestore (adapter->scsi_host->host_lock, flags); }/**
@@ -1487,16 +1496,19 @@ void zfcp_erp_set_port_status(struct zfc {struct scsi_device *sdev;u32 common_mask = mask &ZFCP_COMMON_FLAGS ; +unsigned long flags;atomic_set_mask (mask, &port->status);if (!common_mask)return ; -shost_for_each_device (sdev, port->adapter->scsi_host) +spin_lock_irqsave (port->adapter->scsi_host->host_lock, flags); +__shost_for_each_device (sdev, port->adapter->scsi_host)if (sdev_to_zfcp (sdev)->port == port)atomic_set_mask (common_mask, &sdev_to_zfcp (sdev)->status); +spin_unlock_irqrestore (port->adapter->scsi_host->host_lock, flags); }/**
@@ -1511,6 +1523,7 @@ void zfcp_erp_clear_port_status(struct zstruct scsi_device *sdev;u32 common_mask = mask &ZFCP_COMMON_FLAGS ;u32 clear_counter = mask &ZFCP_STATUS_COMMON_ERP_FAILED ; +unsigned long flags;atomic_clear_mask (mask, &port->status);
@@ -1520,13 +1533,15 @@ void zfcp_erp_clear_port_status(struct zif (clear_counter)atomic_set (&port->erp_counter,0 ); -shost_for_each_device (sdev, port->adapter->scsi_host) +spin_lock_irqsave (port->adapter->scsi_host->host_lock, flags); +__shost_for_each_device (sdev, port->adapter->scsi_host)if (sdev_to_zfcp (sdev)->port == port) {atomic_clear_mask (common_mask, &sdev_to_zfcp (sdev)->status);if (clear_counter)atomic_set (&sdev_to_zfcp (sdev)->erp_counter,0 ); } +spin_unlock_irqrestore (port->adapter->scsi_host->host_lock, flags); }/**
PATCH RESEND 3/3 zfcp: remove access control tables interface (keep sysfs files)
In reply to Steffen MaierFrom: Martin Peschke <[email protected]>
By popular demand, this patch brings back a couple of sysfs attributes removed by commit 663e0890e31cb85f0cca5ac1faaee0d2d52880b5 "[SCSI] zfcp: remove access control tables interface".
The content has been irrelevant for years, but the files must be there forever for whatever user space tools that may rely on them.
Since these files always return a constant value, a new stripped down show-macro was required. Otherwise build warnings would have been introduced.
--- drivers/s390/scsi/zfcp_sysfs.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/s390/scsi/zfcp_sysfs.c +14 -0
@@ -27,6 +27,16 @@ static ssize_t zfcp_sysfs_##_feat##_##_n static ZFCP_DEV_ATTR(_feat, _name, S_IRUGO, \ zfcp_sysfs_##_feat##_##_name##_show, NULL); +#define ZFCP_DEFINE_ATTR_CONST (_feat, _name, _format, _value) \ +static ssize_t zfcp_sysfs_##_feat##_##_name##_show(struct device *dev, \ + struct device_attribute *at,\ + char *buf) \ +{ \ + return sprintf(buf, _format, _value); \ +} \ +static ZFCP_DEV_ATTR(_feat, _name, S_IRUGO, \ + zfcp_sysfs_##_feat##_##_name##_show, NULL); +#define ZFCP_DEFINE_A_ATTR (_name, _format, _value) \ static ssize_t zfcp_sysfs_adapter_##_name##_show(struct device *dev, \ struct device_attribute *at,\
@@ -75,6 +85,8 @@ ZFCP_DEFINE_ATTR(zfcp_unit, unit, in_recZFCP_DEFINE_ATTR (zfcp_unit, unit, access_denied,"%d\n" , (zfcp_unit_sdev_status (unit) &ZFCP_STATUS_COMMON_ACCESS_DENIED ) !=0 ); +ZFCP_DEFINE_ATTR_CONST (unit, access_shared,"%d\n" ,0 ); +ZFCP_DEFINE_ATTR_CONST (unit, access_readonly,"%d\n" ,0 ); static ssize_t zfcp_sysfs_port_failed_show(struct device *dev, struct device_attribute *attr,
@@ -347,6 +359,8 @@ static struct attribute *zfcp_unit_attrs &dev_attr_unit_in_recovery.attr, &dev_attr_unit_status.attr, &dev_attr_unit_access_denied.attr, + &dev_attr_unit_access_shared.attr, + &dev_attr_unit_access_readonly.attr,NULL }; static struct attribute_group zfcp_unit_attr_group = {
James Bottomley
maintainerRe: [PATCH RESEND 3/3] zfcp: remove access control tables interface (keep sysfs files)
Quoted 8 lines · Steffen Maier
From: Martin Peschke <[email protected]>
By popular demand, this patch brings back a couple of sysfs attributes removed by commit
663e0890e31cb85f0cca5ac1faaee0d2d52880b5"[SCSI] zfcp: remove access control tables interface".
The content has been irrelevant for years, but the files must be there forever for whatever user space tools that may rely on them.
Quoted 6 lines
Since these files always return a constant value, a new stripped down show-macro was required. Otherwise build warnings would have been introduced.
Signed-off-by Martin Peschke <[email protected]>Cc [email protected] #3.11+
If I'm sending this for 3.11-rc, this stable tag is unnecessary, right? It will go into 3.11 and you don't want it for 3.10.
James
Re: [PATCH RESEND 3/3] zfcp: remove access control tables interface (keep sysfs files)
Quoted 13 lines · James Bottomley
Quoted 12 lines · Steffen Maier
From: Martin Peschke <[email protected]>
By popular demand, this patch brings back a couple of sysfs attributes removed by commit
663e0890e31cb85f0cca5ac1faaee0d2d52880b5"[SCSI] zfcp: remove access control tables interface".
The content has been irrelevant for years, but the files must be there forever for whatever user space tools that may rely on them.Since these files always return a constant value, a new stripped down show-macro was required. Otherwise build warnings would have been introduced.
Quoted 5 lines
Quoted 2 lines
Signed-off-by Martin Peschke <[email protected]>Cc [email protected] #3.11+If I'm sending this for 3.11-rc, this stable tag is unnecessary, right? It will go into 3.11 and you don't want it for 3.10.
Correct, it's a no-op, my bad.
Signature · 15 lines
Mit freundlichen Grüßen / Kind regards Steffen Maier Linux on System z Development IBM Deutschland Research & Development GmbH Vorsitzende des Aufsichtsrats: Martina Koederitz Geschaeftsfuehrung: Dirk Wittkopp Sitz der Gesellschaft: Boeblingen Registergericht: Amtsgericht Stuttgart, HRB 243294 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
cover zfcp features for 3.12 merge window
In reply to James BottomleyJames,
as discussed, I split up bugfixes and features in two separate sets. Here is a resend of zfcp features for the upcoming merge window preparing kernel v3.12.
The patches apply on top of the current misc branch of your scsi.git.
Compared to the original posting, I had to drop the following patch for now:
zfcp: remove access control tables interface (port leftovers)
because it only builds on top of another patch from the fixes set
(zfcp: remove access control tables interface (keep sysfs files))
which defines a new required helper macro.
I'm going to submit the dropped patch later, once the fixes are merged upstream.
Steffen
Linux on System z Development
IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martin Jetter
Geschaeftsfuehrung: Dirk Wittkopp
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
PATCH RESEND 1/4 zfcp: consistently use appropriate SBAL flag definitions
From: Martin Peschke <[email protected]>
minor cleanup for status read request
--- drivers/s390/scsi/zfcp_fsf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/s390/scsi/zfcp_fsf.c +2 -1
@@ -770,7 +770,8 @@ int zfcp_fsf_status_read(struct zfcp_qdiif (zfcp_qdio_sbal_get (qdio)) goto out; - req =zfcp_fsf_req_create (qdio,FSF_QTCB_UNSOLICITED_STATUS ,0 , + req =zfcp_fsf_req_create (qdio,FSF_QTCB_UNSOLICITED_STATUS , +SBAL_SFLAGS0_TYPE_STATUS , adapter->pool.status_read_req);if (IS_ERR (req)) { retval =PTR_ERR (req);
PATCH RESEND 2/4 zfcp: cleanup use of obsolete strict_strto* functions
In reply to Steffen MaierFrom: Martin Peschke <[email protected]>
strict_strtoul and friends are obsolete. Use kstrtoul functions instead.
--- drivers/s390/scsi/zfcp_aux.c | 4 ++-- drivers/s390/scsi/zfcp_sysfs.c | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-)
drivers/s390/scsi/zfcp_aux.c +2 -2
@@ -104,11 +104,11 @@ static void __init zfcp_init_device_setustrncpy (busid, token,ZFCP_BUS_ID_SIZE ); token =strsep (&str,"," ); -if (!token ||strict_strtoull (token,0 , (unsigned long long *) &wwpn)) +if (!token ||kstrtoull (token,0 , (unsigned long long *) &wwpn)) goto err_out; token =strsep (&str,"," ); -if (!token ||strict_strtoull (token,0 , (unsigned long long *) &lun)) +if (!token ||kstrtoull (token,0 , (unsigned long long *) &lun)) goto err_out;kfree (str_saved);
drivers/s390/scsi/zfcp_sysfs.c +6 -6
@@ -95,7 +95,7 @@ static ssize_t zfcp_sysfs_port_failed_st struct zfcp_port *port = container_of(dev, struct zfcp_port, dev);unsigned long val; -if (strict_strtoul (buf,0 , &val) || val !=0 ) +if (kstrtoul (buf,0 , &val) || val !=0 )return -EINVAL ;zfcp_erp_set_port_status (port,ZFCP_STATUS_COMMON_RUNNING );
@@ -134,7 +134,7 @@ static ssize_t zfcp_sysfs_unit_failed_stunsigned long val;struct scsi_device *sdev; -if (strict_strtoul (buf,0 , &val) || val !=0 ) +if (kstrtoul (buf,0 , &val) || val !=0 )return -EINVAL ; sdev =zfcp_unit_sdev (unit);
@@ -184,7 +184,7 @@ static ssize_t zfcp_sysfs_adapter_failedif (!adapter)return -ENODEV ; -if (strict_strtoul (buf,0 , &val) || val !=0 ) { +if (kstrtoul (buf,0 , &val) || val !=0 ) { retval = -EINVAL ; goto out; }
@@ -236,7 +236,7 @@ static ssize_t zfcp_sysfs_port_remove_stif (!adapter)return -ENODEV ; -if (strict_strtoull (buf,0 , (unsigned long long *) &wwpn)) +if (kstrtoull (buf,0 , (unsigned long long *) &wwpn)) goto out; port =zfcp_get_port_by_wwpn (adapter, wwpn);
@@ -297,7 +297,7 @@ static ssize_t zfcp_sysfs_unit_add_storeu64 fcp_lun;int retval; -if (strict_strtoull (buf,0 , (unsigned long long *) &fcp_lun)) +if (kstrtoull (buf,0 , (unsigned long long *) &fcp_lun))return -EINVAL ; retval =zfcp_unit_add (port, fcp_lun);
@@ -315,7 +315,7 @@ static ssize_t zfcp_sysfs_unit_remove_st struct zfcp_port *port = container_of(dev, struct zfcp_port, dev);u64 fcp_lun; -if (strict_strtoull (buf,0 , (unsigned long long *) &fcp_lun)) +if (kstrtoull (buf,0 , (unsigned long long *) &fcp_lun))return -EINVAL ;if (zfcp_unit_remove (port, fcp_lun))
PATCH RESEND 3/4 zfcp: dead code removal
In reply to Steffen MaierFrom: Martin Peschke <[email protected]>
Get rid of unused function zfcp_fsf_get_req and corresponding prototype definition.
Commit a54ca0f62f953898b05549391ac2a8a4dad6482b in v2.6.28 "[SCSI] zfcp: Redesign of the debug tracing for HBA records." accidentally introduced this code which was dead in the first place.
--- drivers/s390/scsi/zfcp_ext.h | 2 -- drivers/s390/scsi/zfcp_fsf.c | 9 --------- 2 files changed, 11 deletions(-)
drivers/s390/scsi/zfcp_ext.h +0 -2
@@ -126,8 +126,6 @@ extern int zfcp_qdio_sbals_from_sg(strucextern int zfcp_qdio_open (struct zfcp_qdio *);extern void zfcp_qdio_close (struct zfcp_qdio *);extern void zfcp_qdio_siosl (struct zfcp_adapter *); -extern struct zfcp_fsf_req *zfcp_fsf_get_req (struct zfcp_qdio *, -struct qdio_buffer *);/* zfcp_scsi.c */ extern struct scsi_transport_template *zfcp_scsi_transport_template;
drivers/s390/scsi/zfcp_fsf.c +0 -9
@@ -2388,12 +2388,3 @@ void zfcp_fsf_reqid_check(struct zfcp_qdbreak ; } } - -struct zfcp_fsf_req *zfcp_fsf_get_req (struct zfcp_qdio *qdio, -struct qdio_buffer *sbal) -{ -struct qdio_buffer_element *sbale = &sbal->element[0 ]; -u64 req_id = (unsigned long ) sbale->addr; - -return zfcp_reqlist_find (qdio->adapter->req_list, req_id); -}
PATCH RESEND 4/4 zfcp: enable FCP hardware data router by default
In reply to Steffen MaierEnabling the data router support by default
can increase performance in certain situations.
It is safe to do so and tolerated in LPAR and under z/VM in case there is no data router support in that environment.
--- drivers/s390/scsi/zfcp_qdio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/s390/scsi/zfcp_qdio.c +2 -2
@@ -16,9 +16,9 @@#define QBUFF_PER_PAGE (PAGE_SIZE / sizeof(struct qdio_buffer)) -static bool enable_multibuffer; +static bool enable_multibuffer =1 ;module_param_named (datarouter, enable_multibuffer, bool,0400 ); -MODULE_PARM_DESC (datarouter,"Enable hardware data router support" ); +MODULE_PARM_DESC (datarouter,"Enable hardware data router support (default on)" );static int zfcp_qdio_buffers_enqueue (struct qdio_buffer **sbal) {