[PATCH 06/10] fs: set kernel address limit in do_loop_readv_writev

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

 



This will allow to use all iov_iter based read/write for ITER_KVEC
without having to check if the file has the iter version of the
read/write ops, which will allow us to get rid of a large number
of get_fs/set_fs calls in drivers.

Signed-off-by: Christoph Hellwig <hch@xxxxxx>
---
 fs/read_write.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/fs/read_write.c b/fs/read_write.c
index 64b61a032a56..60c64a996ab2 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -704,9 +704,18 @@ static ssize_t do_loop_readv_writev(struct file *filp, struct iov_iter *iter,
 		loff_t *ppos, int type, int flags)
 {
 	ssize_t ret = 0;
+	mm_segment_t uninitialized_var(old_fs);
 
 	if (flags & ~RWF_HIPRI)
 		return -EOPNOTSUPP;
+	if (iter->type & (ITER_BVEC | ITER_PIPE))
+		return -EOPNOTSUPP;
+
+	/* adjust the address limit for in-kernel I/O */
+	if (iter->type & ITER_KVEC) {
+		old_fs = get_fs();
+		set_fs(get_ds());
+	}
 
 	while (iov_iter_count(iter)) {
 		struct iovec iovec = iov_iter_iovec(iter);
@@ -731,6 +740,8 @@ static ssize_t do_loop_readv_writev(struct file *filp, struct iov_iter *iter,
 		iov_iter_advance(iter, nr);
 	}
 
+	if (iter->type & ITER_KVEC)
+		set_fs(old_fs);
 	return ret;
 }
 
-- 
2.11.0

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



[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux