Home Home > GIT Browse > openSUSE-42.3
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQu Wenruo <wqu@suse.com>2019-05-20 14:49:51 +0800
committerQu Wenruo <wqu@suse.com>2019-05-20 14:49:51 +0800
commit7c0883e35e2b948b9435981bfce1ec509d3fab33 (patch)
treea8dd951a1017820c54374c616ad32fd1391764b7
parentb7d3c80811faf02a95c0b65a8d7a0fca287f4e80 (diff)
btrfs: extent-tree: Fix a bug that btrfs is unable to add
pinned bytes (bsc#1063638 bsc#1128052 bsc#1108838).
-rw-r--r--patches.fixes/0001-btrfs-extent-tree-Fix-a-bug-that-btrfs-is-unable-to-.patch72
-rw-r--r--series.conf1
2 files changed, 73 insertions, 0 deletions
diff --git a/patches.fixes/0001-btrfs-extent-tree-Fix-a-bug-that-btrfs-is-unable-to-.patch b/patches.fixes/0001-btrfs-extent-tree-Fix-a-bug-that-btrfs-is-unable-to-.patch
new file mode 100644
index 0000000000..5509fa325a
--- /dev/null
+++ b/patches.fixes/0001-btrfs-extent-tree-Fix-a-bug-that-btrfs-is-unable-to-.patch
@@ -0,0 +1,72 @@
+From 14ae4ec1ee1466b701e0518f9acbb0bbd8ab0684 Mon Sep 17 00:00:00 2001
+From: Qu Wenruo <wqu@suse.com>
+Date: Fri, 10 May 2019 12:45:05 +0800
+Patch-mainline: Submitted, linux-btrfs
+References: bsc#1063638 bsc#1128052 bsc#1108838
+Subject: [PATCH] btrfs: extent-tree: Fix a bug that btrfs is unable to add
+ pinned bytes
+
+Commit ddf30cf03fb5 ("btrfs: extent-tree: Use btrfs_ref to refactor
+add_pinned_bytes()") refactored add_pinned_bytes(), but during that
+refactor, there are two callers which add the pinned bytes instead
+of subtracting.
+
+That refactor misses those two caller, causing incorrect pinned bytes
+calculation and resulting unexpected ENOSPC error.
+
+Fix it by adding a new parameter @sign to restore the original behavior.
+
+Reported-by: kernel test robot <rong.a.chen@intel.com>
+Fixes: ddf30cf03fb5 ("btrfs: extent-tree: Use btrfs_ref to refactor add_pinned_bytes()")
+Signed-off-by: Qu Wenruo <wqu@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+---
+ fs/btrfs/extent-tree.c | 12 +++++++-----
+ 1 file changed, 7 insertions(+), 5 deletions(-)
+
+--- a/fs/btrfs/extent-tree.c
++++ b/fs/btrfs/extent-tree.c
+@@ -756,12 +756,14 @@ static struct btrfs_space_info *__find_s
+ }
+
+ static void add_pinned_bytes(struct btrfs_fs_info *fs_info,
+- struct btrfs_ref *ref)
++ struct btrfs_ref *ref, int sign)
+ {
+ struct btrfs_space_info *space_info;
+- s64 num_bytes = -ref->len;
++ s64 num_bytes;
+ u64 flags;
+
++ ASSERT(sign == 1 || sign == -1);
++ num_bytes = sign * ref->len;
+ if (ref->type == BTRFS_REF_METADATA) {
+ if (ref->tree_ref.root == BTRFS_CHUNK_TREE_OBJECTID)
+ flags = BTRFS_BLOCK_GROUP_SYSTEM;
+@@ -2121,7 +2123,7 @@ int btrfs_inc_extent_ref(struct btrfs_tr
+ &old_ref_mod, &new_ref_mod);
+ }
+ if (ret == 0 && old_ref_mod < 0 && new_ref_mod >= 0)
+- add_pinned_bytes(fs_info, &generic_ref);
++ add_pinned_bytes(fs_info, &generic_ref, -1);
+
+ return ret;
+ }
+@@ -7225,7 +7227,7 @@ void btrfs_free_tree_block(struct btrfs_
+ }
+ out:
+ if (pin)
+- add_pinned_bytes(root->fs_info, &generic_ref);
++ add_pinned_bytes(root->fs_info, &generic_ref, 1);
+
+ if (last_ref) {
+
+@@ -7276,7 +7278,7 @@ int btrfs_free_extent(struct btrfs_trans
+ }
+
+ if (ret == 0 && old_ref_mod >= 0 && new_ref_mod < 0)
+- add_pinned_bytes(fs_info, &generic_ref);
++ add_pinned_bytes(fs_info, &generic_ref, 1);
+
+ return ret;
+ }
diff --git a/series.conf b/series.conf
index fcb9bf812e..d102eef278 100644
--- a/series.conf
+++ b/series.conf
@@ -25379,6 +25379,7 @@
# out-of-tree patches
patches.kabi/0001-move-power_up_on_resume-flag-to-end-of-structure-for.patch
patches.suse/0001-drm-ttm-Remove-warning-about-inconsistent-mapping-in.patch
+ patches.fixes/0001-btrfs-extent-tree-Fix-a-bug-that-btrfs-is-unable-to-.patch
########################################################
# end of sorted patches