Commit c5f8748b authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Andrei Vagin

page-xfer: Handle partial splicing

In case if pipe buffers are full the splicing
may wakeup reader first with incomplete data
transfer. Thus splice data in cycle.
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@gmail.com>
Acked-by: 's avatarMike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 1c37c0d4
......@@ -147,13 +147,21 @@ static inline int send_psi(int sk, struct page_server_iov *pi)
static int write_pages_to_server(struct page_xfer *xfer,
int p, unsigned long len)
{
ssize_t ret, left = len;
pr_debug("Splicing %lu bytes / %lu pages into socket\n", len, len / PAGE_SIZE);
if (splice(p, NULL, xfer->sk, NULL, len, SPLICE_F_MOVE) != len) {
while (left > 0) {
ret = splice(p, NULL, xfer->sk, NULL, left, SPLICE_F_MOVE);
if (ret < 0) {
pr_perror("Can't write pages to socket");
return -1;
}
pr_debug("\tSpliced: %lu bytes sent\n", (unsigned long)ret);
left -= ret;
}
return 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment