aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Mason <chris.mason@fusionio.com>2013-02-20 16:23:40 -0500
committerChris Mason <chris.mason@fusionio.com>2013-02-20 17:08:18 -0500
commit86db25785a6e7cacc1ee868fe437e8a2957eae94 (patch)
tree16a9b9f346a3c2e0bed40e74498367e29a2c4457
parent24542bf7ea5e4fdfdb5157ff544c093fa4dcb536 (diff)
Btrfs: fix max chunk size on raid5/6
We try to limit the size of a chunk to 10GB, which keeps the unit of work reasonable during balance and resize operations. The limit checks were taking into account the number of copies of the data we had but what they really should be doing is comparing against the logical size of the chunk we're creating. This moves the code around a little to use the count of data stripes from raid5/6. Signed-off-by: Chris Mason <chris.mason@fusionio.com>
-rw-r--r--fs/btrfs/volumes.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 5d6010ba8b7e..538c5cfa005f 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -3837,10 +3837,6 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
3837 */ 3837 */
3838 data_stripes = num_stripes / ncopies; 3838 data_stripes = num_stripes / ncopies;
3839 3839
3840 if (stripe_size * ndevs > max_chunk_size * ncopies) {
3841 stripe_size = max_chunk_size * ncopies;
3842 do_div(stripe_size, ndevs);
3843 }
3844 if (type & BTRFS_BLOCK_GROUP_RAID5) { 3840 if (type & BTRFS_BLOCK_GROUP_RAID5) {
3845 raid_stripe_len = find_raid56_stripe_len(ndevs - 1, 3841 raid_stripe_len = find_raid56_stripe_len(ndevs - 1,
3846 btrfs_super_stripesize(info->super_copy)); 3842 btrfs_super_stripesize(info->super_copy));
@@ -3851,6 +3847,27 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
3851 btrfs_super_stripesize(info->super_copy)); 3847 btrfs_super_stripesize(info->super_copy));
3852 data_stripes = num_stripes - 2; 3848 data_stripes = num_stripes - 2;
3853 } 3849 }
3850
3851 /*
3852 * Use the number of data stripes to figure out how big this chunk
3853 * is really going to be in terms of logical address space,
3854 * and compare that answer with the max chunk size
3855 */
3856 if (stripe_size * data_stripes > max_chunk_size) {
3857 u64 mask = (1ULL << 24) - 1;
3858 stripe_size = max_chunk_size;
3859 do_div(stripe_size, data_stripes);
3860
3861 /* bump the answer up to a 16MB boundary */
3862 stripe_size = (stripe_size + mask) & ~mask;
3863
3864 /* but don't go higher than the limits we found
3865 * while searching for free extents
3866 */
3867 if (stripe_size > devices_info[ndevs-1].max_avail)
3868 stripe_size = devices_info[ndevs-1].max_avail;
3869 }
3870
3854 do_div(stripe_size, dev_stripes); 3871 do_div(stripe_size, dev_stripes);
3855 3872
3856 /* align to BTRFS_STRIPE_LEN */ 3873 /* align to BTRFS_STRIPE_LEN */