]> www.infradead.org Git - users/jedix/linux-maple.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)
committerChuck Anderson <chuck.anderson@oracle.com>
Fri, 15 Jul 2016 21:45:26 +0000 (14:45 -0700)
commite62ce84b1f4c8a5aafe17e70366e4f86db7a4105
tree553c3a5740362953bd96611f9b4a4e4b91c9a13f
parent5b694ff66b4fb32b124a6e2b2bb1b4c6b5cce3bb
Btrfs: fix leaking of ordered extents after direct IO write error

Orabug: 23717870

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>
(cherry picked from commit f28a492878170f39002660a26c329201cf678d74)
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
fs/btrfs/inode.c