diff options
Diffstat (limited to 'fs/nfs/file.c')
-rw-r--r-- | fs/nfs/file.c | 69 |
1 files changed, 17 insertions, 52 deletions
diff --git a/fs/nfs/file.c b/fs/nfs/file.c index 284ca901fe16..4042ff58fe3f 100644 --- a/fs/nfs/file.c +++ b/fs/nfs/file.c | |||
@@ -165,22 +165,21 @@ nfs_file_flush(struct file *file, fl_owner_t id) | |||
165 | EXPORT_SYMBOL_GPL(nfs_file_flush); | 165 | EXPORT_SYMBOL_GPL(nfs_file_flush); |
166 | 166 | ||
167 | ssize_t | 167 | ssize_t |
168 | nfs_file_read(struct kiocb *iocb, const struct iovec *iov, | 168 | nfs_file_read(struct kiocb *iocb, struct iov_iter *to) |
169 | unsigned long nr_segs, loff_t pos) | ||
170 | { | 169 | { |
171 | struct inode *inode = file_inode(iocb->ki_filp); | 170 | struct inode *inode = file_inode(iocb->ki_filp); |
172 | ssize_t result; | 171 | ssize_t result; |
173 | 172 | ||
174 | if (iocb->ki_filp->f_flags & O_DIRECT) | 173 | if (iocb->ki_filp->f_flags & O_DIRECT) |
175 | return nfs_file_direct_read(iocb, iov, nr_segs, pos, true); | 174 | return nfs_file_direct_read(iocb, to, iocb->ki_pos, true); |
176 | 175 | ||
177 | dprintk("NFS: read(%pD2, %lu@%lu)\n", | 176 | dprintk("NFS: read(%pD2, %zu@%lu)\n", |
178 | iocb->ki_filp, | 177 | iocb->ki_filp, |
179 | (unsigned long) iov_length(iov, nr_segs), (unsigned long) pos); | 178 | iov_iter_count(to), (unsigned long) iocb->ki_pos); |
180 | 179 | ||
181 | result = nfs_revalidate_mapping(inode, iocb->ki_filp->f_mapping); | 180 | result = nfs_revalidate_mapping(inode, iocb->ki_filp->f_mapping); |
182 | if (!result) { | 181 | if (!result) { |
183 | result = generic_file_aio_read(iocb, iov, nr_segs, pos); | 182 | result = generic_file_read_iter(iocb, to); |
184 | if (result > 0) | 183 | if (result > 0) |
185 | nfs_add_stats(inode, NFSIOS_NORMALREADBYTES, result); | 184 | nfs_add_stats(inode, NFSIOS_NORMALREADBYTES, result); |
186 | } | 185 | } |
@@ -635,24 +634,24 @@ static int nfs_need_sync_write(struct file *filp, struct inode *inode) | |||
635 | return 0; | 634 | return 0; |
636 | } | 635 | } |
637 | 636 | ||
638 | ssize_t nfs_file_write(struct kiocb *iocb, const struct iovec *iov, | 637 | ssize_t nfs_file_write(struct kiocb *iocb, struct iov_iter *from) |
639 | unsigned long nr_segs, loff_t pos) | ||
640 | { | 638 | { |
641 | struct file *file = iocb->ki_filp; | 639 | struct file *file = iocb->ki_filp; |
642 | struct inode *inode = file_inode(file); | 640 | struct inode *inode = file_inode(file); |
643 | unsigned long written = 0; | 641 | unsigned long written = 0; |
644 | ssize_t result; | 642 | ssize_t result; |
645 | size_t count = iov_length(iov, nr_segs); | 643 | size_t count = iov_iter_count(from); |
644 | loff_t pos = iocb->ki_pos; | ||
646 | 645 | ||
647 | result = nfs_key_timeout_notify(file, inode); | 646 | result = nfs_key_timeout_notify(file, inode); |
648 | if (result) | 647 | if (result) |
649 | return result; | 648 | return result; |
650 | 649 | ||
651 | if (file->f_flags & O_DIRECT) | 650 | if (file->f_flags & O_DIRECT) |
652 | return nfs_file_direct_write(iocb, iov, nr_segs, pos, true); | 651 | return nfs_file_direct_write(iocb, from, pos, true); |
653 | 652 | ||
654 | dprintk("NFS: write(%pD2, %lu@%Ld)\n", | 653 | dprintk("NFS: write(%pD2, %zu@%Ld)\n", |
655 | file, (unsigned long) count, (long long) pos); | 654 | file, count, (long long) pos); |
656 | 655 | ||
657 | result = -EBUSY; | 656 | result = -EBUSY; |
658 | if (IS_SWAPFILE(inode)) | 657 | if (IS_SWAPFILE(inode)) |
@@ -670,7 +669,7 @@ ssize_t nfs_file_write(struct kiocb *iocb, const struct iovec *iov, | |||
670 | if (!count) | 669 | if (!count) |
671 | goto out; | 670 | goto out; |
672 | 671 | ||
673 | result = generic_file_aio_write(iocb, iov, nr_segs, pos); | 672 | result = generic_file_write_iter(iocb, from); |
674 | if (result > 0) | 673 | if (result > 0) |
675 | written = result; | 674 | written = result; |
676 | 675 | ||
@@ -691,36 +690,6 @@ out_swapfile: | |||
691 | } | 690 | } |
692 | EXPORT_SYMBOL_GPL(nfs_file_write); | 691 | EXPORT_SYMBOL_GPL(nfs_file_write); |
693 | 692 | ||
694 | ssize_t nfs_file_splice_write(struct pipe_inode_info *pipe, | ||
695 | struct file *filp, loff_t *ppos, | ||
696 | size_t count, unsigned int flags) | ||
697 | { | ||
698 | struct inode *inode = file_inode(filp); | ||
699 | unsigned long written = 0; | ||
700 | ssize_t ret; | ||
701 | |||
702 | dprintk("NFS splice_write(%pD2, %lu@%llu)\n", | ||
703 | filp, (unsigned long) count, (unsigned long long) *ppos); | ||
704 | |||
705 | /* | ||
706 | * The combination of splice and an O_APPEND destination is disallowed. | ||
707 | */ | ||
708 | |||
709 | ret = generic_file_splice_write(pipe, filp, ppos, count, flags); | ||
710 | if (ret > 0) | ||
711 | written = ret; | ||
712 | |||
713 | if (ret >= 0 && nfs_need_sync_write(filp, inode)) { | ||
714 | int err = vfs_fsync(filp, 0); | ||
715 | if (err < 0) | ||
716 | ret = err; | ||
717 | } | ||
718 | if (ret > 0) | ||
719 | nfs_add_stats(inode, NFSIOS_NORMALWRITTENBYTES, written); | ||
720 | return ret; | ||
721 | } | ||
722 | EXPORT_SYMBOL_GPL(nfs_file_splice_write); | ||
723 | |||
724 | static int | 693 | static int |
725 | do_getlk(struct file *filp, int cmd, struct file_lock *fl, int is_local) | 694 | do_getlk(struct file *filp, int cmd, struct file_lock *fl, int is_local) |
726 | { | 695 | { |
@@ -916,10 +885,6 @@ int nfs_flock(struct file *filp, int cmd, struct file_lock *fl) | |||
916 | is_local = 1; | 885 | is_local = 1; |
917 | 886 | ||
918 | /* We're simulating flock() locks using posix locks on the server */ | 887 | /* We're simulating flock() locks using posix locks on the server */ |
919 | fl->fl_owner = (fl_owner_t)filp; | ||
920 | fl->fl_start = 0; | ||
921 | fl->fl_end = OFFSET_MAX; | ||
922 | |||
923 | if (fl->fl_type == F_UNLCK) | 888 | if (fl->fl_type == F_UNLCK) |
924 | return do_unlk(filp, cmd, fl, is_local); | 889 | return do_unlk(filp, cmd, fl, is_local); |
925 | return do_setlk(filp, cmd, fl, is_local); | 890 | return do_setlk(filp, cmd, fl, is_local); |
@@ -939,10 +904,10 @@ EXPORT_SYMBOL_GPL(nfs_setlease); | |||
939 | 904 | ||
940 | const struct file_operations nfs_file_operations = { | 905 | const struct file_operations nfs_file_operations = { |
941 | .llseek = nfs_file_llseek, | 906 | .llseek = nfs_file_llseek, |
942 | .read = do_sync_read, | 907 | .read = new_sync_read, |
943 | .write = do_sync_write, | 908 | .write = new_sync_write, |
944 | .aio_read = nfs_file_read, | 909 | .read_iter = nfs_file_read, |
945 | .aio_write = nfs_file_write, | 910 | .write_iter = nfs_file_write, |
946 | .mmap = nfs_file_mmap, | 911 | .mmap = nfs_file_mmap, |
947 | .open = nfs_file_open, | 912 | .open = nfs_file_open, |
948 | .flush = nfs_file_flush, | 913 | .flush = nfs_file_flush, |
@@ -951,7 +916,7 @@ const struct file_operations nfs_file_operations = { | |||
951 | .lock = nfs_lock, | 916 | .lock = nfs_lock, |
952 | .flock = nfs_flock, | 917 | .flock = nfs_flock, |
953 | .splice_read = nfs_file_splice_read, | 918 | .splice_read = nfs_file_splice_read, |
954 | .splice_write = nfs_file_splice_write, | 919 | .splice_write = iter_file_splice_write, |
955 | .check_flags = nfs_check_flags, | 920 | .check_flags = nfs_check_flags, |
956 | .setlease = nfs_setlease, | 921 | .setlease = nfs_setlease, |
957 | }; | 922 | }; |