Commit 3dae8750c368f8ac11c3c8c2a28f56dcee865c01

Authored by Al Viro
1 parent d4637bc18f

cifs: switch to ->write_iter()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Showing 3 changed files with 35 additions and 42 deletions Side-by-side Diff

... ... @@ -733,8 +733,7 @@
733 733 goto out;
734 734 }
735 735  
736   -static ssize_t cifs_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
737   - unsigned long nr_segs, loff_t pos)
  736 +static ssize_t cifs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
738 737 {
739 738 struct inode *inode = file_inode(iocb->ki_filp);
740 739 struct cifsInodeInfo *cinode = CIFS_I(inode);
741 740  
... ... @@ -745,14 +744,14 @@
745 744 if (written)
746 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 749 if (CIFS_CACHE_WRITE(CIFS_I(inode)))
751 750 goto out;
752 751  
753 752 rc = filemap_fdatawrite(inode->i_mapping);
754 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 755 rc, inode);
757 756  
758 757 out:
759 758  
... ... @@ -889,9 +888,9 @@
889 888  
890 889 const struct file_operations cifs_file_ops = {
891 890 .read = new_sync_read,
892   - .write = do_sync_write,
  891 + .write = new_sync_write,
893 892 .read_iter = generic_file_read_iter,
894   - .aio_write = cifs_file_aio_write,
  893 + .write_iter = cifs_file_write_iter,
895 894 .open = cifs_open,
896 895 .release = cifs_close,
897 896 .lock = cifs_lock,
898 897  
... ... @@ -908,9 +907,9 @@
908 907  
909 908 const struct file_operations cifs_file_strict_ops = {
910 909 .read = new_sync_read,
911   - .write = do_sync_write,
  910 + .write = new_sync_write,
912 911 .read_iter = cifs_strict_readv,
913   - .aio_write = cifs_strict_writev,
  912 + .write_iter = cifs_strict_writev,
914 913 .open = cifs_open,
915 914 .release = cifs_close,
916 915 .lock = cifs_lock,
917 916  
... ... @@ -928,9 +927,9 @@
928 927 const struct file_operations cifs_file_direct_ops = {
929 928 /* BB reevaluate whether they can be done with directio, no cache */
930 929 .read = new_sync_read,
931   - .write = do_sync_write,
  930 + .write = new_sync_write,
932 931 .read_iter = cifs_user_readv,
933   - .aio_write = cifs_user_writev,
  932 + .write_iter = cifs_user_writev,
934 933 .open = cifs_open,
935 934 .release = cifs_close,
936 935 .lock = cifs_lock,
937 936  
... ... @@ -947,9 +946,9 @@
947 946  
948 947 const struct file_operations cifs_file_nobrl_ops = {
949 948 .read = new_sync_read,
950   - .write = do_sync_write,
  949 + .write = new_sync_write,
951 950 .read_iter = generic_file_read_iter,
952   - .aio_write = cifs_file_aio_write,
  951 + .write_iter = cifs_file_write_iter,
953 952 .open = cifs_open,
954 953 .release = cifs_close,
955 954 .fsync = cifs_fsync,
956 955  
... ... @@ -965,9 +964,9 @@
965 964  
966 965 const struct file_operations cifs_file_strict_nobrl_ops = {
967 966 .read = new_sync_read,
968   - .write = do_sync_write,
  967 + .write = new_sync_write,
969 968 .read_iter = cifs_strict_readv,
970   - .aio_write = cifs_strict_writev,
  969 + .write_iter = cifs_strict_writev,
971 970 .open = cifs_open,
972 971 .release = cifs_close,
973 972 .fsync = cifs_strict_fsync,
974 973  
... ... @@ -984,9 +983,9 @@
984 983 const struct file_operations cifs_file_direct_nobrl_ops = {
985 984 /* BB reevaluate whether they can be done with directio, no cache */
986 985 .read = new_sync_read,
987   - .write = do_sync_write,
  986 + .write = new_sync_write,
988 987 .read_iter = cifs_user_readv,
989   - .aio_write = cifs_user_writev,
  988 + .write_iter = cifs_user_writev,
990 989 .open = cifs_open,
991 990 .release = cifs_close,
992 991 .fsync = cifs_fsync,
... ... @@ -87,10 +87,8 @@
87 87 extern int cifs_closedir(struct inode *inode, struct file *file);
88 88 extern ssize_t cifs_user_readv(struct kiocb *iocb, struct iov_iter *to);
89 89 extern ssize_t cifs_strict_readv(struct kiocb *iocb, struct iov_iter *to);
90   -extern ssize_t cifs_user_writev(struct kiocb *iocb, const struct iovec *iov,
91   - unsigned long nr_segs, loff_t pos);
92   -extern ssize_t cifs_strict_writev(struct kiocb *iocb, const struct iovec *iov,
93   - unsigned long nr_segs, loff_t pos);
  90 +extern ssize_t cifs_user_writev(struct kiocb *iocb, struct iov_iter *from);
  91 +extern ssize_t cifs_strict_writev(struct kiocb *iocb, struct iov_iter *from);
94 92 extern int cifs_lock(struct file *, int, struct file_lock *);
95 93 extern int cifs_fsync(struct file *, loff_t, loff_t, int);
96 94 extern int cifs_strict_fsync(struct file *, loff_t, loff_t, int);
... ... @@ -2385,14 +2385,12 @@
2385 2385 }
2386 2386  
2387 2387 static ssize_t
2388   -cifs_iovec_write(struct file *file, const struct iovec *iov,
2389   - unsigned long nr_segs, loff_t *poffset)
  2388 +cifs_iovec_write(struct file *file, struct iov_iter *from, loff_t *poffset)
2390 2389 {
2391 2390 unsigned long nr_pages, i;
2392 2391 size_t bytes, copied, len, cur_len;
2393 2392 ssize_t total_written = 0;
2394 2393 loff_t offset;
2395   - struct iov_iter it;
2396 2394 struct cifsFileInfo *open_file;
2397 2395 struct cifs_tcon *tcon;
2398 2396 struct cifs_sb_info *cifs_sb;
2399 2397  
... ... @@ -2401,14 +2399,16 @@
2401 2399 int rc;
2402 2400 pid_t pid;
2403 2401  
2404   - len = iov_length(iov, nr_segs);
2405   - if (!len)
2406   - return 0;
2407   -
  2402 + len = iov_iter_count(from);
2408 2403 rc = generic_write_checks(file, poffset, &len, 0);
2409 2404 if (rc)
2410 2405 return rc;
2411 2406  
  2407 + if (!len)
  2408 + return 0;
  2409 +
  2410 + iov_iter_truncate(from, len);
  2411 +
2412 2412 INIT_LIST_HEAD(&wdata_list);
2413 2413 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
2414 2414 open_file = file->private_data;
... ... @@ -2424,7 +2424,6 @@
2424 2424 else
2425 2425 pid = current->tgid;
2426 2426  
2427   - iov_iter_init(&it, WRITE, iov, nr_segs, len);
2428 2427 do {
2429 2428 size_t save_len;
2430 2429  
... ... @@ -2446,7 +2445,7 @@
2446 2445 for (i = 0; i < nr_pages; i++) {
2447 2446 bytes = min_t(size_t, cur_len, PAGE_SIZE);
2448 2447 copied = copy_page_from_iter(wdata->pages[i], 0, bytes,
2449   - &it);
  2448 + from);
2450 2449 cur_len -= copied;
2451 2450 /*
2452 2451 * If we didn't copy as much as we expected, then that
2453 2452  
... ... @@ -2545,11 +2544,11 @@
2545 2544 return total_written ? total_written : (ssize_t)rc;
2546 2545 }
2547 2546  
2548   -ssize_t cifs_user_writev(struct kiocb *iocb, const struct iovec *iov,
2549   - unsigned long nr_segs, loff_t pos)
  2547 +ssize_t cifs_user_writev(struct kiocb *iocb, struct iov_iter *from)
2550 2548 {
2551 2549 ssize_t written;
2552 2550 struct inode *inode;
  2551 + loff_t pos = iocb->ki_pos;
2553 2552  
2554 2553 inode = file_inode(iocb->ki_filp);
2555 2554  
... ... @@ -2559,7 +2558,7 @@
2559 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 2562 if (written > 0) {
2564 2563 CIFS_I(inode)->invalid_mapping = true;
2565 2564 iocb->ki_pos = pos;
... ... @@ -2569,8 +2568,7 @@
2569 2568 }
2570 2569  
2571 2570 static ssize_t
2572   -cifs_writev(struct kiocb *iocb, const struct iovec *iov,
2573   - unsigned long nr_segs, loff_t pos)
  2571 +cifs_writev(struct kiocb *iocb, struct iov_iter *from)
2574 2572 {
2575 2573 struct file *file = iocb->ki_filp;
2576 2574 struct cifsFileInfo *cfile = (struct cifsFileInfo *)file->private_data;
2577 2575  
... ... @@ -2588,10 +2586,10 @@
2588 2586 mutex_lock(&inode->i_mutex);
2589 2587 if (file->f_flags & O_APPEND)
2590 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 2590 server->vals->exclusive_lock_type, NULL,
2593 2591 CIFS_WRITE_OP)) {
2594   - rc = __generic_file_aio_write(iocb, iov, nr_segs);
  2592 + rc = __generic_file_write_iter(iocb, from);
2595 2593 mutex_unlock(&inode->i_mutex);
2596 2594  
2597 2595 if (rc > 0) {
... ... @@ -2609,8 +2607,7 @@
2609 2607 }
2610 2608  
2611 2609 ssize_t
2612   -cifs_strict_writev(struct kiocb *iocb, const struct iovec *iov,
2613   - unsigned long nr_segs, loff_t pos)
  2610 +cifs_strict_writev(struct kiocb *iocb, struct iov_iter *from)
2614 2611 {
2615 2612 struct inode *inode = file_inode(iocb->ki_filp);
2616 2613 struct cifsInodeInfo *cinode = CIFS_I(inode);
2617 2614  
... ... @@ -2628,11 +2625,10 @@
2628 2625 if (cap_unix(tcon->ses) &&
2629 2626 (CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability))
2630 2627 && ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0)) {
2631   - written = generic_file_aio_write(
2632   - iocb, iov, nr_segs, pos);
  2628 + written = generic_file_write_iter(iocb, from);
2633 2629 goto out;
2634 2630 }
2635   - written = cifs_writev(iocb, iov, nr_segs, pos);
  2631 + written = cifs_writev(iocb, from);
2636 2632 goto out;
2637 2633 }
2638 2634 /*
... ... @@ -2641,7 +2637,7 @@
2641 2637 * affected pages because it may cause a error with mandatory locks on
2642 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 2641 if (written > 0 && CIFS_CACHE_READ(cinode)) {
2646 2642 /*
2647 2643 * Windows 7 server can delay breaking level2 oplock if a write