]> rtime.felk.cvut.cz Git - linux-imx.git/commit
btrfs: don't loop on large offsets in readdir
authorZach Brown <zab@redhat.com>
Thu, 11 Jul 2013 23:19:42 +0000 (16:19 -0700)
committerChris Mason <chris.mason@fusionio.com>
Fri, 9 Aug 2013 23:34:56 +0000 (19:34 -0400)
commitdb62efbbf883c099d44b0fafe18f8ad8f0396892
treedacc595d4b9e32b1736c01efea0580ba6a153903
parentcfad392b22163eba71d882950e17d2c4d43b2bad
btrfs: don't loop on large offsets in readdir

When btrfs readdir() hits the last entry it sets the readdir offset to a
huge value to stop buggy apps from breaking when the same name is
returned by readdir() with concurrent rename()s.

But unconditionally setting the offset to INT_MAX causes readdir() to
loop returning any entries with offsets past INT_MAX.  It only takes a
few hours of constant file creation and removal to create entries past
INT_MAX.

So let's set the huge offset to LLONG_MAX if the last entry has already
overflowed 32bit loff_t.   Without large offsets behaviour is identical.
With large offsets 64bit apps will work and 32bit apps will be no more
broken than they currently are if they see large offsets.

Signed-off-by: Zach Brown <zab@redhat.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
fs/btrfs/inode.c