Skip to contentSkip to conversation

Question about life time of block device request queue

DISCUSSION Vivek Goyal 1 participant 1 message May 12, 2011

lore
Share & tools
lore
#0 lore raw

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