aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilipe Manana <fdmanana@gmail.com>2014-03-14 16:55:01 -0400
committerChris Mason <clm@fb.com>2014-03-20 20:15:28 -0400
commit21543baddcdbaa49db5ac8766ae564381e7c64d9 (patch)
tree4ce8aee02deb8ed2d37ef08fe7b2bf2ef66eec24
parentc3a468915a384c0015263edd9b7263775599a323 (diff)
Btrfs: fix race when updating existing ref head
While we update an existing ref head's extent_op, we're not holding its spinlock, so while we're updating its extent_op contents (key, flags) we can have a task running __btrfs_run_delayed_refs() that holds the ref head's lock and sets its extent_op to NULL right after the task updating the ref head just checked its extent_op was not NULL. Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> Signed-off-by: Chris Mason <clm@fb.com>
-rw-r--r--fs/btrfs/delayed-ref.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c
index 2502ba5a3ac0..31299646024d 100644
--- a/fs/btrfs/delayed-ref.c
+++ b/fs/btrfs/delayed-ref.c
@@ -495,6 +495,7 @@ update_existing_head_ref(struct btrfs_delayed_ref_node *existing,
495 ref = btrfs_delayed_node_to_head(update); 495 ref = btrfs_delayed_node_to_head(update);
496 BUG_ON(existing_ref->is_data != ref->is_data); 496 BUG_ON(existing_ref->is_data != ref->is_data);
497 497
498 spin_lock(&existing_ref->lock);
498 if (ref->must_insert_reserved) { 499 if (ref->must_insert_reserved) {
499 /* if the extent was freed and then 500 /* if the extent was freed and then
500 * reallocated before the delayed ref 501 * reallocated before the delayed ref
@@ -536,7 +537,6 @@ update_existing_head_ref(struct btrfs_delayed_ref_node *existing,
536 * only need the lock for this case cause we could be processing it 537 * only need the lock for this case cause we could be processing it
537 * currently, for refs we just added we know we're a-ok. 538 * currently, for refs we just added we know we're a-ok.
538 */ 539 */
539 spin_lock(&existing_ref->lock);
540 existing->ref_mod += update->ref_mod; 540 existing->ref_mod += update->ref_mod;
541 spin_unlock(&existing_ref->lock); 541 spin_unlock(&existing_ref->lock);
542} 542}