]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
Btrfs: find_free_dev_extent doesn't handle holes at the start of the device
authorYan Zheng <zheng.yan@oracle.com>
Fri, 24 Jul 2009 15:06:53 +0000 (11:06 -0400)
committerChris Mason <chris.mason@oracle.com>
Fri, 24 Jul 2009 15:22:47 +0000 (11:22 -0400)
find_free_dev_extent does not properly handle the case where
the device is not complete free, and there is a free extent
at the beginning of the device.

Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/volumes.c

index 55c37276a29f9bb2984c01b4b9b3ac8f26e1592c..074c1c56d8c4a7c34a75147d63358250c0be6dbc 100644 (file)
@@ -758,9 +758,13 @@ static noinline int find_free_dev_extent(struct btrfs_trans_handle *trans,
        ret = btrfs_search_slot(trans, root, &key, path, 0, 0);
        if (ret < 0)
                goto error;
-       ret = btrfs_previous_item(root, path, 0, key.type);
-       if (ret < 0)
-               goto error;
+       if (ret > 0) {
+               ret = btrfs_previous_item(root, path, key.objectid, key.type);
+               if (ret < 0)
+                       goto error;
+               if (ret > 0)
+                       start_found = 1;
+       }
        l = path->nodes[0];
        btrfs_item_key_to_cpu(l, &key, path->slots[0]);
        while (1) {