]> git.baikalelectronics.ru Git - kernel.git/commit
Btrfs: fix ->iterate_shared() by upgrading i_rwsem for delayed nodes
authorOmar Sandoval <osandov@fb.com>
Fri, 20 May 2016 20:50:33 +0000 (13:50 -0700)
committerChris Mason <clm@fb.com>
Sat, 25 Jun 2016 13:20:10 +0000 (06:20 -0700)
commit3fc64e00bf6a86008f263af2e3f9b05fbd3e839e
treed08f267bac15ea5939185424bbe73306b7f11cb6
parentfef9870bc2480dcb6423cd64866278a1a0a14a43
Btrfs: fix ->iterate_shared() by upgrading i_rwsem for delayed nodes

Commit 1ecdd52b2e30 ("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
:
done

along with a bunch of parallel finds in another shell:

while true; do
for ((i=0; i<4; i++)); do
find . >/dev/null &
done
wait
done

Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Chris Mason <clm@fb.com>
fs/btrfs/delayed-inode.c
fs/btrfs/delayed-inode.h
fs/btrfs/inode.c