From: Yoshihiro YUNOMAE <yoshihiro.yunomae.ez@hitachi.com>
To: linux-kernel@vger.kernel.org
Cc: Amit Shah <amit.shah@redhat.com>,
Anthony Liguori <anthony@codemonkey.ws>,
Arnd Bergmann <arnd@arndb.de>, Borislav Petkov <bp@amd64.org>,
"Franch Ch. Eigler" <fche@redhat.com>,
Frederic Weisbecker <fweisbec@gmail.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Herbert Xu <herbert@gondor.hengli.com.au>,
Ingo Molnar <mingo@redhat.com>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
Rusty Russell <rusty@rustcorp.com.au>,
Steven Rostedt <rostedt@goodmis.org>,
virtualization@lists.linux-foundation.org, qemu-devel@nongnu.org,
yrl.pp-manager.tt@hitachi.com,
Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Subject: [PATCH V2 3/6] virtio/console: Wait until the port is ready on splice
Date: Thu, 09 Aug 2012 21:31:00 +0900 [thread overview]
Message-ID: <20120809123100.8542.63507.stgit@ltc189.sdl.hitachi.co.jp> (raw)
In-Reply-To: <20120809123029.8542.38311.stgit@ltc189.sdl.hitachi.co.jp>
From: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Wait if the port is not connected or full on splice
like as write is doing.
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
---
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 22b7373..b2fc2ab 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,
next prev parent reply other threads:[~2012-08-09 12:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-09 12:30 [PATCH V2 0/6] virtio-trace: Support virtio-trace Yoshihiro YUNOMAE
2012-08-09 12:30 ` [PATCH V2 1/6] virtio/console: Add splice_write support Yoshihiro YUNOMAE
2012-08-09 12:30 ` [PATCH V2 2/6] virtio/console: Add a failback for unstealable pipe buffer Yoshihiro YUNOMAE
2012-08-09 12:31 ` Yoshihiro YUNOMAE [this message]
2012-08-09 12:31 ` [PATCH V2 4/6] ftrace: Allow stealing pages from " Yoshihiro YUNOMAE
2012-08-09 12:31 ` [PATCH V2 5/6] virtio/console: Allocate scatterlist according to the current pipe size Yoshihiro YUNOMAE
2012-08-09 12:31 ` [PATCH V2 6/6] tools: Add guest trace agent as a user tool Yoshihiro YUNOMAE
2012-08-12 23:28 ` [PATCH V2 0/6] virtio-trace: Support virtio-trace Rusty Russell
2012-08-21 5:16 ` Amit Shah
2012-08-21 12:33 ` Masami Hiramatsu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120809123100.8542.63507.stgit@ltc189.sdl.hitachi.co.jp \
--to=yoshihiro.yunomae.ez@hitachi.com \
--cc=amit.shah@redhat.com \
--cc=anthony@codemonkey.ws \
--cc=arnd@arndb.de \
--cc=bp@amd64.org \
--cc=fche@redhat.com \
--cc=fweisbec@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=herbert@gondor.hengli.com.au \
--cc=linux-kernel@vger.kernel.org \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=mathieu.desnoyers@efficios.com \
--cc=mingo@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rostedt@goodmis.org \
--cc=rusty@rustcorp.com.au \
--cc=virtualization@lists.linux-foundation.org \
--cc=yrl.pp-manager.tt@hitachi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®