diff options
Diffstat (limited to 'fs/cifs/file.c')
-rw-r--r-- | fs/cifs/file.c | 81 |
1 files changed, 34 insertions, 47 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 208f56eca4bf..e90a1e9aa627 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c | |||
@@ -2385,14 +2385,12 @@ cifs_uncached_retry_writev(struct cifs_writedata *wdata) | |||
2385 | } | 2385 | } |
2386 | 2386 | ||
2387 | static ssize_t | 2387 | static ssize_t |
2388 | cifs_iovec_write(struct file *file, const struct iovec *iov, | 2388 | cifs_iovec_write(struct file *file, struct iov_iter *from, loff_t *poffset) |
2389 | unsigned long nr_segs, loff_t *poffset) | ||
2390 | { | 2389 | { |
2391 | unsigned long nr_pages, i; | 2390 | unsigned long nr_pages, i; |
2392 | size_t bytes, copied, len, cur_len; | 2391 | size_t bytes, copied, len, cur_len; |
2393 | ssize_t total_written = 0; | 2392 | ssize_t total_written = 0; |
2394 | loff_t offset; | 2393 | loff_t offset; |
2395 | struct iov_iter it; | ||
2396 | struct cifsFileInfo *open_file; | 2394 | struct cifsFileInfo *open_file; |
2397 | struct cifs_tcon *tcon; | 2395 | struct cifs_tcon *tcon; |
2398 | struct cifs_sb_info *cifs_sb; | 2396 | struct cifs_sb_info *cifs_sb; |
@@ -2401,14 +2399,16 @@ cifs_iovec_write(struct file *file, const struct iovec *iov, | |||
2401 | int rc; | 2399 | int rc; |
2402 | pid_t pid; | 2400 | pid_t pid; |
2403 | 2401 | ||
2404 | len = iov_length(iov, nr_segs); | 2402 | len = iov_iter_count(from); |
2405 | if (!len) | ||
2406 | return 0; | ||
2407 | |||
2408 | rc = generic_write_checks(file, poffset, &len, 0); | 2403 | rc = generic_write_checks(file, poffset, &len, 0); |
2409 | if (rc) | 2404 | if (rc) |
2410 | return rc; | 2405 | return rc; |
2411 | 2406 | ||
2407 | if (!len) | ||
2408 | return 0; | ||
2409 | |||
2410 | iov_iter_truncate(from, len); | ||
2411 | |||
2412 | INIT_LIST_HEAD(&wdata_list); | 2412 | INIT_LIST_HEAD(&wdata_list); |
2413 | cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); | 2413 | cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); |
2414 | open_file = file->private_data; | 2414 | open_file = file->private_data; |
@@ -2424,7 +2424,6 @@ cifs_iovec_write(struct file *file, const struct iovec *iov, | |||
2424 | else | 2424 | else |
2425 | pid = current->tgid; | 2425 | pid = current->tgid; |
2426 | 2426 | ||
2427 | iov_iter_init(&it, iov, nr_segs, len, 0); | ||
2428 | do { | 2427 | do { |
2429 | size_t save_len; | 2428 | size_t save_len; |
2430 | 2429 | ||
@@ -2444,11 +2443,10 @@ cifs_iovec_write(struct file *file, const struct iovec *iov, | |||
2444 | 2443 | ||
2445 | save_len = cur_len; | 2444 | save_len = cur_len; |
2446 | for (i = 0; i < nr_pages; i++) { | 2445 | for (i = 0; i < nr_pages; i++) { |
2447 | bytes = min_t(const size_t, cur_len, PAGE_SIZE); | 2446 | bytes = min_t(size_t, cur_len, PAGE_SIZE); |
2448 | copied = iov_iter_copy_from_user(wdata->pages[i], &it, | 2447 | copied = copy_page_from_iter(wdata->pages[i], 0, bytes, |
2449 | 0, bytes); | 2448 | from); |
2450 | cur_len -= copied; | 2449 | cur_len -= copied; |
2451 | iov_iter_advance(&it, copied); | ||
2452 | /* | 2450 | /* |
2453 | * If we didn't copy as much as we expected, then that | 2451 | * If we didn't copy as much as we expected, then that |
2454 | * may mean we trod into an unmapped area. Stop copying | 2452 | * may mean we trod into an unmapped area. Stop copying |
@@ -2546,11 +2544,11 @@ restart_loop: | |||
2546 | return total_written ? total_written : (ssize_t)rc; | 2544 | return total_written ? total_written : (ssize_t)rc; |
2547 | } | 2545 | } |
2548 | 2546 | ||
2549 | ssize_t cifs_user_writev(struct kiocb *iocb, const struct iovec *iov, | 2547 | ssize_t cifs_user_writev(struct kiocb *iocb, struct iov_iter *from) |
2550 | unsigned long nr_segs, loff_t pos) | ||
2551 | { | 2548 | { |
2552 | ssize_t written; | 2549 | ssize_t written; |
2553 | struct inode *inode; | 2550 | struct inode *inode; |
2551 | loff_t pos = iocb->ki_pos; | ||
2554 | 2552 | ||
2555 | inode = file_inode(iocb->ki_filp); | 2553 | inode = file_inode(iocb->ki_filp); |
2556 | 2554 | ||
@@ -2560,7 +2558,7 @@ ssize_t cifs_user_writev(struct kiocb *iocb, const struct iovec *iov, | |||
2560 | * write request. | 2558 | * write request. |
2561 | */ | 2559 | */ |
2562 | 2560 | ||
2563 | written = cifs_iovec_write(iocb->ki_filp, iov, nr_segs, &pos); | 2561 | written = cifs_iovec_write(iocb->ki_filp, from, &pos); |
2564 | if (written > 0) { | 2562 | if (written > 0) { |
2565 | set_bit(CIFS_INO_INVALID_MAPPING, &CIFS_I(inode)->flags); | 2563 | set_bit(CIFS_INO_INVALID_MAPPING, &CIFS_I(inode)->flags); |
2566 | iocb->ki_pos = pos; | 2564 | iocb->ki_pos = pos; |
@@ -2570,8 +2568,7 @@ ssize_t cifs_user_writev(struct kiocb *iocb, const struct iovec *iov, | |||
2570 | } | 2568 | } |
2571 | 2569 | ||
2572 | static ssize_t | 2570 | static ssize_t |
2573 | cifs_writev(struct kiocb *iocb, const struct iovec *iov, | 2571 | cifs_writev(struct kiocb *iocb, struct iov_iter *from) |
2574 | unsigned long nr_segs, loff_t pos) | ||
2575 | { | 2572 | { |
2576 | struct file *file = iocb->ki_filp; | 2573 | struct file *file = iocb->ki_filp; |
2577 | struct cifsFileInfo *cfile = (struct cifsFileInfo *)file->private_data; | 2574 | struct cifsFileInfo *cfile = (struct cifsFileInfo *)file->private_data; |
@@ -2589,10 +2586,10 @@ cifs_writev(struct kiocb *iocb, const struct iovec *iov, | |||
2589 | mutex_lock(&inode->i_mutex); | 2586 | mutex_lock(&inode->i_mutex); |
2590 | if (file->f_flags & O_APPEND) | 2587 | if (file->f_flags & O_APPEND) |
2591 | lock_pos = i_size_read(inode); | 2588 | lock_pos = i_size_read(inode); |
2592 | if (!cifs_find_lock_conflict(cfile, lock_pos, iov_length(iov, nr_segs), | 2589 | if (!cifs_find_lock_conflict(cfile, lock_pos, iov_iter_count(from), |
2593 | server->vals->exclusive_lock_type, NULL, | 2590 | server->vals->exclusive_lock_type, NULL, |
2594 | CIFS_WRITE_OP)) { | 2591 | CIFS_WRITE_OP)) { |
2595 | rc = __generic_file_aio_write(iocb, iov, nr_segs); | 2592 | rc = __generic_file_write_iter(iocb, from); |
2596 | mutex_unlock(&inode->i_mutex); | 2593 | mutex_unlock(&inode->i_mutex); |
2597 | 2594 | ||
2598 | if (rc > 0) { | 2595 | if (rc > 0) { |
@@ -2610,8 +2607,7 @@ cifs_writev(struct kiocb *iocb, const struct iovec *iov, | |||
2610 | } | 2607 | } |
2611 | 2608 | ||
2612 | ssize_t | 2609 | ssize_t |
2613 | cifs_strict_writev(struct kiocb *iocb, const struct iovec *iov, | 2610 | cifs_strict_writev(struct kiocb *iocb, struct iov_iter *from) |
2614 | unsigned long nr_segs, loff_t pos) | ||
2615 | { | 2611 | { |
2616 | struct inode *inode = file_inode(iocb->ki_filp); | 2612 | struct inode *inode = file_inode(iocb->ki_filp); |
2617 | struct cifsInodeInfo *cinode = CIFS_I(inode); | 2613 | struct cifsInodeInfo *cinode = CIFS_I(inode); |
@@ -2629,11 +2625,10 @@ cifs_strict_writev(struct kiocb *iocb, const struct iovec *iov, | |||
2629 | if (cap_unix(tcon->ses) && | 2625 | if (cap_unix(tcon->ses) && |
2630 | (CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) | 2626 | (CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) |
2631 | && ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0)) { | 2627 | && ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0)) { |
2632 | written = generic_file_aio_write( | 2628 | written = generic_file_write_iter(iocb, from); |
2633 | iocb, iov, nr_segs, pos); | ||
2634 | goto out; | 2629 | goto out; |
2635 | } | 2630 | } |
2636 | written = cifs_writev(iocb, iov, nr_segs, pos); | 2631 | written = cifs_writev(iocb, from); |
2637 | goto out; | 2632 | goto out; |
2638 | } | 2633 | } |
2639 | /* | 2634 | /* |
@@ -2642,7 +2637,7 @@ cifs_strict_writev(struct kiocb *iocb, const struct iovec *iov, | |||
2642 | * affected pages because it may cause a error with mandatory locks on | 2637 | * affected pages because it may cause a error with mandatory locks on |
2643 | * these pages but not on the region from pos to ppos+len-1. | 2638 | * these pages but not on the region from pos to ppos+len-1. |
2644 | */ | 2639 | */ |
2645 | written = cifs_user_writev(iocb, iov, nr_segs, pos); | 2640 | written = cifs_user_writev(iocb, from); |
2646 | if (written > 0 && CIFS_CACHE_READ(cinode)) { | 2641 | if (written > 0 && CIFS_CACHE_READ(cinode)) { |
2647 | /* | 2642 | /* |
2648 | * Windows 7 server can delay breaking level2 oplock if a write | 2643 | * Windows 7 server can delay breaking level2 oplock if a write |
@@ -2831,32 +2826,25 @@ cifs_uncached_read_into_pages(struct TCP_Server_Info *server, | |||
2831 | return total_read > 0 ? total_read : result; | 2826 | return total_read > 0 ? total_read : result; |
2832 | } | 2827 | } |
2833 | 2828 | ||
2834 | ssize_t cifs_user_readv(struct kiocb *iocb, const struct iovec *iov, | 2829 | ssize_t cifs_user_readv(struct kiocb *iocb, struct iov_iter *to) |
2835 | unsigned long nr_segs, loff_t pos) | ||
2836 | { | 2830 | { |
2837 | struct file *file = iocb->ki_filp; | 2831 | struct file *file = iocb->ki_filp; |
2838 | ssize_t rc; | 2832 | ssize_t rc; |
2839 | size_t len, cur_len; | 2833 | size_t len, cur_len; |
2840 | ssize_t total_read = 0; | 2834 | ssize_t total_read = 0; |
2841 | loff_t offset = pos; | 2835 | loff_t offset = iocb->ki_pos; |
2842 | unsigned int npages; | 2836 | unsigned int npages; |
2843 | struct cifs_sb_info *cifs_sb; | 2837 | struct cifs_sb_info *cifs_sb; |
2844 | struct cifs_tcon *tcon; | 2838 | struct cifs_tcon *tcon; |
2845 | struct cifsFileInfo *open_file; | 2839 | struct cifsFileInfo *open_file; |
2846 | struct cifs_readdata *rdata, *tmp; | 2840 | struct cifs_readdata *rdata, *tmp; |
2847 | struct list_head rdata_list; | 2841 | struct list_head rdata_list; |
2848 | struct iov_iter to; | ||
2849 | pid_t pid; | 2842 | pid_t pid; |
2850 | 2843 | ||
2851 | if (!nr_segs) | 2844 | len = iov_iter_count(to); |
2852 | return 0; | ||
2853 | |||
2854 | len = iov_length(iov, nr_segs); | ||
2855 | if (!len) | 2845 | if (!len) |
2856 | return 0; | 2846 | return 0; |
2857 | 2847 | ||
2858 | iov_iter_init(&to, iov, nr_segs, len, 0); | ||
2859 | |||
2860 | INIT_LIST_HEAD(&rdata_list); | 2848 | INIT_LIST_HEAD(&rdata_list); |
2861 | cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); | 2849 | cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); |
2862 | open_file = file->private_data; | 2850 | open_file = file->private_data; |
@@ -2914,7 +2902,7 @@ error: | |||
2914 | if (!list_empty(&rdata_list)) | 2902 | if (!list_empty(&rdata_list)) |
2915 | rc = 0; | 2903 | rc = 0; |
2916 | 2904 | ||
2917 | len = iov_iter_count(&to); | 2905 | len = iov_iter_count(to); |
2918 | /* the loop below should proceed in the order of increasing offsets */ | 2906 | /* the loop below should proceed in the order of increasing offsets */ |
2919 | list_for_each_entry_safe(rdata, tmp, &rdata_list, list) { | 2907 | list_for_each_entry_safe(rdata, tmp, &rdata_list, list) { |
2920 | again: | 2908 | again: |
@@ -2931,7 +2919,7 @@ error: | |||
2931 | goto again; | 2919 | goto again; |
2932 | } | 2920 | } |
2933 | } else { | 2921 | } else { |
2934 | rc = cifs_readdata_to_iov(rdata, &to); | 2922 | rc = cifs_readdata_to_iov(rdata, to); |
2935 | } | 2923 | } |
2936 | 2924 | ||
2937 | } | 2925 | } |
@@ -2939,7 +2927,7 @@ error: | |||
2939 | kref_put(&rdata->refcount, cifs_uncached_readdata_release); | 2927 | kref_put(&rdata->refcount, cifs_uncached_readdata_release); |
2940 | } | 2928 | } |
2941 | 2929 | ||
2942 | total_read = len - iov_iter_count(&to); | 2930 | total_read = len - iov_iter_count(to); |
2943 | 2931 | ||
2944 | cifs_stats_bytes_read(tcon, total_read); | 2932 | cifs_stats_bytes_read(tcon, total_read); |
2945 | 2933 | ||
@@ -2948,15 +2936,14 @@ error: | |||
2948 | rc = 0; | 2936 | rc = 0; |
2949 | 2937 | ||
2950 | if (total_read) { | 2938 | if (total_read) { |
2951 | iocb->ki_pos = pos + total_read; | 2939 | iocb->ki_pos += total_read; |
2952 | return total_read; | 2940 | return total_read; |
2953 | } | 2941 | } |
2954 | return rc; | 2942 | return rc; |
2955 | } | 2943 | } |
2956 | 2944 | ||
2957 | ssize_t | 2945 | ssize_t |
2958 | cifs_strict_readv(struct kiocb *iocb, const struct iovec *iov, | 2946 | cifs_strict_readv(struct kiocb *iocb, struct iov_iter *to) |
2959 | unsigned long nr_segs, loff_t pos) | ||
2960 | { | 2947 | { |
2961 | struct inode *inode = file_inode(iocb->ki_filp); | 2948 | struct inode *inode = file_inode(iocb->ki_filp); |
2962 | struct cifsInodeInfo *cinode = CIFS_I(inode); | 2949 | struct cifsInodeInfo *cinode = CIFS_I(inode); |
@@ -2975,22 +2962,22 @@ cifs_strict_readv(struct kiocb *iocb, const struct iovec *iov, | |||
2975 | * pos+len-1. | 2962 | * pos+len-1. |
2976 | */ | 2963 | */ |
2977 | if (!CIFS_CACHE_READ(cinode)) | 2964 | if (!CIFS_CACHE_READ(cinode)) |
2978 | return cifs_user_readv(iocb, iov, nr_segs, pos); | 2965 | return cifs_user_readv(iocb, to); |
2979 | 2966 | ||
2980 | if (cap_unix(tcon->ses) && | 2967 | if (cap_unix(tcon->ses) && |
2981 | (CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) && | 2968 | (CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) && |
2982 | ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0)) | 2969 | ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0)) |
2983 | return generic_file_aio_read(iocb, iov, nr_segs, pos); | 2970 | return generic_file_read_iter(iocb, to); |
2984 | 2971 | ||
2985 | /* | 2972 | /* |
2986 | * We need to hold the sem to be sure nobody modifies lock list | 2973 | * We need to hold the sem to be sure nobody modifies lock list |
2987 | * with a brlock that prevents reading. | 2974 | * with a brlock that prevents reading. |
2988 | */ | 2975 | */ |
2989 | down_read(&cinode->lock_sem); | 2976 | down_read(&cinode->lock_sem); |
2990 | if (!cifs_find_lock_conflict(cfile, pos, iov_length(iov, nr_segs), | 2977 | if (!cifs_find_lock_conflict(cfile, iocb->ki_pos, iov_iter_count(to), |
2991 | tcon->ses->server->vals->shared_lock_type, | 2978 | tcon->ses->server->vals->shared_lock_type, |
2992 | NULL, CIFS_READ_OP)) | 2979 | NULL, CIFS_READ_OP)) |
2993 | rc = generic_file_aio_read(iocb, iov, nr_segs, pos); | 2980 | rc = generic_file_read_iter(iocb, to); |
2994 | up_read(&cinode->lock_sem); | 2981 | up_read(&cinode->lock_sem); |
2995 | return rc; | 2982 | return rc; |
2996 | } | 2983 | } |
@@ -3703,8 +3690,8 @@ void cifs_oplock_break(struct work_struct *work) | |||
3703 | * Direct IO is not yet supported in the cached mode. | 3690 | * Direct IO is not yet supported in the cached mode. |
3704 | */ | 3691 | */ |
3705 | static ssize_t | 3692 | static ssize_t |
3706 | cifs_direct_io(int rw, struct kiocb *iocb, const struct iovec *iov, | 3693 | cifs_direct_io(int rw, struct kiocb *iocb, struct iov_iter *iter, |
3707 | loff_t pos, unsigned long nr_segs) | 3694 | loff_t pos) |
3708 | { | 3695 | { |
3709 | /* | 3696 | /* |
3710 | * FIXME | 3697 | * FIXME |