Home Home > GIT Browse > openSUSE-42.3
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQu Wenruo <wqu@suse.com>2019-05-17 15:12:22 +0800
committerQu Wenruo <wqu@suse.com>2019-05-17 15:12:22 +0800
commit31277c6f9167e319ebc021aae4424eed79a38eff (patch)
tree8e6abbf1db7b900ca918a801f995efb059f66000
parent9029f90ac577bfcedc54c713f128a9cf917d27cc (diff)
btrfs: move extent_op cleanup to a helper (bsc#1134813).
-rw-r--r--patches.suse/0002-btrfs-move-extent_op-cleanup-to-a-helper.patch127
-rw-r--r--series.conf1
2 files changed, 128 insertions, 0 deletions
diff --git a/patches.suse/0002-btrfs-move-extent_op-cleanup-to-a-helper.patch b/patches.suse/0002-btrfs-move-extent_op-cleanup-to-a-helper.patch
new file mode 100644
index 0000000000..bc94a82ca6
--- /dev/null
+++ b/patches.suse/0002-btrfs-move-extent_op-cleanup-to-a-helper.patch
@@ -0,0 +1,127 @@
+From b00e62507ec6a9b63d9b3019795584e694085b65 Mon Sep 17 00:00:00 2001
+From: Josef Bacik <josef@toxicpanda.com>
+Date: Fri, 29 Sep 2017 15:43:53 -0400
+Git-commit: b00e62507ec6a9b63d9b3019795584e694085b65
+Patch-mainline: v4.15
+References: bsc#1134813
+Subject: [PATCH 2/5] btrfs: move extent_op cleanup to a helper
+
+Move the extent_op cleanup for an empty head ref to a helper function to
+help simplify __btrfs_run_delayed_refs.
+
+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 | 79 +++++++++++++++++++++++++------------------------
+ 1 file changed, 41 insertions(+), 38 deletions(-)
+
+--- a/fs/btrfs/extent-tree.c
++++ b/fs/btrfs/extent-tree.c
+@@ -2502,6 +2502,27 @@ static void unselect_delayed_ref_head(st
+ btrfs_delayed_ref_unlock(head);
+ }
+
++static int cleanup_extent_op(struct btrfs_trans_handle *trans,
++ struct btrfs_fs_info *fs_info,
++ struct btrfs_delayed_ref_head *head)
++{
++ struct btrfs_delayed_extent_op *extent_op = head->extent_op;
++ int ret;
++
++ if (!extent_op)
++ return 0;
++ head->extent_op = NULL;
++ if (head->must_insert_reserved) {
++ btrfs_free_delayed_extent_op(extent_op);
++ return 0;
++ }
++ spin_unlock(&head->lock);
++ ret = run_delayed_extent_op(trans, fs_info->extent_root, &head->node,
++ extent_op);
++ btrfs_free_delayed_extent_op(extent_op);
++ return ret ? ret : 1;
++}
++
+ /*
+ * Returns 0 on success or if called with an already aborted transaction.
+ * Returns -ENOMEM or -EIO on failure and will abort the transaction.
+@@ -2583,16 +2604,6 @@ static noinline int __btrfs_run_delayed_
+ continue;
+ }
+
+- /*
+- * record the must insert reserved flag before we
+- * drop the spin lock.
+- */
+- must_insert_reserved = locked_ref->must_insert_reserved;
+- locked_ref->must_insert_reserved = 0;
+-
+- extent_op = locked_ref->extent_op;
+- locked_ref->extent_op = NULL;
+-
+ if (!ref) {
+
+
+@@ -2602,34 +2613,17 @@ static noinline int __btrfs_run_delayed_
+ */
+ ref = &locked_ref->node;
+
+- if (extent_op && must_insert_reserved) {
+- btrfs_free_delayed_extent_op(extent_op);
+- extent_op = NULL;
+- }
+-
+- if (extent_op) {
+- spin_unlock(&locked_ref->lock);
+- ret = run_delayed_extent_op(trans, root,
+- ref, extent_op);
+- btrfs_free_delayed_extent_op(extent_op);
+-
+- if (ret) {
+- /*
+- * Need to reset must_insert_reserved if
+- * there was an error so the abort stuff
+- * can cleanup the reserved space
+- * properly.
+- */
+- if (must_insert_reserved)
+- locked_ref->must_insert_reserved = 1;
+- unselect_delayed_ref_head(delayed_refs,
+- locked_ref);
+- btrfs_debug(fs_info,
+- "run_delayed_extent_op returned %d",
+- ret);
+- btrfs_delayed_ref_unlock(locked_ref);
+- return ret;
+- }
++ 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) {
++ /* We dropped our lock, we need to loop. */
++ ret = 0;
+ continue;
+ }
+
+@@ -2678,6 +2672,15 @@ static noinline int __btrfs_run_delayed_
+ WARN_ON(1);
+ }
+ }
++ /*
++ * Record the must-insert_reserved flag before we drop the spin
++ * lock.
++ */
++ must_insert_reserved = locked_ref->must_insert_reserved;
++ locked_ref->must_insert_reserved = 0;
++
++ extent_op = locked_ref->extent_op;
++ locked_ref->extent_op = NULL;
+ spin_unlock(&locked_ref->lock);
+
+ ret = run_one_delayed_ref(trans, root, ref, extent_op,
diff --git a/series.conf b/series.conf
index 003b3b2658..b174b7478c 100644
--- a/series.conf
+++ b/series.conf
@@ -23303,6 +23303,7 @@
patches.suse/0009-btrfs-tree-checker-Enhance-output-for-check_extent_d.patch
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/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