summaryrefslogtreecommitdiffstats
path: root/fs/cifs/file.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2014-04-02 19:53:36 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2014-05-06 17:37:58 -0400
commite6a7bcb4c489e3e078ba3cc92ae6621b2b8bb9a7 (patch)
tree8b63cc360ea4bf19d3933918e33dd37dc71cd0aa /fs/cifs/file.c
parent37c20f16e7a73e5fe34815e785ca6c5a46e4d260 (diff)
cifs: switch to ->read_iter()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/cifs/file.c')
-rw-r--r--fs/cifs/file.c32
1 files changed, 12 insertions, 20 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 15201c21ac88..2ec7fce6d350 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -2830,32 +2830,25 @@ cifs_uncached_read_into_pages(struct TCP_Server_Info *server,
2830 return total_read > 0 ? total_read : result; 2830 return total_read > 0 ? total_read : result;
2831} 2831}
2832 2832
2833ssize_t cifs_user_readv(struct kiocb *iocb, const struct iovec *iov, 2833ssize_t cifs_user_readv(struct kiocb *iocb, struct iov_iter *to)
2834 unsigned long nr_segs, loff_t pos)
2835{ 2834{
2836 struct file *file = iocb->ki_filp; 2835 struct file *file = iocb->ki_filp;
2837 ssize_t rc; 2836 ssize_t rc;
2838 size_t len, cur_len; 2837 size_t len, cur_len;
2839 ssize_t total_read = 0; 2838 ssize_t total_read = 0;
2840 loff_t offset = pos; 2839 loff_t offset = iocb->ki_pos;
2841 unsigned int npages; 2840 unsigned int npages;
2842 struct cifs_sb_info *cifs_sb; 2841 struct cifs_sb_info *cifs_sb;
2843 struct cifs_tcon *tcon; 2842 struct cifs_tcon *tcon;
2844 struct cifsFileInfo *open_file; 2843 struct cifsFileInfo *open_file;
2845 struct cifs_readdata *rdata, *tmp; 2844 struct cifs_readdata *rdata, *tmp;
2846 struct list_head rdata_list; 2845 struct list_head rdata_list;
2847 struct iov_iter to;
2848 pid_t pid; 2846 pid_t pid;
2849 2847
2850 if (!nr_segs) 2848 len = iov_iter_count(to);
2851 return 0;
2852
2853 len = iov_length(iov, nr_segs);
2854 if (!len) 2849 if (!len)
2855 return 0; 2850 return 0;
2856 2851
2857 iov_iter_init(&to, READ, iov, nr_segs, len);
2858
2859 INIT_LIST_HEAD(&rdata_list); 2852 INIT_LIST_HEAD(&rdata_list);
2860 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 2853 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
2861 open_file = file->private_data; 2854 open_file = file->private_data;
@@ -2913,7 +2906,7 @@ error:
2913 if (!list_empty(&rdata_list)) 2906 if (!list_empty(&rdata_list))
2914 rc = 0; 2907 rc = 0;
2915 2908
2916 len = iov_iter_count(&to); 2909 len = iov_iter_count(to);
2917 /* the loop below should proceed in the order of increasing offsets */ 2910 /* the loop below should proceed in the order of increasing offsets */
2918 list_for_each_entry_safe(rdata, tmp, &rdata_list, list) { 2911 list_for_each_entry_safe(rdata, tmp, &rdata_list, list) {
2919 again: 2912 again:
@@ -2930,7 +2923,7 @@ error:
2930 goto again; 2923 goto again;
2931 } 2924 }
2932 } else { 2925 } else {
2933 rc = cifs_readdata_to_iov(rdata, &to); 2926 rc = cifs_readdata_to_iov(rdata, to);
2934 } 2927 }
2935 2928
2936 } 2929 }
@@ -2938,7 +2931,7 @@ error:
2938 kref_put(&rdata->refcount, cifs_uncached_readdata_release); 2931 kref_put(&rdata->refcount, cifs_uncached_readdata_release);
2939 } 2932 }
2940 2933
2941 total_read = len - iov_iter_count(&to); 2934 total_read = len - iov_iter_count(to);
2942 2935
2943 cifs_stats_bytes_read(tcon, total_read); 2936 cifs_stats_bytes_read(tcon, total_read);
2944 2937
@@ -2947,15 +2940,14 @@ error:
2947 rc = 0; 2940 rc = 0;
2948 2941
2949 if (total_read) { 2942 if (total_read) {
2950 iocb->ki_pos = pos + total_read; 2943 iocb->ki_pos += total_read;
2951 return total_read; 2944 return total_read;
2952 } 2945 }
2953 return rc; 2946 return rc;
2954} 2947}
2955 2948
2956ssize_t 2949ssize_t
2957cifs_strict_readv(struct kiocb *iocb, const struct iovec *iov, 2950cifs_strict_readv(struct kiocb *iocb, struct iov_iter *to)
2958 unsigned long nr_segs, loff_t pos)
2959{ 2951{
2960 struct inode *inode = file_inode(iocb->ki_filp); 2952 struct inode *inode = file_inode(iocb->ki_filp);
2961 struct cifsInodeInfo *cinode = CIFS_I(inode); 2953 struct cifsInodeInfo *cinode = CIFS_I(inode);
@@ -2974,22 +2966,22 @@ cifs_strict_readv(struct kiocb *iocb, const struct iovec *iov,
2974 * pos+len-1. 2966 * pos+len-1.
2975 */ 2967 */
2976 if (!CIFS_CACHE_READ(cinode)) 2968 if (!CIFS_CACHE_READ(cinode))
2977 return cifs_user_readv(iocb, iov, nr_segs, pos); 2969 return cifs_user_readv(iocb, to);
2978 2970
2979 if (cap_unix(tcon->ses) && 2971 if (cap_unix(tcon->ses) &&
2980 (CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) && 2972 (CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) &&
2981 ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0)) 2973 ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0))
2982 return generic_file_aio_read(iocb, iov, nr_segs, pos); 2974 return generic_file_read_iter(iocb, to);
2983 2975
2984 /* 2976 /*
2985 * We need to hold the sem to be sure nobody modifies lock list 2977 * We need to hold the sem to be sure nobody modifies lock list
2986 * with a brlock that prevents reading. 2978 * with a brlock that prevents reading.
2987 */ 2979 */
2988 down_read(&cinode->lock_sem); 2980 down_read(&cinode->lock_sem);
2989 if (!cifs_find_lock_conflict(cfile, pos, iov_length(iov, nr_segs), 2981 if (!cifs_find_lock_conflict(cfile, iocb->ki_pos, iov_iter_count(to),
2990 tcon->ses->server->vals->shared_lock_type, 2982 tcon->ses->server->vals->shared_lock_type,
2991 NULL, CIFS_READ_OP)) 2983 NULL, CIFS_READ_OP))
2992 rc = generic_file_aio_read(iocb, iov, nr_segs, pos); 2984 rc = generic_file_read_iter(iocb, to);
2993 up_read(&cinode->lock_sem); 2985 up_read(&cinode->lock_sem);
2994 return rc; 2986 return rc;
2995} 2987}