aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/file.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2015-04-09 12:55:47 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2015-04-11 22:30:21 -0400
commit3309dd04cbcd2cdad168485af5cf3576b5051e49 (patch)
tree3e01f865306dee01b31f34c9e7e819a5f42a4087 /fs/btrfs/file.c
parent90320251db0fe3d05f2b10686ec936c7d6ecd99a (diff)
switch generic_write_checks() to iocb and iter
... returning -E... upon error and amount of data left in iter after (possible) truncation upon success. Note, that normal case gives a non-zero (positive) return value, so any tests for != 0 _must_ be updated. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Conflicts: fs/ext4/file.c
Diffstat (limited to 'fs/btrfs/file.c')
-rw-r--r--fs/btrfs/file.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 691a84a81e09..c64d11c41eeb 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1739,27 +1739,19 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb,
1739 u64 start_pos; 1739 u64 start_pos;
1740 u64 end_pos; 1740 u64 end_pos;
1741 ssize_t num_written = 0; 1741 ssize_t num_written = 0;
1742 ssize_t err = 0;
1743 size_t count = iov_iter_count(from);
1744 bool sync = (file->f_flags & O_DSYNC) || IS_SYNC(file->f_mapping->host); 1742 bool sync = (file->f_flags & O_DSYNC) || IS_SYNC(file->f_mapping->host);
1745 loff_t pos = iocb->ki_pos; 1743 ssize_t err;
1744 loff_t pos;
1745 size_t count;
1746 1746
1747 mutex_lock(&inode->i_mutex); 1747 mutex_lock(&inode->i_mutex);
1748 1748 err = generic_write_checks(iocb, from);
1749 current->backing_dev_info = inode_to_bdi(inode); 1749 if (err <= 0) {
1750 err = generic_write_checks(file, &pos, &count);
1751 if (err) {
1752 mutex_unlock(&inode->i_mutex); 1750 mutex_unlock(&inode->i_mutex);
1753 goto out; 1751 return err;
1754 }
1755
1756 if (count == 0) {
1757 mutex_unlock(&inode->i_mutex);
1758 goto out;
1759 } 1752 }
1760 1753
1761 iov_iter_truncate(from, count); 1754 current->backing_dev_info = inode_to_bdi(inode);
1762
1763 err = file_remove_suid(file); 1755 err = file_remove_suid(file);
1764 if (err) { 1756 if (err) {
1765 mutex_unlock(&inode->i_mutex); 1757 mutex_unlock(&inode->i_mutex);
@@ -1786,6 +1778,8 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb,
1786 */ 1778 */
1787 update_time_for_write(inode); 1779 update_time_for_write(inode);
1788 1780
1781 pos = iocb->ki_pos;
1782 count = iov_iter_count(from);
1789 start_pos = round_down(pos, root->sectorsize); 1783 start_pos = round_down(pos, root->sectorsize);
1790 if (start_pos > i_size_read(inode)) { 1784 if (start_pos > i_size_read(inode)) {
1791 /* Expand hole size to cover write data, preventing empty gap */ 1785 /* Expand hole size to cover write data, preventing empty gap */