All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Mason <chris.mason@fusionio.com>
To: Eric Sandeen <sandeen@redhat.com>
Cc: Chris Mason <clmason@fusionio.com>,
	linux-btrfs <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH] use rcu_barrier() to wait for bdev puts at unmount
Date: Sat, 9 Mar 2013 10:03:20 -0500	[thread overview]
Message-ID: <20130309150320.GB15521@shiny.masoncoding.com> (raw)
In-Reply-To: <513B4460.5090607@redhat.com>

On Sat, Mar 09, 2013 at 07:17:04AM -0700, Eric Sandeen wrote:
> On 3/9/13 6:27 AM, Chris Mason wrote:
> > On Fri, Mar 08, 2013 at 10:23:01PM -0700, Eric Sandeen wrote:
> >> Doing this would reliably fail with -EBUSY for me:
> >>
> >> # mount /dev/sdb2 /mnt/scratch; umount /mnt/scratch; mkfs.btrfs -f /dev/sdb2
> >> ...
> >> unable to open /dev/sdb2: Device or resource busy
> >>
> >> because mkfs.btrfs tries to open the device O_EXCL, and somebody still has it.
> >>
> >> Using systemtap to track bdev gets & puts shows a kworker thread doing a
> >> blkdev put after mkfs attempts a get; this is left over from the unmount.
> >>
> >> Adding an rcu_barrier() to btrfs_close_devices() causes unmount to wait
> >> until all blkdev_put()s are done, and the device is truly free once
> >> unmount completes.
> > 
> > Thanks for tracking this down Eric.  
> 
> Sure thing, sorry it took so long.
> 
> > Is this kworker triggered by btrfs
> > or is this something we should be doing for the other filesystems too?
> 
> It's all btrfs ;)
> 
> btrfs_close_devices
> 	__btrfs_close_devices
> 		call_rcu(&device->rcu, free_device);
> 			free_device
> 				INIT_WORK(&device->rcu_work, __free_device);
> 				schedule_work(&device->rcu_work);
> 

Great, that makes a ton more sense.  I'm a little confused on why we're
seeing it so much more now than in the past.

> 
> The behavior came from:
> 
> commit 1f78160ce1b1b8e657e2248118c4d91f881763f0
> Author: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
> Date:   Wed Apr 20 10:09:16 2011 +0000
> 
>     Btrfs: using rcu lock in the reader side of devices list
> 
> Anyway, I can send V2 in close_ctree if you like. Thinking about it more
> though, btrfs_close_devices is closer to the action, so now I think
> I'd leave it there. :)
> 
> I probably should have put a comment in to say what the heck it's for,
> too.  Feel free to fix on merge or I can send another patch.

Ok, please add the comment and a cc to stable.  Thanks again.

-chris


  reply	other threads:[~2013-03-09 15:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-09  5:23 [PATCH] use rcu_barrier() to wait for bdev puts at unmount Eric Sandeen
2013-03-09 12:27 ` Chris Mason
2013-03-09 14:17   ` Eric Sandeen
2013-03-09 15:03     ` Chris Mason [this message]
2013-03-09 15:18 ` [PATCH V2] btrfs: " Eric Sandeen

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=20130309150320.GB15521@shiny.masoncoding.com \
    --to=chris.mason@fusionio.com \
    --cc=clmason@fusionio.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=sandeen@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.