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 A01468045D for ; Tue, 3 Nov 2026 08:38:12 +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 6A38axv7002600; Tue, 3 Nov 2026 11:37:00 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6A38axv7002600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=default; t=1793695021; bh=a4OVmMTq6/aNsfkdZpMJHnqdsTlWHVgICI2uT6jbCdQ=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe; b=UeEmI26Zc1teK9xaNSfpHM8mh00CBxXeMR5EQoMpWSWczxj7eYcZ6UDQlFu8FDEdN NouopR3ZapzmwUf2lHKJHzXF1pRLPvr4jepMcYDzxmO1iY1wD9vtFux9Mte/HDTjjU 2dQ1oWKzB7cr/yLkQM23NP+sHm8/C77ovUH7qcd6tdGlwhzQcdjyafew/A6giz6e4R WIVJ4Krexo9hnqVjichOwgyumoIcg1pzfyoHBDtmB4yINZ5qq2bItEScASVSbohBFy 8+cqGdDnlJ4Aq2zq7iBpNX5Fnn6o9TsTnWk7qOIAMSvbUAAzFdgyz+3hWR3Joiar2N 4Nw44RtuXqhNQ== Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6A38anH0002568 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Tue, 3 Nov 2026 11:36:49 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6A38anH0002568 Authentication-Results: mail.openvz.org; dkim=pass (2048-bit key) header.d=openvz.org header.i=@openvz.org header.b="d1pOZD6Y" Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4a214a5f8a1so37595675e9.0 for ; Tue, 03 Nov 2026 00:36:49 -0800 (PST) X-Forwarded-Encrypted: i=2; AKwUvByC+4zYKcglfN1vy/GMsbBHr9fKwT3jYz8C2vd6dffAqhFLBgnsch+c3wEI9QEpF0F4d7EzVQ==@openvz.org X-Gm-Message-State: APuU4Z92XxR6ZwLOZ5lyJzmqbc7xM6fmuv7V0u5QEJSnxakmyqAdNQgL q0QOa1UQSawfileJVGQW2eS3Uvkn7Gkz7T39cLw9k8m1OmxMzdF/PK6VEyS+JCQSoPDGVk3JW8T r9E9HkkjaoASV624H6HO98W+rSYXnQT6LcCRsygSDeH34J7njprI7OA== X-Gm-Gg: AYBFou3OJ2/npD1Lnrr+pqCKeiDE8E3bWE5Vg//qKKhKc2CSJbMxE8nsjwyurIRUwIN DLdhAziPLRsAz4y0c6RUrua0DllbaGsRxDba+XAkJU92Lts4PTo3vXrKNT+DEnFaFpzz69FRI32 BF9XgtmjiV72E+fTDHjQFMK+Jjwd3XKj8TyXQoZXqr/Z/66GT6r9r4ojc6udDjgeVxgF+glJJp7 7Ojy+D6jeAek4P8qh5u/iGEm3XlMGZYTBshKdJ5AUzTANm9slYhunThJNlyWEiLUR2wdREO0a2f zlBLLBrs6A== X-Received: by 2002:a05:600c:46ce:b0:4a1:f625:2108 with SMTP id 5b1f17b1804b1-4ac18a88820mr290857385e9.33.1793695009374; Tue, 03 Nov 2026 00:36:49 -0800 (PST) X-Received: by 2002:a05:600c:46ce:b0:4a1:f625:2108 with SMTP id 5b1f17b1804b1-4ac18a88820mr290856915e9.33.1793695008814; Tue, 03 Nov 2026 00:36:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1793695008; cv=none; d=google.com; s=arc-20260327; b=s1GBoCPGP0nbGl4hVBlu6YnssPa5CfDH/NJwpy8Wpxb2EmbGjY8AYJDR+PoyqpcNdq KSiVf4ogQQ8vAR6T/c1tNH5575oUIY0QANfpV3vhkj8TphB/BDOAObY4rIphQEMhQ9QM cahxiQa87Baf+8LjkLTUwr9bg9V8ErmFCaEmbryyC/x336+BbsAVj+VA2v6qB99Ws085 kpsmb49vZ51jg6QiGuR/4fxHRCTm2wa9/x0j/rCbeZ/bQanyPhbx4HzLNRpOYoJnm69V bFMdJXF2KaAxU2vjINs6JMMFG0YXWWxmCVB9ejustK4p50x/CYGK78jU34ETtEiXwr1w e7qw== 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=5rEV0ucKmNmRQiiMsBrCGjUjduE0Yvi/2Y04pAOIA+M=; fh=MEODDhfKcSUw3wVBjDVhBv1dEj/EmA1tJSsISyJkYZ8=; b=ijei95Ve+rSQtCqfo/YZiR/UdRSkEOZU6Lq3FluibGA9CS2Zf9yYaNpuHpiD4u5g28 WjdvzTFlliYZhDedDoW3NN0WKBx3C2A/n4sI3DOtmRxTTiN9MVYgwkitUDLaPoF949G7 Mgea8YL9pXAWrZ5oltV6DD5jfZkEPkjzCkm2HWbHytOIFicc/KKioAHljxbORtaTnqth CtuCw6D1+xWK4vjE66GfPrntdRzwskvf/W+brP/TDhdDXf0UUlhnaV79zw3oYTk7SmXf Sl4lqPtIdSXtquOfcMHd8x71vLTrFJYikQ2Hpq3Ibf8JyPWnCtuBDLmSBnP+YMN4qQkv kFUw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@openvz.org header.s=google header.b=d1pOZD6Y; 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 ffacd0b85a97d-48e6ebb6f91sor1537110f8f.7.2026.11.03.00.36.48 for (Google Transport Security); Tue, 03 Nov 2026 00:36:48 -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=d1pOZD6Y; 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=1793695008; x=1794299808; 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=5rEV0ucKmNmRQiiMsBrCGjUjduE0Yvi/2Y04pAOIA+M=; b=d1pOZD6YNaG/UXiGtJ7nYXmQkQu1z/VQ9SL1trlm1qhu/zNF08V8MA00tjob4TAneQ BELq7FLiC08izG2cq9mhBi7DY6c+728gSybw6+FKYP4Mb09XPqyVA9+llCphifGmuZOJ fyWahjcYWfz7duUiY4k2k3Ws3nuTEscQ55Jbof8FOu8OMkpemW+WdYO6GU6e97CnLCrL 1Nf/+un1FNRmg9g6wMJuYSvEIcMQK3zZu6c0P50rxdqFFhl/zD2tnYq7Rc8Ht86Srqab cVLFQzyMsLsbH6Pq3Dk+GpFdxceisZxYtAq4h1dkkRLP20yOeprfhxAfb0bZBbc/opoM 0tTA== X-Forwarded-Encrypted: i=1; AKwUvBydBpWFXbryJRXgQTKUHTybbtKd1vLQj9G9cpBg1n67n6iHLI7nLz89p2+NIFCwwuV2FuQO7A==@openvz.org X-Received: by 2002:adf:e010:0:20b0:48a:f354:aefe with SMTP id ffacd0b85a97d-48e8890c6d0mr4427816f8f.39.1793695008386; Tue, 03 Nov 2026 00:36:48 -0800 (PST) Received: from athena.sw.ru ([2a06:5b06:b600:300:c789:8bc5:fa8e:d502]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e71b72715sm23138568f8f.18.2026.11.03.00.36.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2026 00:36:47 -0800 (PST) From: "Denis V. Lunev" To: andrey.zhadchenko@virtuozzo.com Date: Tue, 3 Nov 2026 09:36:41 +0100 Message-ID: <20261103083642.130885-4-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261103083642.130885-1-den@openvz.org> References: <20261103083642.130885-1-den@openvz.org> MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.1 3/4] dm-ploop: wait for the ploop_allocator() thread before changing deltas[] 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 An allocating pio requests the preallocation of the top delta ahead of itself and does not wait when its cluster already fits, so the allocator can still be working when submission is suspended or the device is dm suspended. It looks up the top delta without a lock and keeps the pointer and the file across its truncate or fallocate, while a cmd rewrites deltas[] under neither of its locks: - merge and notify_merged_backward move the top delta one slot down and zero the old slot. The allocator then reads a zero file_size from it and truncates the live top image down to the preallocation size, or reads a NULL file and oopses; - flip_upper_deltas swaps the two upper slots of a dm suspended device. The allocator computes the new length from the size of the delta now on top and truncates the old top one, now holding data below it, to that length. Wait for the allocator to finish in ploop_suspend_submitting_pios() after the inflight pios are gone, and in ploop_postsuspend() before the device is marked suspended, which is what the flip checks. No pio can request a new preallocation at either point. Wake the waiters with wake_up(), as the one in ploop_postsuspend() sleeps uninterruptibly. Fixes: cf489cf22cd5 ("dm-ploop: make filespace preallocations async") Reported-by: Konstantin Khorenko https://virtuozzo.atlassian.net/browse/VSTOR-152984 Feature: dm-ploop: ploop target driver Signed-off-by: Denis V. Lunev --- drivers/md/dm-ploop-cmd.c | 5 +++++ drivers/md/dm-ploop-map.c | 4 ++-- drivers/md/dm-ploop-target.c | 4 ++++ drivers/md/dm-ploop.h | 1 + 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/md/dm-ploop-cmd.c b/drivers/md/dm-ploop-cmd.c index d85f4d803b61..72a9662d2bdb 100644 --- a/drivers/md/dm-ploop-cmd.c +++ b/drivers/md/dm-ploop-cmd.c @@ -159,6 +159,11 @@ static int ploop_suspend_submitting_pios(struct ploop *ploop) ret = wait_event_interruptible(ploop->inflight_md_wq, !atomic_read(&ploop->inflight_md)); + if (ret) + goto out; + + ret = wait_event_interruptible(ploop->dispatcher_wq_prealloc, + ploop_no_pending_prealloc(ploop)); out: if (ret) ploop_resume_submitting_pios(ploop); diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c index e64fd8965d46..ae3e287604b7 100644 --- a/drivers/md/dm-ploop-map.c +++ b/drivers/md/dm-ploop-map.c @@ -1233,7 +1233,7 @@ void ploop_should_prealloc(struct ploop *ploop) spin_unlock_irqrestore(&ploop->bat_lock, flags); } -static int ploop_no_pending_prealloc(struct ploop *ploop) +int ploop_no_pending_prealloc(struct ploop *ploop) { int ret; unsigned long flags; @@ -2342,7 +2342,7 @@ int ploop_allocator(void *data) PL_FMT("failed to allocate space: %d\n"), ploop_device_name(ploop), ret); } - wake_up_interruptible(&ploop->dispatcher_wq_prealloc); + wake_up(&ploop->dispatcher_wq_prealloc); current_restore_flags(old_flags, PLOOP_PFLAGS); } if (kthread_should_stop()) { diff --git a/drivers/md/dm-ploop-target.c b/drivers/md/dm-ploop-target.c index 3b589579741c..d8279c79ef56 100644 --- a/drivers/md/dm-ploop-target.c +++ b/drivers/md/dm-ploop-target.c @@ -743,6 +743,10 @@ static void ploop_presuspend_undo(struct dm_target *ti) } static void ploop_postsuspend(struct dm_target *ti) { + struct ploop *ploop = ti->private; + + wait_event(ploop->dispatcher_wq_prealloc, + ploop_no_pending_prealloc(ploop)); ploop_set_suspended(ti, true); } static int ploop_preresume(struct dm_target *ti) diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h index 7d0d94e7b266..5ae02ef5ffc2 100644 --- a/drivers/md/dm-ploop.h +++ b/drivers/md/dm-ploop.h @@ -652,6 +652,7 @@ extern void ploop_disable_writeback_delay(struct ploop *ploop); extern void ploop_enable_writeback_delay(struct ploop *ploop); extern void ploop_should_prealloc(struct ploop *ploop); +extern int ploop_no_pending_prealloc(struct ploop *ploop); extern void ploop_resubmit_enospc_pios(struct ploop *ploop); #endif /* __DM_PLOOP_H */ -- 2.53.0 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel