aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2014-04-03 12:05:17 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2014-05-06 17:39:37 -0400
commit3dae8750c368f8ac11c3c8c2a28f56dcee865c01 (patch)
tree49ff95ab7bd8391325a1651b2c30bb0098f6ff2c /fs/cifs
parentd4637bc18f3bf89bd63fe7b967043523aa3a6170 (diff)
cifs: switch to ->write_iter()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/cifs')
-rw-r--r--fs/cifs/cifsfs.c31
-rw-r--r--fs/cifs/cifsfs.h6
-rw-r--r--fs/cifs/file.c40
3 files changed, 35 insertions, 42 deletions
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index f0a567a344cf..496b520934e0 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -733,8 +733,7 @@ out_nls:
733 goto out; 733 goto out;
734} 734}
735 735
736static ssize_t cifs_file_aio_write(struct kiocb *iocb, const struct iovec *iov, 736static ssize_t cifs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
737 unsigned long nr_segs, loff_t pos)
738{ 737{
739 struct inode *inode = file_inode(iocb->ki_filp); 738 struct inode *inode = file_inode(iocb->ki_filp);
740 struct cifsInodeInfo *cinode = CIFS_I(inode); 739 struct cifsInodeInfo *cinode = CIFS_I(inode);
@@ -745,14 +744,14 @@ static ssize_t cifs_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
745 if (written) 744 if (written)
746 return written; 745 return written;
747 746
748 written = generic_file_aio_write(iocb, iov, nr_segs, pos); 747 written = generic_file_write_iter(iocb, from);
749 748
750 if (CIFS_CACHE_WRITE(CIFS_I(inode))) 749 if (CIFS_CACHE_WRITE(CIFS_I(inode)))
751 goto out; 750 goto out;
752 751
753 rc = filemap_fdatawrite(inode->i_mapping); 752 rc = filemap_fdatawrite(inode->i_mapping);
754 if (rc) 753 if (rc)
755 cifs_dbg(FYI, "cifs_file_aio_write: %d rc on %p inode\n", 754 cifs_dbg(FYI, "cifs_file_write_iter: %d rc on %p inode\n",
756 rc, inode); 755 rc, inode);
757 756
758out: 757out:
@@ -889,9 +888,9 @@ const struct inode_operations cifs_symlink_inode_ops = {
889 888
890const struct file_operations cifs_file_ops = { 889const struct file_operations cifs_file_ops = {
891 .read = new_sync_read, 890 .read = new_sync_read,
892 .write = do_sync_write, 891 .write = new_sync_write,
893 .read_iter = generic_file_read_iter, 892 .read_iter = generic_file_read_iter,
894 .aio_write = cifs_file_aio_write, 893 .write_iter = cifs_file_write_iter,
895 .open = cifs_open, 894 .open = cifs_open,
896 .release = cifs_close, 895 .release = cifs_close,
897 .lock = cifs_lock, 896 .lock = cifs_lock,
@@ -908,9 +907,9 @@ const struct file_operations cifs_file_ops = {
908 907
909const struct file_operations cifs_file_strict_ops = { 908const struct file_operations cifs_file_strict_ops = {
910 .read = new_sync_read, 909 .read = new_sync_read,
911 .write = do_sync_write, 910 .write = new_sync_write,
912 .read_iter = cifs_strict_readv, 911 .read_iter = cifs_strict_readv,
913 .aio_write = cifs_strict_writev, 912 .write_iter = cifs_strict_writev,
914 .open = cifs_open, 913 .open = cifs_open,
915 .release = cifs_close, 914 .release = cifs_close,
916 .lock = cifs_lock, 915 .lock = cifs_lock,
@@ -928,9 +927,9 @@ const struct file_operations cifs_file_strict_ops = {
928const struct file_operations cifs_file_direct_ops = { 927const struct file_operations cifs_file_direct_ops = {
929 /* BB reevaluate whether they can be done with directio, no cache */ 928 /* BB reevaluate whether they can be done with directio, no cache */
930 .read = new_sync_read, 929 .read = new_sync_read,
931 .write = do_sync_write, 930 .write = new_sync_write,
932 .read_iter = cifs_user_readv, 931 .read_iter = cifs_user_readv,
933 .aio_write = cifs_user_writev, 932 .write_iter = cifs_user_writev,
934 .open = cifs_open, 933 .open = cifs_open,
935 .release = cifs_close, 934 .release = cifs_close,
936 .lock = cifs_lock, 935 .lock = cifs_lock,
@@ -947,9 +946,9 @@ const struct file_operations cifs_file_direct_ops = {
947 946
948const struct file_operations cifs_file_nobrl_ops = { 947const struct file_operations cifs_file_nobrl_ops = {
949 .read = new_sync_read, 948 .read = new_sync_read,
950 .write = do_sync_write, 949 .write = new_sync_write,
951 .read_iter = generic_file_read_iter, 950 .read_iter = generic_file_read_iter,
952 .aio_write = cifs_file_aio_write, 951 .write_iter = cifs_file_write_iter,
953 .open = cifs_open, 952 .open = cifs_open,
954 .release = cifs_close, 953 .release = cifs_close,
955 .fsync = cifs_fsync, 954 .fsync = cifs_fsync,
@@ -965,9 +964,9 @@ const struct file_operations cifs_file_nobrl_ops = {
965 964
966const struct file_operations cifs_file_strict_nobrl_ops = { 965const struct file_operations cifs_file_strict_nobrl_ops = {
967 .read = new_sync_read, 966 .read = new_sync_read,
968 .write = do_sync_write, 967 .write = new_sync_write,
969 .read_iter = cifs_strict_readv, 968 .read_iter = cifs_strict_readv,
970 .aio_write = cifs_strict_writev, 969 .write_iter = cifs_strict_writev,
971 .open = cifs_open, 970 .open = cifs_open,
972 .release = cifs_close, 971 .release = cifs_close,
973 .fsync = cifs_strict_fsync, 972 .fsync = cifs_strict_fsync,
@@ -984,9 +983,9 @@ const struct file_operations cifs_file_strict_nobrl_ops = {
984const struct file_operations cifs_file_direct_nobrl_ops = { 983const struct file_operations cifs_file_direct_nobrl_ops = {
985 /* BB reevaluate whether they can be done with directio, no cache */ 984 /* BB reevaluate whether they can be done with directio, no cache */
986 .read = new_sync_read, 985 .read = new_sync_read,
987 .write = do_sync_write, 986 .write = new_sync_write,
988 .read_iter = cifs_user_readv, 987 .read_iter = cifs_user_readv,
989 .aio_write = cifs_user_writev, 988 .write_iter = cifs_user_writev,
990 .open = cifs_open, 989 .open = cifs_open,
991 .release = cifs_close, 990 .release = cifs_close,
992 .fsync = cifs_fsync, 991 .fsync = cifs_fsync,
diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h
index d1ef0415c645..c9e91886f0cf 100644
--- a/fs/cifs/cifsfs.h
+++ b/fs/cifs/cifsfs.h
@@ -87,10 +87,8 @@ extern int cifs_close(struct inode *inode, struct file *file);
87extern int cifs_closedir(struct inode *inode, struct file *file); 87extern int cifs_closedir(struct inode *inode, struct file *file);
88extern ssize_t cifs_user_readv(struct kiocb *iocb, struct iov_iter *to); 88extern ssize_t cifs_user_readv(struct kiocb *iocb, struct iov_iter *to);
89extern ssize_t cifs_strict_readv(struct kiocb *iocb, struct iov_iter *to); 89extern ssize_t cifs_strict_readv(struct kiocb *iocb, struct iov_iter *to);
90extern ssize_t cifs_user_writev(struct kiocb *iocb, const struct iovec *iov, 90extern ssize_t cifs_user_writev(struct kiocb *iocb, struct iov_iter *from);
91 unsigned long nr_segs, loff_t pos); 91extern ssize_t cifs_strict_writev(struct kiocb *iocb, struct iov_iter *from);
92extern ssize_t cifs_strict_writev(struct kiocb *iocb, const struct iovec *iov,
93 unsigned long nr_segs, loff_t pos);
94extern int cifs_lock(struct file *, int, struct file_lock *); 92extern int cifs_lock(struct file *, int, struct file_lock *);
95extern int cifs_fsync(struct file *, loff_t, loff_t, int); 93extern int cifs_fsync(struct file *, loff_t, loff_t, int);
96extern int cifs_strict_fsync(struct file *, loff_t, loff_t, int); 94extern int cifs_strict_fsync(struct file *, loff_t, loff_t, int);
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 2ec7fce6d350..60e9b5fa2212 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
2387static ssize_t 2387static ssize_t
2388cifs_iovec_write(struct file *file, const struct iovec *iov, 2388cifs_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, WRITE, iov, nr_segs, len);
2428 do { 2427 do {
2429 size_t save_len; 2428 size_t save_len;
2430 2429
@@ -2446,7 +2445,7 @@ cifs_iovec_write(struct file *file, const struct iovec *iov,
2446 for (i = 0; i < nr_pages; i++) { 2445 for (i = 0; i < nr_pages; i++) {
2447 bytes = min_t(size_t, cur_len, PAGE_SIZE); 2446 bytes = min_t(size_t, cur_len, PAGE_SIZE);
2448 copied = copy_page_from_iter(wdata->pages[i], 0, bytes, 2447 copied = copy_page_from_iter(wdata->pages[i], 0, bytes,
2449 &it); 2448 from);
2450 cur_len -= copied; 2449 cur_len -= copied;
2451 /* 2450 /*
2452 * 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
@@ -2545,11 +2544,11 @@ restart_loop:
2545 return total_written ? total_written : (ssize_t)rc; 2544 return total_written ? total_written : (ssize_t)rc;
2546} 2545}
2547 2546
2548ssize_t cifs_user_writev(struct kiocb *iocb, const struct iovec *iov, 2547ssize_t cifs_user_writev(struct kiocb *iocb, struct iov_iter *from)
2549 unsigned long nr_segs, loff_t pos)
2550{ 2548{
2551 ssize_t written; 2549 ssize_t written;
2552 struct inode *inode; 2550 struct inode *inode;
2551 loff_t pos = iocb->ki_pos;
2553 2552
2554 inode = file_inode(iocb->ki_filp); 2553 inode = file_inode(iocb->ki_filp);
2555 2554
@@ -2559,7 +2558,7 @@ ssize_t cifs_user_writev(struct kiocb *iocb, const struct iovec *iov,
2559 * write request. 2558 * write request.
2560 */ 2559 */
2561 2560
2562 written = cifs_iovec_write(iocb->ki_filp, iov, nr_segs, &pos); 2561 written = cifs_iovec_write(iocb->ki_filp, from, &pos);
2563 if (written > 0) { 2562 if (written > 0) {
2564 CIFS_I(inode)->invalid_mapping = true; 2563 CIFS_I(inode)->invalid_mapping = true;
2565 iocb->ki_pos = pos; 2564 iocb->ki_pos = pos;
@@ -2569,8 +2568,7 @@ ssize_t cifs_user_writev(struct kiocb *iocb, const struct iovec *iov,
2569} 2568}
2570 2569
2571static ssize_t 2570static ssize_t
2572cifs_writev(struct kiocb *iocb, const struct iovec *iov, 2571cifs_writev(struct kiocb *iocb, struct iov_iter *from)
2573 unsigned long nr_segs, loff_t pos)
2574{ 2572{
2575 struct file *file = iocb->ki_filp; 2573 struct file *file = iocb->ki_filp;
2576 struct cifsFileInfo *cfile = (struct cifsFileInfo *)file->private_data; 2574 struct cifsFileInfo *cfile = (struct cifsFileInfo *)file->private_data;
@@ -2588,10 +2586,10 @@ cifs_writev(struct kiocb *iocb, const struct iovec *iov,
2588 mutex_lock(&inode->i_mutex); 2586 mutex_lock(&inode->i_mutex);
2589 if (file->f_flags & O_APPEND) 2587 if (file->f_flags & O_APPEND)
2590 lock_pos = i_size_read(inode); 2588 lock_pos = i_size_read(inode);
2591 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),
2592 server->vals->exclusive_lock_type, NULL, 2590 server->vals->exclusive_lock_type, NULL,
2593 CIFS_WRITE_OP)) { 2591 CIFS_WRITE_OP)) {
2594 rc = __generic_file_aio_write(iocb, iov, nr_segs); 2592 rc = __generic_file_write_iter(iocb, from);
2595 mutex_unlock(&inode->i_mutex); 2593 mutex_unlock(&inode->i_mutex);
2596 2594
2597 if (rc > 0) { 2595 if (rc > 0) {
@@ -2609,8 +2607,7 @@ cifs_writev(struct kiocb *iocb, const struct iovec *iov,
2609} 2607}
2610 2608
2611ssize_t 2609ssize_t
2612cifs_strict_writev(struct kiocb *iocb, const struct iovec *iov, 2610cifs_strict_writev(struct kiocb *iocb, struct iov_iter *from)
2613 unsigned long nr_segs, loff_t pos)
2614{ 2611{
2615 struct inode *inode = file_inode(iocb->ki_filp); 2612 struct inode *inode = file_inode(iocb->ki_filp);
2616 struct cifsInodeInfo *cinode = CIFS_I(inode); 2613 struct cifsInodeInfo *cinode = CIFS_I(inode);
@@ -2628,11 +2625,10 @@ cifs_strict_writev(struct kiocb *iocb, const struct iovec *iov,
2628 if (cap_unix(tcon->ses) && 2625 if (cap_unix(tcon->ses) &&
2629 (CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) 2626 (CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability))
2630 && ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0)) { 2627 && ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0)) {
2631 written = generic_file_aio_write( 2628 written = generic_file_write_iter(iocb, from);
2632 iocb, iov, nr_segs, pos);
2633 goto out; 2629 goto out;
2634 } 2630 }
2635 written = cifs_writev(iocb, iov, nr_segs, pos); 2631 written = cifs_writev(iocb, from);
2636 goto out; 2632 goto out;
2637 } 2633 }
2638 /* 2634 /*
@@ -2641,7 +2637,7 @@ cifs_strict_writev(struct kiocb *iocb, const struct iovec *iov,
2641 * 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
2642 * 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.
2643 */ 2639 */
2644 written = cifs_user_writev(iocb, iov, nr_segs, pos); 2640 written = cifs_user_writev(iocb, from);
2645 if (written > 0 && CIFS_CACHE_READ(cinode)) { 2641 if (written > 0 && CIFS_CACHE_READ(cinode)) {
2646 /* 2642 /*
2647 * Windows 7 server can delay breaking level2 oplock if a write 2643 * Windows 7 server can delay breaking level2 oplock if a write