diff options
Diffstat (limited to 'fs/xfs/xfs_file.c')
-rw-r--r-- | fs/xfs/xfs_file.c | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index a2e1cb8a568b..1f12ad0a8585 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c | |||
@@ -38,7 +38,6 @@ | |||
38 | #include "xfs_icache.h" | 38 | #include "xfs_icache.h" |
39 | #include "xfs_pnfs.h" | 39 | #include "xfs_pnfs.h" |
40 | 40 | ||
41 | #include <linux/aio.h> | ||
42 | #include <linux/dcache.h> | 41 | #include <linux/dcache.h> |
43 | #include <linux/falloc.h> | 42 | #include <linux/falloc.h> |
44 | #include <linux/pagevec.h> | 43 | #include <linux/pagevec.h> |
@@ -280,7 +279,7 @@ xfs_file_read_iter( | |||
280 | 279 | ||
281 | XFS_STATS_INC(xs_read_calls); | 280 | XFS_STATS_INC(xs_read_calls); |
282 | 281 | ||
283 | if (unlikely(file->f_flags & O_DIRECT)) | 282 | if (unlikely(iocb->ki_flags & IOCB_DIRECT)) |
284 | ioflags |= XFS_IO_ISDIRECT; | 283 | ioflags |= XFS_IO_ISDIRECT; |
285 | if (file->f_mode & FMODE_NOCMTIME) | 284 | if (file->f_mode & FMODE_NOCMTIME) |
286 | ioflags |= XFS_IO_INVIS; | 285 | ioflags |= XFS_IO_INVIS; |
@@ -545,18 +544,19 @@ xfs_zero_eof( | |||
545 | */ | 544 | */ |
546 | STATIC ssize_t | 545 | STATIC ssize_t |
547 | xfs_file_aio_write_checks( | 546 | xfs_file_aio_write_checks( |
548 | struct file *file, | 547 | struct kiocb *iocb, |
549 | loff_t *pos, | 548 | struct iov_iter *from, |
550 | size_t *count, | ||
551 | int *iolock) | 549 | int *iolock) |
552 | { | 550 | { |
551 | struct file *file = iocb->ki_filp; | ||
553 | struct inode *inode = file->f_mapping->host; | 552 | struct inode *inode = file->f_mapping->host; |
554 | struct xfs_inode *ip = XFS_I(inode); | 553 | struct xfs_inode *ip = XFS_I(inode); |
555 | int error = 0; | 554 | ssize_t error = 0; |
555 | size_t count = iov_iter_count(from); | ||
556 | 556 | ||
557 | restart: | 557 | restart: |
558 | error = generic_write_checks(file, pos, count, S_ISBLK(inode->i_mode)); | 558 | error = generic_write_checks(iocb, from); |
559 | if (error) | 559 | if (error <= 0) |
560 | return error; | 560 | return error; |
561 | 561 | ||
562 | error = xfs_break_layouts(inode, iolock); | 562 | error = xfs_break_layouts(inode, iolock); |
@@ -570,16 +570,17 @@ restart: | |||
570 | * iolock shared, we need to update it to exclusive which implies | 570 | * iolock shared, we need to update it to exclusive which implies |
571 | * having to redo all checks before. | 571 | * having to redo all checks before. |
572 | */ | 572 | */ |
573 | if (*pos > i_size_read(inode)) { | 573 | if (iocb->ki_pos > i_size_read(inode)) { |
574 | bool zero = false; | 574 | bool zero = false; |
575 | 575 | ||
576 | if (*iolock == XFS_IOLOCK_SHARED) { | 576 | if (*iolock == XFS_IOLOCK_SHARED) { |
577 | xfs_rw_iunlock(ip, *iolock); | 577 | xfs_rw_iunlock(ip, *iolock); |
578 | *iolock = XFS_IOLOCK_EXCL; | 578 | *iolock = XFS_IOLOCK_EXCL; |
579 | xfs_rw_ilock(ip, *iolock); | 579 | xfs_rw_ilock(ip, *iolock); |
580 | iov_iter_reexpand(from, count); | ||
580 | goto restart; | 581 | goto restart; |
581 | } | 582 | } |
582 | error = xfs_zero_eof(ip, *pos, i_size_read(inode), &zero); | 583 | error = xfs_zero_eof(ip, iocb->ki_pos, i_size_read(inode), &zero); |
583 | if (error) | 584 | if (error) |
584 | return error; | 585 | return error; |
585 | } | 586 | } |
@@ -679,10 +680,11 @@ xfs_file_dio_aio_write( | |||
679 | xfs_rw_ilock(ip, iolock); | 680 | xfs_rw_ilock(ip, iolock); |
680 | } | 681 | } |
681 | 682 | ||
682 | ret = xfs_file_aio_write_checks(file, &pos, &count, &iolock); | 683 | ret = xfs_file_aio_write_checks(iocb, from, &iolock); |
683 | if (ret) | 684 | if (ret) |
684 | goto out; | 685 | goto out; |
685 | iov_iter_truncate(from, count); | 686 | count = iov_iter_count(from); |
687 | pos = iocb->ki_pos; | ||
686 | 688 | ||
687 | if (mapping->nrpages) { | 689 | if (mapping->nrpages) { |
688 | ret = filemap_write_and_wait_range(VFS_I(ip)->i_mapping, | 690 | ret = filemap_write_and_wait_range(VFS_I(ip)->i_mapping, |
@@ -735,24 +737,22 @@ xfs_file_buffered_aio_write( | |||
735 | ssize_t ret; | 737 | ssize_t ret; |
736 | int enospc = 0; | 738 | int enospc = 0; |
737 | int iolock = XFS_IOLOCK_EXCL; | 739 | int iolock = XFS_IOLOCK_EXCL; |
738 | loff_t pos = iocb->ki_pos; | ||
739 | size_t count = iov_iter_count(from); | ||
740 | 740 | ||
741 | xfs_rw_ilock(ip, iolock); | 741 | xfs_rw_ilock(ip, iolock); |
742 | 742 | ||
743 | ret = xfs_file_aio_write_checks(file, &pos, &count, &iolock); | 743 | ret = xfs_file_aio_write_checks(iocb, from, &iolock); |
744 | if (ret) | 744 | if (ret) |
745 | goto out; | 745 | goto out; |
746 | 746 | ||
747 | iov_iter_truncate(from, count); | ||
748 | /* We can write back this queue in page reclaim */ | 747 | /* We can write back this queue in page reclaim */ |
749 | current->backing_dev_info = inode_to_bdi(inode); | 748 | current->backing_dev_info = inode_to_bdi(inode); |
750 | 749 | ||
751 | write_retry: | 750 | write_retry: |
752 | trace_xfs_file_buffered_write(ip, count, iocb->ki_pos, 0); | 751 | trace_xfs_file_buffered_write(ip, iov_iter_count(from), |
753 | ret = generic_perform_write(file, from, pos); | 752 | iocb->ki_pos, 0); |
753 | ret = generic_perform_write(file, from, iocb->ki_pos); | ||
754 | if (likely(ret >= 0)) | 754 | if (likely(ret >= 0)) |
755 | iocb->ki_pos = pos + ret; | 755 | iocb->ki_pos += ret; |
756 | 756 | ||
757 | /* | 757 | /* |
758 | * If we hit a space limit, try to free up some lingering preallocated | 758 | * If we hit a space limit, try to free up some lingering preallocated |
@@ -804,7 +804,7 @@ xfs_file_write_iter( | |||
804 | if (XFS_FORCED_SHUTDOWN(ip->i_mount)) | 804 | if (XFS_FORCED_SHUTDOWN(ip->i_mount)) |
805 | return -EIO; | 805 | return -EIO; |
806 | 806 | ||
807 | if (unlikely(file->f_flags & O_DIRECT)) | 807 | if (unlikely(iocb->ki_flags & IOCB_DIRECT)) |
808 | ret = xfs_file_dio_aio_write(iocb, from); | 808 | ret = xfs_file_dio_aio_write(iocb, from); |
809 | else | 809 | else |
810 | ret = xfs_file_buffered_aio_write(iocb, from); | 810 | ret = xfs_file_buffered_aio_write(iocb, from); |
@@ -1387,8 +1387,6 @@ xfs_file_llseek( | |||
1387 | 1387 | ||
1388 | const struct file_operations xfs_file_operations = { | 1388 | const struct file_operations xfs_file_operations = { |
1389 | .llseek = xfs_file_llseek, | 1389 | .llseek = xfs_file_llseek, |
1390 | .read = new_sync_read, | ||
1391 | .write = new_sync_write, | ||
1392 | .read_iter = xfs_file_read_iter, | 1390 | .read_iter = xfs_file_read_iter, |
1393 | .write_iter = xfs_file_write_iter, | 1391 | .write_iter = xfs_file_write_iter, |
1394 | .splice_read = xfs_file_splice_read, | 1392 | .splice_read = xfs_file_splice_read, |