[PATCH 5/5] fs: add async read/write interfaces

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Christoph Hellwig <hch@xxxxxx>
---
 fs/read_write.c    | 37 +++++++++++++++++++++++++++++++++++++
 include/linux/fs.h |  5 +++++
 2 files changed, 42 insertions(+)

diff --git a/fs/read_write.c b/fs/read_write.c
index 955cad3..3add15e 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -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
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 175ed09..3be55d4 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -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);
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux