[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH V2 2/6] virtio/console: Add a failback for unstealab
From: |
Yoshihiro YUNOMAE |
Subject: |
[Qemu-devel] [PATCH V2 2/6] virtio/console: Add a failback for unstealable pipe buffer |
Date: |
Thu, 09 Aug 2012 21:30:50 +0900 |
User-agent: |
StGIT/0.14.3 |
From: Masami Hiramatsu <address@hidden>
Add a failback memcpy path for unstealable pipe buffer.
If buf->ops->steal() fails, virtio-serial tries to
copy the page contents to an allocated page, instead
of just failing splice().
Signed-off-by: Masami Hiramatsu <address@hidden>
---
drivers/char/virtio_console.c | 28 +++++++++++++++++++++++++---
1 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 730816c..22b7373 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -794,7 +794,7 @@ static int pipe_to_sg(struct pipe_inode_info *pipe, struct
pipe_buffer *buf,
struct splice_desc *sd)
{
struct sg_list *sgl = sd->u.data;
- unsigned int len = 0;
+ unsigned int offset, len;
if (sgl->n == MAX_SPLICE_PAGES)
return 0;
@@ -807,9 +807,31 @@ static int pipe_to_sg(struct pipe_inode_info *pipe, struct
pipe_buffer *buf,
len = min(buf->len, sd->len);
sg_set_page(&(sgl->sg[sgl->n]), buf->page, len, buf->offset);
- sgl->n++;
- sgl->len += len;
+ } else {
+ /* Failback to copying a page */
+ struct page *page = alloc_page(GFP_KERNEL);
+ char *src = buf->ops->map(pipe, buf, 1);
+ char *dst;
+
+ if (!page)
+ return -ENOMEM;
+ dst = kmap(page);
+
+ offset = sd->pos & ~PAGE_MASK;
+
+ len = sd->len;
+ if (len + offset > PAGE_SIZE)
+ len = PAGE_SIZE - offset;
+
+ memcpy(dst + offset, src + buf->offset, len);
+
+ kunmap(page);
+ buf->ops->unmap(pipe, buf, src);
+
+ sg_set_page(&(sgl->sg[sgl->n]), page, len, offset);
}
+ sgl->n++;
+ sgl->len += len;
return len;
}
- [Qemu-devel] [PATCH V2 0/6] virtio-trace: Support virtio-trace, Yoshihiro YUNOMAE, 2012/08/09
- [Qemu-devel] [PATCH V2 1/6] virtio/console: Add splice_write support, Yoshihiro YUNOMAE, 2012/08/09
- [Qemu-devel] [PATCH V2 2/6] virtio/console: Add a failback for unstealable pipe buffer,
Yoshihiro YUNOMAE <=
- [Qemu-devel] [PATCH V2 3/6] virtio/console: Wait until the port is ready on splice, Yoshihiro YUNOMAE, 2012/08/09
- [Qemu-devel] [PATCH V2 4/6] ftrace: Allow stealing pages from pipe buffer, Yoshihiro YUNOMAE, 2012/08/09
- [Qemu-devel] [PATCH V2 5/6] virtio/console: Allocate scatterlist according to the current pipe size, Yoshihiro YUNOMAE, 2012/08/09
- [Qemu-devel] [PATCH V2 6/6] tools: Add guest trace agent as a user tool, Yoshihiro YUNOMAE, 2012/08/09
- Re: [Qemu-devel] [PATCH V2 0/6] virtio-trace: Support virtio-trace, Rusty Russell, 2012/08/12
- Re: [Qemu-devel] [PATCH V2 0/6] virtio-trace: Support virtio-trace, Amit Shah, 2012/08/21