Re: [PATCH] block: skip redundant flush for O_DSYNC direct writes
Christoph Hellwig <[email protected]>
| Newsgroups | org.kernel.vger.linux-block |
|---|---|
| Message-ID | <[email protected]> |
> + 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.