public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Vivek Goyal <vgoyal@redhat.com>
To: linux kernel mailing list <linux-kernel@vger.kernel.org>,
	Jens Axboe <jaxboe@fusionio.com>
Cc: Tejun Heo <tj@kernel.org>
Subject: Question about life time of block device request queue
Date: Thu, 12 May 2011 16:21:21 -0400	[thread overview]
Message-ID: <20110512202121.GA24843@redhat.com> (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

                 reply	other threads:[~2011-05-12 20:21 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20110512202121.GA24843@redhat.com \
    --to=vgoyal@redhat.com \
    --cc=jaxboe@fusionio.com \
    --cc=linux-kernel@vger.kernel.org \
    --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