]> git.baikalelectronics.ru Git - kernel.git/commit
Btrfs: fix leaking of ordered extents after direct IO write error
authorFilipe Manana <fdmanana@suse.com>
Tue, 8 Dec 2015 19:23:20 +0000 (19:23 +0000)
committerFilipe Manana <fdmanana@suse.com>
Thu, 17 Dec 2015 10:59:51 +0000 (10:59 +0000)
commit6fd8f432d584761d836bba9680dcc0143a760775
tree9c030f6229100495d8135a50e9aed60c725536ae
parentf9cda8b45ad79c705a932f9b0bc7f288465027f1
Btrfs: fix leaking of ordered extents after direct IO write error

When doing a direct IO write, __blockdev_direct_IO() can call the
btrfs_get_blocks_direct() callback one or more times before it calls the
btrfs_submit_direct() callback. However it can fail after calling the
first callback and before calling the second callback, which is a problem
because the first one creates ordered extents and the second one is the
one that submits bios that cover the ordered extents created by the first
one. That means the ordered extents will never complete nor have any of
the flags BTRFS_ORDERED_IO_DONE / BTRFS_ORDERED_IOERR set, resulting in
subsequent operations (such as other direct IO writes, buffered writes or
hole punching) that lock the same IO range and lookup for ordered extents
in the range to hang forever waiting for those ordered extents because
they can not complete ever, since no bio was submitted.

Fix this by tracking a range of created ordered extents that don't have
yet corresponding bios submitted and completing the ordered extents in
the range if __blockdev_direct_IO() fails with an error.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
fs/btrfs/inode.c