summaryrefslogtreecommitdiffstats
path: root/fs/ext4/inode.c
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2017-05-25 00:05:29 +0200
committerTheodore Ts'o <tytso@mit.edu>2017-05-25 00:05:29 +0200
commite5465795cac48233c9b606a7a419f4190a91851e (patch)
tree94f07f19cf0f86b5586989863069468862873708 /fs/ext4/inode.c
parentext4: fix off-by-one on max nr_pages in ext4_find_unwritten_pgoff() (diff)
downloadlinux-e5465795cac48233c9b606a7a419f4190a91851e.tar.xz
linux-e5465795cac48233c9b606a7a419f4190a91851e.zip
ext4: fix off-by-one error when writing back pages before dio read
The 'lend' argument of filemap_write_and_wait_range() is inclusive, so we need to subtract 1 from pos + count. Note that 'count' is guaranteed to be nonzero since ext4_file_read_iter() returns early when given a 0 count. Fixes: 16c54688592c ("ext4: Allow parallel DIO reads") Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu> Reviewed-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/ext4/inode.c')
-rw-r--r--fs/ext4/inode.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 7cd99de8c4ba..90b264928742 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3713,7 +3713,7 @@ static ssize_t ext4_direct_IO_read(struct kiocb *iocb, struct iov_iter *iter)
*/
inode_lock_shared(inode);
ret = filemap_write_and_wait_range(mapping, iocb->ki_pos,
- iocb->ki_pos + count);
+ iocb->ki_pos + count - 1);
if (ret)
goto out_unlock;
ret = __blockdev_direct_IO(iocb, inode, inode->i_sb->s_bdev,