From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Nick Thomas <nick@bytemark.co.uk>
Subject: [Qemu-devel] [PATCH 2/3] nbd: use TCP_CORK in nbd_co_send_request()
Date: Mon, 15 Apr 2013 16:14:47 +0200 [thread overview]
Message-ID: <1366035288-15840-3-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1366035288-15840-1-git-send-email-stefanha@redhat.com>
Use TCP_CORK to defer packet transmission until both the header and the
payload have been written.
Suggested-by: Nick Thomas <nick@bytemark.co.uk>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
block/nbd.c | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/block/nbd.c b/block/nbd.c
index 662df16..485bbf0 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -334,13 +334,23 @@ static int nbd_co_send_request(BDRVNBDState *s, struct nbd_request *request,
s->send_coroutine = qemu_coroutine_self();
qemu_aio_set_fd_handler(s->sock, nbd_reply_ready, nbd_restart_write,
nbd_have_request, s);
- rc = nbd_send_request(s->sock, request);
- if (rc >= 0 && qiov) {
- ret = qemu_co_sendv(s->sock, qiov->iov, qiov->niov,
- offset, request->len);
- if (ret != request->len) {
- rc = -EIO;
+ if (qiov) {
+ if (!s->is_unix) {
+ socket_set_cork(s->sock, 1);
}
+ rc = nbd_send_request(s->sock, request);
+ if (rc >= 0) {
+ ret = qemu_co_sendv(s->sock, qiov->iov, qiov->niov,
+ offset, request->len);
+ if (ret != request->len) {
+ rc = -EIO;
+ }
+ }
+ if (!s->is_unix) {
+ socket_set_cork(s->sock, 0);
+ }
+ } else {
+ rc = nbd_send_request(s->sock, request);
}
qemu_aio_set_fd_handler(s->sock, nbd_reply_ready, NULL,
nbd_have_request, s);
--
1.8.1.4
next prev parent reply other threads:[~2013-04-15 14:15 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-15 14:14 [Qemu-devel] [PATCH 0/3] nbd: use TCP_NODELAY Stefan Hajnoczi
2013-04-15 14:14 ` [Qemu-devel] [PATCH 1/3] nbd: unlock mutex in nbd_co_send_request() error path Stefan Hajnoczi
2013-04-15 14:14 ` Stefan Hajnoczi [this message]
2013-04-15 14:14 ` [Qemu-devel] [PATCH 3/3] nbd: set TCP_NODELAY Stefan Hajnoczi
2013-04-15 14:28 ` [Qemu-devel] [PATCH 0/3] nbd: use TCP_NODELAY Nicholas Thomas
2013-04-15 14:33 ` Paolo Bonzini
-- strict thread matches above, loose matches on Subject: below --
2013-04-19 14:30 [Qemu-devel] [PULL 0/3] NBD changes for 2013-04-19 Paolo Bonzini
2013-04-19 14:30 ` [Qemu-devel] [PATCH 2/3] nbd: use TCP_CORK in nbd_co_send_request() Paolo Bonzini
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=1366035288-15840-3-git-send-email-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=kwolf@redhat.com \
--cc=nick@bytemark.co.uk \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/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;
as well as URLs for NNTP newsgroup(s).