From: Sasha Levin Date: Wed, 14 Oct 2020 14:19:52 +0000 (-0400) Subject: Fixes for 5.4 X-Git-Tag: v5.9.1~24 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=81bd2df3734eef0bdcf9abbe33be9d7dca3dc1ea;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 5.4 Signed-off-by: Sasha Levin --- diff --git a/queue-5.4/arm-8939-1-kbuild-use-correct-nm-executable.patch b/queue-5.4/arm-8939-1-kbuild-use-correct-nm-executable.patch new file mode 100644 index 00000000000..5345aca8880 --- /dev/null +++ b/queue-5.4/arm-8939-1-kbuild-use-correct-nm-executable.patch @@ -0,0 +1,54 @@ +From b19ca15421f87ab0b820032a1891f1e0a13bce70 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 19 Nov 2019 16:39:42 +0100 +Subject: ARM: 8939/1: kbuild: use correct nm executable + +From: Dmitry Golovin + +[ Upstream commit 29c623d64f0dcd6aa10e0eabd16233e77114090b ] + +Since $(NM) variable can be easily overridden for the whole build, it's +better to use it instead of $(CROSS_COMPILE)nm. The use of $(CROSS_COMPILE) +prefixed variables where their calculated equivalents can be used is +incorrect. This fixes issues with builds where $(NM) is set to llvm-nm. + +Link: https://github.com/ClangBuiltLinux/linux/issues/766 + +Signed-off-by: Dmitry Golovin +Suggested-by: Nick Desaulniers +Cc: Matthias Maennich +Reviewed-by: Nathan Chancellor +Tested-by: Nathan Chancellor +Reviewed-by: Masahiro Yamada +Reviewed-by: Nick Desaulniers +Signed-off-by: Russell King +Signed-off-by: Sasha Levin +--- + arch/arm/boot/compressed/Makefile | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile +index 1483966dcf23b..6da67789ac221 100644 +--- a/arch/arm/boot/compressed/Makefile ++++ b/arch/arm/boot/compressed/Makefile +@@ -121,7 +121,7 @@ ccflags-y := -fpic $(call cc-option,-mno-single-pic-base,) -fno-builtin \ + asflags-y := -DZIMAGE + + # Supply kernel BSS size to the decompressor via a linker symbol. +-KBSS_SZ = $(shell echo $$(($$($(CROSS_COMPILE)nm $(obj)/../../../../vmlinux | \ ++KBSS_SZ = $(shell echo $$(($$($(NM) $(obj)/../../../../vmlinux | \ + sed -n -e 's/^\([^ ]*\) [AB] __bss_start$$/-0x\1/p' \ + -e 's/^\([^ ]*\) [AB] __bss_stop$$/+0x\1/p') )) ) + LDFLAGS_vmlinux = --defsym _kernel_bss_size=$(KBSS_SZ) +@@ -165,7 +165,7 @@ $(obj)/bswapsdi2.S: $(srctree)/arch/$(SRCARCH)/lib/bswapsdi2.S + # The .data section is already discarded by the linker script so no need + # to bother about it here. + check_for_bad_syms = \ +-bad_syms=$$($(CROSS_COMPILE)nm $@ | sed -n 's/^.\{8\} [bc] \(.*\)/\1/p') && \ ++bad_syms=$$($(NM) $@ | sed -n 's/^.\{8\} [bc] \(.*\)/\1/p') && \ + [ -z "$$bad_syms" ] || \ + ( echo "following symbols must have non local/private scope:" >&2; \ + echo "$$bad_syms" >&2; false ) +-- +2.25.1 + diff --git a/queue-5.4/btrfs-don-t-pass-system_chunk-into-can_overcommit.patch b/queue-5.4/btrfs-don-t-pass-system_chunk-into-can_overcommit.patch new file mode 100644 index 00000000000..98e0c632071 --- /dev/null +++ b/queue-5.4/btrfs-don-t-pass-system_chunk-into-can_overcommit.patch @@ -0,0 +1,177 @@ +From 41098b4779b3917f3dc8a3f090737d0037c00e6e Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 14 Oct 2020 10:44:46 +0800 +Subject: btrfs: don't pass system_chunk into can_overcommit + +From: Josef Bacik + +commit 9f246926b4d5db4c5e8c78e4897757de26c95be6 upstream + +We have the space_info, we can just check its flags to see if it's the +system chunk space info. + +Reviewed-by: Nikolay Borisov +Reviewed-by: Qu Wenruo +Reviewed-by: Johannes Thumshirn +Signed-off-by: Josef Bacik +Reviewed-by: David Sterba +Signed-off-by: David Sterba +Signed-off-by: Anand Jain +Signed-off-by: Sasha Levin +--- + fs/btrfs/space-info.c | 42 +++++++++++++++--------------------------- + 1 file changed, 15 insertions(+), 27 deletions(-) + +diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c +index 6f484f0d347eb..e19e538d05f93 100644 +--- a/fs/btrfs/space-info.c ++++ b/fs/btrfs/space-info.c +@@ -162,8 +162,7 @@ static inline u64 calc_global_rsv_need_space(struct btrfs_block_rsv *global) + + static int can_overcommit(struct btrfs_fs_info *fs_info, + struct btrfs_space_info *space_info, u64 bytes, +- enum btrfs_reserve_flush_enum flush, +- bool system_chunk) ++ enum btrfs_reserve_flush_enum flush) + { + u64 profile; + u64 avail; +@@ -174,7 +173,7 @@ static int can_overcommit(struct btrfs_fs_info *fs_info, + if (space_info->flags & BTRFS_BLOCK_GROUP_DATA) + return 0; + +- if (system_chunk) ++ if (space_info->flags & BTRFS_BLOCK_GROUP_SYSTEM) + profile = btrfs_system_alloc_profile(fs_info); + else + profile = btrfs_metadata_alloc_profile(fs_info); +@@ -228,8 +227,7 @@ void btrfs_try_granting_tickets(struct btrfs_fs_info *fs_info, + + /* Check and see if our ticket can be satisified now. */ + if ((used + ticket->bytes <= space_info->total_bytes) || +- can_overcommit(fs_info, space_info, ticket->bytes, flush, +- false)) { ++ can_overcommit(fs_info, space_info, ticket->bytes, flush)) { + btrfs_space_info_update_bytes_may_use(fs_info, + space_info, + ticket->bytes); +@@ -634,8 +632,7 @@ static void flush_space(struct btrfs_fs_info *fs_info, + + static inline u64 + btrfs_calc_reclaim_metadata_size(struct btrfs_fs_info *fs_info, +- struct btrfs_space_info *space_info, +- bool system_chunk) ++ struct btrfs_space_info *space_info) + { + struct reserve_ticket *ticket; + u64 used; +@@ -651,13 +648,12 @@ btrfs_calc_reclaim_metadata_size(struct btrfs_fs_info *fs_info, + + to_reclaim = min_t(u64, num_online_cpus() * SZ_1M, SZ_16M); + if (can_overcommit(fs_info, space_info, to_reclaim, +- BTRFS_RESERVE_FLUSH_ALL, system_chunk)) ++ BTRFS_RESERVE_FLUSH_ALL)) + return 0; + + used = btrfs_space_info_used(space_info, true); + +- if (can_overcommit(fs_info, space_info, SZ_1M, +- BTRFS_RESERVE_FLUSH_ALL, system_chunk)) ++ if (can_overcommit(fs_info, space_info, SZ_1M, BTRFS_RESERVE_FLUSH_ALL)) + expected = div_factor_fine(space_info->total_bytes, 95); + else + expected = div_factor_fine(space_info->total_bytes, 90); +@@ -673,7 +669,7 @@ btrfs_calc_reclaim_metadata_size(struct btrfs_fs_info *fs_info, + + static inline int need_do_async_reclaim(struct btrfs_fs_info *fs_info, + struct btrfs_space_info *space_info, +- u64 used, bool system_chunk) ++ u64 used) + { + u64 thresh = div_factor_fine(space_info->total_bytes, 98); + +@@ -681,8 +677,7 @@ static inline int need_do_async_reclaim(struct btrfs_fs_info *fs_info, + if ((space_info->bytes_used + space_info->bytes_reserved) >= thresh) + return 0; + +- if (!btrfs_calc_reclaim_metadata_size(fs_info, space_info, +- system_chunk)) ++ if (!btrfs_calc_reclaim_metadata_size(fs_info, space_info)) + return 0; + + return (used >= thresh && !btrfs_fs_closing(fs_info) && +@@ -805,8 +800,7 @@ static void btrfs_async_reclaim_metadata_space(struct work_struct *work) + space_info = btrfs_find_space_info(fs_info, BTRFS_BLOCK_GROUP_METADATA); + + spin_lock(&space_info->lock); +- to_reclaim = btrfs_calc_reclaim_metadata_size(fs_info, space_info, +- false); ++ to_reclaim = btrfs_calc_reclaim_metadata_size(fs_info, space_info); + if (!to_reclaim) { + space_info->flush = 0; + spin_unlock(&space_info->lock); +@@ -825,8 +819,7 @@ static void btrfs_async_reclaim_metadata_space(struct work_struct *work) + return; + } + to_reclaim = btrfs_calc_reclaim_metadata_size(fs_info, +- space_info, +- false); ++ space_info); + if (last_tickets_id == space_info->tickets_id) { + flush_state++; + } else { +@@ -898,8 +891,7 @@ static void priority_reclaim_metadata_space(struct btrfs_fs_info *fs_info, + int flush_state; + + spin_lock(&space_info->lock); +- to_reclaim = btrfs_calc_reclaim_metadata_size(fs_info, space_info, +- false); ++ to_reclaim = btrfs_calc_reclaim_metadata_size(fs_info, space_info); + if (!to_reclaim) { + spin_unlock(&space_info->lock); + return; +@@ -1031,8 +1023,7 @@ static int handle_reserve_ticket(struct btrfs_fs_info *fs_info, + static int __reserve_metadata_bytes(struct btrfs_fs_info *fs_info, + struct btrfs_space_info *space_info, + u64 orig_bytes, +- enum btrfs_reserve_flush_enum flush, +- bool system_chunk) ++ enum btrfs_reserve_flush_enum flush) + { + struct reserve_ticket ticket; + u64 used; +@@ -1054,8 +1045,7 @@ static int __reserve_metadata_bytes(struct btrfs_fs_info *fs_info, + */ + if (!pending_tickets && + ((used + orig_bytes <= space_info->total_bytes) || +- can_overcommit(fs_info, space_info, orig_bytes, flush, +- system_chunk))) { ++ can_overcommit(fs_info, space_info, orig_bytes, flush))) { + btrfs_space_info_update_bytes_may_use(fs_info, space_info, + orig_bytes); + ret = 0; +@@ -1097,8 +1087,7 @@ static int __reserve_metadata_bytes(struct btrfs_fs_info *fs_info, + * the async reclaim as we will panic. + */ + if (!test_bit(BTRFS_FS_LOG_RECOVERING, &fs_info->flags) && +- need_do_async_reclaim(fs_info, space_info, +- used, system_chunk) && ++ need_do_async_reclaim(fs_info, space_info, used) && + !work_busy(&fs_info->async_reclaim_work)) { + trace_btrfs_trigger_flush(fs_info, space_info->flags, + orig_bytes, flush, "preempt"); +@@ -1135,10 +1124,9 @@ int btrfs_reserve_metadata_bytes(struct btrfs_root *root, + struct btrfs_fs_info *fs_info = root->fs_info; + struct btrfs_block_rsv *global_rsv = &fs_info->global_block_rsv; + int ret; +- bool system_chunk = (root == fs_info->chunk_root); + + ret = __reserve_metadata_bytes(fs_info, block_rsv->space_info, +- orig_bytes, flush, system_chunk); ++ orig_bytes, flush); + if (ret == -ENOSPC && + unlikely(root->orphan_cleanup_state == ORPHAN_CLEANUP_STARTED)) { + if (block_rsv != global_rsv && +-- +2.25.1 + diff --git a/queue-5.4/btrfs-take-overcommit-into-account-in-inc_block_grou.patch b/queue-5.4/btrfs-take-overcommit-into-account-in-inc_block_grou.patch new file mode 100644 index 00000000000..3ada80eddd9 --- /dev/null +++ b/queue-5.4/btrfs-take-overcommit-into-account-in-inc_block_grou.patch @@ -0,0 +1,174 @@ +From 07feb40c162ebecbea7d1ea560e553e32e0e8b48 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 14 Oct 2020 10:44:47 +0800 +Subject: btrfs: take overcommit into account in inc_block_group_ro + +From: Josef Bacik + +commit a30a3d2067536cbcce26c055e70cc3a6ae4fd45c upstream + +inc_block_group_ro does a calculation to see if we have enough room left +over if we mark this block group as read only in order to see if it's ok +to mark the block group as read only. + +The problem is this calculation _only_ works for data, where our used is +always less than our total. For metadata we will overcommit, so this +will almost always fail for metadata. + +Fix this by exporting btrfs_can_overcommit, and then see if we have +enough space to remove the remaining free space in the block group we +are trying to mark read only. If we do then we can mark this block +group as read only. + +Reviewed-by: Qu Wenruo +Signed-off-by: Josef Bacik +Reviewed-by: David Sterba +Signed-off-by: David Sterba +Signed-off-by: Anand Jain +Signed-off-by: Sasha Levin +--- + fs/btrfs/block-group.c | 38 ++++++++++++++++++++++++++------------ + fs/btrfs/space-info.c | 18 ++++++++++-------- + fs/btrfs/space-info.h | 3 +++ + 3 files changed, 39 insertions(+), 20 deletions(-) + +diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c +index b167649f5f5de..ace49a999ecec 100644 +--- a/fs/btrfs/block-group.c ++++ b/fs/btrfs/block-group.c +@@ -1186,7 +1186,6 @@ static int inc_block_group_ro(struct btrfs_block_group_cache *cache, int force) + { + struct btrfs_space_info *sinfo = cache->space_info; + u64 num_bytes; +- u64 sinfo_used; + u64 min_allocable_bytes; + int ret = -ENOSPC; + +@@ -1213,20 +1212,38 @@ static int inc_block_group_ro(struct btrfs_block_group_cache *cache, int force) + + num_bytes = cache->key.offset - cache->reserved - cache->pinned - + cache->bytes_super - btrfs_block_group_used(&cache->item); +- sinfo_used = btrfs_space_info_used(sinfo, true); + + /* +- * sinfo_used + num_bytes should always <= sinfo->total_bytes. +- * +- * Here we make sure if we mark this bg RO, we still have enough +- * free space as buffer (if min_allocable_bytes is not 0). ++ * Data never overcommits, even in mixed mode, so do just the straight ++ * check of left over space in how much we have allocated. + */ +- if (sinfo_used + num_bytes + min_allocable_bytes <= +- sinfo->total_bytes) { ++ if (force) { ++ ret = 0; ++ } else if (sinfo->flags & BTRFS_BLOCK_GROUP_DATA) { ++ u64 sinfo_used = btrfs_space_info_used(sinfo, true); ++ ++ /* ++ * Here we make sure if we mark this bg RO, we still have enough ++ * free space as buffer. ++ */ ++ if (sinfo_used + num_bytes <= sinfo->total_bytes) ++ ret = 0; ++ } else { ++ /* ++ * We overcommit metadata, so we need to do the ++ * btrfs_can_overcommit check here, and we need to pass in ++ * BTRFS_RESERVE_NO_FLUSH to give ourselves the most amount of ++ * leeway to allow us to mark this block group as read only. ++ */ ++ if (btrfs_can_overcommit(cache->fs_info, sinfo, num_bytes, ++ BTRFS_RESERVE_NO_FLUSH)) ++ ret = 0; ++ } ++ ++ if (!ret) { + sinfo->bytes_readonly += num_bytes; + cache->ro++; + list_add_tail(&cache->ro_list, &sinfo->ro_bgs); +- ret = 0; + } + out: + spin_unlock(&cache->lock); +@@ -1235,9 +1252,6 @@ static int inc_block_group_ro(struct btrfs_block_group_cache *cache, int force) + btrfs_info(cache->fs_info, + "unable to make block group %llu ro", + cache->key.objectid); +- btrfs_info(cache->fs_info, +- "sinfo_used=%llu bg_num_bytes=%llu min_allocable=%llu", +- sinfo_used, num_bytes, min_allocable_bytes); + btrfs_dump_space_info(cache->fs_info, cache->space_info, 0, 0); + } + return ret; +diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c +index e19e538d05f93..90500b6c41fc6 100644 +--- a/fs/btrfs/space-info.c ++++ b/fs/btrfs/space-info.c +@@ -160,9 +160,9 @@ static inline u64 calc_global_rsv_need_space(struct btrfs_block_rsv *global) + return (global->size << 1); + } + +-static int can_overcommit(struct btrfs_fs_info *fs_info, +- struct btrfs_space_info *space_info, u64 bytes, +- enum btrfs_reserve_flush_enum flush) ++int btrfs_can_overcommit(struct btrfs_fs_info *fs_info, ++ struct btrfs_space_info *space_info, u64 bytes, ++ enum btrfs_reserve_flush_enum flush) + { + u64 profile; + u64 avail; +@@ -227,7 +227,8 @@ void btrfs_try_granting_tickets(struct btrfs_fs_info *fs_info, + + /* Check and see if our ticket can be satisified now. */ + if ((used + ticket->bytes <= space_info->total_bytes) || +- can_overcommit(fs_info, space_info, ticket->bytes, flush)) { ++ btrfs_can_overcommit(fs_info, space_info, ticket->bytes, ++ flush)) { + btrfs_space_info_update_bytes_may_use(fs_info, + space_info, + ticket->bytes); +@@ -647,13 +648,14 @@ btrfs_calc_reclaim_metadata_size(struct btrfs_fs_info *fs_info, + return to_reclaim; + + to_reclaim = min_t(u64, num_online_cpus() * SZ_1M, SZ_16M); +- if (can_overcommit(fs_info, space_info, to_reclaim, +- BTRFS_RESERVE_FLUSH_ALL)) ++ if (btrfs_can_overcommit(fs_info, space_info, to_reclaim, ++ BTRFS_RESERVE_FLUSH_ALL)) + return 0; + + used = btrfs_space_info_used(space_info, true); + +- if (can_overcommit(fs_info, space_info, SZ_1M, BTRFS_RESERVE_FLUSH_ALL)) ++ if (btrfs_can_overcommit(fs_info, space_info, SZ_1M, ++ BTRFS_RESERVE_FLUSH_ALL)) + expected = div_factor_fine(space_info->total_bytes, 95); + else + expected = div_factor_fine(space_info->total_bytes, 90); +@@ -1045,7 +1047,7 @@ static int __reserve_metadata_bytes(struct btrfs_fs_info *fs_info, + */ + if (!pending_tickets && + ((used + orig_bytes <= space_info->total_bytes) || +- can_overcommit(fs_info, space_info, orig_bytes, flush))) { ++ btrfs_can_overcommit(fs_info, space_info, orig_bytes, flush))) { + btrfs_space_info_update_bytes_may_use(fs_info, space_info, + orig_bytes); + ret = 0; +diff --git a/fs/btrfs/space-info.h b/fs/btrfs/space-info.h +index 8b9a1d8fefcb7..b9cffc62cafac 100644 +--- a/fs/btrfs/space-info.h ++++ b/fs/btrfs/space-info.h +@@ -129,6 +129,9 @@ int btrfs_reserve_metadata_bytes(struct btrfs_root *root, + enum btrfs_reserve_flush_enum flush); + void btrfs_try_granting_tickets(struct btrfs_fs_info *fs_info, + struct btrfs_space_info *space_info); ++int btrfs_can_overcommit(struct btrfs_fs_info *fs_info, ++ struct btrfs_space_info *space_info, u64 bytes, ++ enum btrfs_reserve_flush_enum flush); + + static inline void btrfs_space_info_free_bytes_may_use( + struct btrfs_fs_info *fs_info, +-- +2.25.1 + diff --git a/queue-5.4/series b/queue-5.4/series index 027db12913c..1c9f9d9278c 100644 --- a/queue-5.4/series +++ b/queue-5.4/series @@ -1 +1,4 @@ perf-cs-etm-move-definition-of-traceid_list-global-variable-from-header-file.patch +btrfs-don-t-pass-system_chunk-into-can_overcommit.patch +btrfs-take-overcommit-into-account-in-inc_block_grou.patch +arm-8939-1-kbuild-use-correct-nm-executable.patch