diff mbox

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

Message ID 1422381313-24034-6-git-send-email-hch@lst.de (mailing list archive)
State New, archived
Headers show

Commit Message

Christoph Hellwig Jan. 27, 2015, 5:55 p.m. UTC
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/read_write.c    | 37 +++++++++++++++++++++++++++++++++++++
 include/linux/fs.h |  5 +++++
 2 files changed, 42 insertions(+)

Comments

Al Viro Jan. 31, 2015, 6:29 a.m. UTC | #1
On Tue, Jan 27, 2015 at 06:55:13PM +0100, Christoph Hellwig wrote:
> +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);

Could we please stop that nonsense?  Any non-GPL module that decides to
use that will simply open-code this oh-so-valuable piece of intellectual
property - all three assignments worth of it.

EXPORT_SYMBOL_GPL() is usually silly posturing - it's borderline
defensible if you are exporting deep guts of otherwise internal objects
and want to limit the scope of damage (but in that case you'd better
have a very good reason for having an export at all), but in cases
like this it's something better kept to alt.sex.masturbation.

I'm not fond of non-GPL modules, but this is simply ridiculous.
Use normal export.  The same goes for other two exports here.
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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);