• Omar Sandoval's avatar
    Btrfs: fix ->iterate_shared() by upgrading i_rwsem for delayed nodes · 02dbfc99
    Omar Sandoval authored
    Commit fe742fd4 ("Revert "btrfs: switch to ->iterate_shared()"")
    backed out the conversion to ->iterate_shared() for Btrfs because the
    delayed inode handling in btrfs_real_readdir() is racy. However, we can
    still do readdir in parallel if there are no delayed nodes.
    This is a temporary fix which upgrades the shared inode lock to an
    exclusive lock only when we have delayed items until we come up with a
    more complete solution. While we're here, rename the
    btrfs_{get,put}_delayed_items functions to make it very clear that
    they're just for readdir.
    Tested with xfstests and by doing a parallel kernel build:
    	while make tinyconfig && make -j4 && git clean dqfx; do
    along with a bunch of parallel finds in another shell:
    	while true; do
    		for ((i=0; i<4; i++)); do
    			find . >/dev/null &
    Signed-off-by: default avatarOmar Sandoval <osandov@fb.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    Signed-off-by: default avatarChris Mason <clm@fb.com>
delayed-inode.c 52.3 KB