[PATCH 0/2] splice: handle zero-count sendfile to full pipes
From: Mehtab Zafar
Date: Sat Nov 28 2026 - 08:42:55 EST
sendfile() sends to a pipe through splice_file_to_pipe() directly. For a
zero-count operation, that helper currently waits for pipe space before the
lower-level read sees the zero length. On a full pipe this makes blocking
sendfile() wait and nonblocking sendfile() return -EAGAIN, while splice()
returns zero immediately.
Patch 1 returns before waiting when the helper receives a zero length.
Patch 2 adds kselftest coverage for full blocking and nonblocking pipes.
This bug was found with AI assistance, which also helped
prepare the fix, tests, and description.
Validation on x86_64, based on vfs/vfs.all at 3857587d9d6f:
- baseline, three fresh no-disk/no-NIC KVM boots: nonblocking returned
-EAGAIN, blocking waited until interrupted, and the selftest passed 0/2
- patched, three fresh no-disk/no-NIC KVM boots: both calls returned zero
immediately and the selftest passed 2/2
- positive-count full-pipe behavior remained -EAGAIN, invalid output fd
remained -EBADF, an
d the input offset and pipe contents did not advance
- W=1 fs/splice.o and full bzImage builds passed
- strict checkpatch was clean for the fix; for the selftest it reported
no errors, warnings, or checks with FILE_PATH_CHANGES ignored. The final
selftest run also logged an spdxcheck.py traceback due to missing Python
ply; unchanged source and SPDX text had passed earlier SPDX validation
Mehtab Zafar (2):
splice: return immediately for zero-length file-to-pipe splices
selftests/splice: cover zero-count sendfile to a full pipe
fs/splice.c | 3 +
tools/testing/selftests/splice/.gitignore | 1 +
tools/testing/selftests/splice/Makefile | 1 +
.../testing/selftests/splice/sendfile_zero.c | 93 +++++++++++++++++++
4 files changed, 98 insertions(+)
create mode 100644 tools/testing/selftests/splice/sendfile_zero.c
--
2.34.1
Attachment:
signature.asc
Description: OpenPGP digital signature