public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Question about life time of block device request queue
@ 2011-05-12 20:21 Vivek Goyal
  0 siblings, 0 replies; only message in thread
From: Vivek Goyal @ 2011-05-12 20:21 UTC (permalink / raw)
  To: linux kernel mailing list, Jens Axboe; +Cc: Tejun Heo

Hi,

I am reading following code and wondering what makes sure that request
queue lock is still valid by the time we call __make_request().

__generic_make_request() {
...
...
                if (unlikely(test_bit(QUEUE_FLAG_DEAD, &q->queue_flags)))
                        goto end_io;

...
...
		ret = q->make_request_fn(q, bio); ---> __make_request();
}

__make_request(q)
{
	spin_lock_irq(q->queue_lock);
}

blk_cleanup_queue()
{
...
...
	queue_flag_set_unlocked(QUEUE_FLAG_DEAD, q);
...
...
}

So when a driver tears down the request queue it should call
blk_cleanup_queue() which will mark queue as DEAD.

In __generic_make_request() once we have checked for dead queue and then
we run bunch of more instructions and then call q->make_request_fn() which
calls __make_request() and in __make_request we take ->queue_lock. What
makes sure that driver did not call blk_cleanup_queue() between DEAD flag
test and taking of spin lock?

Is this a race condition or I am missing something.

Thanks
Vivek

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-05-12 20:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-12 20:21 Question about life time of block device request queue Vivek Goyal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox