Home Home > GIT Browse > SLE12-SP3
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
commit8687b3f6d51fcba9459d41c49eac9522708f6d26 (patch)
tree0caef588297327026859475009e3b9b73436ed70
parent2822cba000af1da338e2e79fa7b591b87ff46d0a (diff)
btrfs: move extent_op cleanup to a helper (bsc#1134813).
-rw-r--r--fs/btrfs/extent-tree.c79
1 files changed, 41 insertions, 38 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 0cb27232702f..70e789a3143a 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -2505,6 +2505,27 @@ static void unselect_delayed_ref_head(struct btrfs_delayed_ref_root *delayed_ref
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.
@@ -2586,16 +2607,6 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
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) {
@@ -2605,34 +2616,17 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
*/
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;
}
@@ -2681,6 +2675,15 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
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,