]> 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)
commit1517bacda81c9c7a509ae26e85be9f72e57c1c10
treee451338c2f68b413f1a3f5821ec0d63f8ef60196
parent34de5dbf8f01cb8d7ca68a4394b6152f32a30a61
Btrfs: lock extents as we map them in DIO

A deadlock in xfstests 113 was uncovered by commit

ccb0854895ec02ed74e0496fd7d91dc4b34658ae

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