Re: [PATCH 0/5] btrfs-progs: use direct-IO for zoned device
From: Naohiro Aota <Naohiro.Aota@wdc.com>
Date: 2021-09-29 02:21:07
On Mon, Sep 27, 2021 at 09:26:18PM +0200, David Sterba wrote:
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).