On Mon, Jun 22, 2020 at 10:24:53AM -0500, Goldwyn Rodrigues wrote: > From: Goldwyn Rodrigues <rgoldwyn@xxxxxxxx> > > The flag indicates that if the page invalidation fails, it should return > back control to the filesystem so it may fallback to buffered mode. > > Signed-off-by: Goldwyn Rodrigues <rgoldwyn@xxxxxxxx> Looks reasonable enough, I suppose... Reviewed-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx> --D > --- > fs/iomap/direct-io.c | 8 +++++++- > include/linux/iomap.h | 5 +++++ > 2 files changed, 12 insertions(+), 1 deletion(-) > > diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c > index 7ed857196a39..20c4370e6b1b 100644 > --- a/fs/iomap/direct-io.c > +++ b/fs/iomap/direct-io.c > @@ -484,8 +484,14 @@ iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, > */ > ret = invalidate_inode_pages2_range(mapping, > pos >> PAGE_SHIFT, end >> PAGE_SHIFT); > - if (ret) > + if (ret) { > + if (dio_flags & IOMAP_DIOF_PGINVALID_FAIL) { > + if (ret == -EBUSY) > + ret = 0; > + goto out_free_dio; > + } > dio_warn_stale_pagecache(iocb->ki_filp); > + } > ret = 0; > > if (iov_iter_rw(iter) == WRITE && !wait_for_completion && > diff --git a/include/linux/iomap.h b/include/linux/iomap.h > index f6230446b08d..95024e28dec5 100644 > --- a/include/linux/iomap.h > +++ b/include/linux/iomap.h > @@ -261,6 +261,11 @@ struct iomap_dio_ops { > > /* Wait for completion of DIO */ > #define IOMAP_DIOF_WAIT_FOR_COMPLETION 0x1 > +/* > + * Return zero if page invalidation fails, so caller filesystem may fallback > + * to buffered I/O > + */ > +#define IOMAP_DIOF_PGINVALID_FAIL 0x2 > > ssize_t iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, > const struct iomap_ops *ops, const struct iomap_dio_ops *dops, > -- > 2.25.0 >