]> git.baikalelectronics.ru Git - kernel.git/commit
Btrfs: lock extents as we map them in DIO
authorJosef Bacik <jbacik@fusionio.com>
Tue, 31 Jul 2012 20:28:48 +0000 (16:28 -0400)
committerChris Mason <chris.mason@oracle.com>
Tue, 28 Aug 2012 20:53:27 +0000 (16:53 -0400)
commit24a33498264aa4049a0c2f43ee4e4b5d2c1492aa
treee451338c2f68b413f1a3f5821ec0d63f8ef60196
parent9bf0d0c65c3c922865e91ccb624c62aaa84639e4
Btrfs: lock extents as we map them in DIO

A deadlock in xfstests 113 was uncovered by commit

4bc2574fd73969caa51baca0638324a2d3ba0431

This is because we would not return EIOCBQUEUED for short AIO reads, instead
we'd wait for the DIO to complete and then return the amount of data we
transferred, which would allow our stuff to unlock the remaning amount.  But
with this change this no longer happens, so if we have a short AIO read (for
example if we try to read past EOF), we could leave the section from EOF to
the end of where we tried to read locked.  Fixing this is tricky since there
is no clear way to know exactly how much data DIO truly submitted for IO, so
to make this less hard on ourselves and less combersome we need to lock the
extents as we try to map them, and then we unlock any areas we didn't
actually map.  This makes us completely safe from deadlocks and reliance on
a particular behavior of the DIO code.  This also lays the groundwork for
allowing us to use the normal csum storage method for reads which means we
can remove an allocation.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fusionio.com>
fs/btrfs/inode.c