History

fs: remove __vfs_read

Fold it into the two callers.

Christoph Hellwig committed 6 years ago

Commit 775802c1 parent 6209dd92 files · +21 −23Browse files

Unified · Split

2 files
  1. fs/read_write.c +21 −22
  2. include/linux/fs.h +0 −1
fs/read_write.c+21−22
@@ -419,17 +419,6 @@ static ssize_t new_sync_read(struct file *filp, char __user *buf, size_t len, lo · 418 unmodified lines
419419 return ret;
420420 }
421421
422−ssize_t __vfs_read(struct file *file, char __user *buf, size_t count,
423− loff_t *pos)
424−{
425− if (file->f_op->read)
426− return file->f_op->read(file, buf, count, pos);
427− else if (file->f_op->read_iter)
428− return new_sync_read(file, buf, count, pos);
429− else
430− return -EINVAL;
431−}
432−
433422 ssize_t __kernel_read(struct file *file, void *buf, size_t count, loff_t *pos)
434423 {
435424 mm_segment_t old_fs = get_fs();
@@ -443,7 +432,12 @@ ssize_t __kernel_read(struct file *file, void *buf, size_t count, loff_t *pos) · 7 unmodified lines
443432 if (count > MAX_RW_COUNT)
444433 count = MAX_RW_COUNT;
445434 set_fs(KERNEL_DS);
446− ret = __vfs_read(file, (void __user *)buf, count, pos);
435+ if (file->f_op->read)
436+ ret = file->f_op->read(file, (void __user *)buf, count, pos);
437+ else if (file->f_op->read_iter)
438+ ret = new_sync_read(file, (void __user *)buf, count, pos);
439+ else
440+ ret = -EINVAL;
447441 set_fs(old_fs);
448442 if (ret > 0) {
449443 fsnotify_access(file);
@@ -476,17 +470,22 @@ ssize_t vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos) · 26 unmodified lines
476470 return -EFAULT;
477471
478472 ret = rw_verify_area(READ, file, pos, count);
479− if (!ret) {
480− if (count > MAX_RW_COUNT)
481− count = MAX_RW_COUNT;
482− ret = __vfs_read(file, buf, count, pos);
483− if (ret > 0) {
484− fsnotify_access(file);
485− add_rchar(current, ret);
486− }
487− inc_syscr(current);
488− }
473+ if (ret)
474+ return ret;
475+ if (count > MAX_RW_COUNT)
476+ count = MAX_RW_COUNT;
489477
478+ if (file->f_op->read)
479+ ret = file->f_op->read(file, buf, count, pos);
480+ else if (file->f_op->read_iter)
481+ ret = new_sync_read(file, buf, count, pos);
482+ else
483+ ret = -EINVAL;
484+ if (ret > 0) {
485+ fsnotify_access(file);
486+ add_rchar(current, ret);
487+ }
488+ inc_syscr(current);
490489 return ret;
491490 }
492491
include/linux/fs.h+0−1
@@ -1917,7 +1917,6 @@ ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector, · 1916 unmodified lines
19171917 struct iovec *fast_pointer,
19181918 struct iovec **ret_pointer);
19191919
1920−extern ssize_t __vfs_read(struct file *, char __user *, size_t, loff_t *);
19211920 extern ssize_t vfs_read(struct file *, char __user *, size_t, loff_t *);
19221921 extern ssize_t vfs_write(struct file *, const char __user *, size_t, loff_t *);
19231922 extern ssize_t vfs_readv(struct file *, const struct iovec __user *,