diff options
author | Chris Mason <chris.mason@fusionio.com> | 2013-03-05 11:11:26 -0500 |
---|---|---|
committer | Chris Mason <chris.mason@fusionio.com> | 2013-03-05 11:30:16 -0500 |
commit | 154ea2893002618bc3f9a1e2d8186c65490968b1 (patch) | |
tree | 5a74f2ccc965aef784891a29d1ded2b8610257a7 | |
parent | d7011f5b9dd3c88feb5cebad7d0b719ed6816ebd (diff) |
Btrfs: enforce min_bytes parameter during extent allocation
Commit 24542bf7ea5e4fdfdb5157ff544c093fa4dcb536 changed preallocation of
extents to cap the max size we try to allocate. It's a valid change,
but the extent reservation code is also used by balance, and that
can't tolerate a smaller extent being allocated.
__btrfs_prealloc_file_range already has a min_size parameter, which is
used by relocation to request a specific extent size. This commit
adds an extra check to enforce that minimum extent size.
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Reported-by: Stefan Behrens <sbehrens@giantdisaster.de>
-rw-r--r-- | fs/btrfs/inode.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index ecd9c4cdb0db..13ab4de0a400 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -8502,6 +8502,7 @@ static int __btrfs_prealloc_file_range(struct inode *inode, int mode, | |||
8502 | struct btrfs_key ins; | 8502 | struct btrfs_key ins; |
8503 | u64 cur_offset = start; | 8503 | u64 cur_offset = start; |
8504 | u64 i_size; | 8504 | u64 i_size; |
8505 | u64 cur_bytes; | ||
8505 | int ret = 0; | 8506 | int ret = 0; |
8506 | bool own_trans = true; | 8507 | bool own_trans = true; |
8507 | 8508 | ||
@@ -8516,8 +8517,9 @@ static int __btrfs_prealloc_file_range(struct inode *inode, int mode, | |||
8516 | } | 8517 | } |
8517 | } | 8518 | } |
8518 | 8519 | ||
8519 | ret = btrfs_reserve_extent(trans, root, | 8520 | cur_bytes = min(num_bytes, 256ULL * 1024 * 1024); |
8520 | min(num_bytes, 256ULL * 1024 * 1024), | 8521 | cur_bytes = max(cur_bytes, min_size); |
8522 | ret = btrfs_reserve_extent(trans, root, cur_bytes, | ||
8521 | min_size, 0, *alloc_hint, &ins, 1); | 8523 | min_size, 0, *alloc_hint, &ins, 1); |
8522 | if (ret) { | 8524 | if (ret) { |
8523 | if (own_trans) | 8525 | if (own_trans) |