public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/7] btrfs-progs: use direct-IO for zoned device
@ 2021-10-05  6:22 Naohiro Aota
  2021-10-05  6:22 ` [PATCH v2 1/7] btrfs-progs: mkfs: do not set zone size on non-zoned mode Naohiro Aota
                   ` (8 more replies)
  0 siblings, 9 replies; 13+ messages in thread
From: Naohiro Aota @ 2021-10-05  6:22 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba, Naohiro Aota

As discussed in the Zoned Storage page [1],  the kernel page cache does not
guarantee that cached dirty pages will be flushed to a block device in
sequential sector order. Thus, we must use O_DIRECT for writing to a zoned
device to ensure the write ordering.

[1] https://zonedstorage.io/linux/overview/#zbd-support-restrictions

As a writng buffer is embedded in some other struct (e.g., "char data[]" in
struct extent_buffer), it is difficult to allocate the struct so that the
writng buffer is aligned.

This series introduces btrfs_{pread,pwrite} to wrap around pread/pwrite,
which allocates an aligned bounce buffer, copy the buffer contents, and
proceeds the IO. And, it now opens a zoned device with O_DIRECT.

Since the allocation and copying are costly, it is better to do them only
when necessary. But, it is cumbersome to call fcntl(F_GETFL) to determine
the file is opened with O_DIRECT or not every time doing an IO.

As zoned device forces to use zoned btrfs, I decided to use the zoned flag
to determine if it is direct-IO or not. This can cause a false-positive (to
use the bounce buffer when a file is *not* opened with O_DIRECT) in case of
emulated zoned mode on a non-zoned device or a regular file. Considering
the emulated zoned mode is mostly for debugging or testing, I believe this
is acceptable.

* Changes
v2
  - Rebased on the latest "devel" branch
  - Add patch to fix segfault in several cases
  - drop ZONED flag from BTRFS_CONVERT_ALLOWED_FEATURES

Patches 1 to 3 are preparation to fix some issues in the current code.

Patches 4 and 5 wraps pread/pwrite with newly introduced function
btrfs_pread/btrfs_pwrite.

Patch 6 deals with the zoned flag while reading the initial trees.

Patch 7 finally opens a zoned device with O_DIRECT.

Naohiro Aota (7):
  btrfs-progs: mkfs: do not set zone size on non-zoned mode
  btrfs-progs: set eb->fs_info properly
  btrfs-progs: drop ZONED flag from BTRFS_CONVERT_ALLOWED_FEATURES
  btrfs-progs: introduce btrfs_pwrite wrapper for pwrite
  btrfs-progs: introduce btrfs_pread wrapper for pread
  btrfs-progs: temporally set zoned flag for initial tree reading
  btrfs-progs: use direct-io for zoned device

 common/device-utils.c     | 76 ++++++++++++++++++++++++++++++++++++---
 common/device-utils.h     | 29 ++++++++++++++-
 common/fsfeatures.h       |  3 +-
 convert/main.c            |  1 +
 kernel-shared/disk-io.c   | 19 +++++++++-
 kernel-shared/extent_io.c | 14 +++++---
 kernel-shared/volumes.c   |  6 ++++
 kernel-shared/zoned.c     |  6 ++--
 mkfs/common.c             | 14 +++++---
 mkfs/main.c               | 12 +++++--
 mkfs/rootdir.c            |  1 +
 11 files changed, 158 insertions(+), 23 deletions(-)

-- 
2.33.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-10-20 16:58 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-05  6:22 [PATCH v2 0/7] btrfs-progs: use direct-IO for zoned device Naohiro Aota
2021-10-05  6:22 ` [PATCH v2 1/7] btrfs-progs: mkfs: do not set zone size on non-zoned mode Naohiro Aota
2021-10-05  6:23 ` [PATCH v2 2/7] btrfs-progs: set eb->fs_info properly Naohiro Aota
2021-10-05  6:23 ` [PATCH v2 3/7] btrfs-progs: drop ZONED flag from BTRFS_CONVERT_ALLOWED_FEATURES Naohiro Aota
2021-10-05  6:23 ` [PATCH v2 4/7] btrfs-progs: introduce btrfs_pwrite wrapper for pwrite Naohiro Aota
2021-10-06 14:10   ` David Sterba
2021-10-05  6:23 ` [PATCH v2 5/7] btrfs-progs: introduce btrfs_pread wrapper for pread Naohiro Aota
2021-10-05  6:23 ` [PATCH v2 6/7] btrfs-progs: temporally set zoned flag for initial tree reading Naohiro Aota
2021-10-05  6:23 ` [PATCH v2 7/7] btrfs-progs: use direct-io for zoned device Naohiro Aota
2021-10-06 14:28 ` [PATCH v2 0/7] btrfs-progs: use direct-IO " David Sterba
2021-10-06 21:02 ` David Sterba
2021-10-20  6:53   ` Naohiro Aota
2021-10-20 16:57     ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox