linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: IDE locking problem
@ 2003-08-03 14:13 Manfred Spraul
  2003-08-03 14:25 ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 16+ messages in thread
From: Manfred Spraul @ 2003-08-03 14:13 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: Jens Axboe, linux-kernel

>
>
>Then, IDE could do something like:
>
> - set dead flag
> - wait for all pending requests to drain (easy: insert a barrier
>   in the queue and wait on it, with a hack for the barrier insertion
>   to bypass the dead flag... ugh... maybe a blk_terminate_queue()
>   doing all that would be helpful ?)
> - unregister blkdev
> - then tear down the queue (leaving the "empty" queue with the dead
>   flag set, not just memset(...,0,...), so that any bozo keeping a
>   reference to it will be rejected trying to insert request instead
>   of trying to tap an uninitalized queue object
>
>What do you think ?
>  
>
The last step is bad - sooner or later the queue will be kfreed, and if 
there are bozos around that still have references, they would access 
random memory. It must be guaranteed that all references expired before 
the tear down begins. Just leaving a dead flag set is not sufficient.

--
    Manfred


^ permalink raw reply	[flat|nested] 16+ messages in thread
* IDE locking problem
@ 2003-08-03  8:42 Benjamin Herrenschmidt
  2003-08-03  9:58 ` Benjamin Herrenschmidt
  2003-08-03 10:04 ` Jens Axboe
  0 siblings, 2 replies; 16+ messages in thread
From: Benjamin Herrenschmidt @ 2003-08-03  8:42 UTC (permalink / raw)
  To: Alan Cox, Bartlomiej Zolnierkiewicz, Jens Axboe; +Cc: linux-kernel mailing list

Hi Alan & Bart !

While fixing my hotswap media-bay IDE controller for 2.6, I found
a locking problem with IDE (again ? :) in ide_unregister_hw. Basically
the problem is that it calls blk_cleanup_queue(), which is unsafe to
call with a lock held (it will call flush_workqueue() at one point).
Other side effect, flush_workqueue() will re-enable IRQs, thus allowing
us to get an IRQ while holding the spinlock -> double lock, but that's
just a side effect of calling flush_workqueue in that context.

So the call to blk_cleanup_queue() shall be moved outside of the
spinlock. I don't know much about the BIO details, is it possible
to first unregister_blkdev, then only call blk_cleanup_queue() ? That
would help making sure we don't get a request sneaking in ?

Ben.



^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2003-08-05 17:17 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-03 14:13 IDE locking problem Manfred Spraul
2003-08-03 14:25 ` Benjamin Herrenschmidt
2003-08-03 15:35   ` Lou Langholtz
2003-08-04  5:40     ` Jens Axboe
  -- strict thread matches above, loose matches on Subject: below --
2003-08-03  8:42 Benjamin Herrenschmidt
2003-08-03  9:58 ` Benjamin Herrenschmidt
2003-08-05  0:28   ` Bartlomiej Zolnierkiewicz
2003-08-05  8:08     ` Benjamin Herrenschmidt
2003-08-05 10:49       ` Bartlomiej Zolnierkiewicz
2003-08-05 11:18         ` Benjamin Herrenschmidt
2003-08-05 12:30           ` Bartlomiej Zolnierkiewicz
2003-08-05 17:13             ` Alan Cox
2003-08-03 10:04 ` Jens Axboe
2003-08-03 10:08   ` Jens Axboe
2003-08-03 10:11   ` Benjamin Herrenschmidt
2003-08-03 10:20     ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).