All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ext4: fix off-by-one error when writing back pages before dio read
@ 2017-05-23  1:34 Eric Biggers
  2017-05-23  7:53 ` Jan Kara
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Biggers @ 2017-05-23  1:34 UTC (permalink / raw)
  To: linux-ext4; +Cc: Theodore Ts'o, Jan Kara, Eric Biggers

From: Eric Biggers <ebiggers@google.com>

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>
---
 fs/ext4/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 7c6e715b4d2e..3080ea82dd6d 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3710,7 +3710,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,
-- 
2.13.0.219.gdb65acc882-goog

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-05-24 22:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-23  1:34 [PATCH] ext4: fix off-by-one error when writing back pages before dio read Eric Biggers
2017-05-23  7:53 ` Jan Kara
2017-05-24 22:08   ` Theodore Ts'o

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.