Btrfs: add mount -o ssd_spread to spread allocations out
[linux-2.6-block.git] / fs / btrfs / free-space-cache.c
index ac23476beb6eac1e6c279cd269001bb67742f9a9..4538e48581a5171b33af2d3d2c632dbff4e412e2 100644 (file)
@@ -579,6 +579,7 @@ out:
  * it returns -enospc
  */
 int btrfs_find_space_cluster(struct btrfs_trans_handle *trans,
+                            struct btrfs_root *root,
                             struct btrfs_block_group_cache *block_group,
                             struct btrfs_free_cluster *cluster,
                             u64 offset, u64 bytes, u64 empty_size)
@@ -595,7 +596,9 @@ int btrfs_find_space_cluster(struct btrfs_trans_handle *trans,
        int ret;
 
        /* for metadata, allow allocates with more holes */
-       if (block_group->flags & BTRFS_BLOCK_GROUP_METADATA) {
+       if (btrfs_test_opt(root, SSD_SPREAD)) {
+               min_bytes = bytes + empty_size;
+       } else if (block_group->flags & BTRFS_BLOCK_GROUP_METADATA) {
                /*
                 * we want to do larger allocations when we are
                 * flushing out the delayed refs, it helps prevent