linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs: reset block group chunk force if we have to wait
@ 2022-06-13 22:31 Josef Bacik
  2022-06-14  9:47 ` Filipe Manana
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Josef Bacik @ 2022-06-13 22:31 UTC (permalink / raw)
  To: linux-btrfs, kernel-team

If you try to force a chunk allocation, but you race with another chunk
allocation, you will end up waiting on the chunk allocation that just
occurred and then allocate another chunk.  If you have many threads all
doing this at once you can way over-allocate chunks.

Fix this by resetting force to NO_FORCE, that way if we think we need to
allocate we can, otherwise we don't force another chunk allocation if
one is already happening.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 fs/btrfs/block-group.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
index ede389f2602d..13358fbc1629 100644
--- a/fs/btrfs/block-group.c
+++ b/fs/btrfs/block-group.c
@@ -3761,6 +3761,7 @@ int btrfs_chunk_alloc(struct btrfs_trans_handle *trans, u64 flags,
 			 * attempt.
 			 */
 			wait_for_alloc = true;
+			force = CHUNK_ALLOC_NO_FORCE;
 			spin_unlock(&space_info->lock);
 			mutex_lock(&fs_info->chunk_mutex);
 			mutex_unlock(&fs_info->chunk_mutex);
-- 
2.26.3


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

* Re: [PATCH] btrfs: reset block group chunk force if we have to wait
  2022-06-13 22:31 [PATCH] btrfs: reset block group chunk force if we have to wait Josef Bacik
@ 2022-06-14  9:47 ` Filipe Manana
  2022-06-14 14:57 ` David Sterba
  2022-06-22 19:43 ` David Sterba
  2 siblings, 0 replies; 4+ messages in thread
From: Filipe Manana @ 2022-06-14  9:47 UTC (permalink / raw)
  To: Josef Bacik; +Cc: linux-btrfs, kernel-team

On Mon, Jun 13, 2022 at 06:31:17PM -0400, Josef Bacik wrote:
> If you try to force a chunk allocation, but you race with another chunk
> allocation, you will end up waiting on the chunk allocation that just
> occurred and then allocate another chunk.  If you have many threads all
> doing this at once you can way over-allocate chunks.
> 
> Fix this by resetting force to NO_FORCE, that way if we think we need to
> allocate we can, otherwise we don't force another chunk allocation if
> one is already happening.
> 
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>

Reviewed-by: Filipe Manana <fdmanana@suse.com>

Looks good, thanks.

> ---
>  fs/btrfs/block-group.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
> index ede389f2602d..13358fbc1629 100644
> --- a/fs/btrfs/block-group.c
> +++ b/fs/btrfs/block-group.c
> @@ -3761,6 +3761,7 @@ int btrfs_chunk_alloc(struct btrfs_trans_handle *trans, u64 flags,
>  			 * attempt.
>  			 */
>  			wait_for_alloc = true;
> +			force = CHUNK_ALLOC_NO_FORCE;
>  			spin_unlock(&space_info->lock);
>  			mutex_lock(&fs_info->chunk_mutex);
>  			mutex_unlock(&fs_info->chunk_mutex);
> -- 
> 2.26.3
> 

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

* Re: [PATCH] btrfs: reset block group chunk force if we have to wait
  2022-06-13 22:31 [PATCH] btrfs: reset block group chunk force if we have to wait Josef Bacik
  2022-06-14  9:47 ` Filipe Manana
@ 2022-06-14 14:57 ` David Sterba
  2022-06-22 19:43 ` David Sterba
  2 siblings, 0 replies; 4+ messages in thread
From: David Sterba @ 2022-06-14 14:57 UTC (permalink / raw)
  To: Josef Bacik; +Cc: linux-btrfs, kernel-team

On Mon, Jun 13, 2022 at 06:31:17PM -0400, Josef Bacik wrote:
> If you try to force a chunk allocation,

Do you mean using the new sysfs force_chunk_allocation ? As the patch
stands I think it could be applied independently but not later than the
sysfs chunk series, or folded in but I'm not sure it's a good idea.

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

* Re: [PATCH] btrfs: reset block group chunk force if we have to wait
  2022-06-13 22:31 [PATCH] btrfs: reset block group chunk force if we have to wait Josef Bacik
  2022-06-14  9:47 ` Filipe Manana
  2022-06-14 14:57 ` David Sterba
@ 2022-06-22 19:43 ` David Sterba
  2 siblings, 0 replies; 4+ messages in thread
From: David Sterba @ 2022-06-22 19:43 UTC (permalink / raw)
  To: Josef Bacik; +Cc: linux-btrfs, kernel-team

On Mon, Jun 13, 2022 at 06:31:17PM -0400, Josef Bacik wrote:
> If you try to force a chunk allocation, but you race with another chunk
> allocation, you will end up waiting on the chunk allocation that just
> occurred and then allocate another chunk.  If you have many threads all
> doing this at once you can way over-allocate chunks.
> 
> Fix this by resetting force to NO_FORCE, that way if we think we need to
> allocate we can, otherwise we don't force another chunk allocation if
> one is already happening.
> 
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>

Added to misc-next, thanks.

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

end of thread, other threads:[~2022-06-22 19:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-13 22:31 [PATCH] btrfs: reset block group chunk force if we have to wait Josef Bacik
2022-06-14  9:47 ` Filipe Manana
2022-06-14 14:57 ` David Sterba
2022-06-22 19:43 ` David Sterba

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).