splice and sendfile lose input into a nonblocking pipe
维护者通常 2 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 48/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- c
调研方向
Start in src/syscall/io.c with sys_splice, splice_drain_chunk, copy_fd_range, and io_rewind_unsent; compare their behavior with the existing SPLICE_F_NONBLOCK handling from #463. Reproduce the reported nonblocking-pipe, sendfile-pipe-input, and interrupted blocking-socket cases against Linux and elfuse. Done means no input is consumed unless written, sendfile rejects pipe input with EINVAL, and splice reports the expected result when interrupted.
由索引模型根据 Issue 内容生成。
描述
splice and sendfile lose input when the output is a pipe the guest set O_NONBLOCK. The emulation reads a whole chunk from the input before it writes it (sys_splice and splice_drain_chunk, copy_fd_range for sendfile in src/syscall/io.c). When the nonblocking write places only part of the chunk, the rest has already been consumed, and io_rewind_unsent cannot hand it back to a pipe or socket input.
Measured with a static aarch64 probe: pipe a holds 8 KiB, pipe b has O_NONBLOCK set by the guest and 4 KiB of free room, then the probe calls splice(a[0], NULL, b[1], NULL, 8192, 0) and, in a second run, sendfile(b[1], a[0], NULL, 8192).
| Call | Linux (qemu) | elfuse main (e9fdbbb) |
|---|---|---|
| splice | returns 4096, 4 KiB still in a |
returns 4096, a empty: 4 KiB lost |
| sendfile | -1, EINVAL (a pipe input is refused) | returns 4096, a empty: 4 KiB lost |
The sendfile row has a second difference: Linux refuses a pipe as the sendfile input, and elfuse accepts it.
#463 fixed the same loss for SPLICE_F_NONBLOCK: a pipe output is polled for POLLOUT before each read and the chunk is capped at PIPE_BUF, since a ready macOS pipe has at least that much free. The O_NONBLOCK case still reaches the old path.
A blocking socket output has a related gap. Linux ignores SPLICE_F_NONBLOCK for a socket output and follows the socket's own O_NONBLOCK, so the call blocks there too. Measured: splice(pipe_with_5_bytes, NULL, full_blocking_af_unix_socket, NULL, 5, SPLICE_F_NONBLOCK) with a 2 s alarm and a handler returns -1 with EINTR on Linux under qemu. elfuse never returns: the chunk has already been read from the pipe and cannot be put back, so splice_drain_chunk keeps retrying the write instead of reporting the signal.
Goal: when the output cannot take a whole chunk without blocking, splice and sendfile read only what the output can take and report what moved, so no input byte is consumed without being written. sendfile refuses a pipe input with EINVAL, as Linux does.
- 主要语言
- C
- 星标
- 287
- 派生
- 33
- 平均合并
- 2 天 17 小时
- 30 天内合并 PR
- 18
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
sysprog21/elfuse 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 64/100
维护者通常 2 天内回复
-
难度 1/5 1 小时以内 新手友好度 80/100
维护者通常 2 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 86/100
维护者通常 2 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 2 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 2 天内回复
相似的 Issue
-
area/docdb kind/failing-test priority/medium status/awaiting-triage
难度 2/5 1-3 小时 新手友好度 82/100
yugabyte/yugabyte-db#39462 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
libreswan/libreswan#3185 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
-
category:port-update
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 2 天内回复