Commit 903889f462409c816893abd02d88636f7b4a7774
Committed by
Chris Mason
1 parent
69ce977a17
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
Btrfs: fix wrong size for the reservation when doing, file pre-allocation.
When we ran fsstress(a program in xfstests), the filesystem hung up when it is full. It was because the space reserved in btrfs_fallocate() was wrong, btrfs_fallocate() just used the size of the pre-allocation to reserve the space, didn't took the block size aligning into account, so the size of the reserved space was less than the allocated space, it caused the over reserve problem and made the filesystem hung up when invoking cow_file_range(). Fix it. Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Showing 1 changed file with 2 additions and 2 deletions Side-by-side Diff
fs/btrfs/file.c
... | ... | @@ -2000,7 +2000,7 @@ |
2000 | 2000 | * Make sure we have enough space before we do the |
2001 | 2001 | * allocation. |
2002 | 2002 | */ |
2003 | - ret = btrfs_check_data_free_space(inode, len); | |
2003 | + ret = btrfs_check_data_free_space(inode, alloc_end - alloc_start + 1); | |
2004 | 2004 | if (ret) |
2005 | 2005 | return ret; |
2006 | 2006 | |
... | ... | @@ -2107,7 +2107,7 @@ |
2107 | 2107 | out: |
2108 | 2108 | mutex_unlock(&inode->i_mutex); |
2109 | 2109 | /* Let go of our reservation. */ |
2110 | - btrfs_free_reserved_data_space(inode, len); | |
2110 | + btrfs_free_reserved_data_space(inode, alloc_end - alloc_start + 1); | |
2111 | 2111 | return ret; |
2112 | 2112 | } |
2113 | 2113 |