@@ -373,6 +373,43 @@ ssize_t vfs_iter_write(struct file *file, struct iov_iter *iter, loff_t *ppos)
}
EXPORT_SYMBOL(vfs_iter_write);
+void init_kernel_kiocb(struct kiocb *iocb, struct file *file, loff_t pos,
+ void (*complete)(struct kiocb *iocb, ssize_t ret))
+{
+ iocb->ki_filp = file;
+ iocb->ki_pos = pos;
+ iocb->complete = complete;
+}
+EXPORT_SYMBOL_GPL(init_kernel_kiocb);
+
+ssize_t vfs_iter_read_async(struct kiocb *iocb, struct iov_iter *iter)
+{
+ ssize_t ret;
+
+ if (!iocb->ki_filp->f_op->read_iter)
+ return -EINVAL;
+
+ ret = iocb->ki_filp->f_op->read_iter(iocb, iter);
+ if (ret != -EIOCBQUEUED)
+ iocb->complete(iocb, ret);
+ return ret;
+}
+EXPORT_SYMBOL_GPL(vfs_iter_read_async);
+
+ssize_t vfs_iter_write_async(struct kiocb *iocb, struct iov_iter *iter)
+{
+ ssize_t ret;
+
+ if (!iocb->ki_filp->f_op->write_iter)
+ return -EINVAL;
+
+ ret = iocb->ki_filp->f_op->write_iter(iocb, iter);
+ if (ret != -EIOCBQUEUED)
+ iocb->complete(iocb, ret);
+ return ret;
+}
+EXPORT_SYMBOL_GPL(vfs_iter_write_async);
+
/*
* rw_verify_area doesn't like huge counts. We limit
* them to something that fits in "int" so that others
@@ -2491,6 +2491,11 @@ extern ssize_t new_sync_write(struct file *filp, const char __user *buf, size_t
ssize_t vfs_iter_read(struct file *file, struct iov_iter *iter, loff_t *ppos);
ssize_t vfs_iter_write(struct file *file, struct iov_iter *iter, loff_t *ppos);
+ssize_t vfs_iter_read_async(struct kiocb *iocb, struct iov_iter *iter);
+ssize_t vfs_iter_write_async(struct kiocb *iocb, struct iov_iter *iter);
+
+void init_kernel_kiocb(struct kiocb *iocb, struct file *file, loff_t pos,
+ void (*complete)(struct kiocb *iocb, ssize_t ret));
/* fs/block_dev.c */
extern ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to);
Signed-off-by: Christoph Hellwig <hch@lst.de> --- fs/read_write.c | 37 +++++++++++++++++++++++++++++++++++++ include/linux/fs.h | 5 +++++ 2 files changed, 42 insertions(+)