OSDN Git Service

Merge branch 'work.iov_iter' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 2 May 2017 18:18:50 +0000 (11:18 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 2 May 2017 18:18:50 +0000 (11:18 -0700)
Pull iov_iter updates from Al Viro:
 "Cleanups that sat in -next + -stable fodder that has just missed 4.11.

  There's more iov_iter work in my local tree, but I'd prefer to push
  the stuff that had been in -next first"

* 'work.iov_iter' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  iov_iter: don't revert iov buffer if csum error
  generic_file_read_iter(): make use of iov_iter_revert()
  generic_file_direct_write(): make use of iov_iter_revert()
  orangefs: use iov_iter_revert()
  sctp: switch to copy_from_iter_full()
  net/9p: switch to copy_from_iter_full()
  switch memcpy_from_msg() to copy_from_iter_full()
  rds: make use of iov_iter_revert()

1  2 
mm/filemap.c

diff --combined mm/filemap.c
@@@ -519,7 -519,7 +519,7 @@@ EXPORT_SYMBOL(filemap_write_and_wait)
   *
   * Write out and wait upon file offsets lstart->lend, inclusive.
   *
 - * Note that `lend' is inclusive (describes the last byte to be written) so
 + * Note that @lend is inclusive (describes the last byte to be written) so
   * that this function can be used to write to the very end-of-file (end = -1).
   */
  int filemap_write_and_wait_range(struct address_space *mapping,
@@@ -1277,14 -1277,12 +1277,14 @@@ EXPORT_SYMBOL(find_lock_entry)
   *
   * PCG flags modify how the page is returned.
   *
 - * FGP_ACCESSED: the page will be marked accessed
 - * FGP_LOCK: Page is return locked
 - * FGP_CREAT: If page is not present then a new page is allocated using
 - *            @gfp_mask and added to the page cache and the VM's LRU
 - *            list. The page is returned locked and with an increased
 - *            refcount. Otherwise, %NULL is returned.
 + * @fgp_flags can be:
 + *
 + * - FGP_ACCESSED: the page will be marked accessed
 + * - FGP_LOCK: Page is return locked
 + * - FGP_CREAT: If page is not present then a new page is allocated using
 + *   @gfp_mask and added to the page cache and the VM's LRU
 + *   list. The page is returned locked and with an increased
 + *   refcount. Otherwise, NULL is returned.
   *
   * If FGP_LOCK or FGP_CREAT are specified then the function may sleep even
   * if the GFP flags specified for FGP_CREAT are atomic.
@@@ -2035,7 -2033,6 +2035,6 @@@ generic_file_read_iter(struct kiocb *io
        if (iocb->ki_flags & IOCB_DIRECT) {
                struct address_space *mapping = file->f_mapping;
                struct inode *inode = mapping->host;
-               struct iov_iter data = *iter;
                loff_t size;
  
                size = i_size_read(inode);
  
                file_accessed(file);
  
-               retval = mapping->a_ops->direct_IO(iocb, &data);
+               retval = mapping->a_ops->direct_IO(iocb, iter);
                if (retval >= 0) {
                        iocb->ki_pos += retval;
-                       iov_iter_advance(iter, retval);
+                       count -= retval;
                }
+               iov_iter_revert(iter, iov_iter_count(iter) - count);
  
                /*
                 * Btrfs can have a short DIO read if we encounter
                 * the rest of the read.  Buffered reads will not work for
                 * DAX files, so don't bother trying.
                 */
-               if (retval < 0 || !iov_iter_count(iter) || iocb->ki_pos >= size ||
+               if (retval < 0 || !count || iocb->ki_pos >= size ||
                    IS_DAX(inode))
                        goto out;
        }
@@@ -2706,7 -2704,6 +2706,6 @@@ generic_file_direct_write(struct kiocb 
        ssize_t         written;
        size_t          write_len;
        pgoff_t         end;
-       struct iov_iter data;
  
        write_len = iov_iter_count(from);
        end = (pos + write_len - 1) >> PAGE_SHIFT;
                }
        }
  
-       data = *from;
-       written = mapping->a_ops->direct_IO(iocb, &data);
+       written = mapping->a_ops->direct_IO(iocb, from);
  
        /*
         * Finally, try again to invalidate clean pages which might have been
  
        if (written > 0) {
                pos += written;
-               iov_iter_advance(from, written);
+               write_len -= written;
                if (pos > i_size_read(inode) && !S_ISBLK(inode->i_mode)) {
                        i_size_write(inode, pos);
                        mark_inode_dirty(inode);
                }
                iocb->ki_pos = pos;
        }
+       iov_iter_revert(from, write_len - iov_iter_count(from));
  out:
        return written;
  }
@@@ -3003,7 -3000,7 +3002,7 @@@ EXPORT_SYMBOL(generic_file_write_iter)
   * @gfp_mask: memory allocation flags (and I/O mode)
   *
   * The address_space is to try to release any data against the page
 - * (presumably at page->private).  If the release was successful, return `1'.
 + * (presumably at page->private).  If the release was successful, return '1'.
   * Otherwise return zero.
   *
   * This may also be called if PG_fscache is set on a page, indicating that the