diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2014-03-22 06:51:37 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2014-05-06 17:32:54 -0400 |
commit | 0c949334a9e2581646c6ff0d1470a805b1e5be99 (patch) | |
tree | 60a4d6bc2260d648915baa9b78626cd4b6915431 /fs/btrfs | |
parent | 28060d5d9b261da110afe48aae7a2aa6555f798f (diff) |
iov_iter_truncate()
Now It Can Be Done(tm) - we don't need to do iov_shorten() in
generic_file_direct_write() anymore, now that all ->direct_IO()
instances are converted to proper iov_iter methods and honour
iter->count and iter->iov_offset properly.
Get rid of count/ocount arguments of generic_file_direct_write(),
while we are at it.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/file.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index f8cee205618a..ea63a51c148c 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c | |||
@@ -1659,8 +1659,7 @@ again: | |||
1659 | 1659 | ||
1660 | static ssize_t __btrfs_direct_write(struct kiocb *iocb, | 1660 | static ssize_t __btrfs_direct_write(struct kiocb *iocb, |
1661 | struct iov_iter *from, | 1661 | struct iov_iter *from, |
1662 | loff_t pos, | 1662 | loff_t pos) |
1663 | size_t count, size_t ocount) | ||
1664 | { | 1663 | { |
1665 | struct file *file = iocb->ki_filp; | 1664 | struct file *file = iocb->ki_filp; |
1666 | ssize_t written; | 1665 | ssize_t written; |
@@ -1668,9 +1667,9 @@ static ssize_t __btrfs_direct_write(struct kiocb *iocb, | |||
1668 | loff_t endbyte; | 1667 | loff_t endbyte; |
1669 | int err; | 1668 | int err; |
1670 | 1669 | ||
1671 | written = generic_file_direct_write(iocb, from, pos, count, ocount); | 1670 | written = generic_file_direct_write(iocb, from, pos); |
1672 | 1671 | ||
1673 | if (written < 0 || written == count) | 1672 | if (written < 0 || !iov_iter_count(from)) |
1674 | return written; | 1673 | return written; |
1675 | 1674 | ||
1676 | pos += written; | 1675 | pos += written; |
@@ -1720,13 +1719,14 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb, | |||
1720 | u64 end_pos; | 1719 | u64 end_pos; |
1721 | ssize_t num_written = 0; | 1720 | ssize_t num_written = 0; |
1722 | ssize_t err = 0; | 1721 | ssize_t err = 0; |
1723 | size_t count, ocount; | 1722 | size_t count; |
1724 | bool sync = (file->f_flags & O_DSYNC) || IS_SYNC(file->f_mapping->host); | 1723 | bool sync = (file->f_flags & O_DSYNC) || IS_SYNC(file->f_mapping->host); |
1725 | struct iov_iter i; | 1724 | struct iov_iter i; |
1726 | 1725 | ||
1727 | mutex_lock(&inode->i_mutex); | 1726 | mutex_lock(&inode->i_mutex); |
1728 | 1727 | ||
1729 | count = ocount = iov_length(iov, nr_segs); | 1728 | count = iov_length(iov, nr_segs); |
1729 | iov_iter_init(&i, WRITE, iov, nr_segs, count); | ||
1730 | 1730 | ||
1731 | current->backing_dev_info = inode->i_mapping->backing_dev_info; | 1731 | current->backing_dev_info = inode->i_mapping->backing_dev_info; |
1732 | err = generic_write_checks(file, &pos, &count, S_ISBLK(inode->i_mode)); | 1732 | err = generic_write_checks(file, &pos, &count, S_ISBLK(inode->i_mode)); |
@@ -1740,7 +1740,7 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb, | |||
1740 | goto out; | 1740 | goto out; |
1741 | } | 1741 | } |
1742 | 1742 | ||
1743 | iov_iter_init(&i, WRITE, iov, nr_segs, count); | 1743 | iov_iter_truncate(&i, count); |
1744 | 1744 | ||
1745 | err = file_remove_suid(file); | 1745 | err = file_remove_suid(file); |
1746 | if (err) { | 1746 | if (err) { |
@@ -1783,8 +1783,7 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb, | |||
1783 | atomic_inc(&BTRFS_I(inode)->sync_writers); | 1783 | atomic_inc(&BTRFS_I(inode)->sync_writers); |
1784 | 1784 | ||
1785 | if (unlikely(file->f_flags & O_DIRECT)) { | 1785 | if (unlikely(file->f_flags & O_DIRECT)) { |
1786 | num_written = __btrfs_direct_write(iocb, &i, | 1786 | num_written = __btrfs_direct_write(iocb, &i, pos); |
1787 | pos, count, ocount); | ||
1788 | } else { | 1787 | } else { |
1789 | num_written = __btrfs_buffered_write(file, &i, pos); | 1788 | num_written = __btrfs_buffered_write(file, &i, pos); |
1790 | if (num_written > 0) | 1789 | if (num_written > 0) |