Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 12 Jun 2014 17:30:18 +0000 (10:30 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 12 Jun 2014 17:30:18 +0000 (10:30 -0700)
Pull vfs updates from Al Viro:
 "This the bunch that sat in -next + lock_parent() fix.  This is the
  minimal set; there's more pending stuff.

  In particular, I really hope to get acct.c fixes merged this cycle -
  we need that to deal sanely with delayed-mntput stuff.  In the next
  pile, hopefully - that series is fairly short and localized
  (kernel/acct.c, fs/super.c and fs/namespace.c).  In this pile: more
  iov_iter work.  Most of prereqs for ->splice_write with sane locking
  order are there and Kent's dio rewrite would also fit nicely on top of
  this pile"

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (70 commits)
  lock_parent: don't step on stale ->d_parent of all-but-freed one
  kill generic_file_splice_write()
  ceph: switch to iter_file_splice_write()
  shmem: switch to iter_file_splice_write()
  nfs: switch to iter_splice_write_file()
  fs/splice.c: remove unneeded exports
  ocfs2: switch to iter_file_splice_write()
  ->splice_write() via ->write_iter()
  bio_vec-backed iov_iter
  optimize copy_page_{to,from}_iter()
  bury generic_file_aio_{read,write}
  lustre: get rid of messing with iovecs
  ceph: switch to ->write_iter()
  ceph_sync_direct_write: stop poking into iov_iter guts
  ceph_sync_read: stop poking into iov_iter guts
  new helper: copy_page_from_iter()
  fuse: switch to ->write_iter()
  btrfs: switch to ->write_iter()
  ocfs2: switch to ->write_iter()
  xfs: switch to ->write_iter()
  ...

47 files changed:
1  2 
drivers/staging/lustre/lustre/lclient/lcommon_cl.c
drivers/staging/lustre/lustre/llite/file.c
drivers/staging/lustre/lustre/llite/llite_internal.h
drivers/staging/lustre/lustre/llite/rw.c
drivers/staging/lustre/lustre/llite/rw26.c
drivers/staging/lustre/lustre/llite/vvp_io.c
drivers/usb/gadget/storage_common.c
fs/9p/vfs_file.c
fs/affs/file.c
fs/block_dev.c
fs/btrfs/file.c
fs/btrfs/inode.c
fs/ceph/addr.c
fs/cifs/cifsfs.c
fs/cifs/cifsfs.h
fs/cifs/file.c
fs/dcache.c
fs/ext3/inode.c
fs/ext4/ext4.h
fs/ext4/file.c
fs/ext4/inode.c
fs/f2fs/data.c
fs/f2fs/file.c
fs/fat/inode.c
fs/file_table.c
fs/fuse/file.c
fs/gfs2/aops.c
fs/gfs2/file.c
fs/nfs/direct.c
fs/nfs/file.c
fs/nfs/internal.h
fs/nfs/nfs4file.c
fs/ntfs/file.c
fs/ocfs2/file.c
fs/reiserfs/file.c
fs/reiserfs/inode.c
fs/ubifs/file.c
fs/xfs/xfs_aops.c
fs/xfs/xfs_file.c
fs/xfs/xfs_trace.h
include/linux/blk_types.h
include/linux/fs.h
include/linux/nfs_fs.h
mm/filemap.c
mm/page_io.c
mm/shmem.c
mm/vmscan.c

Simple merge
Simple merge
diff --cc fs/affs/file.c
Simple merge
diff --cc fs/block_dev.c
Simple merge
diff --cc fs/btrfs/file.c
Simple merge
Simple merge
diff --cc fs/ceph/addr.c
Simple merge
Simple merge
Simple merge
diff --cc fs/cifs/file.c
index 208f56eca4bf4de164d8af873b0050ac4884c5ea,60e9b5fa22128fc7a127a5859f0c6070aae09c36..e90a1e9aa627642c9ccefd428319f43b3d379c2f
@@@ -2560,9 -2558,9 +2558,9 @@@ ssize_t cifs_user_writev(struct kiocb *
         * write request.
         */
  
-       written = cifs_iovec_write(iocb->ki_filp, iov, nr_segs, &pos);
+       written = cifs_iovec_write(iocb->ki_filp, from, &pos);
        if (written > 0) {
 -              CIFS_I(inode)->invalid_mapping = true;
 +              set_bit(CIFS_INO_INVALID_MAPPING, &CIFS_I(inode)->flags);
                iocb->ki_pos = pos;
        }
  
diff --cc fs/dcache.c
Simple merge
diff --cc fs/ext3/inode.c
Simple merge
diff --cc fs/ext4/ext4.h
Simple merge
diff --cc fs/ext4/file.c
Simple merge
diff --cc fs/ext4/inode.c
Simple merge
diff --cc fs/f2fs/data.c
index c1fb6dd10911c01e9b37d533a7588ee6bf934ecb,1d2e7e9624d2c4f5fc372a0f86be916169deebe4..0924521306b40c5087f2c2170c92fe7b03452862
@@@ -1044,14 -1018,11 +1043,14 @@@ static ssize_t f2fs_direct_IO(int rw, s
        if (f2fs_has_inline_data(inode))
                return 0;
  
-       if (check_direct_IO(inode, rw, iov, offset, nr_segs))
+       if (check_direct_IO(inode, rw, iter, offset))
                return 0;
  
-       return blockdev_direct_IO(rw, iocb, inode, iov, offset, nr_segs,
-                                                       get_data_block);
 +      /* clear fsync mark to recover these blocks */
 +      fsync_mark_clear(F2FS_SB(inode->i_sb), inode->i_ino);
 +
+       return blockdev_direct_IO(rw, iocb, inode, iter, offset,
+                                 get_data_block);
  }
  
  static void f2fs_invalidate_data_page(struct page *page, unsigned int offset,
diff --cc fs/f2fs/file.c
index 9c49c593d8eb4ab39a1aa28c1b841f949d02c050,e4ba4b93f96a90e70c173fa309b242c0390ef8cf..c58e330757191392656d2819fd937a1cc564cb37
@@@ -807,11 -678,11 +807,11 @@@ long f2fs_compat_ioctl(struct file *fil
  #endif
  
  const struct file_operations f2fs_file_operations = {
 -      .llseek         = generic_file_llseek,
 +      .llseek         = f2fs_llseek,
-       .read           = do_sync_read,
-       .write          = do_sync_write,
-       .aio_read       = generic_file_aio_read,
-       .aio_write      = generic_file_aio_write,
+       .read           = new_sync_read,
+       .write          = new_sync_write,
+       .read_iter      = generic_file_read_iter,
+       .write_iter     = generic_file_write_iter,
        .open           = generic_file_open,
        .mmap           = f2fs_file_mmap,
        .fsync          = f2fs_sync_file,
diff --cc fs/fat/inode.c
Simple merge
diff --cc fs/file_table.c
Simple merge
diff --cc fs/fuse/file.c
Simple merge
diff --cc fs/gfs2/aops.c
Simple merge
diff --cc fs/gfs2/file.c
Simple merge
diff --cc fs/nfs/direct.c
index 4ad7bc3886791b0078ebc3ae4b326ed5e4c6566b,b122fe21fea0dce3ae5dbcbb362dcbb4820e73b8..8f98138cbc4385ba63b3af77ae907219d22e6991
@@@ -414,60 -322,37 +414,37 @@@ static const struct nfs_pgio_completion
   * handled automatically by nfs_direct_read_result().  Otherwise, if
   * no requests have been sent, just return an error.
   */
- static ssize_t nfs_direct_read_schedule_segment(struct nfs_pageio_descriptor *desc,
-                                               const struct iovec *iov,
-                                               loff_t pos, bool uio)
- {
-       struct nfs_direct_req *dreq = desc->pg_dreq;
-       struct nfs_open_context *ctx = dreq->ctx;
-       struct inode *inode = ctx->dentry->d_inode;
-       unsigned long user_addr = (unsigned long)iov->iov_base;
-       size_t count = iov->iov_len;
-       size_t rsize = NFS_SERVER(inode)->rsize;
-       unsigned int pgbase;
-       int result;
-       ssize_t started = 0;
-       struct page **pagevec = NULL;
-       unsigned int npages;
-       do {
-               size_t bytes;
-               int i;
  
-               pgbase = user_addr & ~PAGE_MASK;
-               bytes = min(max_t(size_t, rsize, PAGE_SIZE), count);
+ static ssize_t nfs_direct_read_schedule_iovec(struct nfs_direct_req *dreq,
+                                             struct iov_iter *iter,
+                                             loff_t pos)
+ {
+       struct nfs_pageio_descriptor desc;
+       struct inode *inode = dreq->inode;
+       ssize_t result = -EINVAL;
+       size_t requested_bytes = 0;
+       size_t rsize = max_t(size_t, NFS_SERVER(inode)->rsize, PAGE_SIZE);
  
-               result = -ENOMEM;
-               npages = nfs_page_array_len(pgbase, bytes);
-               if (!pagevec)
-                       pagevec = kmalloc(npages * sizeof(struct page *),
-                                         GFP_KERNEL);
-               if (!pagevec)
-                       break;
-               if (uio) {
-                       down_read(&current->mm->mmap_sem);
-                       result = get_user_pages(current, current->mm, user_addr,
-                                       npages, 1, 0, pagevec, NULL);
-                       up_read(&current->mm->mmap_sem);
-                       if (result < 0)
-                               break;
-               } else {
-                       WARN_ON(npages != 1);
-                       result = get_kernel_page(user_addr, 1, pagevec);
-                       if (WARN_ON(result != 1))
-                               break;
-               }
 -      NFS_PROTO(dreq->inode)->read_pageio_init(&desc, dreq->inode,
++      nfs_pageio_init_read(&desc, dreq->inode, false,
+                            &nfs_direct_read_completion_ops);
+       get_dreq(dreq);
+       desc.pg_dreq = dreq;
+       atomic_inc(&inode->i_dio_count);
  
-               if ((unsigned)result < npages) {
-                       bytes = result * PAGE_SIZE;
-                       if (bytes <= pgbase) {
-                               nfs_direct_release_pages(pagevec, result);
-                               break;
-                       }
-                       bytes -= pgbase;
-                       npages = result;
-               }
+       while (iov_iter_count(iter)) {
+               struct page **pagevec;
+               size_t bytes;
+               size_t pgbase;
+               unsigned npages, i;
  
+               result = iov_iter_get_pages_alloc(iter, &pagevec, 
+                                                 rsize, &pgbase);
+               if (result < 0)
+                       break;
+       
+               bytes = result;
+               iov_iter_advance(iter, bytes);
+               npages = (result + pgbase + PAGE_SIZE - 1) / PAGE_SIZE;
                for (i = 0; i < npages; i++) {
                        struct nfs_page *req;
                        unsigned int req_len = min_t(size_t, bytes, PAGE_SIZE - pgbase);
@@@ -965,24 -719,58 +813,57 @@@ static ssize_t nfs_direct_write_schedul
        struct inode *inode = dreq->inode;
        ssize_t result = 0;
        size_t requested_bytes = 0;
-       unsigned long seg;
+       size_t wsize = max_t(size_t, NFS_SERVER(inode)->wsize, PAGE_SIZE);
  
 -      NFS_PROTO(inode)->write_pageio_init(&desc, inode, FLUSH_COND_STABLE,
 +      nfs_pageio_init_write(&desc, inode, FLUSH_COND_STABLE, false,
                              &nfs_direct_write_completion_ops);
        desc.pg_dreq = dreq;
        get_dreq(dreq);
        atomic_inc(&inode->i_dio_count);
  
-       NFS_I(dreq->inode)->write_io += iov_length(iov, nr_segs);
-       for (seg = 0; seg < nr_segs; seg++) {
-               const struct iovec *vec = &iov[seg];
-               result = nfs_direct_write_schedule_segment(&desc, vec, pos, uio);
+       NFS_I(inode)->write_io += iov_iter_count(iter);
+       while (iov_iter_count(iter)) {
+               struct page **pagevec;
+               size_t bytes;
+               size_t pgbase;
+               unsigned npages, i;
+               result = iov_iter_get_pages_alloc(iter, &pagevec, 
+                                                 wsize, &pgbase);
                if (result < 0)
                        break;
-               requested_bytes += result;
-               if ((size_t)result < vec->iov_len)
+               bytes = result;
+               iov_iter_advance(iter, bytes);
+               npages = (result + pgbase + PAGE_SIZE - 1) / PAGE_SIZE;
+               for (i = 0; i < npages; i++) {
+                       struct nfs_page *req;
+                       unsigned int req_len = min_t(size_t, bytes, PAGE_SIZE - pgbase);
 -                      req = nfs_create_request(dreq->ctx, inode,
 -                                               pagevec[i],
++                      req = nfs_create_request(dreq->ctx, pagevec[i], NULL,
+                                                pgbase, req_len);
+                       if (IS_ERR(req)) {
+                               result = PTR_ERR(req);
+                               break;
+                       }
+                       nfs_lock_request(req);
+                       req->wb_index = pos >> PAGE_SHIFT;
+                       req->wb_offset = pos & ~PAGE_MASK;
+                       if (!nfs_pageio_add_request(&desc, req)) {
+                               result = desc.pg_error;
+                               nfs_unlock_and_release_request(req);
+                               break;
+                       }
+                       pgbase = 0;
+                       bytes -= req_len;
+                       requested_bytes += req_len;
+                       pos += req_len;
+                       dreq->bytes_left -= req_len;
+               }
+               nfs_direct_release_pages(pagevec, npages);
+               kvfree(pagevec);
+               if (result < 0)
                        break;
-               pos += vec->iov_len;
        }
        nfs_pageio_complete(&desc);
  
diff --cc fs/nfs/file.c
Simple merge
Simple merge
Simple merge
diff --cc fs/ntfs/file.c
Simple merge
diff --cc fs/ocfs2/file.c
Simple merge
Simple merge
index e3ca04894919c4d0a38f2623676d7ffe1ce6aff3,b8003e8dd1f47bf726d78a1f1a40aba7a56ecc30..63b2b0ec49e6afacd955abf9f172751768ee08ee
@@@ -3274,13 -3080,10 +3274,12 @@@ static int reiserfs_releasepage(struct 
        return ret;
  }
  
 -/* We thank Mingming Cao for helping us understand in great detail what
 -   to do in this section of the code. */
 +/*
 + * We thank Mingming Cao for helping us understand in great detail what
 + * to do in this section of the code.
 + */
  static ssize_t reiserfs_direct_IO(int rw, struct kiocb *iocb,
-                                 const struct iovec *iov, loff_t offset,
-                                 unsigned long nr_segs)
+                                 struct iov_iter *iter, loff_t offset)
  {
        struct file *file = iocb->ki_filp;
        struct inode *inode = file->f_mapping->host;
diff --cc fs/ubifs/file.c
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc mm/filemap.c
Simple merge
diff --cc mm/page_io.c
Simple merge
diff --cc mm/shmem.c
Simple merge
diff --cc mm/vmscan.c
Simple merge