linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] btrfs: account for pinned bytes and bytes_may_use in should_alloc_chunk
@ 2017-06-14 15:44 jeffm
  2017-06-14 15:44 ` [PATCH 2/2] btrfs: Simplify math in should_alloc chunk jeffm
  2017-06-21 20:14 ` [PATCH 1/2] btrfs: account for pinned bytes and bytes_may_use in should_alloc_chunk Jeff Mahoney
  0 siblings, 2 replies; 7+ messages in thread
From: jeffm @ 2017-06-14 15:44 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Jeff Mahoney

From: Jeff Mahoney <jeffm@suse.com>

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: Jeff Mahoney <jeffm@suse.com>
---
 fs/btrfs/extent-tree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index cb0b924..d027807 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -4389,7 +4389,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 + sinfo->bytes_may_use;
 	u64 thresh;
 
 	if (force == CHUNK_ALLOC_FORCE)
-- 
1.8.5.6


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-06-21 21:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-14 15:44 [PATCH 1/2] btrfs: account for pinned bytes and bytes_may_use in should_alloc_chunk jeffm
2017-06-14 15:44 ` [PATCH 2/2] btrfs: Simplify math in should_alloc chunk jeffm
2017-06-21 20:14 ` [PATCH 1/2] btrfs: account for pinned bytes and bytes_may_use in should_alloc_chunk Jeff Mahoney
2017-06-21 20:31   ` Chris Mason
2017-06-21 21:08     ` Jeff Mahoney
2017-06-21 21:15       ` Chris Mason
2017-06-21 21:41         ` Jeff Mahoney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).