Skip to content

block: avoid redundant flushes for O_DSYNC direct writes - #1144

Open
blktests-ci-kpd[bot] wants to merge 2 commits into
linus-master_basefrom
series/1146443=>linus-master
Open

block: avoid redundant flushes for O_DSYNC direct writes#1144
blktests-ci-kpd[bot] wants to merge 2 commits into
linus-master_basefrom
series/1146443=>linus-master

Conversation

@blktests-ci-kpd

Copy link
Copy Markdown

Pull request for series with
subject: block: avoid redundant flushes for O_DSYNC direct writes
version: 2
url: https://patchwork.kernel.org/project/linux-block/list/?series=1146443

@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: 3aa1dca
series: https://patchwork.kernel.org/project/linux-block/list/?series=1146443
version: 2

@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: 3aa1dca
series: https://patchwork.kernel.org/project/linux-block/list/?series=1146443
version: 2

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1146443=>linus-master branch from 404d204 to 88ae9d0 Compare August 15, 2026 12:17
@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the linus-master_base branch 2 times, most recently from d89ab11 to fdba928 Compare August 16, 2026 18:34
@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: fd923b3
series: https://patchwork.kernel.org/project/linux-block/list/?series=1146443
version: 2

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1146443=>linus-master branch from 88ae9d0 to 2cd6e62 Compare August 16, 2026 19:49
@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: fd923b3
series: https://patchwork.kernel.org/project/linux-block/list/?series=1146443
version: 2

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1146443=>linus-master branch from 2cd6e62 to ed1590d Compare August 17, 2026 09:49
@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: 8d3ae59
series: https://patchwork.kernel.org/project/linux-block/list/?series=1146443
version: 2

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1146443=>linus-master branch from ed1590d to a7a20a9 Compare August 17, 2026 16:36
@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: bd5f485
series: https://patchwork.kernel.org/project/linux-block/list/?series=1146443
version: 2

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1146443=>linus-master branch from a7a20a9 to 2c168b9 Compare August 19, 2026 05:41
@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: 66498c7
series: https://patchwork.kernel.org/project/linux-block/list/?series=1146443
version: 2

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1146443=>linus-master branch from 2c168b9 to 06d03c0 Compare August 25, 2026 03:49
@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: 502d457
series: https://patchwork.kernel.org/project/linux-block/list/?series=1146443
version: 2

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1146443=>linus-master branch from 06d03c0 to e8c2971 Compare August 26, 2026 21:08
@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: cf72cbb
series: https://patchwork.kernel.org/project/linux-block/list/?series=1146443
version: 2

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1146443=>linus-master branch from e8c2971 to 29c5a09 Compare August 29, 2026 07:07
@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: cee9395
series: https://patchwork.kernel.org/project/linux-block/list/?series=1146443
version: 2

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1146443=>linus-master branch from 29c5a09 to 106abfa Compare August 31, 2026 10:54
@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: 89a3129
series: https://patchwork.kernel.org/project/linux-block/list/?series=1146443
version: 2

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1146443=>linus-master branch from 106abfa to f52267f Compare September 2, 2026 09:25
@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: bc35965
series: https://patchwork.kernel.org/project/linux-block/list/?series=1146443
version: 2

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1146443=>linus-master branch from f52267f to 0c9d29f Compare September 4, 2026 06:40
@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: df29080
series: https://patchwork.kernel.org/series/1146443/
version: 2

Pull request is NOT updated. Failed to apply https://patchwork.kernel.org/series/1146443/
error message:

Cmd('git') failed due to: exit code(128)
  cmdline: git am --3way
  stdout: 'Patch is empty.
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To record the empty patch as an empty commit, run "git am --allow-empty".
To restore the original branch and stop patching, run "git am --abort".'

conflict:


@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: 28924df
series: https://patchwork.kernel.org/series/1146443/
version: 2

@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: 893e117
series: https://patchwork.kernel.org/series/1146443/
version: 2

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1146443=>linus-master branch from b614235 to fa5d400 Compare September 9, 2026 08:25
@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: 50d05c7
series: https://patchwork.kernel.org/series/1146443/
version: 2

@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: 5225b8e
series: https://patchwork.kernel.org/series/1146443/
version: 2

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1146443=>linus-master branch from 17d26ef to afd8108 Compare September 12, 2026 02:55
@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: 2f0c1cf
series: https://patchwork.kernel.org/series/1146443/
version: 2

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1146443=>linus-master branch from afd8108 to 6f07d31 Compare September 13, 2026 10:24
Zhenxian Ma added 2 commits September 13, 2026 23:25
For an O_DIRECT | O_DSYNC write, dio_bio_write_op() adds REQ_FUA to the
bio, so the data is durable once the direct I/O returns.  The
unconditional generic_write_sync() in blkdev_write_iter() then issues a
REQ_PREFLUSH that is redundant.

Skip it when the direct path already provided durability via FUA.  A
need_sync flag, clear by default, is set only for buffered writes and
for the buffered fallback after a partial direct write.

Measured on a Seagate ST20000NM007D (20 TB, 7200 rpm, fua=1,
write_cache=write back), Linux v7.2.0-rc7, single-threaded pwrite()
loop opening the raw block device with O_WRONLY | O_DIRECT | O_DSYNC,
4 KiB writes for 60 s:

  Sequential 4 KiB writes:
                            baseline    patched
    IOPS                       119.7     7497.0
    avg latency (us)            8357        133
    p50 latency (us)            8346        127
    p99 latency (us)            8368        395
    p99.9 latency (us)          8728        569

  Random 4 KiB writes (100 GiB span):
                            baseline    patched
    IOPS                       156.1      666.4
    avg latency (us)            6405       1500
    p50 latency (us)            6186       1450
    p99 latency (us)           16133       2285
    p99.9 latency (us)         17250       9916

Signed-off-by: Zhenxian Ma <mzx199711@gmail.com>
Signed-off-by: Zhenxian Ma <mazhenxian@xiaohongshu.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
When a block device does not support FUA natively, the block layer
emulates it by adding a cache flush to every write bio.  An O_DSYNC
direct write that spans N bios then costs N flushes, rather than the
single generic_write_sync() issued after the write completes.

Introduce blkdev_dio_fua() to decide when REQ_FUA is set.  A synchronous
write can rely on generic_write_sync() when the device lacks FUA, so it
sets REQ_FUA only when bdev_fua() is true.  An asynchronous write
completes in blkdev_bio_end_io() and cannot call the blocking
generic_write_sync(), so it keeps REQ_FUA (emulated when needed) to stay
durable.

Suggested-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Zhenxian Ma <mzx199711@gmail.com>
Signed-off-by: Zhenxian Ma <mazhenxian@xiaohongshu.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: 2f0c1cf
series: https://patchwork.kernel.org/series/1146443/
version: 2

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1146443=>linus-master branch from 6f07d31 to 6af0cf9 Compare September 13, 2026 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants