]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: use RCU in btrfs_show_devname for device list traversal
authorDavid Sterba <dsterba@suse.com>
Fri, 16 Mar 2018 02:27:02 +0000 (03:27 +0100)
committerDavid Sterba <dsterba@suse.com>
Sat, 31 Mar 2018 00:01:06 +0000 (02:01 +0200)
commit0ebd8c8e50435cd93bdb46a0082c0c6061d1b6ff
tree70a5fd92672f1a7a83c63a9b993557b4e7684277
parent92c7fa1b81a8fe70a89b81e1e99a91c5dd43f8be
btrfs: use RCU in btrfs_show_devname for device list traversal

The show_devname callback is used to print device name in
/proc/self/mounts, we need to traverse the device list consistently and
read the name that's copied to a seq buffer so we don't need further
locking.

If the first device is being deleted at the same time, the RCU will
allow us to read the device name, though it will become stale right
after the RCU protection ends. This is unavoidable and the user can
expect that the device will disappear from the filesystem's list at some
point.

The device_list_mutex was pretty heavy as it is used eg. for writing
superblock and a few other IO related contexts. This can stall any
application that reads the proc file for no reason.

Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/super.c