Skip to content

Commit

Permalink
start adding the tag to iov_iter
Browse files Browse the repository at this point in the history
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: Al Viro <[email protected]>
  • Loading branch information
Al Viro committed May 6, 2014
1 parent ed978a8 commit 71d8e53
Show file tree
Hide file tree
Showing 15 changed files with 41 additions and 35 deletions.
2 changes: 1 addition & 1 deletion fs/btrfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions fs/ceph/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions fs/cifs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions fs/fuse/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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++];
Expand Down
4 changes: 2 additions & 2 deletions fs/nfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion fs/ocfs2/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion fs/pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion fs/splice.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions fs/xfs/xfs_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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;

Expand Down
15 changes: 3 additions & 12 deletions include/linux/uio.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ struct kvec {
};

struct iov_iter {
int type;
const struct iovec *iov;
unsigned long nr_segs;
size_t iov_offset;
Expand Down Expand Up @@ -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)
{
Expand Down
4 changes: 2 additions & 2 deletions mm/filemap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)) {
Expand Down
15 changes: 15 additions & 0 deletions mm/iov_iter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
2 changes: 1 addition & 1 deletion mm/page_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions mm/process_vm_access.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion mm/shmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 71d8e53

Please sign in to comment.