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 47E5E811BB for ; Wed, 4 Nov 2026 18:42:05 +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 6A4IemeD025987; Wed, 4 Nov 2026 21:40:49 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6A4IemeD025987 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=default; t=1793817652; bh=Q7A1ZekEjjz4eIGlCCYFr2S8Wuf0FVDdzlQ2vg4guaY=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe; b=hQGHDN+XTqyAFiF8k07dtszcSvW2qDKZVQv8NbShwKK3DbkdW8i/sh22393ZcW04v J0p7QqjX7xMheBq0AXwUTCJC7eVnOX3pZCjgyzWlZakTOn6X8KsUUyFX07qRMqaObe qZrXT4aQDOoDPr/bDfOtIVJb4MO0xVsYBPLDsEdXenX9Fgv3opFjVgZ9tFj349kGK9 4y56Jop3vVw93pSOZaZXo8QMVqmZujkGNrOgwZiRhLvzJ5WW3PBi5idgdYtXQjtnuv tJ8e9ynIJVXz4tzOhHblygipShVOZpsXHBvzW7QSFx1QoTBQZpyKHRREUPRVyumGVK PQEIcs5ausspA== Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6A4IekuM025983 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Wed, 4 Nov 2026 21:40:46 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6A4IekuM025983 Authentication-Results: mail.openvz.org; dkim=pass (2048-bit key) header.d=openvz.org header.i=@openvz.org header.b="CWTfyfbH" Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-6b1d35e3c0fso488334a12.3 for ; Wed, 04 Nov 2026 10:40:46 -0800 (PST) X-Forwarded-Encrypted: i=2; AKwUvBwjDpqY9x10SMmf/U5XID80E4VXEkP/pU38BvOUX+UVUKhR/bZsFSEw9rRzt17JWWreNYyNLw==@openvz.org X-Gm-Message-State: APuU4Z8e6XwN5+/WZGEMzjI1Ph+kSPRng405wWzYi6PNF7l5YYX+kn6N o/31N0FKTizzJ6dsAtUH59+bolANI1Tq9kYn2bcJuen3GBVMwytimxPQeAqHChEkNhrMxs2DLXd Vc5CNGZ3zvfAgg6C5+tBl3GNOSlaPhFceqjmvPkSWcU0OmR9bONj2QQ== X-Gm-Gg: AYBFou3zwT0z5e9UKDHKMTzI85dUrCFDlby82HTS5fGgEmKASSVpROssNryEj+Q2USx 1pllmGfdvI/qMeKOGN5ti7tMPbAHLxbaHRk1DiYcxeg2r1CmTVCcofVMxGgVkp9njT3SkyMG+hU 06jkE/iATdwmj9cp1gPjuYM9nta/DlDxyjnQeDwYVzXhgJXThSO5vvTMVNYRuqF1zTmG7EtkhbH H1CIwFg2xSIgwh/2feZnlPsKBXD16yAG4Y8DoYgh9Ah4tIxGvsIj0b8OLcZFgF3Wk8foMNkcUYN rjKz6TvHcQ== X-Received: by 2002:a05:600c:8b0a:b0:4a1:777b:8a12 with SMTP id 5b1f17b1804b1-4ac1709ae4emr406492115e9.14.1793815271611; Wed, 04 Nov 2026 10:01:11 -0800 (PST) X-Received: by 2002:a05:600c:8b0a:b0:4a1:777b:8a12 with SMTP id 5b1f17b1804b1-4ac1709ae4emr406491555e9.14.1793815271081; Wed, 04 Nov 2026 10:01:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1793815271; cv=none; d=google.com; s=arc-20260327; b=YvaIPjSVyGQxrnTrwWBQQrX78RsE77YwcSEwFcrnMiDjDNj6rVF1kzG2WSgGfoKbzn E1rrrZhI1wkdH6pYLP2OLCO2YdsMSI4FOxXhFRySh64PYrUEz84P7FMRJWe120odocdb 10T8B1HlZPBcLloD1L8KD0sczlnbtLSLg0/6M1WkUQ7pQWrdxiDHK0paw/P9MYmV30/t ldgJ6sIkTO/0/fqT13JxLv1tXEqJdw+HEcMVVzQg+qphG0qaA0fcAEJ4L8FwaOe1k87S OAyoo+PqPzZKwh7K/CjTxexa8TBQ4JzDwPsR1lEuZxOd4AwBt6r096gKwNe8EeDGbAUH M8rA== 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=LSDjpnINekEnW57AF29SI+0coandxRban4E1P2DBZl4=; fh=PL+qNCGYunYXfCtg+ftJekPJGMnvqP4+iYBapqVwDRw=; b=PpRrF6p30rfQ2hi2Hz2zD/CpeGeKjhjqrBWfaKoSlH4lfE5ZDtFqUqxYZ+sjHe6gZW ftXGHR9cFxYLon3CmS9Zvtj9yWYfNSehdzTfZONGExAAXsYBC+CTf9UELP/kdRSQz5nG qFbbLjWRDUIAeBr3SXDIY2O07SXEmozz9e7lQscpds7Ajn+JZQRzbOkyqyRj659aY8UF VCf8prpF5lWd2DzXVGhEk6IIF+58jvtmyUKG9Xv11Qcs0pFGp6TjEppYrYpxyp0AEA1Z 6VUn1AgiGkglnaTjPefnnF+3l/8XmUN/Pww/wr+l3vI68+yxlvImIq9bEcD8HBDfYWRu nw9g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@openvz.org header.s=google header.b=CWTfyfbH; spf=softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:162e:5a6e:fd46:18b7 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-4b43e2524edsor5464265e9.17.2026.11.04.10.01.11 for (Google Transport Security); Wed, 04 Nov 2026 10:01:11 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:162e:5a6e:fd46:18b7 as permitted sender) client-ip=2a06:5b06:b600:300:162e:5a6e:fd46:18b7; Authentication-Results: mx.google.com; dkim=pass header.i=@openvz.org header.s=google header.b=CWTfyfbH; spf=softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:162e:5a6e:fd46:18b7 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=1793815271; x=1794420071; 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=LSDjpnINekEnW57AF29SI+0coandxRban4E1P2DBZl4=; b=CWTfyfbHxtCgRjv1xia3prQw2GvdwvQ1W9K0q8VOH8gRELvIarIRWyV7d5W1QHZf8K MfQu4afUCla3WIm3An6k0Tb5bloIUBTN8xeWO+wo6DEhrRYQT/eTQVkzokqpc7H0KWJE X/YUbQ1FMzPVqU+Uriz/eYvSRHU4FWJBNuKAUrB55pPiJmx723pJKocpe5cvayHPHx2K WbHsPzkFED0RWQAngnHb273D2nN9dOXlVYkaF5p0CHwbWZdPtoNk5hR+j3jG6tuOCPeS Mc0f4H4+s9YAc1VfKlWqM0S/zcSzXCZkRD/A5gfkWwj1r0WGbeRP2f10tCWQ9uXAGiju RnHQ== X-Forwarded-Encrypted: i=1; AKwUvBxcKWm0OZQHm/PMCwsWh7MzzfhS/Lu8n8ambTU8kqz6VXo1IonWltAenmj3oCz9P9enA33ZWQ==@openvz.org X-Received: by 2002:a05:600c:6087:b0:4a1:fe26:24f0 with SMTP id 5b1f17b1804b1-4ac1765ce52mr362405345e9.20.1793815270602; Wed, 04 Nov 2026 10:01:10 -0800 (PST) Received: from athena.sw.ru ([2a06:5b06:b600:300:162e:5a6e:fd46:18b7]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48feda20521sm5050716f8f.53.2026.11.04.10.01.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2026 10:01:10 -0800 (PST) From: "Denis V. Lunev" To: andrey.zhadchenko@virtuozzo.com Date: Wed, 4 Nov 2026 19:01:02 +0100 Message-ID: <20261104180105.1807820-3-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261104180105.1807820-1-den@openvz.org> References: <20261104180105.1807820-1-den@openvz.org> MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.1 v3 2/5] 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. Starting or stopping a merge of an inner image now pauses guest I/O to the top image for the inflight ref switch, as a merge of the top image always did. 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 Reviewed-by: Andrey Zhadchenko Reviewed-by: Konstantin Khorenko 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..0e2c810f657b 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 guest 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