vdisk_fileio, async mode: Submit direct I/O with the "nowait" flag set

git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7987 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2019-02-24 06:05:07 +00:00
parent feb4185bcd
commit c386f64819
2 changed files with 22 additions and 7 deletions
+8
View File
@@ -434,6 +434,14 @@ static inline ssize_t call_write_iter(struct file *file, struct kiocb *kio,
}
#endif
/*
* See also commit b745fafaf70c ("fs: Introduce RWF_NOWAIT and
* FMODE_AIO_NOWAIT") # v4.13.
*/
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0)
#define IOCB_NOWAIT 0
#endif
/* See also commit bdd1d2d3d251 ("fs: fix kernel_read prototype") # v4.14 */
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0)
static inline ssize_t
+14 -7
View File
@@ -3303,13 +3303,20 @@ static enum compl_status_e fileio_exec_async(struct vdisk_cmd_params *p)
.ki_complete = fileio_async_complete,
};
if (virt_dev->o_direct_flag)
iocb->ki_flags |= IOCB_DIRECT;
if (dir == WRITE) {
if (virt_dev->wt_flag && !virt_dev->nv_cache)
iocb->ki_flags |= IOCB_DSYNC;
ret = call_write_iter(fd, iocb, &iter);
} else {
ret = call_read_iter(fd, iocb, &iter);
iocb->ki_flags |= IOCB_DIRECT | IOCB_NOWAIT;
if (dir == WRITE && virt_dev->wt_flag && !virt_dev->nv_cache)
iocb->ki_flags |= IOCB_DSYNC;
for (;;) {
if (dir == WRITE)
ret = call_write_iter(fd, iocb, &iter);
else
ret = call_read_iter(fd, iocb, &iter);
if (ret >= 0 || (ret != -EOPNOTSUPP && ret != -EAGAIN))
break;
if (iocb->ki_flags & IOCB_NOWAIT)
iocb->ki_flags &= ~IOCB_NOWAIT;
else
break;
}
if (p->async.bvec != p->async.small_bvec)
kfree(p->async.bvec);