Jelajahi Sumber

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 <dsterba@suse.com>
David Sterba 9 tahun lalu
induk
melakukan
059f791c6b
1 mengubah file dengan 7 tambahan dan 1 penghapusan
  1. 7 1
      fs/btrfs/extent_io.c

+ 7 - 1
fs/btrfs/extent_io.c

@@ -873,8 +873,14 @@ __set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
 	bits |= EXTENT_FIRST_DELALLOC;
 	bits |= EXTENT_FIRST_DELALLOC;
 again:
 again:
 	if (!prealloc && gfpflags_allow_blocking(mask)) {
 	if (!prealloc && gfpflags_allow_blocking(mask)) {
+		/*
+		 * Don't care for allocation failure here because we might end
+		 * up not needing the pre-allocated extent state at all, which
+		 * is the case if we only have in the tree extent states that
+		 * cover our input range and don't cover too any other range.
+		 * If we end up needing a new extent state we allocate it later.
+		 */
 		prealloc = alloc_extent_state(mask);
 		prealloc = alloc_extent_state(mask);
-		BUG_ON(!prealloc);
 	}
 	}
 
 
 	spin_lock(&tree->lock);
 	spin_lock(&tree->lock);