5.4.90, 5.10.8

This commit is contained in:
Tk-Glitch
2021-01-18 08:59:38 +01:00
parent bc861366c1
commit ec15d047dd
3 changed files with 6 additions and 67 deletions

View File

@@ -34,67 +34,6 @@ index bf7ecab5d9e5..142e9dae2837 100644
--
cgit v1.2.3-1-gf6bb5
From 0128c7314a4d856461caacfdd528a7bffa03d41e Mon Sep 17 00:00:00 2001
From: Josef Bacik <josef@toxicpanda.com>
Date: Wed, 23 Dec 2020 14:41:00 -0500
Subject: btrfs: Fix 500-2000% performance regression w/ 5.10
Josef's tentative fix from
https://lore.kernel.org/linux-btrfs/0382080a1836a12c2d625f8a5bf899828eba204b.1608752315.git.josef@toxicpanda.com/
With the conflict fix mentioned in the reply.
For https://bugs.archlinux.org/task/69077
---
fs/btrfs/space-info.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c
index 64099565ab8f..8a1ce11b6ed8 100644
--- a/fs/btrfs/space-info.c
+++ b/fs/btrfs/space-info.c
@@ -480,6 +480,28 @@ static inline u64 calc_reclaim_items_nr(struct btrfs_fs_info *fs_info,
#define EXTENT_SIZE_PER_ITEM SZ_256K
+static void btrfs_writeback_inodes_sb_nr(struct btrfs_fs_info *fs_info,
+ unsigned long nr_pages, u64 nr_items)
+{
+ struct super_block *sb = fs_info->sb;
+
+ if (down_read_trylock(&sb->s_umount)) {
+ writeback_inodes_sb_nr(sb, nr_pages, WB_REASON_FS_FREE_SPACE);
+ up_read(&sb->s_umount);
+ } else {
+ /*
+ * We needn't worry the filesystem going from r/w to r/o though
+ * we don't acquire ->s_umount mutex, because the filesystem
+ * should guarantee the delalloc inodes list be empty after
+ * the filesystem is readonly(all dirty pages are written to
+ * the disk).
+ */
+ btrfs_start_delalloc_roots(fs_info, nr_items);
+ if (!current->journal_info)
+ btrfs_wait_ordered_roots(fs_info, nr_items, 0, (u64)-1);
+ }
+}
+
/*
* shrink metadata reservation for delalloc
*/
@@ -532,7 +554,8 @@ static void shrink_delalloc(struct btrfs_fs_info *fs_info,
loops = 0;
while ((delalloc_bytes || dio_bytes) && loops < 3) {
- btrfs_start_delalloc_roots(fs_info, items);
+ unsigned long nr_pages = min(delalloc_bytes, to_reclaim) >> PAGE_SHIFT;
+ btrfs_writeback_inodes_sb_nr(fs_info, nr_pages, items);
loops++;
if (wait_ordered && !trans) {
--
cgit v1.2.3-1-gf6bb5
From 61e5f6548784e507eb0662a71976a673436e6e3a Mon Sep 17 00:00:00 2001
From: Eric Dumazet <edumazet@google.com>
Date: Mon, 21 Dec 2020 20:14:02 +0100