Re: [PATCH 6/6] xfs: reduce exclusive locking on unaligned dio

Christoph Hellwig
2021-01-12T10:44:04Z

> diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
> index bba33be17eff..f5c75404b8a5 100644
> --- a/fs/xfs/xfs_file.c
> +++ b/fs/xfs/xfs_file.c
> @@ -408,7 +408,7 @@ xfs_file_aio_write_checks(
> drained_dio = true;
> goto restart;
> }
> -
> +

Spurious unrelated whitespace change.

> struct iomap_dio_rw_args args = {
> .iocb = iocb,
> .iter = from,
> .ops = &xfs_direct_write_iomap_ops,
> .dops = &xfs_dio_write_ops,
> .wait_for_completion = is_sync_kiocb(iocb),
> - .nonblocking = (iocb->ki_flags & IOCB_NOWAIT),
> + .nonblocking = true,

I think this is in many ways wrong. As far as I can tell you want this
so that we get the imap_spans_range in xfs_direct_write_iomap_begin. But
we should not trigger any of the other checks, so we'd really need
another flag instead of reusing this one.

imap_spans_range is a bit pessimistic for avoiding the exclusive lock,
but I guess we could live that if it is clearly documented as helping
with the implementation, but we really should not automatically trigger
all the other effects of nowait I/O.