summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/btrfs/file.c2
-rw-r--r--fs/ceph/file.c8
-rw-r--r--fs/cifs/file.c4
-rw-r--r--fs/fuse/file.c6
-rw-r--r--fs/nfs/file.c4
-rw-r--r--fs/ocfs2/file.c2
-rw-r--r--fs/pipe.c2
-rw-r--r--fs/splice.c2
-rw-r--r--fs/xfs/xfs_file.c4
-rw-r--r--include/linux/uio.h15
-rw-r--r--mm/filemap.c4
-rw-r--r--mm/iov_iter.c15
-rw-r--r--mm/page_io.c2
-rw-r--r--mm/process_vm_access.c4
-rw-r--r--mm/shmem.c2
15 files changed, 41 insertions, 35 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index a0a94a3..f8cee20 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1740,7 +1740,7 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb,
goto out;
}
- iov_iter_init(&i, iov, nr_segs, count, 0);
+ iov_iter_init(&i, WRITE, iov, nr_segs, count);
err = file_remove_suid(file);
if (err) {
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index 910a302..5b93cad 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -582,7 +582,7 @@ ceph_sync_direct_write(struct kiocb *iocb, const struct iovec *iov,
CEPH_OSD_FLAG_ONDISK |
CEPH_OSD_FLAG_WRITE;
- iov_iter_init(&i, iov, nr_segs, count, 0);
+ iov_iter_init(&i, WRITE, iov, nr_segs, count);
while (iov_iter_count(&i) > 0) {
void __user *data = i.iov->iov_base + i.iov_offset;
@@ -703,7 +703,7 @@ static ssize_t ceph_sync_write(struct kiocb *iocb, const struct iovec *iov,
CEPH_OSD_FLAG_WRITE |
CEPH_OSD_FLAG_ACK;
- iov_iter_init(&i, iov, nr_segs, count, 0);
+ iov_iter_init(&i, WRITE, iov, nr_segs, count);
while ((len = iov_iter_count(&i)) > 0) {
size_t left;
@@ -808,7 +808,7 @@ static ssize_t ceph_aio_read(struct kiocb *iocb, const struct iovec *iov,
int checkeof = 0, read = 0;
struct iov_iter i;
- iov_iter_init(&i, iov, nr_segs, len, 0);
+ iov_iter_init(&i, READ, iov, nr_segs, len);
again:
dout("aio_read %p %llx.%llx %llu~%u trying to get caps on %p\n",
@@ -961,7 +961,7 @@ retry_snap:
* are pending vmtruncate. So write and vmtruncate
* can not run at the same time
*/
- iov_iter_init(&from, iov, nr_segs, count, 0);
+ iov_iter_init(&from, WRITE, iov, nr_segs, count);
written = generic_perform_write(file, &from, pos);
if (likely(written >= 0))
iocb->ki_pos = pos + written;
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index a4ccc39..15201c2 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -2424,7 +2424,7 @@ cifs_iovec_write(struct file *file, const struct iovec *iov,
else
pid = current->tgid;
- iov_iter_init(&it, iov, nr_segs, len, 0);
+ iov_iter_init(&it, WRITE, iov, nr_segs, len);
do {
size_t save_len;
@@ -2854,7 +2854,7 @@ ssize_t cifs_user_readv(struct kiocb *iocb, const struct iovec *iov,
if (!len)
return 0;
- iov_iter_init(&to, iov, nr_segs, len, 0);
+ iov_iter_init(&to, READ, iov, nr_segs, len);
INIT_LIST_HEAD(&rdata_list);
cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index fc54d04..4a5519c 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -1217,7 +1217,7 @@ static ssize_t fuse_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
err = generic_write_checks(file, &pos, &count, S_ISBLK(inode->i_mode));
if (err)
goto out;
- iov_iter_init(&i, iov, nr_segs, count, 0);
+ iov_iter_init(&i, WRITE, iov, nr_segs, count);
if (count == 0)
goto out;
@@ -1386,7 +1386,7 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, const struct iovec *iov,
struct fuse_req *req;
struct iov_iter ii;
- iov_iter_init(&ii, iov, nr_segs, count, 0);
+ iov_iter_init(&ii, write ? WRITE : READ, iov, nr_segs, count);
if (io->async)
req = fuse_get_req_for_background(fc, fuse_iter_npages(&ii));
@@ -2367,7 +2367,7 @@ static int fuse_ioctl_copy_user(struct page **pages, struct iovec *iov,
if (!bytes)
return 0;
- iov_iter_init(&ii, iov, nr_segs, bytes, 0);
+ iov_iter_init(&ii, to_user ? READ : WRITE, iov, nr_segs, bytes);
while (iov_iter_count(&ii)) {
struct page *page = pages[page_idx++];
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index a352bc6..ead8f44 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -173,7 +173,7 @@ nfs_file_read(struct kiocb *iocb, const struct iovec *iov,
ssize_t result;
struct iov_iter to;
- iov_iter_init(&to, iov, nr_segs, count, 0);
+ iov_iter_init(&to, READ, iov, nr_segs, count);
if (iocb->ki_filp->f_flags & O_DIRECT)
return nfs_file_direct_read(iocb, &to, pos, true);
@@ -648,7 +648,7 @@ ssize_t nfs_file_write(struct kiocb *iocb, const struct iovec *iov,
ssize_t result;
size_t count = iov_length(iov, nr_segs);
struct iov_iter from;
- iov_iter_init(&from, iov, nr_segs, count, 0);
+ iov_iter_init(&from, WRITE, iov, nr_segs, count);
result = nfs_key_timeout_notify(file, inode);
if (result)
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index d33c4ce..9ce9ed7 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -2361,7 +2361,7 @@ relock:
if (ret)
goto out_dio;
- iov_iter_init(&from, iov, nr_segs, count, 0);
+ iov_iter_init(&from, WRITE, iov, nr_segs, count);
if (direct_io) {
written = generic_file_direct_write(iocb, &from, *ppos,
count, ocount);
diff --git a/fs/pipe.c b/fs/pipe.c
index 034bffa..cd4ccf0 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -287,7 +287,7 @@ pipe_read(struct kiocb *iocb, const struct iovec *_iov,
if (unlikely(total_len == 0))
return 0;
- iov_iter_init(&iter, iov, nr_segs, total_len, 0);
+ iov_iter_init(&iter, READ, iov, nr_segs, total_len);
do_wakeup = 0;
ret = 0;
diff --git a/fs/splice.c b/fs/splice.c
index 9bc07d2..f99e420 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -1548,7 +1548,7 @@ static long vmsplice_to_user(struct file *file, const struct iovec __user *uiov,
if (ret <= 0)
return ret;
- iov_iter_init(&iter, iov, nr_segs, count, 0);
+ iov_iter_init(&iter, READ, iov, nr_segs, count);
sd.len = 0;
sd.total_len = count;
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index f0f8084..762bb3e 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -697,7 +697,7 @@ xfs_file_dio_aio_write(
}
trace_xfs_file_direct_write(ip, count, iocb->ki_pos, 0);
- iov_iter_init(&from, iovp, nr_segs, count, 0);
+ iov_iter_init(&from, WRITE, iovp, nr_segs, count);
ret = generic_file_direct_write(iocb, &from, pos, count, ocount);
out:
@@ -731,7 +731,7 @@ xfs_file_buffered_aio_write(
if (ret)
goto out;
- iov_iter_init(&from, iovp, nr_segs, count, 0);
+ iov_iter_init(&from, WRITE, iovp, nr_segs, count);
/* We can write back this queue in page reclaim */
current->backing_dev_info = mapping->backing_dev_info;
diff --git a/include/linux/uio.h b/include/linux/uio.h
index 4ee1741..b80bbe1 100644
--- a/include/linux/uio.h
+++ b/include/linux/uio.h
@@ -20,6 +20,7 @@ struct kvec {
};
struct iov_iter {
+ int type;
const struct iovec *iov;
unsigned long nr_segs;
size_t iov_offset;
@@ -68,18 +69,8 @@ size_t iov_iter_single_seg_count(const struct iov_iter *i);
size_t copy_page_to_iter(struct page *page, size_t offset, size_t bytes,
struct iov_iter *i);
unsigned long iov_iter_alignment(const struct iov_iter *i);
-
-static inline void iov_iter_init(struct iov_iter *i,
- const struct iovec *iov, unsigned long nr_segs,
- size_t count, size_t written)
-{
- i->iov = iov;
- i->nr_segs = nr_segs;
- i->iov_offset = 0;
- i->count = count + written;
-
- iov_iter_advance(i, written);
-}
+void iov_iter_init(struct iov_iter *i, int direction, const struct iovec *iov,
+ unsigned long nr_segs, size_t count);
static inline size_t iov_iter_count(struct iov_iter *i)
{
diff --git a/mm/filemap.c b/mm/filemap.c
index a7f79e9..3aeaf2d 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -1730,7 +1730,7 @@ generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
size_t count = iov_length(iov, nr_segs);
struct iov_iter i;
- iov_iter_init(&i, iov, nr_segs, count, 0);
+ iov_iter_init(&i, READ, iov, nr_segs, count);
return generic_file_read_iter(iocb, &i);
}
EXPORT_SYMBOL(generic_file_aio_read);
@@ -2596,7 +2596,7 @@ ssize_t __generic_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
if (err)
goto out;
- iov_iter_init(&from, iov, nr_segs, count, 0);
+ iov_iter_init(&from, WRITE, iov, nr_segs, count);
/* coalesce the iovecs and go direct-to-BIO for O_DIRECT */
if (unlikely(file->f_flags & O_DIRECT)) {
diff --git a/mm/iov_iter.c b/mm/iov_iter.c
index 2f762cc..e2c9a2d 100644
--- a/mm/iov_iter.c
+++ b/mm/iov_iter.c
@@ -220,3 +220,18 @@ unsigned long iov_iter_alignment(const struct iov_iter *i)
return res;
}
EXPORT_SYMBOL(iov_iter_alignment);
+
+void iov_iter_init(struct iov_iter *i, int direction,
+ const struct iovec *iov, unsigned long nr_segs,
+ size_t count)
+{
+ /* It will get better. Eventually... */
+ if (segment_eq(get_fs(), KERNEL_DS))
+ direction |= REQ_KERNEL;
+ i->type = direction;
+ i->iov = iov;
+ i->nr_segs = nr_segs;
+ i->iov_offset = 0;
+ i->count = count;
+}
+EXPORT_SYMBOL(iov_iter_init);
diff --git a/mm/page_io.c b/mm/page_io.c
index 0ed0644..313bfed 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -268,7 +268,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
init_sync_kiocb(&kiocb, swap_file);
kiocb.ki_pos = page_file_offset(page);
kiocb.ki_nbytes = PAGE_SIZE;
- iov_iter_init(&from, &iov, 1, PAGE_SIZE, 0);
+ iov_iter_init(&from, KERNEL_WRITE, &iov, 1, PAGE_SIZE);
set_page_writeback(page);
unlock_page(page);
diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
index f32b1fb..5077afc 100644
--- a/mm/process_vm_access.c
+++ b/mm/process_vm_access.c
@@ -274,7 +274,7 @@ static ssize_t process_vm_rw(pid_t pid,
if (rc <= 0)
goto free_iovecs;
- iov_iter_init(&iter, iov_l, liovcnt, rc, 0);
+ iov_iter_init(&iter, vm_write ? WRITE : READ, iov_l, liovcnt, rc);
rc = rw_copy_check_uvector(CHECK_IOVEC_ONLY, rvec, riovcnt, UIO_FASTIOV,
iovstack_r, &iov_r);
@@ -337,7 +337,7 @@ compat_process_vm_rw(compat_pid_t pid,
&iov_l);
if (rc <= 0)
goto free_iovecs;
- iov_iter_init(&iter, iov_l, liovcnt, rc, 0);
+ iov_iter_init(&iter, vm_write ? WRITE : READ, iov_l, liovcnt, rc);
rc = compat_rw_copy_check_uvector(CHECK_IOVEC_ONLY, rvec, riovcnt,
UIO_FASTIOV, iovstack_r,
&iov_r);
diff --git a/mm/shmem.c b/mm/shmem.c
index 2a93e62..e0b7669 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1417,7 +1417,7 @@ static ssize_t shmem_file_aio_read(struct kiocb *iocb,
loff_t *ppos = &iocb->ki_pos;
struct iov_iter iter;
- iov_iter_init(&iter, iov, nr_segs, count, 0);
+ iov_iter_init(&iter, READ, iov, nr_segs, count);
/*
* Might this read be for a stacking filesystem? Then when reading
OpenPOWER on IntegriCloud