Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux...
[sfrench/cifs-2.6.git] / fs / read_write.c
index 7d9318c3d43c70bc16f8939b04e7dfd75389971e..c0805c93b6fa18d34b9b579d5c470af2a5a66b1b 100644 (file)
@@ -412,6 +412,23 @@ ssize_t new_sync_read(struct file *filp, char __user *buf, size_t len, loff_t *p
 
 EXPORT_SYMBOL(new_sync_read);
 
+ssize_t __vfs_read(struct file *file, char __user *buf, size_t count,
+                  loff_t *pos)
+{
+       ssize_t ret;
+
+       if (file->f_op->read)
+               ret = file->f_op->read(file, buf, count, pos);
+       else if (file->f_op->aio_read)
+               ret = do_sync_read(file, buf, count, pos);
+       else if (file->f_op->read_iter)
+               ret = new_sync_read(file, buf, count, pos);
+       else
+               ret = -EINVAL;
+
+       return ret;
+}
+
 ssize_t vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos)
 {
        ssize_t ret;
@@ -426,12 +443,7 @@ ssize_t vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos)
        ret = rw_verify_area(READ, file, pos, count);
        if (ret >= 0) {
                count = ret;
-               if (file->f_op->read)
-                       ret = file->f_op->read(file, buf, count, pos);
-               else if (file->f_op->aio_read)
-                       ret = do_sync_read(file, buf, count, pos);
-               else
-                       ret = new_sync_read(file, buf, count, pos);
+               ret = __vfs_read(file, buf, count, pos);
                if (ret > 0) {
                        fsnotify_access(file);
                        add_rchar(current, ret);