Home Home > GIT Browse > openSUSE-42.3
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQu Wenruo <wqu@suse.com>2019-05-17 15:20:43 +0800
committerQu Wenruo <wqu@suse.com>2019-05-17 15:20:43 +0800
commitf6f2a2dcb1f93f94eeb259e0395d38318996a185 (patch)
tree0a73cdbb5aa06c670e668a006e925be34a5548b6
parent31277c6f9167e319ebc021aae4424eed79a38eff (diff)
btrfs: breakout empty head cleanup to a helper (bsc#1134813).
-rw-r--r--patches.suse/0003-btrfs-breakout-empty-head-cleanup-to-a-helper.patch119
-rw-r--r--series.conf1
2 files changed, 120 insertions, 0 deletions
diff --git a/patches.suse/0003-btrfs-breakout-empty-head-cleanup-to-a-helper.patch b/patches.suse/0003-btrfs-breakout-empty-head-cleanup-to-a-helper.patch
new file mode 100644
index 0000000000..404149f86e
--- /dev/null
+++ b/patches.suse/0003-btrfs-breakout-empty-head-cleanup-to-a-helper.patch
@@ -0,0 +1,119 @@
+From 194ab0bc21cc99c5b804040aa785e0bdcc214656 Mon Sep 17 00:00:00 2001
+From: Josef Bacik <josef@toxicpanda.com>
+Date: Fri, 29 Sep 2017 15:43:54 -0400
+Git-commit: 194ab0bc21cc99c5b804040aa785e0bdcc214656
+Patch-mainline: v4.15
+References: bsc#1134813
+Subject: [PATCH 3/5] btrfs: breakout empty head cleanup to a helper
+
+Move this code out to a helper function to further simplivy
+__btrfs_run_delayed_refs.
+
+Signed-off-by: Josef Bacik <jbacik@fb.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+---
+ fs/btrfs/extent-tree.c | 79 +++++++++++++++++++++++++++----------------------
+ 1 file changed, 45 insertions(+), 34 deletions(-)
+
+--- a/fs/btrfs/extent-tree.c
++++ b/fs/btrfs/extent-tree.c
+@@ -2523,6 +2523,43 @@ static int cleanup_extent_op(struct btrf
+ return ret ? ret : 1;
+ }
+
++static int cleanup_ref_head(struct btrfs_trans_handle *trans,
++ struct btrfs_fs_info *fs_info,
++ struct btrfs_delayed_ref_head *head)
++{
++ struct btrfs_delayed_ref_root *delayed_refs;
++ int ret;
++
++ delayed_refs = &trans->transaction->delayed_refs;
++
++ ret = cleanup_extent_op(trans, fs_info, head);
++ if (ret < 0) {
++ unselect_delayed_ref_head(delayed_refs, head);
++ btrfs_debug(fs_info, "run_delayed_extent_op returned %d", ret);
++ return ret;
++ } else if (ret) {
++ return ret;
++ }
++
++ /*
++ * Need to drop our head ref lock and re-acquire the delayed ref lock
++ * and then re-check to make sure nobody got added.
++ */
++ spin_unlock(&head->lock);
++ spin_lock(&delayed_refs->lock);
++ spin_lock(&head->lock);
++ if (!list_empty(&head->ref_list) || head->extent_op) {
++ spin_unlock(&head->lock);
++ spin_unlock(&delayed_refs->lock);
++ return 1;
++ }
++ head->node.in_tree = 0;
++ delayed_refs->num_heads--;
++ rb_erase(&head->href_node, &delayed_refs->href_root);
++ spin_unlock(&delayed_refs->lock);
++ return 0;
++}
++
+ /*
+ * Returns 0 on success or if called with an already aborted transaction.
+ * Returns -ENOMEM or -EIO on failure and will abort the transaction.
+@@ -2605,47 +2642,21 @@ static noinline int __btrfs_run_delayed_
+ }
+
+ if (!ref) {
+-
+-
+- /* 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;
+-
+- ret = cleanup_extent_op(trans, fs_info, locked_ref);
+- if (ret < 0) {
+- unselect_delayed_ref_head(delayed_refs,
+- locked_ref);
+- btrfs_debug(fs_info,
+- "run_delayed_extent_op returned %d",
+- ret);
+- return ret;
+- } else if (ret > 0) {
++ ret = cleanup_ref_head(trans, fs_info, locked_ref);
++ if (ret > 0 ) {
+ /* We dropped our lock, we need to loop. */
+ ret = 0;
+ continue;
++ } else if (ret) {
++ return ret;
+ }
+
+ /*
+- * Need to drop our head ref lock and re-aqcuire the
+- * delayed ref lock and then re-check to make sure
+- * nobody got added.
++ * 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
+ */
+- spin_unlock(&locked_ref->lock);
+- spin_lock(&delayed_refs->lock);
+- spin_lock(&locked_ref->lock);
+- if (!list_empty(&locked_ref->ref_list) ||
+- locked_ref->extent_op) {
+- spin_unlock(&locked_ref->lock);
+- spin_unlock(&delayed_refs->lock);
+- continue;
+- }
+- ref->in_tree = 0;
+- delayed_refs->num_heads--;
+- rb_erase(&locked_ref->href_node,
+- &delayed_refs->href_root);
+- spin_unlock(&delayed_refs->lock);
++ ref = &locked_ref->node;
+ } else {
+ actual_count++;
+ ref->in_tree = 0;
diff --git a/series.conf b/series.conf
index b174b7478c..ef43f513b7 100644
--- a/series.conf
+++ b/series.conf
@@ -23304,6 +23304,7 @@
patches.suse/0010-btrfs-tree-checker-use-zu-format-string-for-size_t.patch
patches.suse/0001-btrfs-add-a-helper-to-return-a-head-ref.patch
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/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