Commit 71d8e532 authored by Al Viro's avatar Al Viro

start adding the tag to iov_iter

For now, just use the same thing we pass to ->direct_IO() - it's all
iovec-based at the moment.  Pass it explicitly to iov_iter_init() and
account for kvec vs. iovec in there, by the same kludge NFS ->direct_IO()
uses.
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent ed978a81
...@@ -1740,7 +1740,7 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb, ...@@ -1740,7 +1740,7 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb,
goto out; 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); err = file_remove_suid(file);
if (err) { if (err) {
......
...@@ -582,7 +582,7 @@ ceph_sync_direct_write(struct kiocb *iocb, const struct iovec *iov, ...@@ -582,7 +582,7 @@ ceph_sync_direct_write(struct kiocb *iocb, const struct iovec *iov,
CEPH_OSD_FLAG_ONDISK | CEPH_OSD_FLAG_ONDISK |
CEPH_OSD_FLAG_WRITE; 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) { while (iov_iter_count(&i) > 0) {
void __user *data = i.iov->iov_base + i.iov_offset; 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, ...@@ -703,7 +703,7 @@ static ssize_t ceph_sync_write(struct kiocb *iocb, const struct iovec *iov,
CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_WRITE |
CEPH_OSD_FLAG_ACK; 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) { while ((len = iov_iter_count(&i)) > 0) {
size_t left; size_t left;
...@@ -808,7 +808,7 @@ static ssize_t ceph_aio_read(struct kiocb *iocb, const struct iovec *iov, ...@@ -808,7 +808,7 @@ static ssize_t ceph_aio_read(struct kiocb *iocb, const struct iovec *iov,
int checkeof = 0, read = 0; int checkeof = 0, read = 0;
struct iov_iter i; struct iov_iter i;
iov_iter_init(&i, iov, nr_segs, len, 0); iov_iter_init(&i, READ, iov, nr_segs, len);
again: again:
dout("aio_read %p %llx.%llx %llu~%u trying to get caps on %p\n", dout("aio_read %p %llx.%llx %llu~%u trying to get caps on %p\n",
...@@ -961,7 +961,7 @@ static ssize_t ceph_aio_write(struct kiocb *iocb, const struct iovec *iov, ...@@ -961,7 +961,7 @@ static ssize_t ceph_aio_write(struct kiocb *iocb, const struct iovec *iov,
* are pending vmtruncate. So write and vmtruncate * are pending vmtruncate. So write and vmtruncate
* can not run at the same time * 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); written = generic_perform_write(file, &from, pos);
if (likely(written >= 0)) if (likely(written >= 0))
iocb->ki_pos = pos + written; iocb->ki_pos = pos + written;
......
...@@ -2424,7 +2424,7 @@ cifs_iovec_write(struct file *file, const struct iovec *iov, ...@@ -2424,7 +2424,7 @@ cifs_iovec_write(struct file *file, const struct iovec *iov,
else else
pid = current->tgid; pid = current->tgid;
iov_iter_init(&it, iov, nr_segs, len, 0); iov_iter_init(&it, WRITE, iov, nr_segs, len);
do { do {
size_t save_len; size_t save_len;
...@@ -2854,7 +2854,7 @@ ssize_t cifs_user_readv(struct kiocb *iocb, const struct iovec *iov, ...@@ -2854,7 +2854,7 @@ ssize_t cifs_user_readv(struct kiocb *iocb, const struct iovec *iov,
if (!len) if (!len)
return 0; 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); INIT_LIST_HEAD(&rdata_list);
cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
......
...@@ -1217,7 +1217,7 @@ static ssize_t fuse_file_aio_write(struct kiocb *iocb, const struct iovec *iov, ...@@ -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)); err = generic_write_checks(file, &pos, &count, S_ISBLK(inode->i_mode));
if (err) if (err)
goto out; goto out;
iov_iter_init(&i, iov, nr_segs, count, 0); iov_iter_init(&i, WRITE, iov, nr_segs, count);
if (count == 0) if (count == 0)
goto out; goto out;
...@@ -1386,7 +1386,7 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, const struct iovec *iov, ...@@ -1386,7 +1386,7 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, const struct iovec *iov,
struct fuse_req *req; struct fuse_req *req;
struct iov_iter ii; 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) if (io->async)
req = fuse_get_req_for_background(fc, fuse_iter_npages(&ii)); 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, ...@@ -2367,7 +2367,7 @@ static int fuse_ioctl_copy_user(struct page **pages, struct iovec *iov,
if (!bytes) if (!bytes)
return 0; 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)) { while (iov_iter_count(&ii)) {
struct page *page = pages[page_idx++]; struct page *page = pages[page_idx++];
......
...@@ -173,7 +173,7 @@ nfs_file_read(struct kiocb *iocb, const struct iovec *iov, ...@@ -173,7 +173,7 @@ nfs_file_read(struct kiocb *iocb, const struct iovec *iov,
ssize_t result; ssize_t result;
struct iov_iter to; 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) if (iocb->ki_filp->f_flags & O_DIRECT)
return nfs_file_direct_read(iocb, &to, pos, true); 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, ...@@ -648,7 +648,7 @@ ssize_t nfs_file_write(struct kiocb *iocb, const struct iovec *iov,
ssize_t result; ssize_t result;
size_t count = iov_length(iov, nr_segs); size_t count = iov_length(iov, nr_segs);
struct iov_iter from; 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); result = nfs_key_timeout_notify(file, inode);
if (result) if (result)
......
...@@ -2361,7 +2361,7 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb, ...@@ -2361,7 +2361,7 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb,
if (ret) if (ret)
goto out_dio; goto out_dio;
iov_iter_init(&from, iov, nr_segs, count, 0); iov_iter_init(&from, WRITE, iov, nr_segs, count);
if (direct_io) { if (direct_io) {
written = generic_file_direct_write(iocb, &from, *ppos, written = generic_file_direct_write(iocb, &from, *ppos,
count, ocount); count, ocount);
......
...@@ -287,7 +287,7 @@ pipe_read(struct kiocb *iocb, const struct iovec *_iov, ...@@ -287,7 +287,7 @@ pipe_read(struct kiocb *iocb, const struct iovec *_iov,
if (unlikely(total_len == 0)) if (unlikely(total_len == 0))
return 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; do_wakeup = 0;
ret = 0; ret = 0;
......
...@@ -1548,7 +1548,7 @@ static long vmsplice_to_user(struct file *file, const struct iovec __user *uiov, ...@@ -1548,7 +1548,7 @@ static long vmsplice_to_user(struct file *file, const struct iovec __user *uiov,
if (ret <= 0) if (ret <= 0)
return ret; return ret;
iov_iter_init(&iter, iov, nr_segs, count, 0); iov_iter_init(&iter, READ, iov, nr_segs, count);
sd.len = 0; sd.len = 0;
sd.total_len = count; sd.total_len = count;
......
...@@ -697,7 +697,7 @@ xfs_file_dio_aio_write( ...@@ -697,7 +697,7 @@ xfs_file_dio_aio_write(
} }
trace_xfs_file_direct_write(ip, count, iocb->ki_pos, 0); 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); ret = generic_file_direct_write(iocb, &from, pos, count, ocount);
out: out:
...@@ -731,7 +731,7 @@ xfs_file_buffered_aio_write( ...@@ -731,7 +731,7 @@ xfs_file_buffered_aio_write(
if (ret) if (ret)
goto out; 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 */ /* We can write back this queue in page reclaim */
current->backing_dev_info = mapping->backing_dev_info; current->backing_dev_info = mapping->backing_dev_info;
......
...@@ -20,6 +20,7 @@ struct kvec { ...@@ -20,6 +20,7 @@ struct kvec {
}; };
struct iov_iter { struct iov_iter {
int type;
const struct iovec *iov; const struct iovec *iov;
unsigned long nr_segs; unsigned long nr_segs;
size_t iov_offset; size_t iov_offset;
...@@ -68,18 +69,8 @@ size_t iov_iter_single_seg_count(const struct iov_iter *i); ...@@ -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, size_t copy_page_to_iter(struct page *page, size_t offset, size_t bytes,
struct iov_iter *i); struct iov_iter *i);
unsigned long iov_iter_alignment(const struct iov_iter *i); unsigned long iov_iter_alignment(const struct iov_iter *i);
void iov_iter_init(struct iov_iter *i, int direction, const struct iovec *iov,
static inline void iov_iter_init(struct iov_iter *i, unsigned long nr_segs, size_t count);
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);
}
static inline size_t iov_iter_count(struct iov_iter *i) static inline size_t iov_iter_count(struct iov_iter *i)
{ {
......
...@@ -1730,7 +1730,7 @@ generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov, ...@@ -1730,7 +1730,7 @@ generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
size_t count = iov_length(iov, nr_segs); size_t count = iov_length(iov, nr_segs);
struct iov_iter i; 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); return generic_file_read_iter(iocb, &i);
} }
EXPORT_SYMBOL(generic_file_aio_read); EXPORT_SYMBOL(generic_file_aio_read);
...@@ -2596,7 +2596,7 @@ ssize_t __generic_file_aio_write(struct kiocb *iocb, const struct iovec *iov, ...@@ -2596,7 +2596,7 @@ ssize_t __generic_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
if (err) if (err)
goto out; 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 */ /* coalesce the iovecs and go direct-to-BIO for O_DIRECT */
if (unlikely(file->f_flags & O_DIRECT)) { if (unlikely(file->f_flags & O_DIRECT)) {
......
...@@ -220,3 +220,18 @@ unsigned long iov_iter_alignment(const struct iov_iter *i) ...@@ -220,3 +220,18 @@ unsigned long iov_iter_alignment(const struct iov_iter *i)
return res; return res;
} }
EXPORT_SYMBOL(iov_iter_alignment); 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);
...@@ -268,7 +268,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc, ...@@ -268,7 +268,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
init_sync_kiocb(&kiocb, swap_file); init_sync_kiocb(&kiocb, swap_file);
kiocb.ki_pos = page_file_offset(page); kiocb.ki_pos = page_file_offset(page);
kiocb.ki_nbytes = PAGE_SIZE; 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); set_page_writeback(page);
unlock_page(page); unlock_page(page);
......
...@@ -274,7 +274,7 @@ static ssize_t process_vm_rw(pid_t pid, ...@@ -274,7 +274,7 @@ static ssize_t process_vm_rw(pid_t pid,
if (rc <= 0) if (rc <= 0)
goto free_iovecs; 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, rc = rw_copy_check_uvector(CHECK_IOVEC_ONLY, rvec, riovcnt, UIO_FASTIOV,
iovstack_r, &iov_r); iovstack_r, &iov_r);
...@@ -337,7 +337,7 @@ compat_process_vm_rw(compat_pid_t pid, ...@@ -337,7 +337,7 @@ compat_process_vm_rw(compat_pid_t pid,
&iov_l); &iov_l);
if (rc <= 0) if (rc <= 0)
goto free_iovecs; 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, rc = compat_rw_copy_check_uvector(CHECK_IOVEC_ONLY, rvec, riovcnt,
UIO_FASTIOV, iovstack_r, UIO_FASTIOV, iovstack_r,
&iov_r); &iov_r);
......
...@@ -1417,7 +1417,7 @@ static ssize_t shmem_file_aio_read(struct kiocb *iocb, ...@@ -1417,7 +1417,7 @@ static ssize_t shmem_file_aio_read(struct kiocb *iocb,
loff_t *ppos = &iocb->ki_pos; loff_t *ppos = &iocb->ki_pos;
struct iov_iter iter; 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 * Might this read be for a stacking filesystem? Then when reading
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment