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 263F480067 for ; Mon, 23 Nov 2026 15:38:06 +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 6ANFarQ5021176; Mon, 23 Nov 2026 18:36:54 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6ANFarQ5021176 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=default; t=1795448215; bh=bneRvyVsP5MskkTj0kRncfIMTWaJYb4isGBySJXu+9U=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe; b=jw3Nyu66NA0brbiv764j7aTIqHQemsUVZEdeyo3FKK66z7sK3P3Fd3PTseG/+XaMC BrNJFyTJssRWbSsn4YgEhqXduCbsTOk6hX6xoAS+sazRwoBTTEsE6w5aO+EZ7U2gIq /GCvblY4c406kuzgywh9uTbwIfJMFisN0gH0NvmbhLLG/Yi6G6hFpoutaySlpn2UZy JgGi+76/7Cpg9FRmDj0Q2H9mQ8ZbZCdVgMpiYVnmZcrs8KeqPsfM5lq9TqieMH2Dpp F0EchyXZgHt81hCd+ggwpNcN5Vrqqakg7sowRK2XmFB5kpZxQUXAUaRA/EAYYIUS9T gV07ufNISiBYQ== Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6ANFalrx021137 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Mon, 23 Nov 2026 18:36:47 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6ANFalrx021137 Authentication-Results: mail.openvz.org; dkim=pass (2048-bit key) header.d=openvz.org header.i=@openvz.org header.b="TPJuDmyI" Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-4903fc8537aso2236347f8f.0 for ; Mon, 23 Nov 2026 07:36:47 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErFME1MVgyYXLLWHxvQRGLy7/n2w5vfyOj6w9qqr6LqkYM4RTeXiwst4MzYAB06TbDuf17q1+g==@openvz.org X-Gm-Message-State: APuU4Z/UF6lAkFyZY+7cC6c1PRBRCOcB+eqg9dtb8bcpH7xRZ0QoM7HJ NPGlQlEd3W8zpeR7KBtJucDQZK9cc6unjPiJ8kJYsB8OSGOccQJs/qTVHBvHSMRlw/hU+BFybNT Hd/6bWSTw4S0r51fRz5Um4fwBgC71KGcVj6uVytanit8x076o3qWMDQ== X-Gm-Gg: AZFdTZdE5gStyPcMmw2pCH6deoN/kT0XkywxmN2hBxTe5l2JFYGmjojP1DNgolmuv1f mQlV1G331r3Fi51WZo8e7MXpTV8b8kxMQqAKMiRIndz/O2yOaVBqk9G2ZtqiQI3X+mywRqfQUnH RWt0apKH47VdjdaOeALwOtPhrBltIxFRiBYgJMwnnRJuu2/UOXGePu6r5FpNBROztSR1b/Kn91h GgkKML7wHiVKkNqlyR0QB1Cydh2rVgPdJ/lJOvIHP35VYm+JljL8/6pDUzHDPFl0mT+PXYzB/oF TP4XFasXEg== X-Received: by 2002:a05:600c:848d:b0:4ac:86c9:b09c with SMTP id 5b1f17b1804b1-4bb88811da9mr252269895e9.13.1795448206974; Mon, 23 Nov 2026 07:36:46 -0800 (PST) X-Received: by 2002:a05:600c:848d:b0:4ac:86c9:b09c with SMTP id 5b1f17b1804b1-4bb88811da9mr252269515e9.13.1795448206574; Mon, 23 Nov 2026 07:36:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1795448206; cv=none; d=google.com; s=arc-20260327; b=dQ0y9XwmPFJrbfo1ZZJbnnqKTS5rxAYXJDWfJAuZZz4GXCzXmlx+f+Ln7Xnximkovn iKusbet4ThILguPX+ZELmsiWkUH2ehhdwQn/Q9ujEmCsdnY+jRUNbBRc9FNKDpLJlIbD dcrD0tMgF0UOEjWYh4yJPp78yAGvFkU2gIBsRs+RDFn0CjiFxP5t42gTxDOP8l5x/fXD RS+SfRZihuOB64kTXYPeASXh+vEGU1PJfQpVfdUH/FegUBPRvUNzJ7ZMgur1IDhofqTK IXkabNtTD4usrT1GEsc6oTetW3n+ACS4iF9c2Cm8gHgCU5iEMxOFRi0NI1G2+Pqc/z0I nSUQ== 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=Vi5JUAYqOrYcHgixdLnWLQQQ+rfD/fzRFWjtJYu1/Ug=; fh=Sv96/m7REaCWDQ9UUYZCs7ybSyT+NuylPuR5+aVj5xs=; b=CI2dn9e8h2kDK0rEy8gQE8h6T16/aTDUditjGsPAj7F5YN9tnKzOPGQxJ0wzXnant5 gGDNPuQ0kT1kCdrY6bVbvytCYiWPQyoCsZPvkZeg+yzyhAgmMPQ5wXmcQPMWPLUiSyVv CqEJhIHkRlDr4PSy7WX1H4WWkjMmQstKjEq5bfVzxT0vj7OZ8wOsRJH0f5S1Qww8UlMt y3fH/drhK2r2qjSQhGUVMipelNufoBLsGJ75Y1juAYLcnklr8KW+cREtr1meFFdXWG9s t/g9d3+jUn1GrLWmZ+NnLuenLlyvfsi54Kc8ZP/wrjBVVNM1CYGKhJHY0+RTXLB0qRLx YgUg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@openvz.org header.s=google header.b=TPJuDmyI; spf=softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:62d2:2eda:8655:4219 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-4bb8847f9e9sor22529205e9.12.2026.11.23.07.36.46 for (Google Transport Security); Mon, 23 Nov 2026 07:36:46 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:62d2:2eda:8655:4219 as permitted sender) client-ip=2a06:5b06:b600:300:62d2:2eda:8655:4219; Authentication-Results: mx.google.com; dkim=pass header.i=@openvz.org header.s=google header.b=TPJuDmyI; spf=softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:62d2:2eda:8655:4219 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=1795448206; x=1796053006; 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=Vi5JUAYqOrYcHgixdLnWLQQQ+rfD/fzRFWjtJYu1/Ug=; b=TPJuDmyI5Y156myaDIeZfV8WSaaKeCTqDJmTYofSdGNNq36SZr3osTuaJubFJlk5kb CQeHsrXYO9zrhAKm1S0dta6KQr2ABvbpwpD/j2sZuqeznvgvgTyVHrCxlM9tMuRtayjg 5zM/SSQ1UqVJJWBS6XdGN2tdIkNnifK2gMDf9UKugLrB/BuQQ0/3xHxNfq2QvVZWvTXt JCzIqzYL5qLX6jbh0D8HBRtY7IM7Q9ou8cmomsp3TmV2Rz7VHW48Vro2Rw8bMTfPsVqd KeEVt7w4c/jDZ4NDqHei+vH1jiKN+0nHSZNk1jx+zxLDMsbqZeazyeioSoz+K1OpUAax 6YDw== X-Forwarded-Encrypted: i=1; AL+hErFHSfs7xCskJduqge8Mr4xL6oelRtzt3ACGq1WeUWK3JNdYDPlqvMC5CfS6iM2W2EQYhN7hWA==@openvz.org X-Received: by 2002:a05:600c:4f4b:b0:49f:fd2d:23c7 with SMTP id 5b1f17b1804b1-4bb888226c0mr291182685e9.27.1795448206169; Mon, 23 Nov 2026 07:36:46 -0800 (PST) Received: from artemis.sw.ru ([2a06:5b06:b600:300:62d2:2eda:8655:4219]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb884b7515sm491797455e9.13.2026.11.23.07.36.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2026 07:36:45 -0800 (PST) From: "Denis V. Lunev" To: andrey.zhadchenko@virtuozzo.com, alexander.ivanov@virtuozzo.com, vasileios.almpanis@virtuozzo.com Date: Mon, 23 Nov 2026 16:36:34 +0100 Message-ID: <20261123153640.128227-3-den@openvz.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261123153640.128227-1-den@openvz.org> References: <20261123153640.128227-1-den@openvz.org> MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.2 v2 2/8] dm-qcow2: fix do_qio_endio() freeing a qio into a destroyed pool 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 do_qio_endio() calls the endio callback, drops the qio's inflight reference and only then frees a QIO_FREE_ON_ENDIO_FL qio into tgt->qio_pool. Either of the first two can end the last user of the target: a split qio's callback completes its parent request, whose reference goes, and a metadata page read drops its own reference. Suspend then finishes, and a dmsetup remove destroys the pool before the free runs from the backing file system's completion context, which oopses in mempool_free(). Free the qio first, then call the callback, then drop the reference, so that nothing touches the target after the last of them. Read the qio's fields once its last completion has arrived, as children write the status of their parent up to then. https://virtuozzo.atlassian.net/browse/VSTOR-156036 Fixes: 222b6f1291c1 ("dm-qcow2: Introduce driver to create block devices over QCOW2 files") Feature: dm-qcow2: block device over QCOW2 files driver Signed-off-by: Denis V. Lunev --- drivers/md/dm-qcow2-map.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c index 90e699050131..2227e06591e9 100644 --- a/drivers/md/dm-qcow2-map.c +++ b/drivers/md/dm-qcow2-map.c @@ -405,25 +405,30 @@ static void qcow2_free_qio(struct qio *qio, mempool_t *pool) static void do_qio_endio(struct qio *qio) { - struct qcow2 *qcow2 = qio->qcow2; - struct qcow2_target *tgt = qcow2->tgt; - qcow2_endio_t endio_cb = qio->endio_cb; - void *endio_cb_data = qio->endio_cb_data; - unsigned int flags = qio->flags; - u8 ref_index = qio->ref_index; + struct qcow2_target *tgt; + qcow2_endio_t endio_cb; + blk_status_t bi_status; + void *endio_cb_data; + u8 ref_index; if (!atomic_dec_and_test(&qio->remaining)) return; + tgt = qio->qcow2->tgt; + endio_cb = qio->endio_cb; + endio_cb_data = qio->endio_cb_data; + bi_status = qio->bi_status; + ref_index = qio->ref_index; qio->ref_index = REF_INDEX_INVALID; - /* Note, that this may free qio or its container memory */ - if (endio_cb) - endio_cb(tgt, endio_cb_data, qio->bi_status); + /* The callback and the ref drop may end the last user of tgt */ + if (qio->flags & QIO_FREE_ON_ENDIO_FL) + qcow2_free_qio(qio, tgt->qio_pool); + /* Note, that this may free qio's container memory */ + if (endio_cb) + endio_cb(tgt, endio_cb_data, bi_status); if (ref_index < REF_INDEX_INVALID) qcow2_ref_dec(tgt, ref_index); - if (flags & QIO_FREE_ON_ENDIO_FL) - qcow2_free_qio(qio, tgt->qio_pool); } static void qio_endio(struct qio *qio) -- 2.55.0 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel