* [PATCH] splice: Fix filemap of a blockdev
@ 2023-04-19 8:54 David Howells
2023-04-19 11:17 ` Jain, Ayush
2023-04-19 12:45 ` Jens Axboe
0 siblings, 2 replies; 6+ messages in thread
From: David Howells @ 2023-04-19 8:54 UTC (permalink / raw)
To: Jens Axboe
Cc: dhowells, Ayush Jain, Christoph Hellwig, Al Viro,
David Hildenbrand, John Hubbard, Steve French, linux-mm,
linux-block, linux-fsdevel, linux-kernel
Fix the new filemap_splice_read() function to get i_size from
in->f_mapping->host, not in->f_inode so that it works with block devices
too (in->f_inode points to the device file, which is typically zero size).
Fixes: 07073eb01c5f ("splice: Add a func to do a splice from a buffered file without ITER_PIPE")
Link: https://lore.kernel.org/r/0c6b661c-f7ff-cf12-b7f0-00b6b2f1317b@amd.com/
Reported-by: Ayush Jain <ayush.jain3@amd.com>
cc: Jens Axboe <axboe@kernel.dk>
cc: Christoph Hellwig <hch@lst.de>
cc: Al Viro <viro@zeniv.linux.org.uk>
cc: David Hildenbrand <david@redhat.com>
cc: John Hubbard <jhubbard@nvidia.com>
cc: Steve French <stfrench@microsoft.com>
cc: linux-mm@kvack.org
cc: linux-block@vger.kernel.org
cc: linux-fsdevel@vger.kernel.org
---
mm/filemap.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mm/filemap.c b/mm/filemap.c
index 470be06b6096..f86cc8acf33a 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2902,7 +2902,7 @@ ssize_t filemap_splice_read(struct file *in, loff_t *ppos,
do {
cond_resched();
- if (*ppos >= i_size_read(file_inode(in)))
+ if (*ppos >= i_size_read(in->f_mapping->host))
break;
iocb.ki_pos = *ppos;
@@ -2918,7 +2918,7 @@ ssize_t filemap_splice_read(struct file *in, loff_t *ppos,
* part of the page is not copied back to userspace (unless
* another truncate extends the file - this is desired though).
*/
- isize = i_size_read(file_inode(in));
+ isize = i_size_read(in->f_mapping->host);
if (unlikely(*ppos >= isize))
break;
end_offset = min_t(loff_t, isize, *ppos + len);
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] splice: Fix filemap of a blockdev
2023-04-19 8:54 [PATCH] splice: Fix filemap of a blockdev David Howells
@ 2023-04-19 11:17 ` Jain, Ayush
2023-04-19 12:45 ` Jens Axboe
1 sibling, 0 replies; 6+ messages in thread
From: Jain, Ayush @ 2023-04-19 11:17 UTC (permalink / raw)
To: David Howells, Jens Axboe
Cc: Christoph Hellwig, Al Viro, David Hildenbrand, John Hubbard,
Steve French, linux-mm, linux-block, linux-fsdevel, linux-kernel
Hello David,
This resolves the Fio-test issue that i reported in
Link: https://lore.kernel.org/r/0c6b661c-f7ff-cf12-b7f0-00b6b2f1317b@amd.com/
On 4/19/2023 2:24 PM, David Howells wrote:
> Fix the new filemap_splice_read() function to get i_size from
> in->f_mapping->host, not in->f_inode so that it works with block devices
> too (in->f_inode points to the device file, which is typically zero size).
>
> Fixes: 07073eb01c5f ("splice: Add a func to do a splice from a buffered file without ITER_PIPE")
> Link: https://lore.kernel.org/r/0c6b661c-f7ff-cf12-b7f0-00b6b2f1317b@amd.com/
> Reported-by: Ayush Jain <ayush.jain3@amd.com>
Tested-by: Ayush Jain <ayush.jain3@amd.com>
> cc: Jens Axboe <axboe@kernel.dk>
> cc: Christoph Hellwig <hch@lst.de>
> cc: Al Viro <viro@zeniv.linux.org.uk>
> cc: David Hildenbrand <david@redhat.com>
> cc: John Hubbard <jhubbard@nvidia.com>
> cc: Steve French <stfrench@microsoft.com>
> cc: linux-mm@kvack.org
> cc: linux-block@vger.kernel.org
> cc: linux-fsdevel@vger.kernel.org
> ---
> mm/filemap.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/mm/filemap.c b/mm/filemap.c
> index 470be06b6096..f86cc8acf33a 100644
> --- a/mm/filemap.c
> +++ b/mm/filemap.c
> @@ -2902,7 +2902,7 @@ ssize_t filemap_splice_read(struct file *in, loff_t *ppos,
> do {
> cond_resched();
>
> - if (*ppos >= i_size_read(file_inode(in)))
> + if (*ppos >= i_size_read(in->f_mapping->host))
> break;
>
> iocb.ki_pos = *ppos;
> @@ -2918,7 +2918,7 @@ ssize_t filemap_splice_read(struct file *in, loff_t *ppos,
> * part of the page is not copied back to userspace (unless
> * another truncate extends the file - this is desired though).
> */
> - isize = i_size_read(file_inode(in));
> + isize = i_size_read(in->f_mapping->host);
> if (unlikely(*ppos >= isize))
> break;
> end_offset = min_t(loff_t, isize, *ppos + len);
>
Regards,
Ayush Jain
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] splice: Fix filemap of a blockdev
2023-04-19 8:54 [PATCH] splice: Fix filemap of a blockdev David Howells
2023-04-19 11:17 ` Jain, Ayush
@ 2023-04-19 12:45 ` Jens Axboe
2023-04-19 12:57 ` David Howells
2023-04-19 13:01 ` David Howells
1 sibling, 2 replies; 6+ messages in thread
From: Jens Axboe @ 2023-04-19 12:45 UTC (permalink / raw)
To: David Howells
Cc: Ayush Jain, Christoph Hellwig, Al Viro, David Hildenbrand,
John Hubbard, Steve French, linux-mm, linux-block, linux-fsdevel,
linux-kernel
On Wed, 19 Apr 2023 09:54:11 +0100, David Howells wrote:
> Fix the new filemap_splice_read() function to get i_size from
> in->f_mapping->host, not in->f_inode so that it works with block devices
> too (in->f_inode points to the device file, which is typically zero size).
>
>
Applied, thanks!
[1/1] splice: Fix filemap of a blockdev
commit: 5a9515a407d1aec1dd76c24fe99d9981730b74fb
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] splice: Fix filemap of a blockdev
2023-04-19 12:45 ` Jens Axboe
@ 2023-04-19 12:57 ` David Howells
2023-04-19 13:10 ` Jens Axboe
2023-04-19 13:01 ` David Howells
1 sibling, 1 reply; 6+ messages in thread
From: David Howells @ 2023-04-19 12:57 UTC (permalink / raw)
To: Jens Axboe
Cc: dhowells, Ayush Jain, Christoph Hellwig, Al Viro,
David Hildenbrand, John Hubbard, Steve French, linux-mm,
linux-block, linux-fsdevel, linux-kernel
Jens Axboe <axboe@kernel.dk> wrote:
> [1/1] splice: Fix filemap of a blockdev
Actually, would you be able to fix the subject? I left a word out:
splice: Fix filemap splice of a blockdev
or maybe:
splice: Fix buffered splice of a blockdev
Sorry about that,
David
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] splice: Fix filemap of a blockdev
2023-04-19 12:45 ` Jens Axboe
2023-04-19 12:57 ` David Howells
@ 2023-04-19 13:01 ` David Howells
1 sibling, 0 replies; 6+ messages in thread
From: David Howells @ 2023-04-19 13:01 UTC (permalink / raw)
To: Jens Axboe
Cc: dhowells, Ayush Jain, Christoph Hellwig, Al Viro,
David Hildenbrand, John Hubbard, Steve French, linux-mm,
linux-block, linux-fsdevel, linux-kernel
Note that this shouldn't affect direct_splice_read() as that doesn't look at
the size of the file, but rather just keeps reading from it until the
requested amount is read, the pipe is full or ->read_iter() indicates EOF by
returning 0 (so it could work for copy-splicing from a pipe/socket/chardev
too).
David
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] splice: Fix filemap of a blockdev
2023-04-19 12:57 ` David Howells
@ 2023-04-19 13:10 ` Jens Axboe
0 siblings, 0 replies; 6+ messages in thread
From: Jens Axboe @ 2023-04-19 13:10 UTC (permalink / raw)
To: David Howells
Cc: Ayush Jain, Christoph Hellwig, Al Viro, David Hildenbrand,
John Hubbard, Steve French, linux-mm, linux-block, linux-fsdevel,
linux-kernel
On 4/19/23 6:57 AM, David Howells wrote:
> Jens Axboe <axboe@kernel.dk> wrote:
>
>> [1/1] splice: Fix filemap of a blockdev
>
> Actually, would you be able to fix the subject? I left a word out:
>
> splice: Fix filemap splice of a blockdev
>
> or maybe:
>
> splice: Fix buffered splice of a blockdev
Fixed it up.
--
Jens Axboe
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-04-19 13:11 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-19 8:54 [PATCH] splice: Fix filemap of a blockdev David Howells
2023-04-19 11:17 ` Jain, Ayush
2023-04-19 12:45 ` Jens Axboe
2023-04-19 12:57 ` David Howells
2023-04-19 13:10 ` Jens Axboe
2023-04-19 13:01 ` David Howells
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).