From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48577) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDY6O-000728-Aq for qemu-devel@nongnu.org; Thu, 16 Jun 2016 10:17:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bDY6J-00035M-5q for qemu-devel@nongnu.org; Thu, 16 Jun 2016 10:16:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34618) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDY6J-00035E-0B for qemu-devel@nongnu.org; Thu, 16 Jun 2016 10:16:55 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9221B693F3 for ; Thu, 16 Jun 2016 14:16:54 +0000 (UTC) From: Paolo Bonzini Date: Thu, 16 Jun 2016 16:16:12 +0200 Message-Id: <1466086585-16526-18-git-send-email-pbonzini@redhat.com> In-Reply-To: <1466086585-16526-1-git-send-email-pbonzini@redhat.com> References: <1466086585-16526-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 17/30] nbd: Use BDRV_REQ_FUA for better FUA where supported List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org From: Eric Blake Rather than always flushing ourselves, let the block layer forward the FUA on to the underlying device - where all underlying layers also understand FUA, we are now more efficient; and where any underlying layer doesn't understand it, now the block layer takes care of the full flush fallback on our behalf. Signed-off-by: Eric Blake Message-Id: <1463006384-7734-2-git-send-email-eblake@redhat.com> Signed-off-by: Paolo Bonzini --- nbd/server.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/nbd/server.c b/nbd/server.c index 91471f1..7063edb 100644 --- a/nbd/server.c +++ b/nbd/server.c @@ -1038,6 +1038,7 @@ static void nbd_trip(void *opaque) struct nbd_reply reply; ssize_t ret; uint32_t command; + int flags; TRACE("Reading request."); if (client->closing) { @@ -1114,23 +1115,18 @@ static void nbd_trip(void *opaque) TRACE("Writing to device"); + flags = 0; + if (request.type & NBD_CMD_FLAG_FUA) { + flags |= BDRV_REQ_FUA; + } ret = blk_pwrite(exp->blk, request.from + exp->dev_offset, - req->data, request.len, 0); + req->data, request.len, flags); if (ret < 0) { LOG("writing to file failed"); reply.error = -ret; goto error_reply; } - if (request.type & NBD_CMD_FLAG_FUA) { - ret = blk_co_flush(exp->blk); - if (ret < 0) { - LOG("flush failed"); - reply.error = -ret; - goto error_reply; - } - } - if (nbd_co_send_reply(req, &reply, 0) < 0) { goto out; } -- 2.5.5