From: Christoph Hellwig <hch@infradead.org>
To: Zhenxian Ma <mzx199711@gmail.com>
Cc: Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org,
Zhenxian Ma <mazhenxian@xiaohongshu.com>
Subject: Re: [PATCH] block: skip redundant flush for O_DSYNC direct writes
Date: Wed, 12 Aug 2026 09:42:24 -0700 [thread overview]
Message-ID: <anyicCnbACxAiTTD@infradead.org> (raw)
In-Reply-To: <20260812130335.60354-1-mzx199711@gmail.com>
> + bool dio_fua_done = false;
> ssize_t ret;
>
> if (bdev_read_only(bdev))
> @@ -763,9 +764,13 @@ static ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from)
>
> if (iocb->ki_flags & IOCB_DIRECT) {
> ret = blkdev_direct_write(iocb, from);
> - if (ret >= 0 && iov_iter_count(from))
> + if (ret >= 0 && iov_iter_count(from)) {
> ret = direct_write_fallback(iocb, from, ret,
> blkdev_buffered_write(iocb, from));
> + } else if (ret > 0 && iocb_is_dsync(iocb)) {
> + /* FUA from dio_bio_write_op() already made it durable */
> + dio_fua_done = true;
This is kinda the wrong way aroud, it should just have a need_sync
variable that is only set for the fallback.
But looking at this, the original logic here actually is very fishy.
If we have a driver that does not actually support FUA, emulating it
for every write command is a bad idea. So this should be fixed to
only do FUA when actually useful, and then return from the non-fallback
implementations if that actually happened.
next prev parent reply other threads:[~2026-08-12 16:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-12 13:03 [PATCH] block: skip redundant flush for O_DSYNC direct writes Zhenxian Ma
2026-08-12 16:42 ` Christoph Hellwig [this message]
2026-08-13 7:35 ` 马振先
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=anyicCnbACxAiTTD@infradead.org \
--to=hch@infradead.org \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=mazhenxian@xiaohongshu.com \
--cc=mzx199711@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.