[rh7,v2,3/4] fs/iov_iter: Introduce "iov" member in struct iov_iter for ITER_IOVEC

Submitted by Konstantin Khorenko on Dec. 25, 2020, 4:15 p.m.

Details

Message ID 20201225161508.7850-4-khorenko@virtuozzo.com
State New
Series "fs/iov_iter: Fix ZFS kernel module compilation"
Headers show

Commit Message

Konstantin Khorenko Dec. 25, 2020, 4:15 p.m.
zfs code expects the data of ITER_IOVEC iov_iter is accessed
via .iov member, so add the field to struct iov_iter
and fill with the data correctly.

https://bugs.openvz.org/browse/OVZ-7243

Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 fs/ceph/file.c     |  4 ++--
 include/linux/fs.h | 14 ++++++++------
 2 files changed, 10 insertions(+), 8 deletions(-)

Patch hide | download patch | download mbox

diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index 4302940a8a6c..1d06a474fa68 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -115,7 +115,7 @@  dio_get_pages_alloc(const struct iov_iter *it, size_t nbytes,
 		return ERR_PTR(-ENOMEM);
 
 	for (idx = 0; idx < npages; ) {
-		struct iovec *tmp_iov = iov_iter_iovec(&tmp_it);
+		const struct iovec *tmp_iov = iov_iter_iovec(&tmp_it);
 		void __user *data = tmp_iov->iov_base + tmp_it.iov_offset;
 		size_t off = (unsigned long)data & (PAGE_SIZE - 1);
 		size_t len = min_t(size_t, nbytes,
@@ -1216,7 +1216,7 @@  static ssize_t inline_to_iov(struct kiocb *iocb, struct iov_iter *i,
 			zero_user_segment(inline_page, inline_len, end);
 
 		while (left) {
-			struct iovec *iov = iov_iter_iovec(i);
+			const struct iovec *iov = iov_iter_iovec(i);
 			void __user *udata = iov->iov_base;
 			size_t n = min(iov->iov_len - i->iov_offset, left);
 
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 61dcc20052c3..d4c143fa7212 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -351,11 +351,13 @@  struct iov_iter {
 	 * the caller isn't expecting to drop a page reference when done.
 	 */
 	unsigned int type;
-
-	unsigned long data;
-	unsigned long nr_segs;
 	size_t iov_offset;
 	size_t count;
+	union {
+		const struct iovec *iov;
+		unsigned long data;
+	};
+	unsigned long nr_segs;
 };
 
 extern struct iov_iter_ops ii_bvec_ops;
@@ -473,7 +475,7 @@  static inline void iov_iter_init(struct iov_iter *i,
 			size_t count, size_t written)
 {
 	i->type = ITER_IOVEC;
-	i->data = (unsigned long)iov;
+	i->iov = iov;
 	i->nr_segs = nr_segs;
 	i->iov_offset = 0;
 	i->count = count + written;
@@ -484,10 +486,10 @@  static inline int iov_iter_has_iovec(const struct iov_iter *i)
 {
 	return i->type == ITER_IOVEC;
 }
-static inline struct iovec *iov_iter_iovec(const struct iov_iter *i)
+static inline const struct iovec *iov_iter_iovec(const struct iov_iter *i)
 {
 	BUG_ON(!iov_iter_has_iovec(i));
-	return (struct iovec *)i->data;
+	return i->iov;
 }
 
 struct bio_vec;