zfcp: Fix spinlock imbalance in zfcp_qdio_sbal_get
Quoted 26 lines
-------- Original Message --------
Subject: Re: [PATCH] zfcp: Fix spinlock imbalance inzfcp_qdio_sbal_get
Date: Wed, 15 May 2013 18:03:56 +0200
From: Heiko Carstens <[email protected]>
To: Mikulas Patocka <[email protected]>
CC: Steffen Maier <[email protected]>, [email protected], [email protected]Quoted 16 lines · Mikulas Patocka
zfcp: Fix spinlock imbalance in
zfcp_qdio_sbal_getSigned-off-by Mikulas Patocka <[email protected]>--- drivers/s390/scsi/zfcp_qdio.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)Index:
linux-2.6/drivers/s390/scsi/zfcp_qdio.c
===================================================================drivers/s390/scsi/zfcp_qdio.c +0
-0@@ -250,8 +250,11 @@ int zfcp_qdio_sbal_get(struct zfcp_qdio ret =wait_event_interruptible_timeout (qdio->req_q_wq,zfcp_qdio_sbal_check (qdio),5 *HZ );
Quoted 8 lines
drivers/s390/scsi/zfcp_qdio.c int zfcp_qdio_sbal_get(struct zfcp_qdio · line 257
Quoted 6 lines
drivers/s390/scsi/zfcp_qdio.c +4
-1-if (!(atomic_read (&qdio->adapter->status) &ZFCP_STATUS_ADAPTER_QDIOUP )) +if (!(atomic_read (&qdio->adapter->status) &ZFCP_STATUS_ADAPTER_QDIOUP )) { +if (ret <=0 ) +spin_lock_irq (&qdio->req_q_lock);return -EIO ; + }Looks good to me. However it's Steffen's call.
Looking at the commit that introduced this race:
commit c2af7545aaff3495d9bf9a7608c52f0af86fb194
Author: Christof Schmitt <[email protected]> Date: Mon Jun 21 10:11:32 2010 +0200
[SCSI] zfcp: Do not wait for SBALs on stopped queue
Trying to read the FC host statistics on an offline adapter results in a 5 seconds wait. Reading the statistics tries to issue an exchange port data request which first waits up to 5 seconds for an entry in the request queue.
Change the strategy for getting a free SBAL to exit when the queue is stopped. Reading the statistics will then fail without the wait.
makes me think that it would be best to revert it.
A much simpler and less error-prone fix for the initial 5 sec delay usability issue would have been to check the ZFCP_STATUS_COMMON_UNBLOCKED flag when entering that sysfs code path, as done in other places (see zfcp_scsi_queuecommand(), for example).
I am reluctant to add more locking statements like the above. The entire use of req_q_lock sort of works - but the code has become crappy and should be cleaned up anyway. Just look at the lock-unlock-lock sequence done prior to entering the critical section.
Martin