Commit 6424cf07 authored by Zhihao Cheng's avatar Zhihao Cheng
Browse files

iomap: Add a IOMAP_DIO_MAY_INLINE_COMP flag

hulk inclusion
category: perf
bugzilla: https://gitee.com/openeuler/kernel/issues/I90ZB5


CVE: NA

--------------------------------

It will be more efficient to execute quick endio process(eg. non-sync
overwriting case) under irq process rather than starting a worker to
do it.
Add a flag to control DIO to be finished inline(under irq context), which
can be used for non-sync overwriting case.
Besides, skip invalidating pages if DIO is finished inline, which will
keep the same logic with dio_bio_end_aio in non-sync overwriting case.

Signed-off-by: default avatarZhihao Cheng <chengzhihao1@huawei.com>
parent adad6411
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -110,7 +110,8 @@ ssize_t iomap_dio_complete(struct iomap_dio *dio)
	 * zeros from unwritten extents.
	 */
	if (!dio->error && dio->size &&
	    (dio->flags & IOMAP_DIO_WRITE) && inode->i_mapping->nrpages) {
	    (dio->flags & IOMAP_DIO_WRITE) && inode->i_mapping->nrpages &&
	    !(dio->flags & IOMAP_DIO_INLINE_COMP)) {
		int err;
		err = invalidate_inode_pages2_range(inode->i_mapping,
				offset >> PAGE_SHIFT,
@@ -124,8 +125,10 @@ ssize_t iomap_dio_complete(struct iomap_dio *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))
	if (ret > 0 && (dio->flags & IOMAP_DIO_NEED_SYNC)) {
		WARN_ON_ONCE(dio->flags & IOMAP_DIO_INLINE_COMP);
		ret = generic_write_sync(iocb, ret);
	}

	kfree(dio);

@@ -488,6 +491,10 @@ __iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
		/* for data sync or sync, we need sync completion processing */
		if (iocb->ki_flags & IOCB_DSYNC)
			dio->flags |= IOMAP_DIO_NEED_SYNC;
		else if (dio_flags & IOMAP_DIO_MAY_INLINE_COMP) {
			/* writes could complete inline */
			dio->flags |= IOMAP_DIO_INLINE_COMP;
		}

		/*
		 * For datasync only writes, we optimistically try using FUA for
+6 −0
Original line number Diff line number Diff line
@@ -297,6 +297,12 @@ struct iomap_dio_ops {
 */
#define IOMAP_DIO_FORCE_WAIT	(1 << 0)

/*
 * DIO will be completed inline unless sync operation is needed after io is
 * finished.
 */
#define IOMAP_DIO_MAY_INLINE_COMP	(1 << 3)

ssize_t iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
		const struct iomap_ops *ops, const struct iomap_dio_ops *dops,
		unsigned int dio_flags);