diff --git a/nbd-Fix-regression-with-multiple-meta-contexts.patch b/nbd-Fix-regression-with-multiple-meta-contexts.patch new file mode 100644 index 0000000000000000000000000000000000000000..432d00e17b5db6106d6644e2544542db762535cc --- /dev/null +++ b/nbd-Fix-regression-with-multiple-meta-contexts.patch @@ -0,0 +1,60 @@ +From 32c6cb39cbadd6fc2026ff6311fcf58549f71d49 Mon Sep 17 00:00:00 2001 +From: Pan Nengyuan +Date: Wed, 15 Apr 2020 14:29:04 +0800 +Subject: [PATCH] nbd: Fix regression with multiple meta contexts + +Detected by a hang in the libnbd testsuite. If a client requests +multiple meta contexts (both base:allocation and qemu:dirty-bitmap:x) +at the same time, our attempt to silence a false-positive warning +about a potential uninitialized variable introduced botched logic: we +were short-circuiting the second context, and never sending the +NBD_REPLY_FLAG_DONE. Combining two 'if' into one 'if/else' in +bdf200a55 was wrong (I'm a bit embarrassed that such a change was my +initial suggestion after the v1 patch, then I did not review the v2 +patch that actually got committed). Revert that, and instead silence +the false positive warning by replacing 'return ret' with 'return 0' +(the value it always has at that point in the code, even though it +eluded the deduction abilities of the robot that reported the false +positive). + +Fixes: bdf200a5535 +Signed-off-by: Eric Blake +Message-Id: <20200206173832.130004-1-eblake@redhat.com> +Reviewed-by: Laurent Vivier +(cherry picked from commit 73e064ccf09d908febc83761addcc6e76feabf78) +--- + nbd/server.c | 11 +++++++++-- + 1 file changed, 9 insertions(+), 2 deletions(-) + +diff --git a/nbd/server.c b/nbd/server.c +index aefb07d..3630352 100644 +--- a/nbd/server.c ++++ b/nbd/server.c +@@ -2304,15 +2304,22 @@ static coroutine_fn int nbd_handle_request(NBDClient *client, + !client->export_meta.bitmap, + NBD_META_ID_BASE_ALLOCATION, + errp); +- } else { /* client->export_meta.bitmap */ ++ if (ret < 0) { ++ return ret; ++ } ++ } ++ if (client->export_meta.bitmap) { + ret = nbd_co_send_bitmap(client, request->handle, + client->exp->export_bitmap, + request->from, request->len, + dont_fragment, + true, NBD_META_ID_DIRTY_BITMAP, errp); ++ if (ret < 0) { ++ return ret; ++ } + } + +- return ret; ++ return 0; + } else { + return nbd_send_generic_reply(client, request->handle, -EINVAL, + "CMD_BLOCK_STATUS not negotiated", +-- +1.8.3.1 + diff --git a/qemu.spec b/qemu.spec index c2a390b06ad96488c8acb43fc007dd97e068c8fa..752968b9cf14aec2b34ecfca1cd8cd130d4c997c 100644 --- a/qemu.spec +++ b/qemu.spec @@ -63,6 +63,7 @@ Patch0050: pcie-Add-pcie-root-port-fast-plug-unplug-feature.patch Patch0051: pcie-Compat-with-devices-which-do-not-support-Link-W.patch Patch0052: aio-wait-delegate-polling-of-main-AioContext-if-BQL-not-held.patch Patch0053: async-use-explicit-memory-barriers.patch +Patch0054: nbd-Fix-regression-with-multiple-meta-contexts.patch BuildRequires: flex BuildRequires: bison @@ -398,6 +399,9 @@ getent passwd qemu >/dev/null || \ %endif %changelog +* Thu Apr 9 2020 backport nbd fix from qemu upstream +- nbd: Fix regression with multiple meta contexts + * Sat Apr 11 4 2020 Huawei Technologies Co., Ltd. - aio-wait: delegate polling of main AioContext if BQL not held - async: use explicit memory barriers