Btrfs: fix oops while writing data to SSD partitions
authorliubo <liubo2009@cn.fujitsu.com>
Wed, 27 Jul 2011 09:49:18 +0000 (09:49 +0000)
committerChris Mason <chris.mason@oracle.com>
Mon, 1 Aug 2011 18:30:44 +0000 (14:30 -0400)
Here I have a two SSD-partitions btrfs, and they are defaultly set to
"data=raid0, metadata=raid1", then I try to fill my btrfs partition
till "No space left on device", via "dd if=/dev/zero of=/mnt/btrfs/tmp".

I get an oops panic from kernel BUG at fs/btrfs/extent-tree.c:5199!, which
refers to find_free_extent's
BUG_ON(index != get_block_group_index(block_group));

In SSD mode, in order to find enough space to alloc, we may check the
block_group cache which has been checked sometime before, but the index is not
updated, where it hits the BUG_ON.

Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>
Acked-by: Josef Bacik <josef@redhat.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/extent-tree.c

index a4db88da125e9ba8d9d5441160b629c455d4acf1..b172b7fa4889f4bb162d5fc85486bc3a540c6f44 100644 (file)
@@ -5079,7 +5079,9 @@ have_block_group:
                         * group is does point to and try again
                         */
                        if (!last_ptr_loop && last_ptr->block_group &&
-                           last_ptr->block_group != block_group) {
+                           last_ptr->block_group != block_group &&
+                           index <=
+                                get_block_group_index(last_ptr->block_group)) {
 
                                btrfs_put_block_group(block_group);
                                block_group = last_ptr->block_group;