diff options
author | Stefan Hajnoczi <stefanha@redhat.com> | 2013-04-15 16:14:47 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2013-04-15 16:30:40 +0200 |
commit | 0fcece25c0b1b79b39d1dff5c2c55b88feae7eef (patch) | |
tree | a9e69dfb1110c5658b634c1e7b6a4b5fe06ef1c4 /block | |
parent | 6760c47aa42ce30efdd12c132f73c8749c575995 (diff) | |
download | qemu-0fcece25c0b1b79b39d1dff5c2c55b88feae7eef.zip qemu-0fcece25c0b1b79b39d1dff5c2c55b88feae7eef.tar.gz qemu-0fcece25c0b1b79b39d1dff5c2c55b88feae7eef.tar.bz2 |
nbd: use TCP_CORK in nbd_co_send_request()
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>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'block')
-rw-r--r-- | block/nbd.c | 22 |
1 files 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); |