Skip to content

Commit

Permalink
Merge branch 'work.read_write' of git://git.kernel.org/pub/scm/linux/…
Browse files Browse the repository at this point in the history
…kernel/git/viro/vfs

Pull read/write updates from Al Viro:
 "Christoph's fs/read_write.c series - consolidation and cleanups"

* 'work.read_write' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  nfsd: remove nfsd_vfs_read
  nfsd: use vfs_iter_read/write
  fs: implement vfs_iter_write using do_iter_write
  fs: implement vfs_iter_read using do_iter_read
  fs: move more code into do_iter_read/do_iter_write
  fs: remove __do_readv_writev
  fs: remove do_compat_readv_writev
  fs: remove do_readv_writev
  • Loading branch information
torvalds committed Jul 5, 2017
2 parents 4be9513 + a4058c5 commit 89fbf53
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 161 deletions.
6 changes: 3 additions & 3 deletions drivers/block/loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ static int lo_write_bvec(struct file *file, struct bio_vec *bvec, loff_t *ppos)
iov_iter_bvec(&i, ITER_BVEC, bvec, 1, bvec->bv_len);

file_start_write(file);
bw = vfs_iter_write(file, &i, ppos);
bw = vfs_iter_write(file, &i, ppos, 0);
file_end_write(file);

if (likely(bw == bvec->bv_len))
Expand Down Expand Up @@ -349,7 +349,7 @@ static int lo_read_simple(struct loop_device *lo, struct request *rq,

rq_for_each_segment(bvec, rq, iter) {
iov_iter_bvec(&i, ITER_BVEC, &bvec, 1, bvec.bv_len);
len = vfs_iter_read(lo->lo_backing_file, &i, &pos);
len = vfs_iter_read(lo->lo_backing_file, &i, &pos, 0);
if (len < 0)
return len;

Expand Down Expand Up @@ -390,7 +390,7 @@ static int lo_read_transfer(struct loop_device *lo, struct request *rq,
b.bv_len = bvec.bv_len;

iov_iter_bvec(&i, ITER_BVEC, &b, 1, b.bv_len);
len = vfs_iter_read(lo->lo_backing_file, &i, &pos);
len = vfs_iter_read(lo->lo_backing_file, &i, &pos, 0);
if (len < 0) {
ret = len;
goto out_free_page;
Expand Down
6 changes: 3 additions & 3 deletions drivers/target/target_core_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,9 @@ static int fd_do_rw(struct se_cmd *cmd, struct file *fd,

iov_iter_bvec(&iter, ITER_BVEC, bvec, sgl_nents, len);
if (is_write)
ret = vfs_iter_write(fd, &iter, &pos);
ret = vfs_iter_write(fd, &iter, &pos, 0);
else
ret = vfs_iter_read(fd, &iter, &pos);
ret = vfs_iter_read(fd, &iter, &pos, 0);

if (is_write) {
if (ret < 0 || ret != data_length) {
Expand Down Expand Up @@ -409,7 +409,7 @@ fd_execute_write_same(struct se_cmd *cmd)
}

iov_iter_bvec(&iter, ITER_BVEC, bvec, nolb, len);
ret = vfs_iter_write(fd_dev->fd_file, &iter, &pos);
ret = vfs_iter_write(fd_dev->fd_file, &iter, &pos, 0);

kfree(bvec);
if (ret < 0 || ret != len) {
Expand Down
4 changes: 2 additions & 2 deletions fs/coda/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ coda_file_read_iter(struct kiocb *iocb, struct iov_iter *to)

BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);

return vfs_iter_read(cfi->cfi_container, to, &iocb->ki_pos);
return vfs_iter_read(cfi->cfi_container, to, &iocb->ki_pos, 0);
}

static ssize_t
Expand All @@ -51,7 +51,7 @@ coda_file_write_iter(struct kiocb *iocb, struct iov_iter *to)
host_file = cfi->cfi_container;
file_start_write(host_file);
inode_lock(coda_inode);
ret = vfs_iter_write(cfi->cfi_container, to, &iocb->ki_pos);
ret = vfs_iter_write(cfi->cfi_container, to, &iocb->ki_pos, 0);
coda_inode->i_size = file_inode(host_file)->i_size;
coda_inode->i_blocks = (coda_inode->i_size + 511) >> 9;
coda_inode->i_mtime = coda_inode->i_ctime = current_time(coda_inode);
Expand Down
34 changes: 13 additions & 21 deletions fs/nfsd/vfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -911,24 +911,13 @@ __be32 nfsd_splice_read(struct svc_rqst *rqstp,
__be32 nfsd_readv(struct file *file, loff_t offset, struct kvec *vec, int vlen,
unsigned long *count)
{
mm_segment_t oldfs;
struct iov_iter iter;
int host_err;

oldfs = get_fs();
set_fs(KERNEL_DS);
host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset, 0);
set_fs(oldfs);
return nfsd_finish_read(file, count, host_err);
}
iov_iter_kvec(&iter, READ | ITER_KVEC, vec, vlen, *count);
host_err = vfs_iter_read(file, &iter, &offset, 0);

static __be32
nfsd_vfs_read(struct svc_rqst *rqstp, struct file *file,
loff_t offset, struct kvec *vec, int vlen, unsigned long *count)
{
if (file->f_op->splice_read && test_bit(RQ_SPLICE_OK, &rqstp->rq_flags))
return nfsd_splice_read(rqstp, file, offset, count);
else
return nfsd_readv(file, offset, vec, vlen, count);
return nfsd_finish_read(file, count, host_err);
}

/*
Expand Down Expand Up @@ -974,7 +963,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
unsigned long *cnt, int stable)
{
struct svc_export *exp;
mm_segment_t oldfs;
struct iov_iter iter;
__be32 err = 0;
int host_err;
int use_wgather;
Expand All @@ -1000,10 +989,8 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
if (stable && !use_wgather)
flags |= RWF_SYNC;

/* Write the data. */
oldfs = get_fs(); set_fs(KERNEL_DS);
host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos, flags);
set_fs(oldfs);
iov_iter_kvec(&iter, WRITE | ITER_KVEC, vec, vlen, *cnt);
host_err = vfs_iter_write(file, &iter, &pos, flags);
if (host_err < 0)
goto out_nfserr;
*cnt = host_err;
Expand Down Expand Up @@ -1044,7 +1031,12 @@ __be32 nfsd_read(struct svc_rqst *rqstp, struct svc_fh *fhp,
ra = nfsd_init_raparms(file);

trace_read_opened(rqstp, fhp, offset, vlen);
err = nfsd_vfs_read(rqstp, file, offset, vec, vlen, count);

if (file->f_op->splice_read && test_bit(RQ_SPLICE_OK, &rqstp->rq_flags))
err = nfsd_splice_read(rqstp, file, offset, count);
else
err = nfsd_readv(file, offset, vec, vlen, count);

trace_read_io_done(rqstp, fhp, offset, vlen);

if (ra)
Expand Down
Loading

0 comments on commit 89fbf53

Please sign in to comment.