summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjc_gargma <jc_gargma@iserlohn-fortress.net>2019-09-17 22:41:02 -0700
committerjc_gargma <jc_gargma@iserlohn-fortress.net>2019-09-17 22:41:02 -0700
commit46e07485e555d9ffbe4831c57d14aa4b41de59fa (patch)
treec88be9090335270bc575ef1f44fe794f1f56f804
parentAdd hotfix for btrfs extent buffer hangs (diff)
downloadlinux-libre-hardened-46e07485e555d9ffbe4831c57d14aa4b41de59fa.tar.xz
Updated to 5.2.15.a
-rw-r--r--0003-Btrfs-fix-unwritten-extent-buffers-and-hangs-on-future-writeback-attempts.patch145
-rw-r--r--PKGBUILD11
2 files changed, 4 insertions, 152 deletions
diff --git a/0003-Btrfs-fix-unwritten-extent-buffers-and-hangs-on-future-writeback-attempts.patch b/0003-Btrfs-fix-unwritten-extent-buffers-and-hangs-on-future-writeback-attempts.patch
deleted file mode 100644
index b6d19c3..0000000
--- a/0003-Btrfs-fix-unwritten-extent-buffers-and-hangs-on-future-writeback-attempts.patch
+++ /dev/null
@@ -1,145 +0,0 @@
-From 45fc8773f47b7cbe56caab0e14abf26d1e044e63 Mon Sep 17 00:00:00 2001
-From: Filipe Manana <fdmanana@suse.com>
-Date: Wed, 11 Sep 2019 17:42:00 +0100
-Subject: Btrfs: fix unwritten extent buffers and hangs on future writeback
- attempts
-
-The lock_extent_buffer_io() returns 1 to the caller to tell it everything
-went fine and the callers needs to start writeback for the extent buffer
-(submit a bio, etc), 0 to tell the caller everything went fine but it does
-not need to start writeback for the extent buffer, and a negative value if
-some error happened.
-
-When it's about to return 1 it tries to lock all pages, and if a try lock
-on a page fails, and we didn't flush any existing bio in our "epd", it
-calls flush_write_bio(epd) and overwrites the return value of 1 to 0 or
-an error. The page might have been locked elsewhere, not with the goal
-of starting writeback of the extent buffer, and even by some code other
-than btrfs, like page migration for example, so it does not mean the
-writeback of the extent buffer was already started by some other task,
-so returning a 0 tells the caller (btree_write_cache_pages()) to not
-start writeback for the extent buffer. Note that epd might currently have
-either no bio, so flush_write_bio() returns 0 (success) or it might have
-a bio for another extent buffer with a lower index (logical address).
-
-Since we return 0 with the EXTENT_BUFFER_WRITEBACK bit set on the
-extent buffer and writeback is never started for the extent buffer,
-future attempts to writeback the extent buffer will hang forever waiting
-on that bit to be cleared, since it can only be cleared after writeback
-completes. Such hang is reported with a trace like the following:
-
- [49887.347053] INFO: task btrfs-transacti:1752 blocked for more than 122 seconds.
- [49887.347059] Not tainted 5.2.13-gentoo #2
- [49887.347060] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
- [49887.347062] btrfs-transacti D 0 1752 2 0x80004000
- [49887.347064] Call Trace:
- [49887.347069] ? __schedule+0x265/0x830
- [49887.347071] ? bit_wait+0x50/0x50
- [49887.347072] ? bit_wait+0x50/0x50
- [49887.347074] schedule+0x24/0x90
- [49887.347075] io_schedule+0x3c/0x60
- [49887.347077] bit_wait_io+0x8/0x50
- [49887.347079] __wait_on_bit+0x6c/0x80
- [49887.347081] ? __lock_release.isra.29+0x155/0x2d0
- [49887.347083] out_of_line_wait_on_bit+0x7b/0x80
- [49887.347084] ? var_wake_function+0x20/0x20
- [49887.347087] lock_extent_buffer_for_io+0x28c/0x390
- [49887.347089] btree_write_cache_pages+0x18e/0x340
- [49887.347091] do_writepages+0x29/0xb0
- [49887.347093] ? kmem_cache_free+0x132/0x160
- [49887.347095] ? convert_extent_bit+0x544/0x680
- [49887.347097] filemap_fdatawrite_range+0x70/0x90
- [49887.347099] btrfs_write_marked_extents+0x53/0x120
- [49887.347100] btrfs_write_and_wait_transaction.isra.4+0x38/0xa0
- [49887.347102] btrfs_commit_transaction+0x6bb/0x990
- [49887.347103] ? start_transaction+0x33e/0x500
- [49887.347105] transaction_kthread+0x139/0x15c
-
-So fix this by not overwriting the return value (ret) with the result
-from flush_write_bio(). We also need to clear the EXTENT_BUFFER_WRITEBACK
-bit in case flush_write_bio() returns an error, otherwise it will hang
-any future attempts to writeback the extent buffer, and undo all work
-done before (set back EXTENT_BUFFER_DIRTY, etc).
-
-This is a regression introduced in the 5.2 kernel.
-
-Fixes: 2e3c25136adfb ("btrfs: extent_io: add proper error handling to lock_extent_buffer_for_io()")
-Fixes: f4340622e0226 ("btrfs: extent_io: Move the BUG_ON() in flush_write_bio() one level up")
-Reported-by: Zdenek Sojka <zsojka@seznam.cz>
-Link: https://lore.kernel.org/linux-btrfs/GpO.2yos.3WGDOLpx6t%7D.1TUDYM@seznam.cz/T/#u
-Reported-by: Stefan Priebe - Profihost AG <s.priebe@profihost.ag>
-Link: https://lore.kernel.org/linux-btrfs/5c4688ac-10a7-fb07-70e8-c5d31a3fbb38@profihost.ag/T/#t
-Reported-by: Drazen Kacar <drazen.kacar@oradian.com>
-Link: https://lore.kernel.org/linux-btrfs/DB8PR03MB562876ECE2319B3E579590F799C80@DB8PR03MB5628.eurprd03.prod.outlook.com/
-Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=204377
-Signed-off-by: Filipe Manana <fdmanana@suse.com>
----
- fs/btrfs/extent_io.c | 35 ++++++++++++++++++++++++++---------
- 1 file changed, 26 insertions(+), 9 deletions(-)
-
-diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
-index db337e53aab3..93900ff87df7 100644
---- a/fs/btrfs/extent_io.c
-+++ b/fs/btrfs/extent_io.c
-@@ -3591,6 +3591,13 @@ void wait_on_extent_buffer_writeback(struct extent_buffer *eb)
- TASK_UNINTERRUPTIBLE);
- }
-
-+static void end_extent_buffer_writeback(struct extent_buffer *eb)
-+{
-+ clear_bit(EXTENT_BUFFER_WRITEBACK, &eb->bflags);
-+ smp_mb__after_atomic();
-+ wake_up_bit(&eb->bflags, EXTENT_BUFFER_WRITEBACK);
-+}
-+
- /*
- * Lock eb pages and flush the bio if we can't the locks
- *
-@@ -3662,8 +3669,11 @@ static noinline_for_stack int lock_extent_buffer_for_io(struct extent_buffer *eb
-
- if (!trylock_page(p)) {
- if (!flush) {
-- ret = flush_write_bio(epd);
-- if (ret < 0) {
-+ int err;
-+
-+ err = flush_write_bio(epd);
-+ if (err < 0) {
-+ ret = err;
- failed_page_nr = i;
- goto err_unlock;
- }
-@@ -3678,16 +3688,23 @@ err_unlock:
- /* Unlock already locked pages */
- for (i = 0; i < failed_page_nr; i++)
- unlock_page(eb->pages[i]);
-+ /*
-+ * Clear EXTENT_BUFFER_WRITEBACK and wake up anyone waiting on it.
-+ * Also set back EXTENT_BUFFER_DIRTY so future attempts to this eb can
-+ * be made and undo everything done before.
-+ */
-+ btrfs_tree_lock(eb);
-+ spin_lock(&eb->refs_lock);
-+ set_bit(EXTENT_BUFFER_DIRTY, &eb->bflags);
-+ end_extent_buffer_writeback(eb);
-+ spin_unlock(&eb->refs_lock);
-+ percpu_counter_add_batch(&fs_info->dirty_metadata_bytes, eb->len,
-+ fs_info->dirty_metadata_batch);
-+ btrfs_clear_header_flag(eb, BTRFS_HEADER_FLAG_WRITTEN);
-+ btrfs_tree_unlock(eb);
- return ret;
- }
-
--static void end_extent_buffer_writeback(struct extent_buffer *eb)
--{
-- clear_bit(EXTENT_BUFFER_WRITEBACK, &eb->bflags);
-- smp_mb__after_atomic();
-- wake_up_bit(&eb->bflags, EXTENT_BUFFER_WRITEBACK);
--}
--
- static void set_btree_ioerr(struct page *page)
- {
- struct extent_buffer *eb = (struct extent_buffer *)page->private;
---
-cgit v1.2.1-1-g437b
-
diff --git a/PKGBUILD b/PKGBUILD
index ab6695f..b7ac40a 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -18,7 +18,7 @@
pkgbase=linux-libre-hardened
_majver=5.2
-_minver=14
+_minver=15
if [ "$_minver" == "0" ]; then
_pkgver=${_majver}
else
@@ -43,7 +43,6 @@ options=('!strip')
source=(
https://linux-libre.fsfla.org/pub/linux-libre/releases/${_gnumajver}/linux-libre-${_gnumajver}.tar.xz{,.sign}
https://linux-libre.fsfla.org/pub/linux-libre/releases/${_gnupkgver}/patch-${_gnumajver}-${_gnupkgver}.xz{,.sign}
- 0003-Btrfs-fix-unwritten-extent-buffers-and-hangs-on-future-writeback-attempts.patch
https://github.com/anthraxx/linux-hardened/releases/download/${pkgver}/linux-hardened-${pkgver}.patch{,.sig}
graysky_bdver2-hotfix.patch
kernel_gcc_patch-${_gccpatchver}.tar.gz::https://github.com/graysky2/kernel_gcc_patch/archive/${_gccpatchver}.tar.gz
@@ -56,10 +55,9 @@ source=(
)
sha256sums=('abbf0a5cacc1031e55f181f61b3c417bd3a37d0960f7596cbcae6ee1b96439e9'
'SKIP'
- '4cc1262507c4013f18964e803909e9abeaa9d56d59dedf52be6bea1f5c9597a8'
+ '5785c81842fe2a0b44dace47086ece4cbc2264f80efb63d9fa42ef00b42886f9'
'SKIP'
- '940719452e133a7350dd5efea974190af07eb365a6a60d117b76efca4ca53e7a'
- 'fe3086755a5d677fd1f31b919a622e4c83bc97f354e7ca4683dd7cdefbd666d6'
+ '17d8a2c9e1b89cf87da778071d7539102c9009728f7afd6e87cdc3e66ab64cf6'
'SKIP'
'c5405139aa0a90a6f68f6a13e066a2bd0600c970f9f525cd3aa114b044a7f73b'
'8c11086809864b5cef7d079f930bd40da8d0869c091965fa62e95de9a0fe13b5'
@@ -87,8 +85,7 @@ prepare() {
fi
# Hotfixes
- msg2 "Applying hotfixes"
- patch -p1 -i ../0003-Btrfs-fix-unwritten-extent-buffers-and-hangs-on-future-writeback-attempts.patch
+# msg2 "Applying hotfixes"
# linux hardened patch
msg2 "Applying hardened patch"