xen-blkfront: fix a deadlock while handling discard response
authorLi Dongyang <lidongyang@novell.com>
Wed, 14 Sep 2011 06:02:40 +0000 (14:02 +0800)
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Thu, 13 Oct 2011 13:48:32 +0000 (09:48 -0400)
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

Signed-off-by: Li Dongyang <lidongyang@novell.com>
[v1: Updated description a bit and removed comment from source]
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
drivers/block/xen-blkfront.c

index 52076b0d03268d5667964ede95e9b850658cfb65..7d148776028347caebc9f71df925cad631ec3443 100644 (file)
@@ -747,9 +747,7 @@ 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);
                                queue_flag_clear(QUEUE_FLAG_DISCARD, rq);
-                               spin_unlock(rq->queue_lock);
                        }
                        __blk_end_request_all(req, error);
                        break;