Skip to content

Commit 53ad862

Browse files
author
Christoph Hellwig
committed
fs: remove __vfs_write
Fold it into the two callers. Signed-off-by: Christoph Hellwig <[email protected]>
1 parent 81238b2 commit 53ad862

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

fs/read_write.c

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -488,17 +488,6 @@ static ssize_t new_sync_write(struct file *filp, const char __user *buf, size_t
488488
return ret;
489489
}
490490

491-
static ssize_t __vfs_write(struct file *file, const char __user *p,
492-
size_t count, loff_t *pos)
493-
{
494-
if (file->f_op->write)
495-
return file->f_op->write(file, p, count, pos);
496-
else if (file->f_op->write_iter)
497-
return new_sync_write(file, p, count, pos);
498-
else
499-
return -EINVAL;
500-
}
501-
502491
/* caller is responsible for file_start_write/file_end_write */
503492
ssize_t __kernel_write(struct file *file, const void *buf, size_t count, loff_t *pos)
504493
{
@@ -516,7 +505,12 @@ ssize_t __kernel_write(struct file *file, const void *buf, size_t count, loff_t
516505
p = (__force const char __user *)buf;
517506
if (count > MAX_RW_COUNT)
518507
count = MAX_RW_COUNT;
519-
ret = __vfs_write(file, p, count, pos);
508+
if (file->f_op->write)
509+
ret = file->f_op->write(file, p, count, pos);
510+
else if (file->f_op->write_iter)
511+
ret = new_sync_write(file, p, count, pos);
512+
else
513+
ret = -EINVAL;
520514
set_fs(old_fs);
521515
if (ret > 0) {
522516
fsnotify_modify(file);
@@ -554,19 +548,23 @@ ssize_t vfs_write(struct file *file, const char __user *buf, size_t count, loff_
554548
return -EFAULT;
555549

556550
ret = rw_verify_area(WRITE, file, pos, count);
557-
if (!ret) {
558-
if (count > MAX_RW_COUNT)
559-
count = MAX_RW_COUNT;
560-
file_start_write(file);
561-
ret = __vfs_write(file, buf, count, pos);
562-
if (ret > 0) {
563-
fsnotify_modify(file);
564-
add_wchar(current, ret);
565-
}
566-
inc_syscw(current);
567-
file_end_write(file);
551+
if (ret)
552+
return ret;
553+
if (count > MAX_RW_COUNT)
554+
count = MAX_RW_COUNT;
555+
file_start_write(file);
556+
if (file->f_op->write)
557+
ret = file->f_op->write(file, buf, count, pos);
558+
else if (file->f_op->write_iter)
559+
ret = new_sync_write(file, buf, count, pos);
560+
else
561+
ret = -EINVAL;
562+
if (ret > 0) {
563+
fsnotify_modify(file);
564+
add_wchar(current, ret);
568565
}
569-
566+
inc_syscw(current);
567+
file_end_write(file);
570568
return ret;
571569
}
572570

0 commit comments

Comments
 (0)