diff mbox series

btrfs: run delayed iputs when flushing delalloc

Message ID c718e1eef33488e3cd232a650b7c2d97701bbf24.1724341245.git.josef@toxicpanda.com (mailing list archive)
State New
Headers show
Series btrfs: run delayed iputs when flushing delalloc | expand

Commit Message

Josef Bacik Aug. 22, 2024, 3:40 p.m. UTC
We have transient failures with btrfs/301, specifically in the part
where we do

for i in $(seq 0 10); do
	write 50m to file
	rm -f file
done

Sometimes this will result in a transient quota error, and it's because
sometimes we start writeback on the file which results in a delayed
iput, and thus the rm doesn't actually clean the file up.  When we're
flushing the quota space we need to run the delayed iputs to make sure
all the unlinks that we think have completed have actually completed.
This removes the small window where we could fail to find enough space
in our quota.

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

Comments

Qu Wenruo Aug. 22, 2024, 11 p.m. UTC | #1
在 2024/8/23 01:10, Josef Bacik 写道:
> We have transient failures with btrfs/301, specifically in the part
> where we do
>
> for i in $(seq 0 10); do
> 	write 50m to file
> 	rm -f file
> done
>
> Sometimes this will result in a transient quota error, and it's because
> sometimes we start writeback on the file which results in a delayed
> iput, and thus the rm doesn't actually clean the file up.  When we're
> flushing the quota space we need to run the delayed iputs to make sure
> all the unlinks that we think have completed have actually completed.
> This removes the small window where we could fail to find enough space
> in our quota.
>
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks for pinning down this random failure!
Qu

> ---
>   fs/btrfs/qgroup.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
> index be9a56a5d298..a77d2cd9d89d 100644
> --- a/fs/btrfs/qgroup.c
> +++ b/fs/btrfs/qgroup.c
> @@ -4185,6 +4185,8 @@ static int try_flush_qgroup(struct btrfs_root *root)
>   		return 0;
>   	}
>
> +	btrfs_run_delayed_iputs(root->fs_info);
> +	btrfs_wait_on_delayed_iputs(root->fs_info);
>   	ret = btrfs_start_delalloc_snapshot(root, true);
>   	if (ret < 0)
>   		goto out;
diff mbox series

Patch

diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
index be9a56a5d298..a77d2cd9d89d 100644
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -4185,6 +4185,8 @@  static int try_flush_qgroup(struct btrfs_root *root)
 		return 0;
 	}
 
+	btrfs_run_delayed_iputs(root->fs_info);
+	btrfs_wait_on_delayed_iputs(root->fs_info);
 	ret = btrfs_start_delalloc_snapshot(root, true);
 	if (ret < 0)
 		goto out;