public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Roland Dreier <roland@kernel.org>
Cc: open list <linux-kernel@vger.kernel.org>
Subject: Re: warning because of race between userspace and add_disk()?
Date: Wed, 06 Jul 2011 16:56:57 +0200	[thread overview]
Message-ID: <4E1477B9.1050701@kernel.dk> (raw)
In-Reply-To: <CAG4TOxP1eTY_R_t57U1Ux=RTFa=3BWWL9yzL-p9sC+YWrpZmYQ@mail.gmail.com>

On 2011-07-06 02:14, Roland Dreier wrote:
> Hi Jens!
> 
> I'm seeing the warning below (with 3.0-rc5) when I hot-add a disk.
> The system has a JBOD with 4 SAS paths, so we get 4 /dev/sdXX for the
> disk (I don't think this is strictly required to trigger this, but I
> think it makes the race bigger).
> 
> What I _think_ is happening is that add_disk() exposes the /dev/sdXX
> device to userspace before it does disk_add_events(), and the
> multipath daemon immediately tries to open the device.  This means
> that blkdev_get() (called from blkdev_open()) races with
> disk_add_events() and so the first call to disk_block_events() returns
> immediately because of
> 
> 	struct disk_events *ev = disk->ev;
> 	if (!ev)
> 		return;
> 
> but then on the way out, disk_unblock_events() finds that disk->ev has
> been set and so hits the warning.
> 
> I guess the fix would be to be more careful about the order we expose
> things when registering disks?

It certainly looks like it, we need to order disk_add_events() before
register_disk() or handle this more gracefully. I'll cook up a patch.

-- 
Jens Axboe


  reply	other threads:[~2011-07-06 14:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-06  0:14 warning because of race between userspace and add_disk()? Roland Dreier
2011-07-06 14:56 ` Jens Axboe [this message]
2011-07-07 18:36   ` Roland Dreier

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=4E1477B9.1050701@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=roland@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