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 F3F3B80027 for ; Thu, 19 Nov 2026 11:50:47 +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 6AJBnOxi021499; Thu, 19 Nov 2026 14:49:25 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AJBnOxi021499 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=default; t=1795088968; bh=QhMW9ltbJwwmNTWm2W1ifMOgizsTkNS2Dw9/KW3XUKU=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe; b=Et63fp342gQzSLnmfcd9Lg+qLaeCiG2WSwcCsPItXKhmceEf+eiRp6+Sx/5mWQSzT uAhR+9pGLxpYpdY6ZPQYB/f3GCqlNgRjYiNo66RBzNHgCtEnYxnBvDdGPCLDvdIu7R YTSRTZi8nG9n0IIGqMkBUHRp9KspHuOfCUM3sk+Qwh/YckIxKPxOYOgouWjWw/iDZN BNJKQ3MZcg4DZQKBSG7n0iQjgptqewM2+iZaaiKxBBVEU+y99pMi1aJGY3pwZdiLhD i8pY89zmBGBCMBvukGxFnEXN+gJ7zieZGD2hdVZK2epYiuQ4FIe6G9r8C2L9V0i4DB PpTy/aiSo+Mng== 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 6AJBnJ4r021472 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Thu, 19 Nov 2026 14:49:20 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AJBnJ4r021472 Authentication-Results: mail.openvz.org; dkim=pass (2048-bit key) header.d=openvz.org header.i=@openvz.org header.b="JYiOWvPk" Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-4925ef75fc4so1634062f8f.1 for ; Thu, 19 Nov 2026 03:49:19 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErEYcd7FpAqVpA7FTnf1vW1F66GPrPjyCiUWchJk8I0MAq234g5RQ5ODx9q8CAwKH1ZIhS3WDQ==@openvz.org X-Gm-Message-State: APuU4Z+oXDfxZYZCqo/F8EBk/+z8QtaZ0OHtqnUS26j90qmacSUDizCL Bk7uXjbtUtLWHxvekfbh/481FKUor8+PBGJ8YPalty4PNimAuxupR2Q6vyn4L6VdMzBcqRoZPO7 pN8LV0XP8xiP2ma9mbeHcubHep4X9yK3JdSwdRaSqPQbtZGj9fT6cgw== X-Gm-Gg: AYBFou0saAn52oHEMgUzIGVvp49TfL+2kEvxeV+NszDbBhymCYt3irVgleLMLSGqWq5 WorDUyiiZeAYrV7FSnMj8Phrn2CiOW0CEMCUNSLU6h+gkjZ/LGyzqMmmfeR7pMpqqxoaQ+FqNEm E2xLLpH2MUOTnnD7DkmxnpJj9b33VSS6WfxbD5o/Yn14trWFmSjZQ4t6S7nUKxgPS0+im53RjOq 4KlYLz2Cj1Wbb5qeOxmFwK/f5RDkiN7C5i6dGcOZVCaW413dp/EWO9WXpQPtQxGBnytJQVvUH1y C2SqvO15PQ== X-Received: by 2002:a05:600c:4715:b0:4bb:76d9:f81a with SMTP id 5b1f17b1804b1-4bb7da3d288mr110974705e9.34.1795088959590; Thu, 19 Nov 2026 03:49:19 -0800 (PST) X-Received: by 2002:a05:600c:4715:b0:4bb:76d9:f81a with SMTP id 5b1f17b1804b1-4bb7da3d288mr110974175e9.34.1795088959126; Thu, 19 Nov 2026 03:49:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1795088959; cv=none; d=google.com; s=arc-20260327; b=fHLWFWjtWxjusLPsoaz62M7IMeqby1Fp53BnD6hqFae7vvFkeYr75aV6xVtdUqOENe zR9ydAw5TSXh2dYqnGg/aINUyvgL1bB+wMqorndwW3g6l4NvmKMHZsip4ZvtvwVNzF5I OAmrNRyct8EN0lpr2cKnqR5RF46fxG/gUsNOqMVtnn+ZDKmPkO1auaeWkjY4CA2SJbjm OIa/yohPYK84J+schCJwttSU6AVm2XoFOAbEJREQvZIGgc1wN6z6+wEvINP/I/GqvE5Y /iI9eiWHOHDa2O3ei1feTRVsC8knqzwGhladvfqY25Byo1oJzBlijn/NX2tNShcIplLq IZFA== 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=EfJX6pEFKmNOI2bo23O0MKA/UeIa/UGUaQ8uy9zH9Hs=; fh=5N5v3Wwp9UxmZEgGz+czqSKj8/aW+0WvtI1xFFcot6A=; b=Nh+X8AqRb9cdA1JDBmj41S6QxOstQ6/7GQzENCJGTb9/fxXKXTB4XR9MAC8uash9gQ tep3RWwVVXmuhzljvVHcH+JK/ysv0MZ11EkP4zqSOKcbN74KZfCUEY5z2Z3hsVA6Vg78 j8oFIKGRpUpybddmgRSxNc6JtGEIO1nOUBFVL2cXIr+zSNn6ISvXQhIRNwMTms/G+PVA iBJYk1URRp2xUGCrM3zQlnmB8uytsA2X3jSpsXKdS0vbqwZS1kQ8XtdOo8eBjxZZ5yXy gTrw0YGPgEos41VmX71VEiAZw/729HtwmxAQQ4OGfj02ncsVY+ZV+7yP1ZAnNIjBMv5u sZzw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@openvz.org header.s=google header.b=JYiOWvPk; spf=softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:989f:a206:d03d:c3d5 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-4bb8274de3bsor3534845e9.17.2026.11.19.03.49.19 for (Google Transport Security); Thu, 19 Nov 2026 03:49:19 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:989f:a206:d03d:c3d5 as permitted sender) client-ip=2a06:5b06:b600:300:989f:a206:d03d:c3d5; Authentication-Results: mx.google.com; dkim=pass header.i=@openvz.org header.s=google header.b=JYiOWvPk; spf=softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:989f:a206:d03d:c3d5 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=1795088959; x=1795693759; 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=EfJX6pEFKmNOI2bo23O0MKA/UeIa/UGUaQ8uy9zH9Hs=; b=JYiOWvPkgXhF7eQ8OkjIdw3IynJ9bveftgsTeecgPQGEfovURU5YP4vlElrjCLKrUO UuCiCTIFumIoDJzvc19qm+5T9kc0f92+fmqgPC6uTdbgA6lg7GZoDTjDe/SJF7/F5SYm PvXWX6HKQNh9gVo3l7KgAgfPXY7Z0em5t0/F/x+AYjnL/S4npK4slSwYjnKkfdLhWcnx m8bdXpXKSkEbCcjzZXGYEMjOHt17jhcFLgAyX9NF+z21arJDZqQshySuPBmkRhmfloLy VsBvxt4ZXBUrFtOiv7rSp603IUPlA0n09ymzMuMApruo3Y9JoMu4i5lfwcvLwh0D/+78 QO2A== X-Forwarded-Encrypted: i=1; AL+hErEugF1zAy+g7QXdCc9Zs5flfhsJ6OQUKxDj1QUGsdGGwOTpUfUmL9Ch+3wBgbrNNV9913qHow==@openvz.org X-Received: by 2002:a05:600c:4715:b0:4bb:76d9:f81a with SMTP id 5b1f17b1804b1-4bb7da3d288mr110973765e9.34.1795088958678; Thu, 19 Nov 2026 03:49:18 -0800 (PST) Received: from artemis.sw.ru ([2a06:5b06:b600:300:989f:a206:d03d:c3d5]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4a65560b1ddsm9973486f8f.28.2026.11.19.03.49.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Nov 2026 03:49:18 -0800 (PST) From: "Denis V. Lunev" To: alexander.ivanov@virtuozzo.com, vasileios.almpanis@virtuozzo.com Date: Thu, 19 Nov 2026 12:49:14 +0100 Message-ID: <20261119114914.767536-3-den@openvz.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261119114914.767536-1-den@openvz.org> References: <20261119114914.767536-1-den@openvz.org> MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.2 2/2] dm-qcow2: queue the worker before dropping deferred_lock in completions 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 qcow2_dispatch_qios(), qcow2_queue_resubmit() and md_page_write_complete() add a qio to a worker list under deferred_lock, drop the lock and only then queue the worker. Called from an image I/O completion, they let the worker take the qio in that gap and end it, and suspend and a dmsetup remove can then destroy tgt->wq before queue_work() runs on it. A backward merge has the same gap without a remove: qcow2_merge_backward_complete() frees the merged image, and with it the qcow2->worker that the late queue_work() uses. Queue the worker before dropping the lock. The worker takes its lists under the same lock, so the qio, and the inflight reference it holds, outlive the queue_work() call. 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 | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c index ec07bcce6150..1b1367bb2ef8 100644 --- a/drivers/md/dm-qcow2-map.c +++ b/drivers/md/dm-qcow2-map.c @@ -463,9 +463,8 @@ void qcow2_dispatch_qios(struct qcow2 *qcow2, struct qio *qio, qcow2_dispatch_qio(qcow2, qio); } - spin_unlock_irqrestore(&qcow2->deferred_lock, flags); - queue_work(qcow2->tgt->wq, &qcow2->worker); + spin_unlock_irqrestore(&qcow2->deferred_lock, flags); } static void end_qios(struct list_head *qio_list, blk_status_t status) @@ -1584,8 +1583,8 @@ static void md_page_write_complete(struct qio *qio) qio->queue_list_id = QLIST_COMPLETED_WB; spin_lock_irqsave(&qcow2->deferred_lock, flags); list_add_tail(&qio->link, &qcow2->qios[QLIST_COMPLETED_WB]); - spin_unlock_irqrestore(&qcow2->deferred_lock, flags); queue_work(qcow2->tgt->wq, &qcow2->fsync_worker); + spin_unlock_irqrestore(&qcow2->deferred_lock, flags); } static void submit_rw_md_page(unsigned int rw, struct qcow2 *qcow2, @@ -3003,8 +3002,8 @@ static void qcow2_queue_resubmit(struct qio *qio) spin_lock_irqsave(&qcow2->deferred_lock, flags); list_add_tail(&qio->link, &qcow2->resubmit_qios); - spin_unlock_irqrestore(&qcow2->deferred_lock, flags); queue_work(qcow2->tgt->wq, &qcow2->worker); + spin_unlock_irqrestore(&qcow2->deferred_lock, flags); } static void data_rw_complete(struct qio *qio) -- 2.55.0 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel