WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] xen-blkfront: fix a deadlock while handling discard

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] xen-blkfront: fix a deadlock while handling discard response
From: Li Dongyang <lidongyang@xxxxxxxxxx>
Date: Wed, 14 Sep 2011 14:02:40 +0800
Cc: JBeulich@xxxxxxxxxx, konrad.wilk@xxxxxxxxxx
Delivery-date: Tue, 13 Sep 2011 23:05:26 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
When we get EOPNOTSUPP response for a discard request, we will clear
the discard flag on the request queue so we won't attempt to send discard
requests to backend again, and this should be protected under rq->queue_lock.
However, when we setup the request queue, we pass blkif_io_lock to
blk_init_queue so rq->queue_lock is blkif_io_lock indeed,
and this lock is already taken when we are in blkif_interrpt, so remove the
spin_lock/spin_unlock when we clear the discard flag or we will end up
with deadlock here, Thanks
Sorry for the stupid mistake.

Signed-off-by: Li Dongyang <lidongyang@xxxxxxxxxx>
---
 drivers/block/xen-blkfront.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index 86e2c63..d9789f18 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -747,9 +747,12 @@ static irqreturn_t blkif_interrupt(int irq, void *dev_id)
                                           info->gd->disk_name);
                                error = -EOPNOTSUPP;
                                info->feature_discard = 0;
-                               spin_lock(rq->queue_lock);
+                               /*
+                                * rq->queue_lock should be acquired before 
this call,
+                                * it is actually blkif_io_lock, and already 
been taken
+                                * once we are in blkif_interrupt
+                                */
                                queue_flag_clear(QUEUE_FLAG_DISCARD, rq);
-                               spin_unlock(rq->queue_lock);
                        }
                        __blk_end_request_all(req, error);
                        break;
-- 
1.7.6.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] xen-blkfront: fix a deadlock while handling discard response, Li Dongyang <=