]> www.infradead.org Git - users/jedix/linux-maple.git/commit
Btrfs: fix error path when failing to submit bio for direct IO write
authorFilipe Manana <fdmanana@suse.com>
Tue, 24 Nov 2015 16:23:54 +0000 (16:23 +0000)
committerChuck Anderson <chuck.anderson@oracle.com>
Fri, 15 Jul 2016 21:45:26 +0000 (14:45 -0700)
commit5b694ff66b4fb32b124a6e2b2bb1b4c6b5cce3bb
tree73bd4ee7b54a4e7f1a12d06fc9862248ccf58c67
parentf2416ac194cc0cf9abe52fadde7872ecbb0c25c8
Btrfs: fix error path when failing to submit bio for direct IO write

Orabug: 23717870

Commit 61de718fceb6 ("Btrfs: fix memory corruption on failure to submit
bio for direct IO") fixed problems with the error handling code after we
fail to submit a bio for direct IO. However there were 2 problems that it
did not address when the failure is due to memory allocation failures for
direct IO writes:

1) We considered that there could be only one ordered extent for the whole
   IO range, which is not always true, as we can have multiple;

2) It did not set the bit BTRFS_ORDERED_IO_DONE in the ordered extent,
   which can make other tasks running btrfs_wait_logged_extents() hang
   forever, since they wait for that bit to be set. The general assumption
   is that regardless of an error, the BTRFS_ORDERED_IO_DONE is always set
   and it precedes setting the bit BTRFS_ORDERED_COMPLETE.

Fix these issues by moving part of the btrfs_endio_direct_write() handler
into a new helper function and having that new helper function called when
we fail to allocate memory to submit the bio (and its private object) for
a direct IO write.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Liu Bo <bo.li.liu@oracle.com>
(cherry picked from commit 14543774bd67a64f616431e5c9d1472f58979841)
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
fs/btrfs/inode.c