[PATCH] xen-scsifront: don't deadlock if the ring becomes full

2014-09-11 Thread David Vrabel
scsifront_action_handler() will deadlock on host-host_lock, if the
ring is full and it has to wait for entries to become available.

Signed-off-by: David Vrabel david.vra...@citrix.com
---
This was found with sparse. I've not tested it.
---
 drivers/scsi/xen-scsifront.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/xen-scsifront.c b/drivers/scsi/xen-scsifront.c
index 7e88659..cc14c8d 100644
--- a/drivers/scsi/xen-scsifront.c
+++ b/drivers/scsi/xen-scsifront.c
@@ -541,8 +541,9 @@ static int scsifront_action_handler(struct scsi_cmnd *sc, 
uint8_t act)
if (!shadow)
return FAILED;
 
+   spin_lock_irq(host-host_lock);
+
for (;;) {
-   spin_lock_irq(host-host_lock);
if (!RING_FULL(info-ring)) {
ring_req = scsifront_command2ring(info, sc, shadow);
if (ring_req)
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] xen-scsifront: don't deadlock if the ring becomes full

2014-09-11 Thread Juergen Gross

On 09/11/2014 03:31 PM, David Vrabel wrote:

scsifront_action_handler() will deadlock on host-host_lock, if the
ring is full and it has to wait for entries to become available.

Signed-off-by: David Vrabel david.vra...@citrix.com
---
This was found with sparse. I've not tested it.


Test might be difficult. :-)

Reviewed-by: Juergen Gross jgr...@suse.com

Thanks for spotting this.

Juergen


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

diff --git a/drivers/scsi/xen-scsifront.c b/drivers/scsi/xen-scsifront.c
index 7e88659..cc14c8d 100644
--- a/drivers/scsi/xen-scsifront.c
+++ b/drivers/scsi/xen-scsifront.c
@@ -541,8 +541,9 @@ static int scsifront_action_handler(struct scsi_cmnd *sc, 
uint8_t act)
if (!shadow)
return FAILED;

+   spin_lock_irq(host-host_lock);
+
for (;;) {
-   spin_lock_irq(host-host_lock);
if (!RING_FULL(info-ring)) {
ring_req = scsifront_command2ring(info, sc, shadow);
if (ring_req)



--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html