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 B8F70811BB for ; Tue, 3 Nov 2026 09:09:43 +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 6A398Tik003102; Tue, 3 Nov 2026 12:08:30 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6A398Tik003102 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=default; t=1793696912; 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=qsYmEroqxda1OZD1cTN7UJFJEx+zdni2KzRjMgM7yORpRjEmUaEx1HRzYjGnAXY32 6vlCrkt0DHI6Bc/dzcUVe/7kUlY4Gyg0O692qtFaL507AWBZRQP6mXiQ8adklXOjkZ Z9VBjDW+aIp+UJVGaDB2CIbBIF0pTIga1U4bly1Hpzzw9OSBGia5vIy36Qp4kEaDGO lHIKHlvJc+3VpKFvg+OxtK5hqYZmUKNntB8CerkAtwIYWkaSixPYW9AbNH/gGSd+Sx ismzfq7mofB4sR0SEEzwpzKw/Q0renCbwJcuJKQEZ/4mdeENwnU4Wj5f1OZ5Jq4cWd oVvLL1NDeiekA== Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6A398JmC003080 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Tue, 3 Nov 2026 12:08:19 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6A398JmC003080 Authentication-Results: mail.openvz.org; dkim=pass (2048-bit key) header.d=openvz.org header.i=@openvz.org header.b="gYR+j+Sn" Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4a77c1cbd15so39045175e9.0 for ; Tue, 03 Nov 2026 01:08:19 -0800 (PST) X-Forwarded-Encrypted: i=2; AKwUvBzY/t7nKa5mieUOhmSd7uP9aSyvev6rGAIomdwB7Yn5+peaHYG+0EMQuzgc10QPxTTCrYcmaQ==@openvz.org X-Gm-Message-State: APuU4Z91uWrxgkKSBoiiI1EOE1LD6g4zxfDXGN45roi3G6pINluFG9eE nikQYHLlWezuhq1dpgo36cUd43SDQD0MZW4piek7cTJxprlJW7/OMRXBr37bJTwkY6PPggyL9u1 0h2WwCr1D7WCm6P7KV9J0zkiP0D7mEjYdmxJusggwdJ1QITsJGntQlw== X-Gm-Gg: AYBFou1gdp06FtpN27brfOxm29x/8NmJhlZley15C+KcTWsr18GvAOkEVE1o2GlwuPq QhmV4T7skoUlPcpAnKAzdNTggBq7cRgf0k4+RnyGOVNaFePOlkNoWp2JA62TeS8aJXUEyeAteGO HukZkpNKCeyr6wu3xcTwduwkXkGld13nq5lMHVV0qgR1rVFT+84JYnV1U9okkk+gFnyT/vk4YJZ OpO2GYVIVvkSJ1NIdFs758xfHdsy0V4bDZAYua09idCuhRzZ0DpepFrfKhamVG59/co7ugJUcMP OA6uDaahHQ== X-Received: by 2002:a05:600c:1990:b0:4a7:462c:6b9e with SMTP id 5b1f17b1804b1-4ac1923581cmr271479315e9.32.1793696898967; Tue, 03 Nov 2026 01:08:18 -0800 (PST) X-Received: by 2002:a05:600c:1990:b0:4a7:462c:6b9e with SMTP id 5b1f17b1804b1-4ac1923581cmr271478755e9.32.1793696898495; Tue, 03 Nov 2026 01:08:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1793696898; cv=none; d=google.com; s=arc-20260327; b=WN105Ocv9tr3MYvlUZzapcrgmVbF4t9kJX5gT+xkgl85fKJAYBHy/Zn/fiqfK9jB4E pWklmTnwT/sa5nhTOPTMYsITEuTbm8dBqQBhffZ7o3t/09GjE/OiaEBspECMluF7xYQ0 l9XiwY2rcskucMjtNzsxf/79ios71CMzPa/zmYLx4arow25coQyC/1Sknxugibf8Kplh ftvicnx1h58mlszDF/wiBQWvurr6CB6/uq4RY7M42Z/+dq1z1esqT0nvWuLpZegsDafK iLfuAF6p6+tMQOHWohxyzHOHMOYjM7+zrxd/qRfVD1Q81+Pf7bOUuQAyHXZPCumOXyg1 +v6g== 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=ZCKsYY8eiXLBV2iDPm7x0FjKFvH/xGjNtVPfXK6u97s=; b=UKza8I5Ex0CYPFr3wbyFtuTJ9CfFKqLrW+IqRhlspi/Zzb0QaNshOls3Y/Xw3NZP6l X1pfTcfxRN+Q8jdf+fjRohyZjaHjQyYNUPkFclW3zTCDbJOuIXBf4PVCJhr3ARinwLhO IUv2eosy2b5u6VESFweNHrrKFkr2TBMrPr6FYgzN6zokmH4uk/qKScq8BGZLv0Dip0uc N22TOeOkXVQcS0x7E/ZwQeAeSYp4HL4nVJYPsP6tvuSEb+gd+8PpfDrZQ2NJ4w0FNJoC +/GUROGI/wZTjphSO+NUvLGMV7YBUDz6tBI3RtbCsukQ6gcbCEnQMhAn5Pw2Fozo/0g5 dt8A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@openvz.org header.s=google header.b=gYR+j+Sn; 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 5b1f17b1804b1-4ad382323c0sor18287095e9.17.2026.11.03.01.08.18 for (Google Transport Security); Tue, 03 Nov 2026 01:08:18 -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=gYR+j+Sn; 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=1793696898; x=1794301698; 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=gYR+j+SnbLVjE5WBcf8cq07arvg6lafGIc+8IeG68e4qsXjiXdta5KRIde9LFOzDgu SmQdgoQ3pUQ9n2FQTaNXWwZ67e0sVnEPdrTCHvDhcrmUy+PA2CKxST8sECN5F0IoE+8+ zzy4JC9rqnKn/UvcdczGeqOpPm5Z8AfGAswKuzJzWWGwcghbrO8nLyH3jrZNtEVBdzdQ +spRjEeFHm/9o+Hd0C6GLJV8a43vFbNa1CbB0uzaUiwIrl1AcHmDeO2mK14TXAkbzHmJ ubOy52PUsuTatZ6aT3a5Dd+O1OxL0GN4W2v6dyY780dT/M4QmFl/4gy/PCN4r3a6QzS6 x/Cg== X-Forwarded-Encrypted: i=1; AKwUvBw8xw228zUdWqYjGbXpF7BUvYmB0JF90eOLuX0lJET40rBMnu/qCkfSRwaQxDG4PMXG8rcs1Q==@openvz.org X-Received: by 2002:a05:600c:c87:b0:4a8:cb23:f71b with SMTP id 5b1f17b1804b1-4ac186b1a2amr289986175e9.18.1793696898087; Tue, 03 Nov 2026 01:08:18 -0800 (PST) Received: from athena.sw.ru ([2a06:5b06:b600:300:c789:8bc5:fa8e:d502]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4b2a96fc933sm45453365e9.11.2026.11.03.01.08.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2026 01:08:17 -0800 (PST) From: "Denis V. Lunev" To: andrey.zhadchenko@virtuozzo.com Date: Tue, 3 Nov 2026 10:08:12 +0100 Message-ID: <20261103090813.166986-3-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261103090813.166986-1-den@openvz.org> References: <20261103090813.166986-1-den@openvz.org> MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.1 v2 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