From 3f19f2ad6af8bde3c3e7eaa10e6f237e7004f0cd Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 15 Feb 2018 11:08:13 +0100 Subject: [PATCH] 4.14-stable patches added patches: btrfs-handle-btrfs_set_extent_delalloc-failure-in-fixup-worker.patch --- ...ent_delalloc-failure-in-fixup-worker.patch | 46 +++++++++++++++++++ queue-4.14/series | 1 + 2 files changed, 47 insertions(+) create mode 100644 queue-4.14/btrfs-handle-btrfs_set_extent_delalloc-failure-in-fixup-worker.patch diff --git a/queue-4.14/btrfs-handle-btrfs_set_extent_delalloc-failure-in-fixup-worker.patch b/queue-4.14/btrfs-handle-btrfs_set_extent_delalloc-failure-in-fixup-worker.patch new file mode 100644 index 00000000000..65d4bb805f8 --- /dev/null +++ b/queue-4.14/btrfs-handle-btrfs_set_extent_delalloc-failure-in-fixup-worker.patch @@ -0,0 +1,46 @@ +From f3038ee3a3f1017a1cbe9907e31fa12d366c5dcb Mon Sep 17 00:00:00 2001 +From: Nikolay Borisov +Date: Tue, 5 Dec 2017 09:29:19 +0200 +Subject: btrfs: Handle btrfs_set_extent_delalloc failure in fixup worker + +From: Nikolay Borisov + +commit f3038ee3a3f1017a1cbe9907e31fa12d366c5dcb upstream. + +This function was introduced by 247e743cbe6e ("Btrfs: Use async helpers +to deal with pages that have been improperly dirtied") and it didn't do +any error handling then. This function might very well fail in ENOMEM +situation, yet it's not handled, this could lead to inconsistent state. +So let's handle the failure by setting the mapping error bit. + +Signed-off-by: Nikolay Borisov +Reviewed-by: Qu Wenruo +Reviewed-by: David Sterba +Signed-off-by: David Sterba +Signed-off-by: Greg Kroah-Hartman + + +--- + fs/btrfs/inode.c | 11 +++++++++-- + 1 file changed, 9 insertions(+), 2 deletions(-) + +--- a/fs/btrfs/inode.c ++++ b/fs/btrfs/inode.c +@@ -2101,8 +2101,15 @@ again: + goto out; + } + +- btrfs_set_extent_delalloc(inode, page_start, page_end, &cached_state, +- 0); ++ ret = btrfs_set_extent_delalloc(inode, page_start, page_end, ++ &cached_state, 0); ++ if (ret) { ++ mapping_set_error(page->mapping, ret); ++ end_extent_writepage(page, ret, page_start, page_end); ++ ClearPageChecked(page); ++ goto out; ++ } ++ + ClearPageChecked(page); + set_page_dirty(page); + out: diff --git a/queue-4.14/series b/queue-4.14/series index 5a0de06a27a..ddb2845c615 100644 --- a/queue-4.14/series +++ b/queue-4.14/series @@ -179,3 +179,4 @@ blk-mq-quiesce-queue-before-freeing-queue.patch clocksource-drivers-stm32-fix-kernel-panic-with-multiple-timers.patch lib-ubsan.c-s-missaligned-misaligned.patch lib-ubsan-add-type-mismatch-handler-for-new-gcc-clang.patch +btrfs-handle-btrfs_set_extent_delalloc-failure-in-fixup-worker.patch -- 2.47.3