Thread (19 messages) 19 messages, 3 authors, 2021-10-05

Re: [PATCH 0/5] btrfs-progs: use direct-IO for zoned device

From: David Sterba <hidden>
Date: 2021-09-29 10:17:35

On Wed, Sep 29, 2021 at 02:21:02AM +0000, Naohiro Aota wrote:
On Mon, Sep 27, 2021 at 09:26:18PM +0200, David Sterba wrote:
quoted
On Mon, Sep 27, 2021 at 01:15:49PM +0900, Naohiro Aota wrote:
quoted
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.
This should be in the changelog somewhere too, the last patch looks like
a good place so I'll copy it there.
quoted
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.
Agreed.

All patches added to devel. Would be good to add some tests for the
emulated mode, ie. that we can test at least something regularly without
special devices.
Will do. We may also add some tests for zoned device by setting up
null_blk (provided the machine has enough memory).
As setting up the elated zoned devices requires some resources or
non-trivial setup we can add a separate class of tests. As there are
still limitations to what zoned mode supports, running all current tests
won't work anyway without tons of workarounds or quirks to existing
tests.

Adding a separate class would probably duplicate some of the tests but
that's IMHO less error prone way than changing the other tests. If the
zoned-tests are not run by default it should be safe for regular
testing.

Eventually, to avoid code duplication, we cand do some sort of test
links. The zoned-test will set up the environment and then run the
existing test from other directory.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help