aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@fusionio.com>2013-06-03 16:42:36 -0400
committerJosef Bacik <jbacik@fusionio.com>2013-06-14 11:30:13 -0400
commite78417d1921c538ea195537c7bea1b31a6a55961 (patch)
treee588950c7b2af3d686fdc7fb34dc704e4e66c170
parenta5959bc0a1920d54c07b26a67b104caaf28f0a8c (diff)
Btrfs: do not pin while under spin lock
When testing a corrupted fs I noticed I was getting sleep while atomic errors when the transaction aborted. This is because btrfs_pin_extent may need to allocate memory and we are calling this under the spin lock. Fix this by moving it out and doing the pin after dropping the spin lock but before dropping the mutex, the same way it works when delayed refs run normally. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com>
-rw-r--r--fs/btrfs/disk-io.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 9b7020197c71..3c2886ca7d8c 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3762,6 +3762,7 @@ int btrfs_destroy_delayed_refs(struct btrfs_transaction *trans,
3762 3762
3763 while ((node = rb_first(&delayed_refs->root)) != NULL) { 3763 while ((node = rb_first(&delayed_refs->root)) != NULL) {
3764 struct btrfs_delayed_ref_head *head = NULL; 3764 struct btrfs_delayed_ref_head *head = NULL;
3765 bool pin_bytes = false;
3765 3766
3766 ref = rb_entry(node, struct btrfs_delayed_ref_node, rb_node); 3767 ref = rb_entry(node, struct btrfs_delayed_ref_node, rb_node);
3767 atomic_set(&ref->refs, 1); 3768 atomic_set(&ref->refs, 1);
@@ -3782,8 +3783,7 @@ int btrfs_destroy_delayed_refs(struct btrfs_transaction *trans,
3782 } 3783 }
3783 3784
3784 if (head->must_insert_reserved) 3785 if (head->must_insert_reserved)
3785 btrfs_pin_extent(root, ref->bytenr, 3786 pin_bytes = true;
3786 ref->num_bytes, 1);
3787 btrfs_free_delayed_extent_op(head->extent_op); 3787 btrfs_free_delayed_extent_op(head->extent_op);
3788 delayed_refs->num_heads--; 3788 delayed_refs->num_heads--;
3789 if (list_empty(&head->cluster)) 3789 if (list_empty(&head->cluster))
@@ -3794,9 +3794,13 @@ int btrfs_destroy_delayed_refs(struct btrfs_transaction *trans,
3794 ref->in_tree = 0; 3794 ref->in_tree = 0;
3795 rb_erase(&ref->rb_node, &delayed_refs->root); 3795 rb_erase(&ref->rb_node, &delayed_refs->root);
3796 delayed_refs->num_entries--; 3796 delayed_refs->num_entries--;
3797 if (head)
3798 mutex_unlock(&head->mutex);
3799 spin_unlock(&delayed_refs->lock); 3797 spin_unlock(&delayed_refs->lock);
3798 if (head) {
3799 if (pin_bytes)
3800 btrfs_pin_extent(root, ref->bytenr,
3801 ref->num_bytes, 1);
3802 mutex_unlock(&head->mutex);
3803 }
3800 btrfs_put_delayed_ref(ref); 3804 btrfs_put_delayed_ref(ref);
3801 3805
3802 cond_resched(); 3806 cond_resched();