From patchwork Mon Apr 15 14:14:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 236617 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D14292C00CC for ; Tue, 16 Apr 2013 00:16:23 +1000 (EST) Received: from localhost ([::1]:50122 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URkCh-0007HR-4Z for incoming@patchwork.ozlabs.org; Mon, 15 Apr 2013 10:16:19 -0400 Received: from eggs.gnu.org ([208.118.235.92]:50791) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URkBa-00065y-LS for qemu-devel@nongnu.org; Mon, 15 Apr 2013 10:15:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1URkBU-00084y-9W for qemu-devel@nongnu.org; Mon, 15 Apr 2013 10:15:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:11574) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URkBU-00084V-0U for qemu-devel@nongnu.org; Mon, 15 Apr 2013 10:15:04 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r3FEEvWh024068 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 15 Apr 2013 10:14:57 -0400 Received: from localhost (ovpn-112-34.ams2.redhat.com [10.36.112.34]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r3FEEukt005760; Mon, 15 Apr 2013 10:14:56 -0400 From: Stefan Hajnoczi To: Date: Mon, 15 Apr 2013 16:14:47 +0200 Message-Id: <1366035288-15840-3-git-send-email-stefanha@redhat.com> In-Reply-To: <1366035288-15840-1-git-send-email-stefanha@redhat.com> References: <1366035288-15840-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Paolo Bonzini , Stefan Hajnoczi , Nick Thomas Subject: [Qemu-devel] [PATCH 2/3] nbd: use TCP_CORK in nbd_co_send_request() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Use TCP_CORK to defer packet transmission until both the header and the payload have been written. Suggested-by: Nick Thomas Signed-off-by: Stefan Hajnoczi --- 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);