* [PATCH] btrfs: set cache_block_group_error if we find an error
@ 2023-08-02 13:20 Josef Bacik
2023-08-09 20:08 ` David Sterba
0 siblings, 1 reply; 2+ messages in thread
From: Josef Bacik @ 2023-08-02 13:20 UTC (permalink / raw)
To: linux-btrfs, kernel-team
We set cache_block_group_error if btrfs_cache_block_group() returns an
error, this is because we could end up not finding space to allocate and
mistakenly return -ENOSPC, and which could then abort the transaction
with the incorrect errno, and in the case of ENOSPC result in a
WARN_ON() that will trip up tests like generic/475.
However there's the case where multiple threads can be racing, one
thread gets the proper error, and the other thread doesn't actually call
btrfs_cache_block_group(), it instead sees ->cached ==
BTRFS_CACHE_ERROR. Again the result is the same, we fail to allocate
our space and return -ENOSPC. Instead we need to set
cache_block_group_error to -EIO in this case to make sure that if we do
not make our allocation we get the appropriate error returned back to
the caller.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
fs/btrfs/extent-tree.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 6a3414545e01..7fce05cc6090 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -4277,8 +4277,11 @@ static noinline int find_free_extent(struct btrfs_root *root,
ret = 0;
}
- if (unlikely(block_group->cached == BTRFS_CACHE_ERROR))
+ if (unlikely(block_group->cached == BTRFS_CACHE_ERROR)) {
+ if (!cache_block_group_error)
+ cache_block_group_error = -EIO;
goto loop;
+ }
if (!find_free_extent_check_size_class(ffe_ctl, block_group))
goto loop;
--
2.41.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] btrfs: set cache_block_group_error if we find an error
2023-08-02 13:20 [PATCH] btrfs: set cache_block_group_error if we find an error Josef Bacik
@ 2023-08-09 20:08 ` David Sterba
0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2023-08-09 20:08 UTC (permalink / raw)
To: Josef Bacik; +Cc: linux-btrfs, kernel-team
On Wed, Aug 02, 2023 at 09:20:24AM -0400, Josef Bacik wrote:
> We set cache_block_group_error if btrfs_cache_block_group() returns an
> error, this is because we could end up not finding space to allocate and
> mistakenly return -ENOSPC, and which could then abort the transaction
> with the incorrect errno, and in the case of ENOSPC result in a
> WARN_ON() that will trip up tests like generic/475.
>
> However there's the case where multiple threads can be racing, one
> thread gets the proper error, and the other thread doesn't actually call
> btrfs_cache_block_group(), it instead sees ->cached ==
> BTRFS_CACHE_ERROR. Again the result is the same, we fail to allocate
> our space and return -ENOSPC. Instead we need to set
> cache_block_group_error to -EIO in this case to make sure that if we do
> not make our allocation we get the appropriate error returned back to
> the caller.
>
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Added to misc-next, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-08-09 20:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-02 13:20 [PATCH] btrfs: set cache_block_group_error if we find an error Josef Bacik
2023-08-09 20:08 ` 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).