diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2015-04-07 11:28:12 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2015-04-11 22:29:47 -0400 |
commit | 5f380c7fa7e01f15ca0816bd241ece9a64a73192 (patch) | |
tree | 2136f54098eb85d21d17ee43f73724a5befd70a1 /mm | |
parent | 0b8def9d6dfa6b2a9a2740cf81d8d2c134688d39 (diff) |
lift generic_write_checks() into callers of __generic_file_write_iter()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/filemap.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/mm/filemap.c b/mm/filemap.c index 353f82e09e63..a794a7f98743 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2560,19 +2560,9 @@ ssize_t __generic_file_write_iter(struct kiocb *iocb, struct iov_iter *from) ssize_t written = 0; ssize_t err; ssize_t status; - size_t count = iov_iter_count(from); /* We can write back this queue in page reclaim */ current->backing_dev_info = inode_to_bdi(inode); - err = generic_write_checks(file, &iocb->ki_pos, &count, S_ISBLK(inode->i_mode)); - if (err) - goto out; - - if (count == 0) - goto out; - - iov_iter_truncate(from, count); - err = file_remove_suid(file); if (err) goto out; @@ -2651,9 +2641,14 @@ ssize_t generic_file_write_iter(struct kiocb *iocb, struct iov_iter *from) struct file *file = iocb->ki_filp; struct inode *inode = file->f_mapping->host; ssize_t ret; + size_t count = iov_iter_count(from); mutex_lock(&inode->i_mutex); - ret = __generic_file_write_iter(iocb, from); + ret = generic_write_checks(file, &iocb->ki_pos, &count, 0); + if (!ret && count) { + iov_iter_truncate(from, count); + ret = __generic_file_write_iter(iocb, from); + } mutex_unlock(&inode->i_mutex); if (ret > 0) { |