On Wed 18-04-18 14:08:28, Dave Chinner wrote:
> @@ -1012,8 +1035,16 @@ iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
> dio->flags |= IOMAP_DIO_DIRTY;
> } else {
> dio->flags |= IOMAP_DIO_WRITE;
> - if (iocb->ki_flags & IOCB_DSYNC)
> + if (iocb->ki_flags & IOCB_DSYNC) {
> dio->flags |= IOMAP_DIO_NEED_SYNC;
> + /*
> + * We optimistically try using FUA for this IO. Any
> + * non-FUA write that occurs will clear this flag, hence
> + * we know before completion whether a cache flush is
> + * necessary.
> + */
> + dio->flags |= IOMAP_DIO_WRITE_FUA;
> + }
So I don't think this is quite correct. IOCB_DSYNC gets set also for O_SYNC
writes (in that case we also set IOCB_SYNC). And for those we cannot use
the FUA optimization AFAICT (definitely IOMAP_F_DIRTY isn't a safe
indicator of a need of full fsync for O_SYNC). Other than that the patch
looks good to me.
Honza
--
Jan Kara <[email protected]>
SUSE Labs, CR