Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Johannes Thumshirn <johannes.thumshirn@wdc.com>,
	linux-btrfs@vger.kernel.org
Cc: Qu Wenruo <wqu@suse.com>
Subject: Re: [PATCH v2] btrfs-progs: zoned: open host-managed devices with O_DIRECT for read-only
Date: Thu, 16 Jul 2026 21:07:05 +0930	[thread overview]
Message-ID: <d92523f8-38c1-4b84-b4e1-82288f8de3fa@gmx.com> (raw)
In-Reply-To: <20260716112819.1315467-1-johannes.thumshirn@wdc.com>



在 2026/7/16 20:58, Johannes Thumshirn 写道:
> On host-managed zoned block devices the page cache cannot be used for
> writing to the device because it does not guarantee ordering, therefore
> direct I/O is used to write any on-disk data structures.
> 
> But reading in btrfs-progs is still performed using buffered I/O. This
> mix of direct and buffered I/O can lead to stale page cache entries
> being handed off to btrfs-progs and tools like "btrfs check" can report
> spurious errors like:
> 
> 	checksum verify failed on <bytenr> wanted 0x00000000 found 0xb6bde3e4
> 
> even though both copies are intact on disk.
> 
> Drop the O_RDWR condition so host-managed zoned devices always use
> O_DIRECT, matching btrfstune.
> 
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

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

Thanks,
Qu

> ---
> Changes to v1:
> - reworded commit message
> 
>   kernel-shared/disk-io.c | 2 +-
>   kernel-shared/volumes.c | 2 +-
>   2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel-shared/disk-io.c b/kernel-shared/disk-io.c
> index 7f87e567f0b1..8b9c6dcac967 100644
> --- a/kernel-shared/disk-io.c
> +++ b/kernel-shared/disk-io.c
> @@ -1722,7 +1722,7 @@ struct btrfs_fs_info *open_ctree_fs_info(struct open_ctree_args *oca)
>   	if (!(oca->flags & OPEN_CTREE_WRITES))
>   		oflags = O_RDONLY;
> 
> -	if ((oflags & O_RDWR) && zoned_model(oca->filename) == ZONED_HOST_MANAGED)
> +	if (zoned_model(oca->filename) == ZONED_HOST_MANAGED)
>   		oflags |= O_DIRECT;
> 
>   	fp = open(oca->filename, oflags);
> diff --git a/kernel-shared/volumes.c b/kernel-shared/volumes.c
> index f35b59bcc20e..e2b6708ad872 100644
> --- a/kernel-shared/volumes.c
> +++ b/kernel-shared/volumes.c
> @@ -697,7 +697,7 @@ int btrfs_open_devices(struct btrfs_fs_info *fs_info,
>   			continue;
>   		}
> 
> -		if ((flags & O_RDWR) && zoned_model(device->name) == ZONED_HOST_MANAGED)
> +		if (zoned_model(device->name) == ZONED_HOST_MANAGED)
>   			flags |= O_DIRECT;
> 
>   		fd = open(device->name, flags);
> --
> 2.54.0
> 
> 


      reply	other threads:[~2026-07-16 11:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-16 11:28 [PATCH v2] btrfs-progs: zoned: open host-managed devices with O_DIRECT for read-only Johannes Thumshirn
2026-07-16 11:37 ` Qu Wenruo [this message]

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=d92523f8-38c1-4b84-b4e1-82288f8de3fa@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=johannes.thumshirn@wdc.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=wqu@suse.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