aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/inode.c
diff options
context:
space:
mode:
authorNaohiro Aota <naohiro.aota@wdc.com>2022-07-09 08:18:50 +0900
committerDavid Sterba <dsterba@suse.com>2022-07-25 17:45:42 +0200
commit2ce543f478433a0eec0f72090d7e814f1d53d456 (patch)
tree468257359ff4f00ee1b11ac4c52f90d5289c84c6 /fs/btrfs/inode.c
parentbtrfs: zoned: write out partially allocated region (diff)
downloadlinux-dev-2ce543f478433a0eec0f72090d7e814f1d53d456.tar.xz
linux-dev-2ce543f478433a0eec0f72090d7e814f1d53d456.zip
btrfs: zoned: wait until zone is finished when allocation didn't progress
When the allocated position doesn't progress, we cannot submit IOs to finish a block group, but there should be ongoing IOs that will finish a block group. So, in that case, we wait for a zone to be finished and retry the allocation after that. Introduce a new flag BTRFS_FS_NEED_ZONE_FINISH for fs_info->flags to indicate we need a zone finish to have proceeded. The flag is set when the allocator detected it cannot activate a new block group. And, it is cleared once a zone is finished. CC: stable@vger.kernel.org # 5.16+ Fixes: afba2bc036b0 ("btrfs: zoned: implement active zone tracking") Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r--fs/btrfs/inode.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index a8f972835544..16789bbacf75 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -1643,8 +1643,13 @@ static noinline int run_delalloc_zoned(struct btrfs_inode *inode,
if (ret == 0)
done_offset = end;
- if (done_offset == start)
- return -ENOSPC;
+ if (done_offset == start) {
+ struct btrfs_fs_info *info = inode->root->fs_info;
+
+ wait_var_event(&info->zone_finish_wait,
+ !test_bit(BTRFS_FS_NEED_ZONE_FINISH, &info->flags));
+ continue;
+ }
if (!locked_page_done) {
__set_page_dirty_nobuffers(locked_page);