Skip to content

Commit a47a25e

Browse files
committed
Debug rawhide failures
Signed-off-by: Andrei Vagin <[email protected]>
1 parent d18912f commit a47a25e

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

criu/pie/parasite.c

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ static int dump_pages(struct parasite_dump_pages_args *args)
7373
int p, ret, tsock;
7474
struct iovec *iovs;
7575
int off, nr_segs;
76+
long buf_off;
7677
unsigned long spliced_bytes = 0;
7778

7879
tsock = parasite_get_rpc_sock();
@@ -82,22 +83,37 @@ static int dump_pages(struct parasite_dump_pages_args *args)
8283

8384
iovs = pargs_iovs(args);
8485
off = 0;
85-
nr_segs = args->nr_segs;
86-
if (nr_segs > UIO_MAXIOV)
87-
nr_segs = UIO_MAXIOV;
86+
buf_off = 0;
8887
while (1) {
88+
nr_segs = args->nr_segs - off;
89+
if (nr_segs > UIO_MAXIOV)
90+
nr_segs = UIO_MAXIOV;
91+
92+
iovs[args->off + off].iov_base += buf_off;
93+
iovs[args->off + off].iov_len -= buf_off;
8994
ret = sys_vmsplice(p, &iovs[args->off + off], nr_segs, SPLICE_F_GIFT | SPLICE_F_NONBLOCK);
95+
iovs[args->off + off].iov_base -= buf_off;
96+
iovs[args->off + off].iov_len += buf_off;
9097
if (ret < 0) {
9198
sys_close(p);
99+
pr_err("iov_base %p iov_len %lx\n", iovs[args->off + off].iov_base, iovs[args->off + off].iov_len);
92100
pr_err("Can't splice pages to pipe (%d/%d/%d)\n", ret, nr_segs, args->off + off);
93101
return -1;
94102
}
95103
spliced_bytes += ret;
96-
off += nr_segs;
104+
while (ret) {
105+
long l = iovs[args->off + off].iov_len - buf_off;
106+
if (ret < l) {
107+
buf_off += ret;
108+
break;
109+
}
110+
ret -= l;
111+
buf_off = 0;
112+
off++;
113+
}
97114
if (off == args->nr_segs)
98115
break;
99-
if (off + nr_segs > args->nr_segs)
100-
nr_segs = args->nr_segs - off;
116+
BUG_ON(off > args->nr_segs);
101117
}
102118
if (spliced_bytes != args->nr_pages * PAGE_SIZE) {
103119
sys_close(p);

0 commit comments

Comments
 (0)