Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pipe: Fall back to write() on vmsplice() EPERM #2294

Open
wants to merge 1 commit into
base: criu-dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion criu/pipes.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ int restore_pipe_data(int img_type, int pfd, u32 id, struct pipe_data_rst **hash
int ret;
struct pipe_data_rst *pd;
struct iovec iov;
bool try_vmsplice = true;

for (pd = hash[id & PIPE_DATA_HASH_MASK]; pd != NULL; pd = pd->next)
if (pd->pde->pipe_id == id)
Expand Down Expand Up @@ -179,7 +180,16 @@ int restore_pipe_data(int img_type, int pfd, u32 id, struct pipe_data_rst **hash
iov.iov_len = pd->pde->bytes;

while (iov.iov_len > 0) {
ret = vmsplice(pfd, &iov, 1, SPLICE_F_GIFT | SPLICE_F_NONBLOCK);
if (try_vmsplice) {
ret = vmsplice(pfd, &iov, 1, SPLICE_F_GIFT | SPLICE_F_NONBLOCK);
if (ret < 0 && errno == EPERM) {
pr_info("%#x: vmsplice() returned EPERM, falling back to write()\n", id);
try_vmsplice = false;
ret = write(pfd, iov.iov_base, iov.iov_len);
}
} else
ret = write(pfd, iov.iov_base, iov.iov_len);

if (ret < 0) {
pr_perror("%#x: Error splicing data", id);
return -1;
Expand Down
Loading