From patchwork Thu Oct 4 10:03:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis V. Lunev" X-Patchwork-Id: 978728 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=openvz.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42QpPW2ZrJz9s8T for ; Thu, 4 Oct 2018 20:03:41 +1000 (AEST) Received: from localhost ([::1]:54886 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g80Tq-0001Wv-IY for incoming@patchwork.ozlabs.org; Thu, 04 Oct 2018 06:03:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40210) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g80T9-0001Wp-Gj for qemu-devel@nongnu.org; Thu, 04 Oct 2018 06:03:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g80T6-0007Pa-6C for qemu-devel@nongnu.org; Thu, 04 Oct 2018 06:02:55 -0400 Received: from relay.sw.ru ([185.231.240.75]:38936) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g80T2-0007Gx-2S; Thu, 04 Oct 2018 06:02:50 -0400 Received: from [172.16.24.44] (helo=iris.sw.ru) by relay.sw.ru with esmtp (Exim 4.90_1) (envelope-from ) id 1g80Su-0000cg-P4; Thu, 04 Oct 2018 13:02:40 +0300 From: "Denis V. Lunev" To: qemu-devel@nongnu.org Date: Thu, 4 Oct 2018 13:03:13 +0300 Message-Id: <20181004100313.4253-1-den@openvz.org> X-Mailer: git-send-email 2.17.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 Subject: [Qemu-devel] [PATCH 1/1] nbd: fix NBD_CMD_CACHE negitiation according to the NBD specification X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vladimir Sementsov-Ogievskiy , Valery Vdovin , qemu-stable@nongnu.org, Paolo Bonzini , den@openvz.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Commit bc37b06a5 was made very bad thing, it has been added NBD_FLAG_SEND_CACHE flag for negotiation. The problem is that the value of the flag was taken wrong and directly violates NBD specification. This value (bit 8) is used at least in the Linux kernel as a part of stable userspace-kernel API since 4.10 as NBD_FLAG_CAN_MULTI_CONN as defined in the specification: "bit 8, NBD_FLAG_CAN_MULTI_CONN: Indicates that the server operates entirely without cache, or that the cache it uses is shared among all connections to the given device. In particular, if this flag is present, then the effects of NBD_CMD_FLUSH and NBD_CMD_FLAG_FUA MUST be visible across all connections when the server sends its reply to that command to the client. In the absense of this flag, clients SHOULD NOT multiplex their commands over more than one connection to the export. ... bit 10, NBD_FLAG_SEND_CACHE: documents that the server understands NBD_CMD_CACHE; however, note that server implementations exist which support the command without advertising this bit, and conversely that this bit does not guarantee that the command will succeed or have an impact." Personally I do not see any option that we will be allowed to fix the specification in favor of QEMU and apply the fix to the kernel. This is a big-big problem. Let us fix this in QEMU as soon as possible. Thus the commit fixes negotiation flag in QEMU accoring to the specification. Fortunately enough the bit has been added by Virtuozzo and there are no released products in the field with this bit used so far. Signed-off-by: Denis V. Lunev CC: Vladimir Sementsov-Ogievskiy CC: Valery Vdovin CC: Eric Blake CC: Paolo Bonzini Reviewed-by: Eric Blake Reviewed-by: Vladimir Sementsov-Ogievskiy --- include/block/nbd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/block/nbd.h b/include/block/nbd.h index 4638c839f5..4377fa502c 100644 --- a/include/block/nbd.h +++ b/include/block/nbd.h @@ -135,7 +135,7 @@ typedef struct NBDExtent { #define NBD_FLAG_SEND_TRIM (1 << 5) /* Send TRIM (discard) */ #define NBD_FLAG_SEND_WRITE_ZEROES (1 << 6) /* Send WRITE_ZEROES */ #define NBD_FLAG_SEND_DF (1 << 7) /* Send DF (Do not Fragment) */ -#define NBD_FLAG_SEND_CACHE (1 << 8) /* Send CACHE (prefetch) */ +#define NBD_FLAG_SEND_CACHE (1 << 10) /* Send CACHE (prefetch) */ /* New-style handshake (global) flags, sent from server to client, and control what will happen during handshake phase. */