]> git.baikalelectronics.ru Git - kernel.git/commit
Btrfs: fix stale entries in readdir
authorJosef Bacik <jbacik@fb.com>
Tue, 23 Jan 2018 20:17:05 +0000 (15:17 -0500)
committerDavid Sterba <dsterba@suse.com>
Wed, 24 Jan 2018 19:27:48 +0000 (20:27 +0100)
commitefd600157cb8d51a28d0c47bcd21604064b74848
tree4a441647383900205628eb4e4230e9dd4878479a
parenta02239278d7b37b31ab26ba91806c308d348f3bc
Btrfs: fix stale entries in readdir

In fixing the readdir+pagefault deadlock I accidentally introduced a
stale entry regression in readdir.  If we get close to full for the
temporary buffer, and then skip a few delayed deletions, and then try to
add another entry that won't fit, we will emit the entries we found and
retry.  Unfortunately we delete entries from our del_list as we find
them, assuming we won't need them.  However our pos will be with
whatever our last entry was, which could be before the delayed deletions
we skipped, so the next search will add the deleted entries back into
our readdir buffer.  So instead don't delete entries we find in our
del_list so we can make sure we always find our delayed deletions.  This
is a slight perf hit for readdir with lots of pending deletions, but
hopefully this isn't a common occurrence.  If it is we can revist this
and optimize it.

cc: stable@vger.kernel.org
Fixes: 2fe50a721051 ("btrfs: fix readdir deadlock with pagefault")
Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/delayed-inode.c