ext4: fix off-by-one error when writing back pages before dio read
PATCH 1/1 ext4: fix off-by-one error when writing back pages before dio read
From: Eric Biggers <[email protected]>
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.
--- fs/ext4/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/inode.c +1 -1
@@ -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,
Signature · 1 line
2.13.0.219.gdb65acc882-goog
Quoted 10 lines · Eric Biggers
From: Eric Biggers <[email protected]>
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 <[email protected]>
Yeah. You can add:
Honza
Quoted 20 lines
--- fs/ext4/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/ext4/inode.c +1
-1@@ -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,Signature · 1 line
2.13.0.219.gdb65acc882-goog
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Quoted 9 lines · Jan Kara
Quoted 8 lines · Eric Biggers
From: Eric Biggers <[email protected]>
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.
Quoted 6 lines
Quoted 2 lines
Fixes 16c54688592c ("ext4: Allow parallel DIO reads")Signed-off-by Eric Biggers <[email protected]>Yeah. You can add:
Reviewed-by Jan Kara <[email protected]>
Thanks, applied.
- Ted