[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH 3/6] virtio/console: Wait until the port is read
From: |
Yoshihiro YUNOMAE |
Subject: |
[Qemu-devel] [RFC PATCH 3/6] virtio/console: Wait until the port is ready on splice |
Date: |
Tue, 24 Jul 2012 11:37:28 +0900 |
User-agent: |
StGIT/0.14.3 |
From: Masami Hiramatsu <address@hidden>
Wait if the port is not connected or full on splice
like as write is doing.
Signed-off-by: Masami Hiramatsu <address@hidden>
Cc: Amit Shah <address@hidden>
Cc: Arnd Bergmann <address@hidden>
Cc: Greg Kroah-Hartman <address@hidden>
---
drivers/char/virtio_console.c | 39 +++++++++++++++++++++++++++------------
1 files changed, 27 insertions(+), 12 deletions(-)
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 911cb3e..e49d435 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -724,6 +724,26 @@ static ssize_t port_fops_read(struct file *filp, char
__user *ubuf,
return fill_readbuf(port, ubuf, count, true);
}
+static int wait_port_writable(struct port *port, bool nonblock)
+{
+ int ret;
+
+ if (will_write_block(port)) {
+ if (nonblock)
+ return -EAGAIN;
+
+ ret = wait_event_freezable(port->waitqueue,
+ !will_write_block(port));
+ if (ret < 0)
+ return ret;
+ }
+ /* Port got hot-unplugged. */
+ if (!port->guest_connected)
+ return -ENODEV;
+
+ return 0;
+}
+
static ssize_t port_fops_write(struct file *filp, const char __user *ubuf,
size_t count, loff_t *offp)
{
@@ -740,18 +760,9 @@ static ssize_t port_fops_write(struct file *filp, const
char __user *ubuf,
nonblock = filp->f_flags & O_NONBLOCK;
- if (will_write_block(port)) {
- if (nonblock)
- return -EAGAIN;
-
- ret = wait_event_freezable(port->waitqueue,
- !will_write_block(port));
- if (ret < 0)
- return ret;
- }
- /* Port got hot-unplugged. */
- if (!port->guest_connected)
- return -ENODEV;
+ ret = wait_port_writable(port, nonblock);
+ if (ret < 0)
+ return ret;
count = min((size_t)(32 * 1024), count);
@@ -851,6 +862,10 @@ static ssize_t port_fops_splice_write(struct
pipe_inode_info *pipe,
.u.data = &sgl,
};
+ ret = wait_port_writable(port, filp->f_flags & O_NONBLOCK);
+ if (ret < 0)
+ return ret;
+
sgl.n = 0;
sgl.len = 0;
sgl.sg = kmalloc(sizeof(struct scatterlist) * MAX_SPLICE_PAGES,
- [Qemu-devel] [RFC PATCH 0/6] virtio-trace: Support virtio-trace, Yoshihiro YUNOMAE, 2012/07/23
- [Qemu-devel] [RFC PATCH 1/6] virtio/console: Add splice_write support, Yoshihiro YUNOMAE, 2012/07/23
- [Qemu-devel] [RFC PATCH 2/6] virtio/console: Add a failback for unstealable pipe buffer, Yoshihiro YUNOMAE, 2012/07/23
- [Qemu-devel] [RFC PATCH 3/6] virtio/console: Wait until the port is ready on splice,
Yoshihiro YUNOMAE <=
- [Qemu-devel] [RFC PATCH 4/6] ftrace: Allow stealing pages from pipe buffer, Yoshihiro YUNOMAE, 2012/07/23
- [Qemu-devel] [RFC PATCH 5/6] virtio/console: Allocate scatterlist according to the current pipe size, Yoshihiro YUNOMAE, 2012/07/23
- [Qemu-devel] [RFC PATCH 6/6] tools: Add guest trace agent as a user tool, Yoshihiro YUNOMAE, 2012/07/23
- Re: [Qemu-devel] [RFC PATCH 0/6] virtio-trace: Support virtio-trace, Masami Hiramatsu, 2012/07/23
- Re: [Qemu-devel] [RFC PATCH 0/6] virtio-trace: Support virtio-trace, Stefan Hajnoczi, 2012/07/24