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 047AD8017D for ; Wed, 4 Nov 2026 18:56:45 +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 6A4ItWiV026198; Wed, 4 Nov 2026 21:55:33 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6A4ItWiV026198 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=default; t=1793818534; bh=OX6LSzT9w4rNEsmrJKL76lb+wz9W155OVyRr2HH5f2Y=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe; b=E1Oiwk020ksNIj0Wd0C/5VOvnPAfpRRm8tDUNLvNnsOqDitpsQ94jSGtNlcCm0Rwu tYXFI4/pmELlbaGV88+OdRYtWMnyHUvJya7mcR5ICcBnAlFB3qYXjmfGjF6E5rSpy+ +/Q/8V9rxzjqyxBZaIzjgVWk371nPp5lkwZco+FKst9M8l2vAfu5ELlmYSWr8HEy58 09V0HV0UTzG//ESeTNy18dGJZPGoGTfhhSnoVMJdhFe5XQ+XN4Aaiy0Gd5uGRGRha2 xYxEvYLciQh+1tREn0B2TAhgvbGa8jFTPZeKERsB1ta52OVYaN16zdlxQyxaiE8Jsk 06GIcJBvS5VhA== 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 6A4ItQ1K026172 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Wed, 4 Nov 2026 21:55:26 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6A4ItQ1K026172 Authentication-Results: mail.openvz.org; dkim=pass (2048-bit key) header.d=openvz.org header.i=@openvz.org header.b="KGuqWmOJ" Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-48b02d63407so911433f8f.0 for ; Wed, 04 Nov 2026 10:55:26 -0800 (PST) X-Forwarded-Encrypted: i=2; AKwUvBybeOamWMRTX17Q7aIxftlyycjhWupnGBX65mrEvaYfQLsGx2Add28YltEXoOn6QFQO40oNMQ==@openvz.org X-Gm-Message-State: APuU4Z8ISyXg3BMJtKLs2knrfzLQbNScmuiN9CNDQZab0ezMaQ00uzkV nWWzqG+ic+wd+HBYnS3+ygtQFu3qvsqZY0gfVaPg3LNPAsm7LMZj3eCnN5BxcmquBRLaSV1ctuF GYNZJlZviPoh0pplibr9QgUpXR5956xRxTDOJ2hb23lBxIO858btCOw== X-Gm-Gg: AYBFou2pZrPMCurZ2C9rg5Z0e4qSopMeKwq+X05DejQ42oEiubWK1B50Zu8hZtr1o+P CVPfPeUJnh3Re8HxVLD1LWhomhtwWcdV0InNsIOAEv7uHlohJt2nNzQAJj1oj9N7+w8beOoc264 A+QnyAp15gmJdcG2rRkSq8O/oWM0kj5TdxJaWXgC5VWcvxYjw0RbZXAmvIHWUY8B/0M4pbCjHO2 18DNxVn3XM61T10z/DdlNLsM3bd/tpW9RpyrBleSW0Wb4H0IS8FunQvBx58CPZaZ30mbj4P0kEq /qCI8vM4hw== X-Received: by 2002:a05:6000:310c:b0:48c:6f3a:fe30 with SMTP id ffacd0b85a97d-48e6e2fabcbmr38583415f8f.15.1793818525908; Wed, 04 Nov 2026 10:55:25 -0800 (PST) X-Received: by 2002:a05:6000:310c:b0:48c:6f3a:fe30 with SMTP id ffacd0b85a97d-48e6e2fabcbmr38583387f8f.15.1793818525462; Wed, 04 Nov 2026 10:55:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1793818525; cv=none; d=google.com; s=arc-20260327; b=JC6X1eQnZ2TXIW2uMhmb8qSxRkPXFkDZARfN3WdI3KTF0GCMBa2n583Xl/+cMQ0BF8 RMUmAQ6vGVeNJpTGUtFAsVuWlsV2LI3I1gQJShU7f2OgHH+YedL2osIfUGn+0Lr/46GA BIoMghkERbEGnrQ3rUyX2GoUzXCR3qE9/iQZUOBU/0k72aMXj+lPPRRvKNHPY+95WvnM GyiABsW+8WZnWPKUxmUA2tXdMNI2Upzky/gnfXCXAnXqXlstvOmzdHddJ+oDYMTJt/ii 3LbjL5VHSFXTTJWjObpB+A01SCSJE2vuzUQtZ5w6y79o2YV3+Nl2053Sy1V1YS97jKNH GuBg== 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=H/ossQn1YwDwsRd5Tk3px4tMGVPoWvAXaD1Ju7jF5mw=; fh=FBgevYbPtpBMmbrpkcLLuC1IIRcmgAOZ9XS2Aa4pwGw=; b=L/3fBRH9LxQuW/xSPkOc15K9gD7WtChtvkhfZzwDd6pfY6jpUlVAgVN4oCFB9YVnm5 aIyVrB17+c5YwWIxsgMHgb/ezO8oL7Z7qe3ugiRg8cY47ralcHUULzZ2RF1/TyjFyReu NWl3sd0ymokaoz91wfChZdJA4kH3s2wbgBr0QpS7JdQa8a9JLhDs/ZTTOOFbw1R0HZXJ C//HkbeR+DEJZHXdZRbFRY6/pqwcVzImQSai3cNbR2j7xJPDYwrNw/8bjyAfeYtir6dO 2mH1vYMvmkKc/mjVIA5/9OUBnFqYobuz8qQ32oIlRID3gCnQT0+Fd2YlEZDry7x217IB 9D+A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@openvz.org header.s=google header.b=KGuqWmOJ; 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 ffacd0b85a97d-48fed17a6e5sor537521f8f.13.2026.11.04.10.55.25 for (Google Transport Security); Wed, 04 Nov 2026 10:55:25 -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=KGuqWmOJ; 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=1793818525; x=1794423325; 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=H/ossQn1YwDwsRd5Tk3px4tMGVPoWvAXaD1Ju7jF5mw=; b=KGuqWmOJR/iwrZxhRub81WKw+Bq5lDvghV8gXsViHGUWOaad6AHI6RrzK006OBK2Wv b9xZcIc4aShy0j23H73dPbbR97A2rdTHMmhl7TatGGhrJVeDimaZfigA0PbxdBAGM8cZ DHT5juu/cDr+rBh4Q+ufUVNxZPY35h1p00fJsJYt0sEAibK2aGdqTSGJm2DbHhFPN1Hc CLuV5patVHNCcFmjqT6xnZaMKzkn7cKbRfhwUmklOCtJ/p3Wv0MPhSqDRv/bTIYt3Fqf ake9AXsU1VCaDgakEfRv4uHnuHT4ff1V5ZgE0eFzHA2T+pI+LEdHp3aH2Yfi6R0UBtG5 f43A== X-Forwarded-Encrypted: i=1; AKwUvBwL7uir7QT7CjsuZDq/Hykz6oMMBW/PPmeKTVANBkM6gE54oWqKKT9LbWIozloLI2yfa1YgQA==@openvz.org X-Received: by 2002:a05:600c:3b1a:b0:4a8:b8b4:6226 with SMTP id 5b1f17b1804b1-4ac18c73d17mr382186125e9.28.1793818524966; Wed, 04 Nov 2026 10:55:24 -0800 (PST) Received: from athena.sw.ru ([2a06:5b06:b600:300:162e:5a6e:fd46:18b7]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4b56e2ae762sm4482435e9.2.2026.11.04.10.55.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2026 10:55:24 -0800 (PST) From: "Denis V. Lunev" To: andrey.zhadchenko@virtuozzo.com Date: Wed, 4 Nov 2026 19:55:18 +0100 Message-ID: <20261104185519.1870488-4-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261104185519.1870488-1-den@openvz.org> References: <20261104185519.1870488-1-den@openvz.org> MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.1 v2 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 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 after either point, but a resize of a dm suspended device can, as the grow allocates clusters, so wait in ploop_flip_upper_deltas() too. 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 | 11 +++++++++++ drivers/md/dm-ploop-map.c | 4 ++-- drivers/md/dm-ploop-target.c | 4 ++++ drivers/md/dm-ploop.h | 1 + 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/md/dm-ploop-cmd.c b/drivers/md/dm-ploop-cmd.c index d85f4d803b61..29f9a7ee7540 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); @@ -1176,6 +1181,12 @@ static int ploop_flip_upper_deltas(struct ploop *ploop) if (ret) return ret; + /* A resize of the suspended device may have restarted the allocator */ + ret = wait_event_interruptible(ploop->dispatcher_wq_prealloc, + ploop_no_pending_prealloc(ploop)); + if (ret) + return ret; + return process_flip_upper_deltas(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