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) | |||
2560 | ssize_t written = 0; | 2560 | ssize_t written = 0; |
2561 | ssize_t err; | 2561 | ssize_t err; |
2562 | ssize_t status; | 2562 | ssize_t status; |
2563 | size_t count = iov_iter_count(from); | ||
2564 | 2563 | ||
2565 | /* We can write back this queue in page reclaim */ | 2564 | /* We can write back this queue in page reclaim */ |
2566 | current->backing_dev_info = inode_to_bdi(inode); | 2565 | current->backing_dev_info = inode_to_bdi(inode); |
2567 | err = generic_write_checks(file, &iocb->ki_pos, &count, S_ISBLK(inode->i_mode)); | ||
2568 | if (err) | ||
2569 | goto out; | ||
2570 | |||
2571 | if (count == 0) | ||
2572 | goto out; | ||
2573 | |||
2574 | iov_iter_truncate(from, count); | ||
2575 | |||
2576 | err = file_remove_suid(file); | 2566 | err = file_remove_suid(file); |
2577 | if (err) | 2567 | if (err) |
2578 | goto out; | 2568 | goto out; |
@@ -2651,9 +2641,14 @@ ssize_t generic_file_write_iter(struct kiocb *iocb, struct iov_iter *from) | |||
2651 | struct file *file = iocb->ki_filp; | 2641 | struct file *file = iocb->ki_filp; |
2652 | struct inode *inode = file->f_mapping->host; | 2642 | struct inode *inode = file->f_mapping->host; |
2653 | ssize_t ret; | 2643 | ssize_t ret; |
2644 | size_t count = iov_iter_count(from); | ||
2654 | 2645 | ||
2655 | mutex_lock(&inode->i_mutex); | 2646 | mutex_lock(&inode->i_mutex); |
2656 | ret = __generic_file_write_iter(iocb, from); | 2647 | ret = generic_write_checks(file, &iocb->ki_pos, &count, 0); |
2648 | if (!ret && count) { | ||
2649 | iov_iter_truncate(from, count); | ||
2650 | ret = __generic_file_write_iter(iocb, from); | ||
2651 | } | ||
2657 | mutex_unlock(&inode->i_mutex); | 2652 | mutex_unlock(&inode->i_mutex); |
2658 | 2653 | ||
2659 | if (ret > 0) { | 2654 | if (ret > 0) { |