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 3358E803F6 for ; Fri, 13 Nov 2026 11:18:15 +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 6ADBFtO1016613; Fri, 13 Nov 2026 14:15:55 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6ADBFtO1016613 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="NoqLFL43" Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6ADBFlGF016576 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Fri, 13 Nov 2026 14:15:47 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6ADBFlGF016576 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-4903fc8537aso429243f8f.0 for ; Fri, 13 Nov 2026 03:15:47 -0800 (PST) X-Gm-Message-State: APuU4Z9/MieBtP/xBkxFYR5dqvumin6RXHN3xDJ+QRpFBlFFr4FSqge0 KtOntxkD/QlyHb3AxrCCM6m1iU8CsGqXRBrVGKCfwjC8BkMEfqZlGkG5Bn9xB5BRy6OZDb4b+aQ p07gEDuY6rDFfklDGc8exsGXctVKgTJV6nrLPKVdBhPAUlg3gnT4YmQ== X-Gm-Gg: AYBFou2MQfEOdIvyOHGP297FlMaKLyVySqHY4wMf1tqdUXch+RmBJODr4Qw/6Id86/M 8FnIzF8zxboL2oioiEAP3eZSgmFrzENb6TxNN113tokZUKJYnJ20n26DKhyElHwvtrXk250vNcz cOydTcybfGvigPcvN2ho9QpXhjcBgp2b0EuYJBnnjbVs62fqKIa8bWdXRk7a75mktYNTb7pORnS Zkkf3NuVLe85MkBKWic6Mri8za21nwqlkwnlQciu/vUp/bkdCw3jOI0NKPgksnsXQIw96KR9W0i rD/JjeyO8kkid+yrN17xH5/PUNO+LbQEU/KictjYT/ibD6bnOWVxXyCtmFbe5sHRzFC7IVqBnbV GT1uret58oL0cEoYG73itnPMZ7H6GnQ== X-Received: by 2002:a05:6000:25e3:b0:492:b1c5:6db5 with SMTP id ffacd0b85a97d-49c73bf096bmr4520508f8f.32.1794568546801; Fri, 13 Nov 2026 03:15:46 -0800 (PST) X-Received: by 2002:a05:6000:25e3:b0:492:b1c5:6db5 with SMTP id ffacd0b85a97d-49c73bf096bmr4520454f8f.32.1794568546217; Fri, 13 Nov 2026 03:15:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1794568546; cv=none; d=google.com; s=arc-20260327; b=QLB3IEmjfDQFsLUR9qP4T69qenRAIJgHsmZA85ACeBTyxHM5usNFF1vi8YEI0wWION IblFMbRY6Vy/kVXDsF6PeRnjZ71SaH8jFHteV9sBKVI6SWTP4gb4WyyaylwpFCbC0BOg Ja1ldwW9qQNwPU3TBcNQHiuMCYazrT+yHQ3YJyrr7S0mlSbTdlWR4Mbv6ftaZSpzS0dV x2n6BD7zUViucHvxxaCs81ELOUc5M/Wpt/ugwXKysxLm//sKJT2ka2kDq09P6XK95vMU UH3WWvTbE3NKGWbp0kpKn18V3pY1g4m/h1y1T7GEYPzFsgCeQapw5Eox3oKCTvW/1/qF aUMg== 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=x+mHIfPPu73tiXTHYOwhLVERdyO44euj/khb6BGOwW4=; fh=ElTTnnNtphHTCCOZ+58STyaWac7y7ytLDJZIF4HMMJ4=; b=Zfvd2HptIp1s1g2wW/Wza6Cx49878PA6CtXoMmpfAobKpLp5GVu2p84VGCUG9y7Bjt MVBnU83D8Aulx5ck/7IzxHdxVBCJMEyboK6luAQQJ8576S4LXI0cMdtBlC+injgmqIWN tvDOEY1c+eqOSJcfT4e+tzfa8yLPZ3AugXeT+IrQnNTCvMyqZ60sJ3sLpEV62m4dU/PL v7sTHjGiOFdN8Vm66300jf9Y701qqAvTT4wX8g4NXG7tlkR/V5FTgYt3yZH11h/Pvv2f H9/Sshx6pNqpbXDvVC1MUleIKybs30wx5PwZUzjAzNSERzkwNxgkuSG5UgAb9yWFb6bV 1YYQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=NoqLFL43; spf=pass (google.com: domain of andrey.zhadchenko@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=andrey.zhadchenko@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Received: from relay.virtuozzo.com (relay.virtuozzo.com. [130.117.225.111]) by mx.google.com with ESMTPS id ffacd0b85a97d-49c64b0a2e8si4673706f8f.396.2026.11.13.03.15.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2026 03:15:46 -0800 (PST) Received-SPF: pass (google.com: domain of andrey.zhadchenko@virtuozzo.com designates 130.117.225.111 as permitted sender) client-ip=130.117.225.111; Authentication-Results: mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=NoqLFL43; spf=pass (google.com: domain of andrey.zhadchenko@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=andrey.zhadchenko@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-ID:Date:Subject:From: Content-Type; bh=x+mHIfPPu73tiXTHYOwhLVERdyO44euj/khb6BGOwW4=; b=NoqLFL43FCeX CsoFbbbvolansfIZmGWu6IBBXVk7mYynZY/i65FxImVSqVH0MfxVDXAXRzMsnC8ON6VripB0tV4p3 CX9dJ9j7XXZFuJn+i45K9ZgqeyaOPsYc9fycNl7uUcvPhuik73PkiCN1/5KK9vhwzMQO+pc54031O P0Qa0RGMnCsJDgXFdUbviQyce1O5i2HQBe0SR8y5roqmlW4CAf6ZRRYxXxDBs1WdG2UrsSx5PBQjx S2SBXusBiUmVyQaLzkOhBMaY1fv/GPOzYGHLETzUiwIkQsb1YclwR2QQLtlRKzdiG+eLmdCnvPNNO 5/lTbr3ugWgX+PPYAIUakw==; Received: from [130.117.225.5] (helo=vz9-demens-1.aci.vzint.dev) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1xRpBn-007Dd6-1Y; Fri, 13 Nov 2026 12:15:42 +0100 From: Andrey Zhadchenko To: khorenko@virtuozzo.com, alexander.ivanov@virtuozzo.com Date: Fri, 13 Nov 2026 14:11:19 +0300 Message-ID: <20261113111126.793039-2-andrey.zhadchenko@virtuozzo.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20261113111126.793039-1-andrey.zhadchenko@virtuozzo.com> References: <20261113111126.793039-1-andrey.zhadchenko@virtuozzo.com> MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.1 v3 1/8] dm-qcow2: repeat md page lookup if it was inserted in parallel 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 parse_metadata() is called not only from the main kwork: qcow2_llseek_hole() calls it in process context, in parallel with the kwork. When both miss the same md page, both drop md_pages_lock in submit_read_md_page() and try to insert a new md page. The one that loses the insert gets -EEXIST from qcow2_alloc_and_insert_md_page() and returns it as is: a guest I/O on the kwork side ends with EIO, or lseek(SEEK_DATA/SEEK_HOLE) fails with -EEXIST. Teach __handle_md_page() to handle -EEXIST by repeating the lookup: the page inserted in parallel is found then, and the qio is either served from it or postponed until its read completes. Repeat it once only. The second lookup misses the page only if its read failed and erased it in between, and then the qio fails with -EIO as the qios waiting for that read did. https://virtuozzo.atlassian.net/browse/VSTOR-95494 Fixes: 412d5a4f7bf1 ("dm/dm-qcow2: add llseek_hole") Feature: dm-qcow2: block device over QCOW2 files driver Signed-off-by: Andrey Zhadchenko --- v2: say in the message what fails without the patch: the race of qcow2_llseek_hole() with main kwork; added Fixes: tag v3: repeat the lookup once only, a second miss fails the qio with -EIO drivers/md/dm-qcow2-map.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c index 32373114580e9..58b95d7a955cf 100644 --- a/drivers/md/dm-qcow2-map.c +++ b/drivers/md/dm-qcow2-map.c @@ -1676,20 +1676,33 @@ static int submit_read_md_page(struct qcow2 *qcow2, struct qio **qio, /* * This may be called with @qio == NULL, in case of we are * interesting in searching cached in memory md only. - * This is aimed to be called not only from main kwork - * for L1/L2 pages, so all callers looking for L1/L2 - * must care about submit_read_md_page() may return EEXIST. + * + * submit_read_md_page() drops md_pages_lock, so the page may be + * inserted in parallel. Then it is looked up once more. It is not + * found again only if its read failed in the meantime, and then + * @qio fails too. */ static int __handle_md_page(struct qcow2 *qcow2, u64 page_id, struct qio **qio, struct md_page **ret_md) { + bool retried = false; struct md_page *md; + int ret; lockdep_assert_held(&qcow2->md_pages_lock); +again: md = qcow2_md_page_find_or_postpone(qcow2, page_id, qio); if (!md) { - if (qio && *qio) - return submit_read_md_page(qcow2, qio, page_id); + if (qio && *qio) { + ret = submit_read_md_page(qcow2, qio, page_id); + if (unlikely(ret == -EEXIST)) { + if (retried) + return -EIO; + retried = true; + goto again; + } + return ret; + } return 0; } -- 2.43.5 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel