Skip to content

Commit

Permalink
Merge branch 'for-linus-2' of git://git.kernel.org/pub/scm/linux/kern…
Browse files Browse the repository at this point in the history
…el/git/viro/vfs

Pull second vfs update from Al Viro:
 "Now that net-next went in...  Here's the next big chunk - killing
  ->aio_read() and ->aio_write().

  There'll be one more pile today (direct_IO changes and
  generic_write_checks() cleanups/fixes), but I'd prefer to keep that
  one separate"

* 'for-linus-2' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (37 commits)
  ->aio_read and ->aio_write removed
  pcm: another weird API abuse
  infinibad: weird APIs switched to ->write_iter()
  kill do_sync_read/do_sync_write
  fuse: use iov_iter_get_pages() for non-splice path
  fuse: switch to ->read_iter/->write_iter
  switch drivers/char/mem.c to ->read_iter/->write_iter
  make new_sync_{read,write}() static
  coredump: accept any write method
  switch /dev/loop to vfs_iter_write()
  serial2002: switch to __vfs_read/__vfs_write
  ashmem: use __vfs_read()
  export __vfs_read()
  autofs: switch to __vfs_write()
  new helper: __vfs_write()
  switch hugetlbfs to ->read_iter()
  coda: switch to ->read_iter/->write_iter
  ncpfs: switch to ->read_iter/->write_iter
  net/9p: remove (now-)unused helpers
  p9_client_attach(): set fid->uid correctly
  ...
  • Loading branch information
torvalds committed Apr 15, 2015
2 parents c841e12 + 8436318 commit fa92789
Show file tree
Hide file tree
Showing 90 changed files with 598 additions and 1,185 deletions.
2 changes: 0 additions & 2 deletions Documentation/filesystems/Locking
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,6 @@ prototypes:
loff_t (*llseek) (struct file *, loff_t, int);
ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);
ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
ssize_t (*aio_read) (struct kiocb *, const struct iovec *, unsigned long, loff_t);
ssize_t (*aio_write) (struct kiocb *, const struct iovec *, unsigned long, loff_t);
ssize_t (*read_iter) (struct kiocb *, struct iov_iter *);
ssize_t (*write_iter) (struct kiocb *, struct iov_iter *);
int (*iterate) (struct file *, struct dir_context *);
Expand Down
12 changes: 12 additions & 0 deletions Documentation/filesystems/porting
Original file line number Diff line number Diff line change
Expand Up @@ -471,3 +471,15 @@ in your dentry operations instead.
[mandatory]
f_dentry is gone; use f_path.dentry, or, better yet, see if you can avoid
it entirely.
--
[mandatory]
never call ->read() and ->write() directly; use __vfs_{read,write} or
wrappers; instead of checking for ->write or ->read being NULL, look for
FMODE_CAN_{WRITE,READ} in file->f_mode.
--
[mandatory]
do _not_ use new_sync_{read,write} for ->read/->write; leave it NULL
instead.
--
[mandatory]
->aio_read/->aio_write are gone. Use ->read_iter/->write_iter.
6 changes: 0 additions & 6 deletions Documentation/filesystems/vfs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -804,8 +804,6 @@ struct file_operations {
loff_t (*llseek) (struct file *, loff_t, int);
ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);
ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
ssize_t (*aio_read) (struct kiocb *, const struct iovec *, unsigned long, loff_t);
ssize_t (*aio_write) (struct kiocb *, const struct iovec *, unsigned long, loff_t);
ssize_t (*read_iter) (struct kiocb *, struct iov_iter *);
ssize_t (*write_iter) (struct kiocb *, struct iov_iter *);
int (*iterate) (struct file *, struct dir_context *);
Expand Down Expand Up @@ -838,14 +836,10 @@ otherwise noted.

read: called by read(2) and related system calls

aio_read: vectored, possibly asynchronous read

read_iter: possibly asynchronous read with iov_iter as destination

write: called by write(2) and related system calls

aio_write: vectored, possibly asynchronous write

write_iter: possibly asynchronous write with iov_iter as source

iterate: called when the VFS needs to read the directory contents
Expand Down
2 changes: 0 additions & 2 deletions arch/s390/hypfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,6 @@ struct dentry *hypfs_create_str(struct dentry *dir,
static const struct file_operations hypfs_file_ops = {
.open = hypfs_open,
.release = hypfs_release,
.read = new_sync_read,
.write = new_sync_write,
.read_iter = hypfs_read_iter,
.write_iter = hypfs_write_iter,
.llseek = no_llseek,
Expand Down
12 changes: 7 additions & 5 deletions drivers/block/loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
#include <linux/sysfs.h>
#include <linux/miscdevice.h>
#include <linux/falloc.h>
#include <linux/uio.h>
#include "loop.h"

#include <asm/uaccess.h>
Expand Down Expand Up @@ -229,13 +230,14 @@ lo_do_transfer(struct loop_device *lo, int cmd,
static int __do_lo_send_write(struct file *file,
u8 *buf, const int len, loff_t pos)
{
struct kvec kvec = {.iov_base = buf, .iov_len = len};
struct iov_iter from;
ssize_t bw;
mm_segment_t old_fs = get_fs();

iov_iter_kvec(&from, ITER_KVEC | WRITE, &kvec, 1, len);

file_start_write(file);
set_fs(get_ds());
bw = file->f_op->write(file, buf, len, &pos);
set_fs(old_fs);
bw = vfs_iter_write(file, &from, &pos);
file_end_write(file);
if (likely(bw == len))
return 0;
Expand Down Expand Up @@ -767,7 +769,7 @@ static int loop_set_fd(struct loop_device *lo, fmode_t mode,
goto out_putf;

if (!(file->f_mode & FMODE_WRITE) || !(mode & FMODE_WRITE) ||
!file->f_op->write)
!file->f_op->write_iter)
lo_flags |= LO_FLAGS_READ_ONLY;

lo_blocksize = S_ISBLK(inode->i_mode) ?
Expand Down
20 changes: 9 additions & 11 deletions drivers/char/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -607,16 +607,16 @@ static ssize_t write_null(struct file *file, const char __user *buf,
return count;
}

static ssize_t aio_read_null(struct kiocb *iocb, const struct iovec *iov,
unsigned long nr_segs, loff_t pos)
static ssize_t read_iter_null(struct kiocb *iocb, struct iov_iter *to)
{
return 0;
}

static ssize_t aio_write_null(struct kiocb *iocb, const struct iovec *iov,
unsigned long nr_segs, loff_t pos)
static ssize_t write_iter_null(struct kiocb *iocb, struct iov_iter *from)
{
return iov_length(iov, nr_segs);
size_t count = iov_iter_count(from);
iov_iter_advance(from, count);
return count;
}

static int pipe_to_null(struct pipe_inode_info *info, struct pipe_buffer *buf,
Expand Down Expand Up @@ -718,7 +718,7 @@ static int open_port(struct inode *inode, struct file *filp)
#define zero_lseek null_lseek
#define full_lseek null_lseek
#define write_zero write_null
#define aio_write_zero aio_write_null
#define write_iter_zero write_iter_null
#define open_mem open_port
#define open_kmem open_mem

Expand Down Expand Up @@ -750,8 +750,8 @@ static const struct file_operations null_fops = {
.llseek = null_lseek,
.read = read_null,
.write = write_null,
.aio_read = aio_read_null,
.aio_write = aio_write_null,
.read_iter = read_iter_null,
.write_iter = write_iter_null,
.splice_write = splice_write_null,
};

Expand All @@ -764,10 +764,9 @@ static const struct file_operations __maybe_unused port_fops = {

static const struct file_operations zero_fops = {
.llseek = zero_lseek,
.read = new_sync_read,
.write = write_zero,
.read_iter = read_iter_zero,
.aio_write = aio_write_zero,
.write_iter = write_iter_zero,
.mmap = mmap_zero,
#ifndef CONFIG_MMU
.mmap_capabilities = zero_mmap_capabilities,
Expand All @@ -776,7 +775,6 @@ static const struct file_operations zero_fops = {

static const struct file_operations full_fops = {
.llseek = full_lseek,
.read = new_sync_read,
.read_iter = read_iter_zero,
.write = write_full,
};
Expand Down
2 changes: 0 additions & 2 deletions drivers/char/raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,7 @@ static long raw_ctl_compat_ioctl(struct file *file, unsigned int cmd,
#endif

static const struct file_operations raw_fops = {
.read = new_sync_read,
.read_iter = blkdev_read_iter,
.write = new_sync_write,
.write_iter = blkdev_write_iter,
.fsync = blkdev_fsync,
.open = raw_open,
Expand Down
18 changes: 11 additions & 7 deletions drivers/infiniband/hw/ipath/ipath_file_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include <linux/io.h>
#include <linux/jiffies.h>
#include <linux/cpu.h>
#include <linux/uio.h>
#include <asm/pgtable.h>

#include "ipath_kernel.h"
Expand All @@ -52,15 +53,19 @@ static int ipath_open(struct inode *, struct file *);
static int ipath_close(struct inode *, struct file *);
static ssize_t ipath_write(struct file *, const char __user *, size_t,
loff_t *);
static ssize_t ipath_writev(struct kiocb *, const struct iovec *,
unsigned long , loff_t);
static ssize_t ipath_write_iter(struct kiocb *, struct iov_iter *from);
static unsigned int ipath_poll(struct file *, struct poll_table_struct *);
static int ipath_mmap(struct file *, struct vm_area_struct *);

/*
* This is really, really weird shit - write() and writev() here
* have completely unrelated semantics. Sucky userland ABI,
* film at 11.
*/
static const struct file_operations ipath_file_ops = {
.owner = THIS_MODULE,
.write = ipath_write,
.aio_write = ipath_writev,
.write_iter = ipath_write_iter,
.open = ipath_open,
.release = ipath_close,
.poll = ipath_poll,
Expand Down Expand Up @@ -2413,18 +2418,17 @@ static ssize_t ipath_write(struct file *fp, const char __user *data,
return ret;
}

static ssize_t ipath_writev(struct kiocb *iocb, const struct iovec *iov,
unsigned long dim, loff_t off)
static ssize_t ipath_write_iter(struct kiocb *iocb, struct iov_iter *from)
{
struct file *filp = iocb->ki_filp;
struct ipath_filedata *fp = filp->private_data;
struct ipath_portdata *pd = port_fp(filp);
struct ipath_user_sdma_queue *pq = fp->pq;

if (!dim)
if (!iter_is_iovec(from) || !from->nr_segs)
return -EINVAL;

return ipath_user_sdma_writev(pd->port_dd, pq, iov, dim);
return ipath_user_sdma_writev(pd->port_dd, pq, from->iov, from->nr_segs);
}

static struct class *ipath_class;
Expand Down
20 changes: 12 additions & 8 deletions drivers/infiniband/hw/qib/qib_file_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include <asm/pgtable.h>
#include <linux/delay.h>
#include <linux/export.h>
#include <linux/uio.h>

#include "qib.h"
#include "qib_common.h"
Expand All @@ -54,15 +55,19 @@
static int qib_open(struct inode *, struct file *);
static int qib_close(struct inode *, struct file *);
static ssize_t qib_write(struct file *, const char __user *, size_t, loff_t *);
static ssize_t qib_aio_write(struct kiocb *, const struct iovec *,
unsigned long, loff_t);
static ssize_t qib_write_iter(struct kiocb *, struct iov_iter *);
static unsigned int qib_poll(struct file *, struct poll_table_struct *);
static int qib_mmapf(struct file *, struct vm_area_struct *);

/*
* This is really, really weird shit - write() and writev() here
* have completely unrelated semantics. Sucky userland ABI,
* film at 11.
*/
static const struct file_operations qib_file_ops = {
.owner = THIS_MODULE,
.write = qib_write,
.aio_write = qib_aio_write,
.write_iter = qib_write_iter,
.open = qib_open,
.release = qib_close,
.poll = qib_poll,
Expand Down Expand Up @@ -2248,17 +2253,16 @@ static ssize_t qib_write(struct file *fp, const char __user *data,
return ret;
}

static ssize_t qib_aio_write(struct kiocb *iocb, const struct iovec *iov,
unsigned long dim, loff_t off)
static ssize_t qib_write_iter(struct kiocb *iocb, struct iov_iter *from)
{
struct qib_filedata *fp = iocb->ki_filp->private_data;
struct qib_ctxtdata *rcd = ctxt_fp(iocb->ki_filp);
struct qib_user_sdma_queue *pq = fp->pq;

if (!dim || !pq)
if (!iter_is_iovec(from) || !from->nr_segs || !pq)
return -EINVAL;

return qib_user_sdma_writev(rcd, pq, iov, dim);
return qib_user_sdma_writev(rcd, pq, from->iov, from->nr_segs);
}

static struct class *qib_class;
Expand Down
2 changes: 0 additions & 2 deletions drivers/net/macvtap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1118,8 +1118,6 @@ static const struct file_operations macvtap_fops = {
.owner = THIS_MODULE,
.open = macvtap_open,
.release = macvtap_release,
.read = new_sync_read,
.write = new_sync_write,
.read_iter = macvtap_read_iter,
.write_iter = macvtap_write_iter,
.poll = macvtap_poll,
Expand Down
2 changes: 0 additions & 2 deletions drivers/net/tun.c
Original file line number Diff line number Diff line change
Expand Up @@ -2223,8 +2223,6 @@ static void tun_chr_show_fdinfo(struct seq_file *m, struct file *f)
static const struct file_operations tun_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.read = new_sync_read,
.write = new_sync_write,
.read_iter = tun_chr_read_iter,
.write_iter = tun_chr_write_iter,
.poll = tun_chr_poll,
Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/android/ashmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ static ssize_t ashmem_read(struct file *file, char __user *buf,
* be destroyed until all references to the file are dropped and
* ashmem_release is called.
*/
ret = asma->file->f_op->read(asma->file, buf, len, pos);
ret = __vfs_read(asma->file, buf, len, pos);
if (ret >= 0) {
/** Update backing file pos, since f_ops->read() doesn't */
asma->file->f_pos = *pos;
Expand Down
18 changes: 6 additions & 12 deletions drivers/staging/comedi/drivers/serial2002.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,24 +108,16 @@ static int serial2002_tty_write(struct file *f, unsigned char *buf, int count)
{
const char __user *p = (__force const char __user *)buf;
int result;
loff_t offset = 0;
mm_segment_t oldfs;

oldfs = get_fs();
set_fs(KERNEL_DS);
f->f_pos = 0;
result = f->f_op->write(f, p, count, &f->f_pos);
result = __vfs_write(f, p, count, &offset);
set_fs(oldfs);
return result;
}

static int serial2002_tty_readb(struct file *f, unsigned char *buf)
{
char __user *p = (__force char __user *)buf;

f->f_pos = 0;
return f->f_op->read(f, p, 1, &f->f_pos);
}

static void serial2002_tty_read_poll_wait(struct file *f, int timeout)
{
struct poll_wqueues table;
Expand Down Expand Up @@ -161,13 +153,15 @@ static int serial2002_tty_read(struct file *f, int timeout)
result = -1;
if (!IS_ERR(f)) {
mm_segment_t oldfs;
char __user *p = (__force char __user *)&ch;
loff_t offset = 0;

oldfs = get_fs();
set_fs(KERNEL_DS);
if (f->f_op->poll) {
serial2002_tty_read_poll_wait(f, timeout);

if (serial2002_tty_readb(f, &ch) == 1)
if (__vfs_read(f, p, 1, &offset) == 1)
result = ch;
} else {
/* Device does not support poll, busy wait */
Expand All @@ -178,7 +172,7 @@ static int serial2002_tty_read(struct file *f, int timeout)
if (retries >= timeout)
break;

if (serial2002_tty_readb(f, &ch) == 1) {
if (__vfs_read(f, p, 1, &offset) == 1) {
result = ch;
break;
}
Expand Down
6 changes: 0 additions & 6 deletions drivers/staging/lustre/lustre/llite/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -3135,9 +3135,7 @@ int ll_inode_permission(struct inode *inode, int mask)

/* -o localflock - only provides locally consistent flock locks */
struct file_operations ll_file_operations = {
.read = new_sync_read,
.read_iter = ll_file_read_iter,
.write = new_sync_write,
.write_iter = ll_file_write_iter,
.unlocked_ioctl = ll_file_ioctl,
.open = ll_file_open,
Expand All @@ -3150,9 +3148,7 @@ struct file_operations ll_file_operations = {
};

struct file_operations ll_file_operations_flock = {
.read = new_sync_read,
.read_iter = ll_file_read_iter,
.write = new_sync_write,
.write_iter = ll_file_write_iter,
.unlocked_ioctl = ll_file_ioctl,
.open = ll_file_open,
Expand All @@ -3168,9 +3164,7 @@ struct file_operations ll_file_operations_flock = {

/* These are for -o noflock - to return ENOSYS on flock calls */
struct file_operations ll_file_operations_noflock = {
.read = new_sync_read,
.read_iter = ll_file_read_iter,
.write = new_sync_write,
.write_iter = ll_file_write_iter,
.unlocked_ioctl = ll_file_ioctl,
.open = ll_file_open,
Expand Down
2 changes: 0 additions & 2 deletions drivers/staging/lustre/lustre/llite/llite_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -938,10 +938,8 @@ struct ll_cl_context {
};

struct vvp_thread_info {
struct iovec vti_local_iov;
struct vvp_io_args vti_args;
struct ra_io_arg vti_ria;
struct kiocb vti_kiocb;
struct ll_cl_context vti_io_ctx;
};

Expand Down
Loading

0 comments on commit fa92789

Please sign in to comment.