diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2014-03-03 22:09:39 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2014-05-06 17:32:43 -0400 |
commit | 0ae5e4d370599592eab845527b31708a4f3411be (patch) | |
tree | e4116194315802a5911b3cfcb5a9af82896c5e22 /fs | |
parent | f8579f8673b7ecdb7a81d5d5bb1d981093d9aa94 (diff) |
__btrfs_direct_write(): switch to iov_iter
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/file.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 9fe20c2052af..1dafe0701daf 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c | |||
@@ -1658,25 +1658,23 @@ again: | |||
1658 | } | 1658 | } |
1659 | 1659 | ||
1660 | static ssize_t __btrfs_direct_write(struct kiocb *iocb, | 1660 | static ssize_t __btrfs_direct_write(struct kiocb *iocb, |
1661 | const struct iovec *iov, | 1661 | struct iov_iter *from, |
1662 | unsigned long nr_segs, loff_t pos, | 1662 | loff_t pos, |
1663 | size_t count, size_t ocount) | 1663 | size_t count, size_t ocount) |
1664 | { | 1664 | { |
1665 | struct file *file = iocb->ki_filp; | 1665 | struct file *file = iocb->ki_filp; |
1666 | struct iov_iter i; | ||
1667 | ssize_t written; | 1666 | ssize_t written; |
1668 | ssize_t written_buffered; | 1667 | ssize_t written_buffered; |
1669 | loff_t endbyte; | 1668 | loff_t endbyte; |
1670 | int err; | 1669 | int err; |
1671 | 1670 | ||
1672 | iov_iter_init(&i, iov, nr_segs, count, 0); | 1671 | written = generic_file_direct_write(iocb, from, pos, count, ocount); |
1673 | written = generic_file_direct_write(iocb, &i, pos, count, ocount); | ||
1674 | 1672 | ||
1675 | if (written < 0 || written == count) | 1673 | if (written < 0 || written == count) |
1676 | return written; | 1674 | return written; |
1677 | 1675 | ||
1678 | pos += written; | 1676 | pos += written; |
1679 | written_buffered = __btrfs_buffered_write(file, &i, pos); | 1677 | written_buffered = __btrfs_buffered_write(file, from, pos); |
1680 | if (written_buffered < 0) { | 1678 | if (written_buffered < 0) { |
1681 | err = written_buffered; | 1679 | err = written_buffered; |
1682 | goto out; | 1680 | goto out; |
@@ -1724,6 +1722,7 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb, | |||
1724 | ssize_t err = 0; | 1722 | ssize_t err = 0; |
1725 | size_t count, ocount; | 1723 | size_t count, ocount; |
1726 | bool sync = (file->f_flags & O_DSYNC) || IS_SYNC(file->f_mapping->host); | 1724 | bool sync = (file->f_flags & O_DSYNC) || IS_SYNC(file->f_mapping->host); |
1725 | struct iov_iter i; | ||
1727 | 1726 | ||
1728 | mutex_lock(&inode->i_mutex); | 1727 | mutex_lock(&inode->i_mutex); |
1729 | 1728 | ||
@@ -1746,6 +1745,8 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb, | |||
1746 | goto out; | 1745 | goto out; |
1747 | } | 1746 | } |
1748 | 1747 | ||
1748 | iov_iter_init(&i, iov, nr_segs, count, 0); | ||
1749 | |||
1749 | err = file_remove_suid(file); | 1750 | err = file_remove_suid(file); |
1750 | if (err) { | 1751 | if (err) { |
1751 | mutex_unlock(&inode->i_mutex); | 1752 | mutex_unlock(&inode->i_mutex); |
@@ -1787,13 +1788,9 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb, | |||
1787 | atomic_inc(&BTRFS_I(inode)->sync_writers); | 1788 | atomic_inc(&BTRFS_I(inode)->sync_writers); |
1788 | 1789 | ||
1789 | if (unlikely(file->f_flags & O_DIRECT)) { | 1790 | if (unlikely(file->f_flags & O_DIRECT)) { |
1790 | num_written = __btrfs_direct_write(iocb, iov, nr_segs, | 1791 | num_written = __btrfs_direct_write(iocb, &i, |
1791 | pos, count, ocount); | 1792 | pos, count, ocount); |
1792 | } else { | 1793 | } else { |
1793 | struct iov_iter i; | ||
1794 | |||
1795 | iov_iter_init(&i, iov, nr_segs, count, num_written); | ||
1796 | |||
1797 | num_written = __btrfs_buffered_write(file, &i, pos); | 1794 | num_written = __btrfs_buffered_write(file, &i, pos); |
1798 | if (num_written > 0) | 1795 | if (num_written > 0) |
1799 | iocb->ki_pos = pos + num_written; | 1796 | iocb->ki_pos = pos + num_written; |