|
|
7711c0 |
From 5d77bd2fe5220f026648c9e2f49e65ff45c5475d Mon Sep 17 00:00:00 2001
|
|
|
7711c0 |
From: John Snow <jsnow@redhat.com>
|
|
|
7711c0 |
Date: Tue, 9 Oct 2018 22:14:32 +0200
|
|
|
7711c0 |
Subject: [PATCH 02/22] nbd: fix NBD_FLAG_SEND_CACHE value
|
|
|
7711c0 |
|
|
|
7711c0 |
RH-Author: John Snow <jsnow@redhat.com>
|
|
|
7711c0 |
Message-id: <20181009221432.18359-3-jsnow@redhat.com>
|
|
|
7711c0 |
Patchwork-id: 82509
|
|
|
7711c0 |
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 2/2] nbd: fix NBD_FLAG_SEND_CACHE value
|
|
|
7711c0 |
Bugzilla: 1636148
|
|
|
7711c0 |
RH-Acked-by: Eric Blake <eblake@redhat.com>
|
|
|
7711c0 |
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
|
|
7711c0 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
7711c0 |
|
|
|
7711c0 |
From: "Denis V. Lunev" <den@openvz.org>
|
|
|
7711c0 |
|
|
|
7711c0 |
Commit bc37b06a5 added NBD_CMD_CACHE support, but used the wrong value
|
|
|
7711c0 |
for NBD_FLAG_SEND_CACHE flag for negotiation. That commit picked bit 8,
|
|
|
7711c0 |
which had already been assigned by the NBD specification to mean
|
|
|
7711c0 |
NBD_FLAG_CAN_MULTI_CONN, and which was already implemented in the
|
|
|
7711c0 |
Linux kernel as a part of stable userspace-kernel API since 4.10:
|
|
|
7711c0 |
|
|
|
7711c0 |
"bit 8, NBD_FLAG_CAN_MULTI_CONN: Indicates that the server operates
|
|
|
7711c0 |
entirely without cache, or that the cache it uses is shared among all
|
|
|
7711c0 |
connections to the given device. In particular, if this flag is
|
|
|
7711c0 |
present, then the effects of NBD_CMD_FLUSH and NBD_CMD_FLAG_FUA
|
|
|
7711c0 |
MUST be visible across all connections when the server sends its reply
|
|
|
7711c0 |
to that command to the client. In the absense of this flag, clients
|
|
|
7711c0 |
SHOULD NOT multiplex their commands over more than one connection to
|
|
|
7711c0 |
the export.
|
|
|
7711c0 |
...
|
|
|
7711c0 |
bit 10, NBD_FLAG_SEND_CACHE: documents that the server understands
|
|
|
7711c0 |
NBD_CMD_CACHE; however, note that server implementations exist
|
|
|
7711c0 |
which support the command without advertising this bit, and
|
|
|
7711c0 |
conversely that this bit does not guarantee that the command will
|
|
|
7711c0 |
succeed or have an impact."
|
|
|
7711c0 |
|
|
|
7711c0 |
Consequences:
|
|
|
7711c0 |
- a client trying to use NBD_CMD_CACHE per the NBD spec will not
|
|
|
7711c0 |
see the feature as available from a qemu 3.0 server (not fatal,
|
|
|
7711c0 |
clients already have to be prepared for caching to not exist)
|
|
|
7711c0 |
- a client accidentally coded to the qemu 3.0 bit value instead
|
|
|
7711c0 |
of following the spec may interpret NBD_CMD_CACHE as being available
|
|
|
7711c0 |
when it is not (probably not fatal, the spec says the server should
|
|
|
7711c0 |
gracefully fail unknown commands, and that clients of NBD_CMD_CACHE
|
|
|
7711c0 |
should be prepared for failure even when the feature is advertised);
|
|
|
7711c0 |
such clients are unlikely (perhaps only in unreleased Virtuozzo code),
|
|
|
7711c0 |
and will disappear over time
|
|
|
7711c0 |
- a client prepared to use multiple connections based on
|
|
|
7711c0 |
NBD_FLAG_CAN_MULTI_CONN may cause data corruption when it assumes
|
|
|
7711c0 |
that caching is consistent when in reality qemu 3.0 did not have
|
|
|
7711c0 |
a consistent cache. Partially mitigated by using read-only
|
|
|
7711c0 |
connections (where nothing needs to be flushed, so caching is
|
|
|
7711c0 |
indeed consistent) or when using qemu-nbd with the default -e 1
|
|
|
7711c0 |
(at most one client at a time); visible only when using -e 2 or
|
|
|
7711c0 |
more for a writable export.
|
|
|
7711c0 |
|
|
|
7711c0 |
Thus the commit fixes negotiation flag in QEMU according to the
|
|
|
7711c0 |
specification.
|
|
|
7711c0 |
|
|
|
7711c0 |
Signed-off-by: Denis V. Lunev <den@openvz.org>
|
|
|
7711c0 |
CC: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
|
|
|
7711c0 |
CC: Valery Vdovin <valery.vdovin@acronis.com>
|
|
|
7711c0 |
CC: Eric Blake <eblake@redhat.com>
|
|
|
7711c0 |
CC: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
7711c0 |
CC: qemu-stable@nongnu.org
|
|
|
7711c0 |
Message-Id: <20181004100313.4253-1-den@openvz.org>
|
|
|
7711c0 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
7711c0 |
[eblake: enhance commit message, add defines for unimplemented flags]
|
|
|
7711c0 |
Signed-off-by: Eric Blake <eblake@redhat.com>
|
|
|
7711c0 |
(cherry picked from commit df91328adab8490367776d2b21b35d790a606120)
|
|
|
7711c0 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
7711c0 |
|
|
|
7711c0 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
7711c0 |
---
|
|
|
7711c0 |
include/block/nbd.h | 4 +++-
|
|
|
7711c0 |
1 file changed, 3 insertions(+), 1 deletion(-)
|
|
|
7711c0 |
|
|
|
7711c0 |
diff --git a/include/block/nbd.h b/include/block/nbd.h
|
|
|
7711c0 |
index 4638c83..a53b0cf 100644
|
|
|
7711c0 |
--- a/include/block/nbd.h
|
|
|
7711c0 |
+++ b/include/block/nbd.h
|
|
|
7711c0 |
@@ -135,7 +135,9 @@ typedef struct NBDExtent {
|
|
|
7711c0 |
#define NBD_FLAG_SEND_TRIM (1 << 5) /* Send TRIM (discard) */
|
|
|
7711c0 |
#define NBD_FLAG_SEND_WRITE_ZEROES (1 << 6) /* Send WRITE_ZEROES */
|
|
|
7711c0 |
#define NBD_FLAG_SEND_DF (1 << 7) /* Send DF (Do not Fragment) */
|
|
|
7711c0 |
-#define NBD_FLAG_SEND_CACHE (1 << 8) /* Send CACHE (prefetch) */
|
|
|
7711c0 |
+#define NBD_FLAG_CAN_MULTI_CONN (1 << 8) /* Multi-client cache consistent */
|
|
|
7711c0 |
+#define NBD_FLAG_SEND_RESIZE (1 << 9) /* Send resize */
|
|
|
7711c0 |
+#define NBD_FLAG_SEND_CACHE (1 << 10) /* Send CACHE (prefetch) */
|
|
|
7711c0 |
|
|
|
7711c0 |
/* New-style handshake (global) flags, sent from server to client, and
|
|
|
7711c0 |
control what will happen during handshake phase. */
|
|
|
7711c0 |
--
|
|
|
7711c0 |
1.8.3.1
|
|
|
7711c0 |
|