On Tue, Dec 15, 2020 at 12:06:35PM -0600, Goldwyn Rodrigues wrote: > From: Goldwyn Rodrigues <rgoldwyn@xxxxxxxx> > > This introduces a separate function __iomap_dio_complte() which > completes the Direct I/O without performing the write sync. > > Filesystems such as btrfs which require an inode_lock for sync can call > __iomap_dio_complete() and must perform sync on their own after unlock. > > Signed-off-by: Goldwyn Rodrigues <rgoldwyn@xxxxxxxx> > --- > fs/iomap/direct-io.c | 16 +++++++++++++--- > include/linux/iomap.h | 2 +- > 2 files changed, 14 insertions(+), 4 deletions(-) > > diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c > index 933f234d5bec..11a108f39fd9 100644 > --- a/fs/iomap/direct-io.c > +++ b/fs/iomap/direct-io.c > @@ -76,7 +76,7 @@ static void iomap_dio_submit_bio(struct iomap_dio *dio, struct iomap *iomap, > dio->submit.cookie = submit_bio(bio); > } > > -ssize_t iomap_dio_complete(struct iomap_dio *dio) > +ssize_t __iomap_dio_complete(struct iomap_dio *dio) > { > const struct iomap_dio_ops *dops = dio->dops; > struct kiocb *iocb = dio->iocb; > @@ -119,18 +119,28 @@ ssize_t iomap_dio_complete(struct iomap_dio *dio) > } > > inode_dio_end(file_inode(iocb->ki_filp)); > + > + return ret; > +} > +EXPORT_SYMBOL_GPL(__iomap_dio_complete); > + > +ssize_t iomap_dio_complete(struct iomap_dio *dio) > +{ > + ssize_t ret; > + > + ret = __iomap_dio_complete(dio); > /* > * If this is a DSYNC write, make sure we push it to stable storage now > * that we've written data. > */ > if (ret > 0 && (dio->flags & IOMAP_DIO_NEED_SYNC)) > - ret = generic_write_sync(iocb, ret); > + ret = generic_write_sync(dio->iocb, ret); > > kfree(dio); > > return ret; > } > -EXPORT_SYMBOL_GPL(iomap_dio_complete); > + NACK. If you don't want iomap_dio_complete to do O_DSYNC work after successfully writing data, strip those flags out of the kiocb before you call iomap_dio_rw() and do it yourself after calling iomap_dio_complete(). Cheers, Dave. -- Dave Chinner david@xxxxxxxxxxxxx