Btrfs: use rcu to protect device->name
authorJosef Bacik <josef@redhat.com>
Mon, 4 Jun 2012 18:03:51 +0000 (14:03 -0400)
committerChris Mason <chris.mason@oracle.com>
Fri, 15 Jun 2012 01:29:16 +0000 (21:29 -0400)
commit606686eeac4550d2212bf3d621a810407ef5e9bf
tree50adade3a750137b68304dc280d7a75436417b12
parent17ca04aff7e6171df684b7b65804df8830eb8c15
Btrfs: use rcu to protect device->name

Al pointed out that we can just toss out the old name on a device and add a
new one arbitrarily, so anybody who uses device->name in printk could
possibly use free'd memory.  Instead of adding locking around all of this he
suggested doing it with RCU, so I've introduced a struct rcu_string that
does just that and have gone through and protected all accesses to
device->name that aren't under the uuid_mutex with rcu_read_lock().  This
protects us and I will use it for dealing with removing the device that we
used to mount the file system in a later patch.  Thanks,

Reviewed-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Josef Bacik <josef@redhat.com>
fs/btrfs/check-integrity.c
fs/btrfs/disk-io.c
fs/btrfs/extent_io.c
fs/btrfs/ioctl.c
fs/btrfs/rcu-string.h [new file with mode: 0644]
fs/btrfs/scrub.c
fs/btrfs/volumes.c
fs/btrfs/volumes.h