Home Home > GIT Browse > openSUSE-42.3
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQu Wenruo <wqu@suse.com>2019-05-17 15:37:54 +0800
committerQu Wenruo <wqu@suse.com>2019-05-17 15:37:54 +0800
commitb27bb39365ff35c8308957af35067359c060f3e8 (patch)
treeeb16747638253f8f34be2c2915bdaec5c45cf7fe
parentd41af4370f1811cc42551b65b90b74344cb3a8bd (diff)
- btrfs: move all ref head cleanup to the helper function
(bsc#1134813). - Refresh patches.fixes/0001-btrfs-qgroup-Move-reserved-data-accounting-from-btrf.patch. - Refresh patches.suse/btrfs-fix-race-condition-between-delayed-refs-and-blockgroup-removal.patch.
-rw-r--r--patches.fixes/0001-btrfs-qgroup-Move-reserved-data-accounting-from-btrf.patch19
-rw-r--r--patches.suse/0005-btrfs-move-all-ref-head-cleanup-to-the-helper-functi.patch208
-rw-r--r--patches.suse/btrfs-fix-race-condition-between-delayed-refs-and-blockgroup-removal.patch64
-rw-r--r--series.conf1
4 files changed, 251 insertions, 41 deletions
diff --git a/patches.fixes/0001-btrfs-qgroup-Move-reserved-data-accounting-from-btrf.patch b/patches.fixes/0001-btrfs-qgroup-Move-reserved-data-accounting-from-btrf.patch
index 7dc5e56949..fb1fc47758 100644
--- a/patches.fixes/0001-btrfs-qgroup-Move-reserved-data-accounting-from-btrf.patch
+++ b/patches.fixes/0001-btrfs-qgroup-Move-reserved-data-accounting-from-btrf.patch
@@ -104,11 +104,11 @@ Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/delayed-ref.c | 40 ++++------------------------------------
fs/btrfs/delayed-ref.h | 11 -----------
- fs/btrfs/extent-tree.c | 4 ----
+ fs/btrfs/extent-tree.c | 3 ---
fs/btrfs/qgroup.c | 19 +++++++++++++++----
fs/btrfs/qgroup.h | 22 +++++++++++-----------
include/trace/events/btrfs.h | 29 -----------------------------
- 6 files changed, 30 insertions(+), 95 deletions(-)
+ 6 files changed, 30 insertions(+), 94 deletions(-)
--- a/fs/btrfs/delayed-ref.c
+++ b/fs/btrfs/delayed-ref.c
@@ -213,17 +213,16 @@ Signed-off-by: David Sterba <dsterba@suse.com>
* until the delayed ref is processed. must_insert_reserved is
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
-@@ -2455,10 +2455,6 @@ static int run_one_delayed_ref(struct bt
- }
+@@ -2555,9 +2555,6 @@ static int cleanup_ref_head(struct btrfs
}
-
-- /* Also free its reserved qgroup space */
-- btrfs_qgroup_free_delayed_ref(root->fs_info,
-- head->qgroup_ref_root,
-- head->qgroup_reserved);
- return ret;
}
+- /* Also free its reserved qgroup space */
+- btrfs_qgroup_free_delayed_ref(fs_info, head->qgroup_ref_root,
+- head->qgroup_reserved);
+ btrfs_delayed_ref_unlock(head);
+ btrfs_put_delayed_ref(&head->node);
+ return 0;
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -1481,12 +1481,18 @@ int btrfs_qgroup_trace_extent_nolock(str
diff --git a/patches.suse/0005-btrfs-move-all-ref-head-cleanup-to-the-helper-functi.patch b/patches.suse/0005-btrfs-move-all-ref-head-cleanup-to-the-helper-functi.patch
new file mode 100644
index 0000000000..2f13e4fafe
--- /dev/null
+++ b/patches.suse/0005-btrfs-move-all-ref-head-cleanup-to-the-helper-functi.patch
@@ -0,0 +1,208 @@
+From c1103f7a5d7a544dfdaca6102de68792909dc834 Mon Sep 17 00:00:00 2001
+From: Josef Bacik <josef@toxicpanda.com>
+Date: Fri, 29 Sep 2017 15:43:56 -0400
+Git-commit: c1103f7a5d7a544dfdaca6102de68792909dc834
+Patch-mainline: v4.15
+References: bsc#1134813
+Subject: [PATCH 5/5] btrfs: move all ref head cleanup to the helper function
+
+We do a couple different cleanup operations on the ref head. We adjust
+counters, we'll free any reserved space if we didn't end up using the
+ref, and we clear the pending csum bytes. Move all these disparate
+things into cleanup_ref_head and clean up the logic in
+__btrfs_run_delayed_refs so that it handles the !ref case a lot cleaner,
+as well as making run_one_delayed_ref() only deal with real refs and not
+the ref head.
+
+Signed-off-by: Josef Bacik <jbacik@fb.com>
+Reviewed-by: David Sterba <dsterba@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+---
+ fs/btrfs/extent-tree.c | 147 +++++++++++++++++++++----------------------------
+ 1 file changed, 64 insertions(+), 83 deletions(-)
+
+--- a/fs/btrfs/extent-tree.c
++++ b/fs/btrfs/extent-tree.c
+@@ -2415,46 +2415,6 @@ static int run_one_delayed_ref(struct bt
+ return 0;
+ }
+
+- if (btrfs_delayed_ref_is_head(node)) {
+- struct btrfs_delayed_ref_head *head;
+- /*
+- * we've hit the end of the chain and we were supposed
+- * to insert this extent into the tree. But, it got
+- * deleted before we ever needed to insert it, so all
+- * we have to do is clean up the accounting
+- */
+- BUG_ON(extent_op);
+- head = btrfs_delayed_node_to_head(node);
+- trace_run_delayed_ref_head(root->fs_info, node, head,
+- node->action);
+-
+- if (head->total_ref_mod < 0) {
+- struct btrfs_block_group_cache *cache;
+-
+- cache = btrfs_lookup_block_group(root->fs_info, node->bytenr);
+- ASSERT(cache);
+- percpu_counter_add(&cache->space_info->total_bytes_pinned,
+- -node->num_bytes);
+- btrfs_put_block_group(cache);
+- }
+-
+- if (insert_reserved) {
+- btrfs_pin_extent(root, node->bytenr,
+- node->num_bytes, 1);
+- if (head->is_data) {
+- ret = btrfs_del_csums(trans, root,
+- node->bytenr,
+- node->num_bytes);
+- }
+- }
+-
+- /* Also free its reserved qgroup space */
+- btrfs_qgroup_free_delayed_ref(root->fs_info,
+- head->qgroup_ref_root,
+- head->qgroup_reserved);
+- return ret;
+- }
+-
+ if (node->type == BTRFS_TREE_BLOCK_REF_KEY ||
+ node->type == BTRFS_SHARED_BLOCK_REF_KEY)
+ ret = run_delayed_tree_ref(trans, root, node, extent_op,
+@@ -2557,6 +2517,43 @@ static int cleanup_ref_head(struct btrfs
+ delayed_refs->num_heads--;
+ rb_erase(&head->href_node, &delayed_refs->href_root);
+ spin_unlock(&delayed_refs->lock);
++ spin_unlock(&head->lock);
++ atomic_dec(&delayed_refs->num_entries);
++
++ trace_run_delayed_ref_head(fs_info, &head->node, head,
++ head->node.action);
++
++ if (head->total_ref_mod < 0) {
++ struct btrfs_block_group_cache *cache;
++
++ cache = btrfs_lookup_block_group(fs_info, head->node.bytenr);
++ ASSERT(cache);
++ percpu_counter_add(&cache->space_info->total_bytes_pinned,
++ -head->node.num_bytes);
++ btrfs_put_block_group(cache);
++
++ if (head->is_data) {
++ spin_lock(&delayed_refs->lock);
++ delayed_refs->pending_csums -= head->node.num_bytes;
++ spin_unlock(&delayed_refs->lock);
++ }
++ }
++
++ if (head->must_insert_reserved) {
++ btrfs_pin_extent(fs_info->extent_root, head->node.bytenr,
++ head->node.num_bytes, 1);
++ if (head->is_data) {
++ ret = btrfs_del_csums(trans, fs_info->csum_root,
++ head->node.bytenr,
++ head->node.num_bytes);
++ }
++ }
++
++ /* Also free its reserved qgroup space */
++ btrfs_qgroup_free_delayed_ref(fs_info, head->qgroup_ref_root,
++ head->qgroup_reserved);
++ btrfs_delayed_ref_unlock(head);
++ btrfs_put_delayed_ref(&head->node);
+ return 0;
+ }
+
+@@ -2641,6 +2638,10 @@ static noinline int __btrfs_run_delayed_
+ continue;
+ }
+
++ /*
++ * We're done processing refs in this ref_head, clean everything
++ * up and move on to the next ref_head.
++ */
+ if (!ref) {
+ ret = cleanup_ref_head(trans, fs_info, locked_ref);
+ if (ret > 0 ) {
+@@ -2650,34 +2651,30 @@ static noinline int __btrfs_run_delayed_
+ } else if (ret) {
+ return ret;
+ }
++ locked_ref = NULL;
++ count++;
++ continue;
++ }
+
+- /*
+- * All delayed refs have been processed, Go ahead and
+- * send the head node to run_one_delayed_ref, so that
+- * any accounting fixes can happen
+- */
+- ref = &locked_ref->node;
+- } else {
+- actual_count++;
+- ref->in_tree = 0;
+- list_del(&ref->list);
+- if (!list_empty(&ref->add_list))
+- list_del(&ref->add_list);
+- /*
+- * when we play the delayed ref, also correct the
+- * ref_mod on head
+- */
+- switch (ref->action) {
+- case BTRFS_ADD_DELAYED_REF:
+- case BTRFS_ADD_DELAYED_EXTENT:
+- locked_ref->node.ref_mod -= ref->ref_mod;
+- break;
+- case BTRFS_DROP_DELAYED_REF:
+- locked_ref->node.ref_mod += ref->ref_mod;
+- break;
+- default:
+- WARN_ON(1);
+- }
++ actual_count++;
++ ref->in_tree = 0;
++ list_del(&ref->list);
++ if (!list_empty(&ref->add_list))
++ list_del(&ref->add_list);
++ /*
++ * When we play the delayed ref, also correct the ref_mod on
++ * head
++ */
++ switch (ref->action) {
++ case BTRFS_ADD_DELAYED_REF:
++ case BTRFS_ADD_DELAYED_EXTENT:
++ locked_ref->node.ref_mod -= ref->ref_mod;
++ break;
++ case BTRFS_DROP_DELAYED_REF:
++ locked_ref->node.ref_mod += ref->ref_mod;
++ break;
++ default:
++ WARN_ON(1);
+ }
+ atomic_dec(&delayed_refs->num_entries);
+
+@@ -2704,22 +2701,6 @@ static noinline int __btrfs_run_delayed_
+ return ret;
+ }
+
+- /*
+- * If this node is a head, that means all the refs in this head
+- * have been dealt with, and we will pick the next head to deal
+- * with, so we must unlock the head and drop it from the cluster
+- * list before we release it.
+- */
+- if (btrfs_delayed_ref_is_head(ref)) {
+- if (locked_ref->is_data &&
+- locked_ref->total_ref_mod < 0) {
+- spin_lock(&delayed_refs->lock);
+- delayed_refs->pending_csums -= ref->num_bytes;
+- spin_unlock(&delayed_refs->lock);
+- }
+- btrfs_delayed_ref_unlock(locked_ref);
+- locked_ref = NULL;
+- }
+ btrfs_put_delayed_ref(ref);
+ count++;
+ cond_resched();
diff --git a/patches.suse/btrfs-fix-race-condition-between-delayed-refs-and-blockgroup-removal.patch b/patches.suse/btrfs-fix-race-condition-between-delayed-refs-and-blockgroup-removal.patch
index 424187bd24..102cd4d2f5 100644
--- a/patches.suse/btrfs-fix-race-condition-between-delayed-refs-and-blockgroup-removal.patch
+++ b/patches.suse/btrfs-fix-race-condition-between-delayed-refs-and-blockgroup-removal.patch
@@ -51,12 +51,12 @@ Acked-by: Jeff Mahoney <jeffm@suse.com>
---
fs/btrfs/delayed-ref.c | 16 ++++++++++++----
fs/btrfs/delayed-ref.h | 1 +
- fs/btrfs/extent-tree.c | 16 +++++++++++-----
- 3 files changed, 24 insertions(+), 9 deletions(-)
+ fs/btrfs/extent-tree.c | 19 ++++++++++++-------
+ 3 files changed, 25 insertions(+), 11 deletions(-)
--- a/fs/btrfs/delayed-ref.c
+++ b/fs/btrfs/delayed-ref.c
-@@ -553,8 +553,9 @@ add_delayed_ref_head(struct btrfs_fs_inf
+@@ -557,8 +557,9 @@ add_delayed_ref_head(struct btrfs_fs_inf
struct btrfs_delayed_ref_node *ref,
struct btrfs_qgroup_extent_record *qrecord,
u64 bytenr, u64 num_bytes, u64 ref_root, u64 reserved,
@@ -67,7 +67,7 @@ Acked-by: Jeff Mahoney <jeffm@suse.com>
{
struct btrfs_delayed_ref_head *existing;
struct btrfs_delayed_ref_head *head_ref = NULL;
-@@ -606,6 +607,7 @@ add_delayed_ref_head(struct btrfs_fs_inf
+@@ -610,6 +611,7 @@ add_delayed_ref_head(struct btrfs_fs_inf
head_ref = btrfs_delayed_node_to_head(ref);
head_ref->must_insert_reserved = must_insert_reserved;
head_ref->is_data = is_data;
@@ -75,7 +75,7 @@ Acked-by: Jeff Mahoney <jeffm@suse.com>
INIT_LIST_HEAD(&head_ref->ref_list);
INIT_LIST_HEAD(&head_ref->ref_add_list);
head_ref->processing = 0;
-@@ -789,6 +791,7 @@ int btrfs_add_delayed_tree_ref(struct bt
+@@ -793,6 +795,7 @@ int btrfs_add_delayed_tree_ref(struct bt
struct btrfs_delayed_ref_head *head_ref;
struct btrfs_delayed_ref_root *delayed_refs;
struct btrfs_qgroup_extent_record *record = NULL;
@@ -83,7 +83,7 @@ Acked-by: Jeff Mahoney <jeffm@suse.com>
BUG_ON(extent_op && extent_op->is_data);
ref = kmem_cache_alloc(btrfs_delayed_tree_ref_cachep, GFP_NOFS);
-@@ -817,7 +820,7 @@ int btrfs_add_delayed_tree_ref(struct bt
+@@ -821,7 +824,7 @@ int btrfs_add_delayed_tree_ref(struct bt
*/
head_ref = add_delayed_ref_head(fs_info, trans, &head_ref->node, record,
bytenr, num_bytes, 0, 0, action, 0,
@@ -92,7 +92,7 @@ Acked-by: Jeff Mahoney <jeffm@suse.com>
add_delayed_tree_ref(fs_info, trans, head_ref, &ref->node, bytenr,
num_bytes, parent, ref_root, level, action);
-@@ -882,7 +885,7 @@ int btrfs_add_delayed_data_ref(struct bt
+@@ -886,7 +889,7 @@ int btrfs_add_delayed_data_ref(struct bt
*/
head_ref = add_delayed_ref_head(fs_info, trans, &head_ref->node, record,
bytenr, num_bytes, ref_root, reserved,
@@ -101,7 +101,7 @@ Acked-by: Jeff Mahoney <jeffm@suse.com>
add_delayed_data_ref(fs_info, trans, head_ref, &ref->node, bytenr,
num_bytes, parent, ref_root, owner, offset,
-@@ -937,9 +940,14 @@ int btrfs_add_delayed_extent_op(struct b
+@@ -941,9 +944,14 @@ int btrfs_add_delayed_extent_op(struct b
delayed_refs = &trans->transaction->delayed_refs;
spin_lock(&delayed_refs->lock);
@@ -129,28 +129,30 @@ Acked-by: Jeff Mahoney <jeffm@suse.com>
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
-@@ -2429,13 +2429,19 @@ static int run_one_delayed_ref(struct bt
- node->action);
+@@ -2525,14 +2525,19 @@ static int cleanup_ref_head(struct btrfs
+ head->node.action);
- if (head->total_ref_mod < 0) {
-- struct btrfs_block_group_cache *cache;
-+ struct btrfs_space_info *space_info;
-+ u64 flags;
+ if (head->total_ref_mod < 0) {
+- struct btrfs_block_group_cache *cache;
+-
+- cache = btrfs_lookup_block_group(fs_info, head->node.bytenr);
+- ASSERT(cache);
+- percpu_counter_add(&cache->space_info->total_bytes_pinned,
+- -head->node.num_bytes);
+- btrfs_put_block_group(cache);
++ struct btrfs_space_info *space_info;
++ u64 flags;
-- cache = btrfs_lookup_block_group(root->fs_info, node->bytenr);
-- ASSERT(cache);
-- percpu_counter_add(&cache->space_info->total_bytes_pinned,
-+ if (head->is_data)
-+ flags = BTRFS_BLOCK_GROUP_DATA;
-+ else if (head->is_system)
-+ flags = BTRFS_BLOCK_GROUP_SYSTEM;
-+ else
-+ flags = BTRFS_BLOCK_GROUP_METADATA;
-+ space_info = __find_space_info(root->fs_info, flags);
-+ ASSERT(space_info);
-+ percpu_counter_add(&space_info->total_bytes_pinned,
- -node->num_bytes);
-- btrfs_put_block_group(cache);
- }
-
- if (insert_reserved) {
++ if (head->is_data)
++ flags = BTRFS_BLOCK_GROUP_DATA;
++ else if (head->is_system)
++ flags = BTRFS_BLOCK_GROUP_SYSTEM;
++ else
++ flags = BTRFS_BLOCK_GROUP_METADATA;
++ space_info = __find_space_info(fs_info, flags);
++ ASSERT(space_info);
++ percpu_counter_add(&space_info->total_bytes_pinned,
++ -head->node.num_bytes);
+ if (head->is_data) {
+ spin_lock(&delayed_refs->lock);
+ delayed_refs->pending_csums -= head->node.num_bytes;
diff --git a/series.conf b/series.conf
index 63c50cdd82..f02b4fe311 100644
--- a/series.conf
+++ b/series.conf
@@ -23306,6 +23306,7 @@
patches.suse/0002-btrfs-move-extent_op-cleanup-to-a-helper.patch
patches.suse/0003-btrfs-breakout-empty-head-cleanup-to-a-helper.patch
patches.suse/0004-btrfs-move-ref_mod-modification-into-the-if-ref-logi.patch
+ patches.suse/0005-btrfs-move-all-ref-head-cleanup-to-the-helper-functi.patch
patches.suse/0020-btrfs-remove-type-argument-from-comp_tree_refs.patch
patches.suse/0016-btrfs-cleanup-extent-locking-sequence.patch
patches.suse/0017-Btrfs-rework-outstanding_extents.patch