Skip to content

Commit 059f791

Browse files
committed
btrfs: make state preallocation more speculative in __set_extent_bit
Similar to __clear_extent_bit, do not fail if the state preallocation fails as we might not need it. One less BUG_ON. Signed-off-by: David Sterba <[email protected]>
1 parent 03bf538 commit 059f791

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

fs/btrfs/extent_io.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -873,8 +873,14 @@ __set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
873873
bits |= EXTENT_FIRST_DELALLOC;
874874
again:
875875
if (!prealloc && gfpflags_allow_blocking(mask)) {
876+
/*
877+
* Don't care for allocation failure here because we might end
878+
* up not needing the pre-allocated extent state at all, which
879+
* is the case if we only have in the tree extent states that
880+
* cover our input range and don't cover too any other range.
881+
* If we end up needing a new extent state we allocate it later.
882+
*/
876883
prealloc = alloc_extent_state(mask);
877-
BUG_ON(!prealloc);
878884
}
879885

880886
spin_lock(&tree->lock);

0 commit comments

Comments
 (0)