From 8de972b4faa4be9b2a3c53103e18d86092a5da45 Mon Sep 17 00:00:00 2001 From: Chris Mason Date: Fri, 4 Jan 2013 15:39:43 -0500 Subject: [PATCH] Btrfs: fix cluster alignment for mount -o ssd With the new raid56 code, we want to make sure we're properly aligning our allocation clusters with -o ssd Signed-off-by: Chris Mason --- fs/btrfs/extent-tree.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 3345f68fc64b..f13402104c96 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -5715,6 +5715,7 @@ static noinline int find_free_extent(struct btrfs_trans_handle *trans, * lets look there */ if (last_ptr) { + unsigned long aligned_cluster; /* * the refill lock keeps out other * people trying to start a new cluster @@ -5781,11 +5782,15 @@ static noinline int find_free_extent(struct btrfs_trans_handle *trans, goto unclustered_alloc; } + aligned_cluster = max_t(unsigned long, + empty_cluster + empty_size, + block_group->full_stripe_len); + /* allocate a cluster in this block group */ ret = btrfs_find_space_cluster(trans, root, block_group, last_ptr, search_start, num_bytes, - empty_cluster + empty_size); + aligned_cluster); if (ret == 0) { /* * now pull our allocation out of this