Skip to content

Commit d792b0f

Browse files
josefbacikkdave
authored andcommitted
btrfs: always reserve our entire size for the global reserve
While messing with the overcommit logic I noticed that sometimes we'd ENOSPC out when really we should have run out of space much earlier. It turns out it's because we'll only reserve up to the free amount left in the space info for the global reserve, but that doesn't make sense with overcommit because we could be well above our actual size. This results in the global reserve not carving out it's entire reservation, and thus not putting enough pressure on the rest of the infrastructure to do the right thing and ENOSPC out at a convenient time. Fix this by always taking our full reservation amount for the global reserve. Reviewed-by: Nikolay Borisov <[email protected]> Signed-off-by: Josef Bacik <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 3593ce3 commit d792b0f

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

fs/btrfs/block-rsv.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -296,15 +296,10 @@ void btrfs_update_global_block_rsv(struct btrfs_fs_info *fs_info)
296296
block_rsv->size = min_t(u64, num_bytes, SZ_512M);
297297

298298
if (block_rsv->reserved < block_rsv->size) {
299-
num_bytes = btrfs_space_info_used(sinfo, true);
300-
if (sinfo->total_bytes > num_bytes) {
301-
num_bytes = sinfo->total_bytes - num_bytes;
302-
num_bytes = min(num_bytes,
303-
block_rsv->size - block_rsv->reserved);
304-
block_rsv->reserved += num_bytes;
305-
btrfs_space_info_update_bytes_may_use(fs_info, sinfo,
306-
num_bytes);
307-
}
299+
num_bytes = block_rsv->size - block_rsv->reserved;
300+
block_rsv->reserved += num_bytes;
301+
btrfs_space_info_update_bytes_may_use(fs_info, sinfo,
302+
num_bytes);
308303
} else if (block_rsv->reserved > block_rsv->size) {
309304
num_bytes = block_rsv->reserved - block_rsv->size;
310305
btrfs_space_info_update_bytes_may_use(fs_info, sinfo,

0 commit comments

Comments
 (0)