mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] splice: handle zero-count sendfile to full pipes
@ 2026-11-28 13:42 Mehtab Zafar
  2026-11-28 13:42 ` [PATCH 1/2] splice: return immediately for zero-length file-to-pipe splices Mehtab Zafar
  2026-11-28 13:42 ` [PATCH 2/2] selftests/splice: cover zero-count sendfile to a full pipe Mehtab Zafar
  0 siblings, 2 replies; 3+ messages in thread
From: Mehtab Zafar @ 2026-11-28 13:42 UTC (permalink / raw)
  To: Al Viro, Christian Brauner, linux-fsdevel
  Cc: Jan Kara, Shuah Khan, linux-kselftest, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1876 bytes --]

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 #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 563 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-28 13:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-28 13:42 [PATCH 0/2] splice: handle zero-count sendfile to full pipes Mehtab Zafar
2026-11-28 13:42 ` [PATCH 1/2] splice: return immediately for zero-length file-to-pipe splices Mehtab Zafar
2026-11-28 13:42 ` [PATCH 2/2] selftests/splice: cover zero-count sendfile to a full pipe Mehtab Zafar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®