summaryrefslogtreecommitdiffstats
path: root/fs/ext4
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2015-04-09 18:55:47 +0200
committerAl Viro <viro@zeniv.linux.org.uk>2015-04-12 04:30:21 +0200
commit3309dd04cbcd2cdad168485af5cf3576b5051e49 (patch)
tree3e01f865306dee01b31f34c9e7e819a5f42a4087 /fs/ext4
parentocfs2: move generic_write_checks() before the alignment checks (diff)
downloadlinux-3309dd04cbcd2cdad168485af5cf3576b5051e49.tar.xz
linux-3309dd04cbcd2cdad168485af5cf3576b5051e49.zip
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/ext4')
-rw-r--r--fs/ext4/file.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index 42b1fa33a17a..c10785f10d1d 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -97,9 +97,7 @@ ext4_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
struct blk_plug plug;
int o_direct = io_is_direct(file);
int overwrite = 0;
- size_t length = iov_iter_count(from);
ssize_t ret;
- loff_t pos;
/*
* Unaligned direct AIO must be serialized; see comment above
@@ -116,16 +114,10 @@ ext4_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
}
mutex_lock(&inode->i_mutex);
- ret = generic_write_checks(file, &iocb->ki_pos, &length);
- if (ret)
+ ret = generic_write_checks(iocb, from);
+ if (ret <= 0)
goto out;
- if (length == 0)
- goto out;
-
- iov_iter_truncate(from, length);
- pos = iocb->ki_pos;
-
/*
* If we have encountered a bitmap-format file, the size limit
* is smaller than s_maxbytes, which is for extent-mapped files.
@@ -133,19 +125,19 @@ ext4_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) {
struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
- if (pos >= sbi->s_bitmap_maxbytes) {
+ if (iocb->ki_pos >= sbi->s_bitmap_maxbytes) {
ret = -EFBIG;
goto out;
}
- iov_iter_truncate(from, sbi->s_bitmap_maxbytes - pos);
+ iov_iter_truncate(from, sbi->s_bitmap_maxbytes - iocb->ki_pos);
}
iocb->private = &overwrite;
if (o_direct) {
- length = iov_iter_count(from);
+ size_t length = iov_iter_count(from);
+ loff_t pos = iocb->ki_pos;
blk_start_plug(&plug);
-
/* check whether we do a DIO overwrite or not */
if (ext4_should_dioread_nolock(inode) && !aio_mutex &&
!file->f_mapping->nrpages && pos + length <= i_size_read(inode)) {