linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] use rcu_barrier() to wait for bdev puts at unmount
@ 2013-03-09  5:23 Eric Sandeen
  2013-03-09 12:27 ` Chris Mason
  2013-03-09 15:18 ` [PATCH V2] btrfs: " Eric Sandeen
  0 siblings, 2 replies; 5+ messages in thread
From: Eric Sandeen @ 2013-03-09  5:23 UTC (permalink / raw)
  To: linux-btrfs

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.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

p.s. I debated putting it into close_ctree(); I don't know if there' anything
else to wait for.  Thoughts?

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 5cbb7f4..258316a 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -680,6 +680,7 @@ int btrfs_close_devices(struct btrfs_fs_devices *fs_devices)
 		__btrfs_close_devices(fs_devices);
 		free_fs_devices(fs_devices);
 	}
+	rcu_barrier();
 	return ret;
 }
 


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-03-09 15:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2013-03-09 15:18 ` [PATCH V2] btrfs: " Eric Sandeen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).