Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 331392
b: refs/heads/master
c: ec8fc87
h: refs/heads/master
v: v3
  • Loading branch information
Masami Hiramatsu authored and Rusty Russell committed Sep 28, 2012
1 parent 4dafa54 commit 581d156
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: eb5e89fc70bb3f115b3206ed0c57d3aba1fdd155
refs/heads/master: ec8fc870156b2b144f55b6a5a7d135018f04b30e
28 changes: 25 additions & 3 deletions trunk/drivers/char/virtio_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down

0 comments on commit 581d156

Please sign in to comment.