From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.openvz.org (mail.openvz.org [69.168.225.77]) by lore.virtuozzo.com (Postfix) with ESMTPS id 8EE5080E7E for ; Tue, 3 Nov 2026 08:38:34 +0000 (UTC) Received: from mail.openvz.org (localhost [127.0.0.1]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6A38bKEE002651; Tue, 3 Nov 2026 11:37:21 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6A38bKEE002651 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=default; t=1793695043; bh=Zt2wr0rYLOdLKcvrmlyUnnqf51adfUkBDTi/6ySkuRM=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe; b=gXJuD/JVQeButW94CNpxzNOhUvB+yKiLq1YsZ+s9sRcHQCnqQ3XsTtJlKWiKXvV74 HCAYalunClxE3Kl6SlyhvIgjtVOSPANjPdOyAZyyyc0VZtkn+xXoCsAc8mBm0pG8xy mzZ/E/JpMkWwOvx9zh6H/3kWkldQrYQFIxix2DZW/LRXJkpJ/8FTzTpv9DWJNOiMYd 1op1CkmL9ZQmh+nAomLQemP1jpcd+bzkRO3iM4rCFSXZ0fiNN/90lRN6hBj/VAXW/4 dvSNKj1V8xEAwReFbXhwya+ipdLm79cgzHmIEx+HexHGkqM4A6xQBQi9SRP+5K3S/m YSd2kPR3wUONQ== Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6A38bDfb002622 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Tue, 3 Nov 2026 11:37:13 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6A38bDfb002622 Authentication-Results: mail.openvz.org; dkim=pass (2048-bit key) header.d=openvz.org header.i=@openvz.org header.b="FXktnV3L" Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4b0a307487aso9473955e9.1 for ; Tue, 03 Nov 2026 00:37:13 -0800 (PST) X-Forwarded-Encrypted: i=2; AKwUvBxENn/mrfIw3aziwkqJbjvKRgdnHzA94brhoYFVSPRDpzblUeS13k59P7xNWYPMV1YCpsvQAA==@openvz.org X-Gm-Message-State: APuU4Z+xskLEEAqTDNO3YYr29CSeynrz6jHzCjZeyv3UaoXaMp1GN1uM dxqSsjP3t5hYZ3eelMkzkdHDPa028GHbv3eS59ulPVl1kFuRK+YkRhP9vmx6RAlfwG1BMaOBZZm ceFkC/Dc8KFHT8gsfOBdARetIxPmNAD1d9J2FjL64mmmIPwsEdtarmw== X-Gm-Gg: AYBFou0oF4nW8ilOrTREf2b7ZHqqCFZO8OxmG5kc+qYeVhcmnEFAzk17ZWBj4WtHdwd BYMV8SfkenmXY3OsT4ADzdg6e+d5Scyv/3V7yTuYgTygGcfoshe7+menEeOS/oSBiAHlVUhV/UQ EC4QplMEycnrFDUMUEweztlNgChakOHWCbaAKTzy6pu3w2qqeVdBLHCg5Gy+YlxjfoCpAxeNgMZ 9d0xeya4wQ7i/RXOmMiArrtoEmP3FpDHv5hpaPpxCDfLM92/TYANh/ytcdjpXUkgYEh53x20jKO 6PDWffF7vw== X-Received: by 2002:a05:600c:3b2a:b0:4a2:cbe:bec2 with SMTP id 5b1f17b1804b1-4ac18a8882cmr283591465e9.32.1793695033262; Tue, 03 Nov 2026 00:37:13 -0800 (PST) X-Received: by 2002:a05:600c:3b2a:b0:4a2:cbe:bec2 with SMTP id 5b1f17b1804b1-4ac18a8882cmr283591085e9.32.1793695032830; Tue, 03 Nov 2026 00:37:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1793695032; cv=none; d=google.com; s=arc-20260327; b=LD7pzaxDtH4vqQiJZNCFnhfuLJOcadQLH0q+HwTaGSGtmEDlinaVbB1cn/5bYbuJM7 uOu+rfwquztolwhnsedrM8iLoJscOdcJsAvH/lsOUI4chrgsMgkflFTxiR7tdlniBwu6 xLXylyrLGY8VyNaOZrXybGLr8x2fKAbxC5fhjvhUQUikhz/rCtbp8zujjSEl7eXhGCmz liS4UOXAmLBVZ6ITGZ83hmdFC46UdUKFvJ6lALDGM2ClEvUwg0f8LwN7LNGR5xwDagnH bEhXmBQak0ZG3FO6b/rxdnEkucHLa1f+FrRtR0+H807yw+eGNleBBpneOAMRb0TXlTWk +jkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=OX2ZORp5N/OaAXVgecRdIVnEujHIzpA0+7LZ4EV4+KI=; fh=vltfd8c9Ya3muTL/bB64/Rc/YlDdOawwxz7Ce1M9jbw=; b=FIfgux/dsNYesCkM9CDX4amVXihLZSwJ2iq0Us0r4OvnWEO35gees66wt1YESf6Wn5 0BHwZD7euD42VhxIojYtiGPfrcGdWInmkLPciHm4gvVNnTCxWqBxAF4axA8/cx4qO0ZE 4JyyM2BmcCyDqm1ClrqFgfh/IuIUu2iX2rOUQX8hoa90sc3v2XTlXXCaoQS5PO3sGfY5 BX99s/BqfVn02mbjCQyq7SRvsaCbXmzyeCM3/Bb1S7C0GHkFg61WwiXpQnVeRJj4r1Oo ohbq0jDee4oommoGqcOPzMNo8dLlFLlxjDaL3dZ6m92qT39x9Mka3rQJbp5LZIgUUDfi 0+QQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@openvz.org header.s=google header.b=FXktnV3L; spf=softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:c789:8bc5:fa8e:d502 as permitted sender) smtp.mailfrom=den@openvz.org; dara=neutral header.i=@openvz.org Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id ffacd0b85a97d-48e8a280f6dsor253302f8f.12.2026.11.03.00.37.12 for (Google Transport Security); Tue, 03 Nov 2026 00:37:12 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:c789:8bc5:fa8e:d502 as permitted sender) client-ip=2a06:5b06:b600:300:c789:8bc5:fa8e:d502; Authentication-Results: mx.google.com; dkim=pass header.i=@openvz.org header.s=google header.b=FXktnV3L; spf=softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:c789:8bc5:fa8e:d502 as permitted sender) smtp.mailfrom=den@openvz.org; dara=neutral header.i=@openvz.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1793695032; x=1794299832; darn=openvz.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=OX2ZORp5N/OaAXVgecRdIVnEujHIzpA0+7LZ4EV4+KI=; b=FXktnV3L6JMdglvr8ADepBkgfMvSnCaVMXobbpgFhh8XtAeho5aZ6glK6+kzGhXu3w 7GUadQr5hGLbf5qQ3og/ZVS2G/TovpgjHv1sEUrFhkBvX6G3YeqJpF+XdU94rr0Tck+P olXn5eaTeJniy5BgI3+wv+M8hmRDB4WXkf6gEPDLXxGhQwpzwbcEYFkJ7cLHtVnau6Hy NYiC70BmePD//vMGaFb5njjN0wSMsi7jUxdHFfUIAOhwss6a3PehS7JH8MiKM60XZE4F cX870kdCYg8mTQR2WN3ahSAofCT2FFa6MKpQfFjeNWITHUq2yKcbfR6bDeeVL6T5ZDuG krwA== X-Forwarded-Encrypted: i=1; AKwUvBzY5WGGKE5yKtQGgRNvt0QmDPLOMhJSQt5KI8rb3p4go5hLAoTleF4jTV7DcVCfd+3tOpPQ0w==@openvz.org X-Received: by 2002:a05:6000:4210:b0:48d:f984:4a7f with SMTP id ffacd0b85a97d-48e6e2f7356mr30079002f8f.24.1793695032378; Tue, 03 Nov 2026 00:37:12 -0800 (PST) Received: from athena.sw.ru ([2a06:5b06:b600:300:c789:8bc5:fa8e:d502]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e71b9b54dsm23304588f8f.47.2026.11.03.00.37.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2026 00:37:12 -0800 (PST) From: "Denis V. Lunev" To: andrey.zhadchenko@virtuozzo.com Date: Tue, 3 Nov 2026 09:37:07 +0100 Message-ID: <20261103083708.131379-3-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261103083708.131379-1-den@openvz.org> References: <20261103083708.131379-1-den@openvz.org> MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.1 2/3] dm-qcow2: fix backward merge of an inner image racing its reads X-BeenThere: devel@openvz.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: OpenVZ development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: devel-bounces@openvz.org Errors-To: devel-bounces@openvz.org From: Denis V. Lunev set_backward_merge_in_process() sets the flag of an image other than the top one without stopping submission, as nothing writes to it. It is still read: a read of a cluster the top image does not map goes on to the lower image, and when that image is writable its worker tests the flag twice for the qio. When the merge starts between the two tests, the first one, in handle_metadata(), skips prepare_backward_merge() and leaves qio->ext NULL, the second one, in process_one_qio(), takes the merge path and submit_top_delta_read() dereferences qio->ext. Pause submission and switch the inflight refs for every image. The pause flag is only tested on the top image, where all qios enter, so pause that one; clearing the flag of an inner image paused the inner image itself, which held nothing back. Fixes: 8e522723a085 ("dm-qcow2: allow specifying depth to merge intermediate images") https://virtuozzo.atlassian.net/browse/VSTOR-153049 Feature: dm-qcow2: block device over QCOW2 files driver Signed-off-by: Denis V. Lunev --- drivers/md/dm-qcow2-cmd.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/drivers/md/dm-qcow2-cmd.c b/drivers/md/dm-qcow2-cmd.c index e520d8fd6929..cb28cf6456df 100644 --- a/drivers/md/dm-qcow2-cmd.c +++ b/drivers/md/dm-qcow2-cmd.c @@ -149,34 +149,28 @@ static int qcow2_break_l1cow(struct qcow2_target *tgt, struct qcow2 *qcow2) static void set_backward_merge_in_process(struct qcow2_target *tgt, struct qcow2 *qcow2, bool set) { + struct qcow2 *top = tgt->top; LIST_HEAD(list); - /* - * There are no writes if it is not the top qcow2 image. - * so we do not need to stop and flush requests when setting - */ - if (qcow2 != tgt->top && set) { - qcow2->backward_merge_in_process = set; - return; - } - /* * To avoid race between allocations and COWS * we completely stop queueing qios and wait * for pending qios. Lock is for visability. + * A lower image has no writes, but it is read by + * qios of the top one, so stop the top image even then. */ - spin_lock_irq(&qcow2->deferred_lock); - qcow2->pause_submitting_qios = true; - spin_unlock_irq(&qcow2->deferred_lock); + spin_lock_irq(&top->deferred_lock); + top->pause_submitting_qios = true; + spin_unlock_irq(&top->deferred_lock); qcow2_inflight_ref_switch(tgt); /* queue is stopped */ - spin_lock_irq(&qcow2->deferred_lock); + spin_lock_irq(&top->deferred_lock); WARN_ON_ONCE(qcow2->backward_merge_in_process == set); qcow2->backward_merge_in_process = set; - qcow2->pause_submitting_qios = false; - list_splice_init(&qcow2->paused_qios, &list); - spin_unlock_irq(&qcow2->deferred_lock); + top->pause_submitting_qios = false; + list_splice_init(&top->paused_qios, &list); + spin_unlock_irq(&top->deferred_lock); qcow2_submit_embedded_qios(tgt, &list); } -- 2.53.0 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel