diff options
-rw-r--r-- | fs/btrfs/extent-tree.c | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 2f03181b777f..07f7f6942128 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -3925,7 +3925,6 @@ static int can_overcommit(struct btrfs_root *root, | |||
3925 | u64 space_size; | 3925 | u64 space_size; |
3926 | u64 avail; | 3926 | u64 avail; |
3927 | u64 used; | 3927 | u64 used; |
3928 | u64 to_add; | ||
3929 | 3928 | ||
3930 | used = space_info->bytes_used + space_info->bytes_reserved + | 3929 | used = space_info->bytes_used + space_info->bytes_reserved + |
3931 | space_info->bytes_pinned + space_info->bytes_readonly; | 3930 | space_info->bytes_pinned + space_info->bytes_readonly; |
@@ -3959,25 +3958,17 @@ static int can_overcommit(struct btrfs_root *root, | |||
3959 | BTRFS_BLOCK_GROUP_RAID10)) | 3958 | BTRFS_BLOCK_GROUP_RAID10)) |
3960 | avail >>= 1; | 3959 | avail >>= 1; |
3961 | 3960 | ||
3962 | to_add = space_info->total_bytes; | ||
3963 | |||
3964 | /* | 3961 | /* |
3965 | * If we aren't flushing all things, let us overcommit up to | 3962 | * If we aren't flushing all things, let us overcommit up to |
3966 | * 1/2th of the space. If we can flush, don't let us overcommit | 3963 | * 1/2th of the space. If we can flush, don't let us overcommit |
3967 | * too much, let it overcommit up to 1/8 of the space. | 3964 | * too much, let it overcommit up to 1/8 of the space. |
3968 | */ | 3965 | */ |
3969 | if (flush == BTRFS_RESERVE_FLUSH_ALL) | 3966 | if (flush == BTRFS_RESERVE_FLUSH_ALL) |
3970 | to_add >>= 3; | 3967 | avail >>= 3; |
3971 | else | 3968 | else |
3972 | to_add >>= 1; | 3969 | avail >>= 1; |
3973 | |||
3974 | /* | ||
3975 | * Limit the overcommit to the amount of free space we could possibly | ||
3976 | * allocate for chunks. | ||
3977 | */ | ||
3978 | to_add = min(avail, to_add); | ||
3979 | 3970 | ||
3980 | if (used + bytes < space_info->total_bytes + to_add) | 3971 | if (used + bytes < space_info->total_bytes + avail) |
3981 | return 1; | 3972 | return 1; |
3982 | return 0; | 3973 | return 0; |
3983 | } | 3974 | } |