shmem: minor fixes to splice-read implementation
authorHugh Dickins <hughd@google.com>
Mon, 17 Apr 2023 04:46:16 +0000 (21:46 -0700)
committerJens Axboe <axboe@kernel.dk>
Mon, 17 Apr 2023 13:48:20 +0000 (07:48 -0600)
commit72887c976a7c9ee7527f4a2e3d109576efea98ab
tree4194080eb0bc7eb2ab06a38b9d50dd85fb8fafb5
parent867e1cbba73ea240f9417439479df7eb74b1299c
shmem: minor fixes to splice-read implementation

generic_file_splice_read() makes a couple of preliminary checks (for
s_maxbytes and zero len), but shmem_file_splice_read() is called without
those: so check them inside it.  (But shmem does not support O_DIRECT,
so no need for that one here - and even if O_DIRECT support were stubbed
in, it would still just be using the page cache.)

HWPoison: my reading of folio_test_hwpoison() is that it only tests the
head page of a large folio, whereas splice_folio_into_pipe() will splice
as much of the folio as it can: so for safety we should also check the
has_hwpoisoned flag, set if any of the folio's pages are hwpoisoned.
(Perhaps that ugliness can be improved at the mm end later.)

The call to splice_zeropage_into_pipe() risked overrunning past EOF:
ask it for "part" not "len".

Fixes: b81d7b89becc ("shmem: Implement splice-read")
Signed-off-by: Hugh Dickins <hughd@google.com>
Reviewed-by: David Howells <dhowells@redhat.com>
Link: https://lore.kernel.org/r/2d5fa5e3-dac5-6973-74e5-eeedf36a42b@google.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
mm/shmem.c