Re: [PATCH] btrfs: zoned: skip fully truncated ordered extents at zone finish
Qu Wenruo <[email protected]>
| Newsgroups | org.kernel.vger.linux-btrfs |
|---|---|
| Message-ID | <[email protected]> |
在 2026/7/16 17:53, Johannes Thumshirn 写道:
> A fully truncated ordered extent (truncated_len == 0) wrote no data, so its
> ->csum_list is empty and btrfs_finish_ordered_zoned() trips:
>
> assertion failed: !list_empty(&ordered->csum_list), in fs/btrfs/zoned.c:2141
>
> Since commit 66ff4d366e7e a short or cancelled direct IO write finishes the
> unsubmitted ordered extent as truncated with uptodate = true instead of
> setting BTRFS_ORDERED_IOERR, so it now reaches btrfs_finish_ordered_zoned()
> rather than being skipped by the IOERR check in btrfs_finish_ordered_io().
> generic/208 hits this on a zoned filesystem.
>
> Return early for these, like the BTRFS_ORDERED_PREALLOC case; there is no
> zone append result to record and btrfs_finish_one_ordered() skips them too.
>
> Fixes: 66ff4d366e7e ("btrfs: fix false IO failure after falling back to buffered write")
> Signed-off-by: Johannes Thumshirn <[email protected]>
Reviewed-by: Qu Wenruo <[email protected]>
Thanks,
Qu
> ---
> fs/btrfs/zoned.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
> index bff209b552c3..9668a5928735 100644
> --- a/fs/btrfs/zoned.c
> +++ b/fs/btrfs/zoned.c
> @@ -2138,6 +2138,16 @@ void btrfs_finish_ordered_zoned(struct btrfs_ordered_extent *ordered)
> if (test_bit(BTRFS_ORDERED_PREALLOC, &ordered->flags))
> return;
>
> + /*
> + * A fully truncated ordered extent wrote no data and so has
> + * no zone append result to record.
> + */
> + if (test_bit(BTRFS_ORDERED_TRUNCATED, &ordered->flags) &&
> + ordered->truncated_len == 0) {
> + ASSERT(list_empty(&ordered->csum_list));
> + return;
> + }
> +
> ASSERT(!list_empty(&ordered->csum_list));
> sum = list_first_entry(&ordered->csum_list, struct btrfs_ordered_sum, list);
> logical = sum->logical;