summaryrefslogtreecommitdiff
path: root/fs/ext4
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2015-04-07 18:28:12 +0300
committerAl Viro <viro@zeniv.linux.org.uk>2015-04-12 05:29:47 +0300
commit5f380c7fa7e01f15ca0816bd241ece9a64a73192 (patch)
tree2136f54098eb85d21d17ee43f73724a5befd70a1 /fs/ext4
parent0b8def9d6dfa6b2a9a2740cf81d8d2c134688d39 (diff)
downloadlinux-5f380c7fa7e01f15ca0816bd241ece9a64a73192.tar.xz
lift generic_write_checks() into callers of __generic_file_write_iter()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/ext4')
-rw-r--r--fs/ext4/file.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index 9ad03036d9f5..f7cca423dded 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -132,9 +132,8 @@ ext4_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
ret = -EFBIG;
goto errout;
}
-
- if (pos + length > sbi->s_bitmap_maxbytes)
- iov_iter_truncate(from, sbi->s_bitmap_maxbytes - pos);
+ iov_iter_truncate(from, sbi->s_bitmap_maxbytes - pos);
+ length = iov_iter_count(from);
}
iocb->private = &overwrite;
@@ -172,7 +171,16 @@ ext4_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
}
}
+ ret = generic_write_checks(file, &iocb->ki_pos, &length, 0);
+ if (ret)
+ goto out;
+
+ if (length == 0)
+ goto out;
+
+ iov_iter_truncate(from, length);
ret = __generic_file_write_iter(iocb, from);
+out:
mutex_unlock(&inode->i_mutex);
if (ret > 0) {