提交 71d8e532 编写于 作者: A 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: NAl Viro <viro@zeniv.linux.org.uk>
上级 ed978a81
......@@ -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) {
......
......@@ -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 @@ static ssize_t ceph_aio_write(struct kiocb *iocb, const struct iovec *iov,
* 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;
......
......@@ -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);
......
......@@ -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++];
......
......@@ -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)
......
......@@ -2361,7 +2361,7 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb,
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);
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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)
{
......
......@@ -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)) {
......
......@@ -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);
......@@ -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);
......
......@@ -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);
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册