mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: Tejun Heo <tj@kernel.org>
Cc: Steven Whitehouse <swhiteho@redhat.com>,
	linux-kernel@vger.kernel.org, Jens Axboe <jaxboe@fusionio.com>
Subject: Re: Strange block/scsi/workqueue issue
Date: Tue, 12 Apr 2011 00:02:51 -0500	[thread overview]
Message-ID: <1302584571.2558.24.camel@mulgrave.site> (raw)
In-Reply-To: <1302583757.2558.21.camel@mulgrave.site>

On Mon, 2011-04-11 at 23:49 -0500, James Bottomley wrote:
> The entangled deadlock seems to have been introduced by commit
> 3cca6dc1c81e2407928dc4c6105252146fd3924f prior to that, there was no
> synchronous cancel in the destroy path.
> 
> A fix might be to shunt more stuff off to workqueues, but that's
> producing a more complex system which would be prone to entanglements
> that would be even harder to spot.
> 
> Perhaps a better solution is just not to use sync cancellations in
> block?  As long as the work in the queue holds a queue ref, they can be
> done asynchronously.

So this is a possible implementation, does this fix the problem?
(compile tested only).

James

---

diff --git a/block/blk-core.c b/block/blk-core.c
index 90f22cc..f600f88 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -219,6 +219,7 @@ static void blk_delay_work(struct work_struct *work)
 	spin_lock_irq(q->queue_lock);
 	__blk_run_queue(q, false);
 	spin_unlock_irq(q->queue_lock);
+	blk_put_queue(q);
 }
 
 /**
@@ -233,7 +234,8 @@ static void blk_delay_work(struct work_struct *work)
  */
 void blk_delay_queue(struct request_queue *q, unsigned long msecs)
 {
-	schedule_delayed_work(&q->delay_work, msecs_to_jiffies(msecs));
+	if (!blk_get_queue(q))
+		schedule_delayed_work(&q->delay_work, msecs_to_jiffies(msecs));
 }
 EXPORT_SYMBOL(blk_delay_queue);
 
@@ -271,7 +273,8 @@ EXPORT_SYMBOL(blk_start_queue);
  **/
 void blk_stop_queue(struct request_queue *q)
 {
-	__cancel_delayed_work(&q->delay_work);
+	if (__cancel_delayed_work(&q->delay_work))
+		blk_put_queue(q);
 	queue_flag_set(QUEUE_FLAG_STOPPED, q);
 }
 EXPORT_SYMBOL(blk_stop_queue);
@@ -297,7 +300,8 @@ EXPORT_SYMBOL(blk_stop_queue);
 void blk_sync_queue(struct request_queue *q)
 {
 	del_timer_sync(&q->timeout);
-	cancel_delayed_work_sync(&q->delay_work);
+	if (__cancel_delayed_work(&q->delay_work))
+		blk_put_queue(q);
 	queue_sync_plugs(q);
 }
 EXPORT_SYMBOL(blk_sync_queue);



  reply	other threads:[~2011-04-12  5:02 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-11 14:56 Steven Whitehouse
2011-04-11 17:18 ` Tejun Heo
2011-04-11 17:29   ` Jens Axboe
2011-04-11 17:52   ` Steven Whitehouse
2011-04-12  0:14     ` Tejun Heo
2011-04-12  8:49       ` Steven Whitehouse
2011-04-12  0:47   ` James Bottomley
2011-04-12  2:51     ` Tejun Heo
2011-04-12  4:49       ` James Bottomley
2011-04-12  5:02         ` James Bottomley [this message]
2011-04-12  8:42           ` Steven Whitehouse
2011-04-12 13:42             ` James Bottomley
2011-04-12 14:06               ` Steven Whitehouse
2011-04-12 15:14                 ` James Bottomley
2011-04-12 16:04                   ` Steven Whitehouse
2011-04-12 16:27                     ` James Bottomley
2011-04-12 16:51                       ` Steven Whitehouse
2011-04-12 17:41                         ` James Bottomley
2011-04-12 18:33                           ` Steven Whitehouse
2011-04-12 19:56                             ` James Bottomley
2011-04-12 20:30                               ` Steven Whitehouse
2011-04-12 20:43                                 ` James Bottomley
2011-04-13  5:18                                   ` Tejun Heo
2011-04-13  6:06                                     ` Tejun Heo
2011-04-13  9:20                                       ` Steven Whitehouse
2011-04-13 14:00                                         ` Steven Whitehouse
2011-04-13 17:01                                           ` James Bottomley
2011-04-13 19:35                                             ` Steven Whitehouse
2011-04-13 20:12                                             ` Jens Axboe
2011-04-13 20:17                                               ` James Bottomley
2011-04-22 18:01                                                 ` Tejun Heo
2011-04-22 18:06                                                   ` James Bottomley
2011-04-22 18:30                                                     ` Tejun Heo
2011-05-31  6:05                                             ` Anton V. Boyarshinov
2011-04-22 18:03                                           ` Tejun Heo
2011-04-12  5:15         ` Tejun Heo
2011-04-12 15:15           ` James Bottomley
2011-04-13  5:11             ` Tejun Heo
2011-04-13 14:15               ` James Bottomley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1302584571.2558.24.camel@mulgrave.site \
    --to=james.bottomley@hansenpartnership.com \
    --cc=jaxboe@fusionio.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=swhiteho@redhat.com \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome