Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f44d2287 authored by Jeff Mahoney's avatar Jeff Mahoney Committed by David Sterba
Browse files

btrfs: account for pinned bytes in should_alloc_chunk



In a heavy write scenario, we can end up with a large number of pinned bytes.
This can translate into (very) premature ENOSPC because pinned bytes
must be accounted for when allowing a reservation but aren't accounted for
when deciding whether to create a new chunk.

This patch adds the accounting to should_alloc_chunk so that we can
create the chunk.

Signed-off-by: default avatarJeff Mahoney <jeffm@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent a7164fa4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -4419,7 +4419,7 @@ static int should_alloc_chunk(struct btrfs_fs_info *fs_info,
{
	struct btrfs_block_rsv *global_rsv = &fs_info->global_block_rsv;
	u64 num_bytes = sinfo->total_bytes - sinfo->bytes_readonly;
	u64 num_allocated = sinfo->bytes_used + sinfo->bytes_reserved;
	u64 num_allocated = sinfo->bytes_used + sinfo->bytes_reserved + sinfo->bytes_pinned;
	u64 thresh;

	if (force == CHUNK_ALLOC_FORCE)