Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Michal Grzedzicki <mge@meta.com>,
	linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Chris Mason <clm@fb.com>, David Sterba <dsterba@suse.com>
Subject: Re: [PATCH] btrfs: fix silent IO error loss in encoded writes and zoned split
Date: Tue, 31 Mar 2026 07:53:11 +1030	[thread overview]
Message-ID: <b4077e08-18e1-480f-8c1c-0d08b9fd5bc8@gmx.com> (raw)
In-Reply-To: <20260330160644.3678224-1-mge@meta.com>



在 2026/3/31 02:36, Michal Grzedzicki 写道:
> can_finish_ordered_extent() and btrfs_finish_ordered_zoned() set
> BTRFS_ORDERED_IOERR via bare set_bit(). Later,
> btrfs_mark_ordered_extent_error() in btrfs_finish_one_ordered() uses
> test_and_set_bit(), finds it already set, and skips
> mapping_set_error(). The error is never recorded on the inode's
> address_space, making it invisible to fsync. For encoded writes this
> causes btrfs receive to silently produce files with zero-filled holes.
> 
> Fix: replace bare set_bit(BTRFS_ORDERED_IOERR) with
> btrfs_mark_ordered_extent_error() which pairs test_and_set_bit() with
> mapping_set_error(), guaranteeing the error is recorded exactly once.
> 
> Signed-off-by: Michal Grzedzicki <mge@meta.com>

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

Thanks,
Qu

> ---
>   fs/btrfs/ordered-data.c | 2 +-
>   fs/btrfs/zoned.c        | 2 +-
>   2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
> index 5df02c707aee..b65c1f1e2956 100644
> --- a/fs/btrfs/ordered-data.c
> +++ b/fs/btrfs/ordered-data.c
> @@ -385,7 +385,7 @@ static bool can_finish_ordered_extent(struct btrfs_ordered_extent *ordered,
>   	}
>   
>   	if (!uptodate)
> -		set_bit(BTRFS_ORDERED_IOERR, &ordered->flags);
> +		btrfs_mark_ordered_extent_error(ordered);
>   
>   	if (ordered->bytes_left)
>   		return false;
> diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
> index 0cd7fd3fcfa3..d728c3bafc09 100644
> --- a/fs/btrfs/zoned.c
> +++ b/fs/btrfs/zoned.c
> @@ -2136,7 +2136,7 @@ void btrfs_finish_ordered_zoned(struct btrfs_ordered_extent *ordered)
>   			continue;
>   		}
>   		if (!btrfs_zoned_split_ordered(ordered, logical, len)) {
> -			set_bit(BTRFS_ORDERED_IOERR, &ordered->flags);
> +			btrfs_mark_ordered_extent_error(ordered);
>   			btrfs_err(fs_info, "failed to split ordered extent");
>   			goto out;
>   		}


  reply	other threads:[~2026-03-30 21:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-30 16:06 [PATCH] btrfs: fix silent IO error loss in encoded writes and zoned split Michal Grzedzicki
2026-03-30 21:23 ` Qu Wenruo [this message]
2026-03-31  8:12 ` Johannes Thumshirn
2026-04-07 16:41 ` Mark Harmstone

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b4077e08-18e1-480f-8c1c-0d08b9fd5bc8@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mge@meta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox