Home Home > GIT Browse > SLE15-AZURE
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQu Wenruo <wqu@suse.com>2019-05-15 15:24:52 +0800
committerQu Wenruo <wqu@suse.com>2019-05-15 15:24:52 +0800
commit37707c4de7ae72bb785a3083f06798f65e1c0a60 (patch)
tree71c02e9454f5494ea3858f111e26335949750980
parentf19a7abcc81bd378d2ee96d62b7e7f2e78a012e9 (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.suse/0001-btrfs-extent-tree-Fix-a-bug-that-btrfs-is-unable-to-.patch87
-rw-r--r--series.conf1
2 files changed, 88 insertions, 0 deletions
diff --git a/patches.suse/0001-btrfs-extent-tree-Fix-a-bug-that-btrfs-is-unable-to-.patch b/patches.suse/0001-btrfs-extent-tree-Fix-a-bug-that-btrfs-is-unable-to-.patch
new file mode 100644
index 0000000000..01af8fc3c3
--- /dev/null
+++ b/patches.suse/0001-btrfs-extent-tree-Fix-a-bug-that-btrfs-is-unable-to-.patch
@@ -0,0 +1,87 @@
+From 965fe8a6e29ede784cb38b97bb894aac1e8337a6 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, 10 May 2019
+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 refactoring add_pinned_bytes() to add_pinned_bytes() and
+sub_pinned_bytes() to explicitly show what we're doing.
+
+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 | 36 ++++++++++++++++++++++++------------
+ 1 file changed, 24 insertions(+), 12 deletions(-)
+
+--- a/fs/btrfs/extent-tree.c
++++ b/fs/btrfs/extent-tree.c
+@@ -767,25 +767,37 @@ static struct btrfs_space_info *__find_s
+ return NULL;
+ }
+
++static u64 generic_ref_to_space_flags(struct btrfs_ref *ref)
++{
++ if (ref->type == BTRFS_REF_METADATA) {
++ if (ref->tree_ref.root == BTRFS_CHUNK_TREE_OBJECTID)
++ return BTRFS_BLOCK_GROUP_SYSTEM;
++ else
++ return BTRFS_BLOCK_GROUP_METADATA;
++ }
++ return BTRFS_BLOCK_GROUP_DATA;
++}
++
+ static void add_pinned_bytes(struct btrfs_fs_info *fs_info,
+ struct btrfs_ref *ref)
+ {
+ struct btrfs_space_info *space_info;
+- s64 num_bytes = -ref->len;
+- u64 flags;
++ u64 flags = generic_ref_to_space_flags(ref);
+
+- if (ref->type == BTRFS_REF_METADATA) {
+- if (ref->tree_ref.root == BTRFS_CHUNK_TREE_OBJECTID)
+- flags = BTRFS_BLOCK_GROUP_SYSTEM;
+- else
+- flags = BTRFS_BLOCK_GROUP_METADATA;
+- } else {
+- flags = BTRFS_BLOCK_GROUP_DATA;
+- }
++ space_info = __find_space_info(fs_info, flags);
++ ASSERT(space_info);
++ percpu_counter_add(&space_info->total_bytes_pinned, ref->len);
++}
++
++static void sub_pinned_bytes(struct btrfs_fs_info *fs_info,
++ struct btrfs_ref *ref)
++{
++ struct btrfs_space_info *space_info;
++ u64 flags = generic_ref_to_space_flags(ref);
+
+ space_info = __find_space_info(fs_info, flags);
+ ASSERT(space_info);
+- percpu_counter_add(&space_info->total_bytes_pinned, num_bytes);
++ percpu_counter_add(&space_info->total_bytes_pinned, -ref->len);
+ }
+
+ /*
+@@ -2135,7 +2147,7 @@ int btrfs_inc_extent_ref(struct btrfs_tr
+ }
+
+ if (ret == 0 && old_ref_mod < 0 && new_ref_mod >= 0)
+- add_pinned_bytes(fs_info, &generic_ref);
++ sub_pinned_bytes(fs_info, &generic_ref);
+
+ return ret;
+ }
diff --git a/series.conf b/series.conf
index 352380fe33..1c2e10f50f 100644
--- a/series.conf
+++ b/series.conf
@@ -21927,6 +21927,7 @@
patches.fixes/qla2xxx-always-allocate-qla_tgt_wq.patch
patches.suse/lpfc-validate-command-in-lpfc_sli4_scmd_to_wqidx_dis.patch
patches.suse/0001-drm-ttm-Remove-warning-about-inconsistent-mapping-in.patch
+ patches.suse/0001-btrfs-extent-tree-Fix-a-bug-that-btrfs-is-unable-to-.patch
########################################################
# end of sorted patches