Skip to content

Commit

Permalink
Btrfs: [PATCH] extent_map: fix locking for bio completion
Browse files Browse the repository at this point in the history
The bio completion handlers can be run in any context, e.g. when using
the old ide driver they run in hardirq context with irqs disabled so
lockdep rightfully warns about using write_lock_irq useage in these
handlers.

This patch switches clear_extent_bit and set_extent_bit to
write_lock_irqsave to fix this problem.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
  • Loading branch information
Christoph Hellwig authored and David Woodhouse committed Sep 11, 2007
1 parent 9433063 commit 90f1c19
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions fs/btrfs/extent_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ int clear_extent_bit(struct extent_map_tree *tree, u64 start, u64 end,
struct extent_state *state;
struct extent_state *prealloc = NULL;
struct rb_node *node;
unsigned long flags;
int err;
int set = 0;

Expand All @@ -466,7 +467,7 @@ int clear_extent_bit(struct extent_map_tree *tree, u64 start, u64 end,
return -ENOMEM;
}

write_lock_irq(&tree->lock);
write_lock_irqsave(&tree->lock, flags);
/*
* this search will find the extents that end after
* our range starts
Expand Down Expand Up @@ -533,7 +534,7 @@ int clear_extent_bit(struct extent_map_tree *tree, u64 start, u64 end,
goto search_again;

out:
write_unlock_irq(&tree->lock);
write_unlock_irqrestore(&tree->lock, flags);
if (prealloc)
free_extent_state(prealloc);

Expand All @@ -542,7 +543,7 @@ int clear_extent_bit(struct extent_map_tree *tree, u64 start, u64 end,
search_again:
if (start >= end)
goto out;
write_unlock_irq(&tree->lock);
write_unlock_irqrestore(&tree->lock, flags);
if (mask & __GFP_WAIT)
cond_resched();
goto again;
Expand Down Expand Up @@ -628,6 +629,7 @@ int set_extent_bit(struct extent_map_tree *tree, u64 start, u64 end, int bits,
struct extent_state *state;
struct extent_state *prealloc = NULL;
struct rb_node *node;
unsigned long flags;
int err = 0;
int set;
u64 last_start;
Expand All @@ -639,7 +641,7 @@ int set_extent_bit(struct extent_map_tree *tree, u64 start, u64 end, int bits,
return -ENOMEM;
}

write_lock_irq(&tree->lock);
write_lock_irqsave(&tree->lock, flags);
/*
* this search will find all the extents that end after
* our range starts.
Expand Down Expand Up @@ -759,7 +761,7 @@ int set_extent_bit(struct extent_map_tree *tree, u64 start, u64 end, int bits,
goto search_again;

out:
write_unlock_irq(&tree->lock);
write_unlock_irqrestore(&tree->lock, flags);
if (prealloc)
free_extent_state(prealloc);

Expand All @@ -768,7 +770,7 @@ int set_extent_bit(struct extent_map_tree *tree, u64 start, u64 end, int bits,
search_again:
if (start > end)
goto out;
write_unlock_irq(&tree->lock);
write_unlock_irqrestore(&tree->lock, flags);
if (mask & __GFP_WAIT)
cond_resched();
goto again;
Expand Down

0 comments on commit 90f1c19

Please sign in to comment.