Skip to content

Commit c372220

Browse files
dhowellsaxboe
authored andcommitted
splice: Fix filemap_splice_read() to use the correct inode
Fix filemap_splice_read() to use file->f_mapping->host, not file->f_inode, as the source of the file size because in the case of a block device, file->f_inode points to the block-special file (which is typically 0 length) and not the backing store. Fixes: 07073eb ("splice: Add a func to do a splice from a buffered file without ITER_PIPE") Signed-off-by: David Howells <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Christian Brauner <[email protected]> cc: Steve French <[email protected]> cc: Jens Axboe <[email protected]> cc: Al Viro <[email protected]> cc: David Hildenbrand <[email protected]> cc: John Hubbard <[email protected]> cc: [email protected] cc: [email protected] cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent f1fcbaa commit c372220

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

mm/filemap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2900,7 +2900,7 @@ ssize_t filemap_splice_read(struct file *in, loff_t *ppos,
29002900
do {
29012901
cond_resched();
29022902

2903-
if (*ppos >= i_size_read(file_inode(in)))
2903+
if (*ppos >= i_size_read(in->f_mapping->host))
29042904
break;
29052905

29062906
iocb.ki_pos = *ppos;
@@ -2916,7 +2916,7 @@ ssize_t filemap_splice_read(struct file *in, loff_t *ppos,
29162916
* part of the page is not copied back to userspace (unless
29172917
* another truncate extends the file - this is desired though).
29182918
*/
2919-
isize = i_size_read(file_inode(in));
2919+
isize = i_size_read(in->f_mapping->host);
29202920
if (unlikely(*ppos >= isize))
29212921
break;
29222922
end_offset = min_t(loff_t, isize, *ppos + len);

0 commit comments

Comments
 (0)