diff mbox series

[1/2] shmem: Fix splice of a missing page

Message ID 20230727161016.169066-2-dhowells@redhat.com (mailing list archive)
State New, archived
Headers show
Series shmem, splice: Fixes for shmem_splice_read() | expand

Commit Message

David Howells July 27, 2023, 4:10 p.m. UTC
Fix shmem_splice_read() to splice only part of the partial page at the end
of a splice and not all of it.

This can be seen by splicing from a tmpfs file that's not a multiple of
PAGE_SIZE in size.  Without this fix, it splices extra data to round up to
PAGE_SIZE.

Fixes: bd194b187115 ("shmem: Implement splice-read")
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Hugh Dickins <hughd@google.com>
cc: Christoph Hellwig <hch@lst.de>
cc: Jens Axboe <axboe@kernel.dk>
cc: Al Viro <viro@zeniv.linux.org.uk>
cc: John Hubbard <jhubbard@nvidia.com>
cc: David Hildenbrand <david@redhat.com>
cc: Matthew Wilcox <willy@infradead.org>
cc: Chuck Lever <chuck.lever@oracle.com>
cc: linux-block@vger.kernel.org
cc: linux-fsdevel@vger.kernel.org
cc: linux-mm@kvack.org
---
 mm/shmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andrew Morton July 27, 2023, 4:35 p.m. UTC | #1
On Thu, 27 Jul 2023 17:10:15 +0100 David Howells <dhowells@redhat.com> wrote:

> Fix shmem_splice_read() to splice only part of the partial page at the end
> of a splice and not all of it.
> 
> This can be seen by splicing from a tmpfs file that's not a multiple of
> PAGE_SIZE in size.  Without this fix, it splices extra data to round up to
> PAGE_SIZE.

This is already in mm-unstable (and hence linux-next) via Hugh's
"shmem: minor fixes to splice-read implementation"
(https://lkml.kernel.org/r/32c72c9c-72a8-115f-407d-f0148f368@google.com)
David Howells July 27, 2023, 4:47 p.m. UTC | #2
Andrew Morton <akpm@linux-foundation.org> wrote:

> This is already in mm-unstable (and hence linux-next) via Hugh's
> "shmem: minor fixes to splice-read implementation"
> (https://lkml.kernel.org/r/32c72c9c-72a8-115f-407d-f0148f368@google.com)

And I've already reviewed it:-)

David
Hugh Dickins July 27, 2023, 6:45 p.m. UTC | #3
On Thu, 27 Jul 2023, David Howells wrote:
> Andrew Morton <akpm@linux-foundation.org> wrote:
> 
> > This is already in mm-unstable (and hence linux-next) via Hugh's
> > "shmem: minor fixes to splice-read implementation"
> > (https://lkml.kernel.org/r/32c72c9c-72a8-115f-407d-f0148f368@google.com)
> 
> And I've already reviewed it:-)

I'm not sure whether that ":-)" is implying (good-natured) denial.

You reviewed the original on 17 April, when Jens took it into his tree;
then it vanished in a rewrite, and you didn't respond when I asked about
that on 28 June; then you were Cc'ed when I sent it to Andrew on 23 July
(where I explained about dropping two mods but keeping your Reviewed-by).

This version that Andrew has in mm-unstable includes the hwpoison fix
that we agreed on before, in addition to the len -> part fix.

Hugh
David Howells July 27, 2023, 7:49 p.m. UTC | #4
Hugh Dickins <hughd@google.com> wrote:

> On Thu, 27 Jul 2023, David Howells wrote:
> > Andrew Morton <akpm@linux-foundation.org> wrote:
> > 
> > > This is already in mm-unstable (and hence linux-next) via Hugh's
> > > "shmem: minor fixes to splice-read implementation"
> > > (https://lkml.kernel.org/r/32c72c9c-72a8-115f-407d-f0148f368@google.com)
> > 
> > And I've already reviewed it:-)
> 
> I'm not sure whether that ":-)" is implying (good-natured) denial.

I've reviewed it, and the review still seems good.

> You reviewed the original on 17 April, when Jens took it into his tree;
> then it vanished in a rewrite, and you didn't respond when I asked about
> that on 28 June;

I missed it in the rush to try and get everything debugged during the merge
window prior to going on holiday.

> then you were Cc'ed when I sent it to Andrew on 23 July (where I explained
> about dropping two mods but keeping your Reviewed-by).

Hmmm...  I don't find that one in my inbox.

> This version that Andrew has in mm-unstable includes the hwpoison fix
> that we agreed on before, in addition to the len -> part fix.

Ok.

David
diff mbox series

Patch

diff --git a/mm/shmem.c b/mm/shmem.c
index 2f2e0e618072..0164cccdcd71 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2841,7 +2841,7 @@  static ssize_t shmem_file_splice_read(struct file *in, loff_t *ppos,
 			folio_put(folio);
 			folio = NULL;
 		} else {
-			n = splice_zeropage_into_pipe(pipe, *ppos, len);
+			n = splice_zeropage_into_pipe(pipe, *ppos, part);
 		}
 
 		if (!n)