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 E0CA580E7E for ; Tue, 3 Nov 2026 08:38:02 +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 6A38aphC002580; Tue, 3 Nov 2026 11:36:51 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6A38aphC002580 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=default; t=1793695013; bh=u0qRSW9q5ctHih6tlH7PmdaQa+Md6WBmXf/BLOlc408=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe; b=mpZDOj84owo1gPnVNOumSdTJUjTmRfPFxIxWjtT5o/mXvDHLNnKxC16NR26BpqhP0 Ys2sdx3i//SX47Rs9M8oTsDJ/pozM9LrYxd1xZCTsoUc2Nd3MAteLy4nwaFRbOpmjO z39Qi4wnUuA0CTff/J5mWFNrExZlfDYGE7EsKWGct22YEbl/4Z83Nkch3VX4hMq2wb pfWLqFA0NNBM0sk/uwjyaKPmPrOZF/x9cwuEpHectHDS5j+HpjERbu193TjfZtDYs7 vI6v6oiMqLOittKRzzDCuirhzxom4KmusNxK+ZIliwqyOl5tYrvy1YrO5+VIYcPIar iETPZsWvipV6Q== Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6A38alaB002559 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Tue, 3 Nov 2026 11:36:47 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6A38alaB002559 Authentication-Results: mail.openvz.org; dkim=pass (2048-bit key) header.d=openvz.org header.i=@openvz.org header.b="Ntf6BHMT" Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-48afcecb035so103753f8f.0 for ; Tue, 03 Nov 2026 00:36:47 -0800 (PST) X-Forwarded-Encrypted: i=2; AKwUvByrD34I+hNpVtnUEZlnDim/cHvLeoN4rPS+Ch9MuOR3v171sLvLSjvC1NibNXquUg3NlztZrQ==@openvz.org X-Gm-Message-State: APuU4Z/IHT0G277ed17uBAwjDVpNeoG9E7u8tLCgs8oCZuYiPj/D1SQv P/CtwaknGtJq2ZojKI0X5vhgHL6GeX8mHSmbRFtxAXdnro6QGilOj0LhCUfKD+kqY0A1/p3zJZU K5zQZRfAcH8ZzE2Yxj9WZxzaJI6u9vHbW0N4mpAoNcWS/Xtu0bUliHw== X-Gm-Gg: AYBFou3HxwANk5bmHscAjoIH/C3qx/Z2Zicmg0j+WK3GYZdzM/NDo+HW9GmhBqmhMoz m5posPcso5RMvREiUPPv6z8EifvKyuTc8mH2tD+hYjS+aVkyJWYMXnReC/xmN/WFYLRohpkyOtl PN31apeSqLjBxrYIKC0VU4XY0NnqxN6IXW1hSV6j5cAQDDhLlgr/YdOKHWPwJXI5/RhdDAO82cE CGtR+wcwmnDY5zHuQbE+MMByqj4+4dmZ5OpxTOn1vWyomtmFJSMi9EKo2fvFpTjo1tnzQfCmOln +dRkqaXy5Q== X-Received: by 2002:a5d:5886:0:b0:48d:fce6:884e with SMTP id ffacd0b85a97d-48e6e2cb717mr27971701f8f.12.1793695007087; Tue, 03 Nov 2026 00:36:47 -0800 (PST) X-Received: by 2002:a5d:5886:0:b0:48d:fce6:884e with SMTP id ffacd0b85a97d-48e6e2cb717mr27971660f8f.12.1793695006642; Tue, 03 Nov 2026 00:36:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1793695006; cv=none; d=google.com; s=arc-20260327; b=DNzKXCbHt0CzQV481sy0Ma1UtkQwwktyD0y44l4DQI9kz7tbXspI0OMEz7p7lywQSW 5ZPDLq89YU54ipIAX4z2XycG+wd16jUoIneSU9cXeQCBfvg4RNPaDfQRC1gEsQAynygU 2O8R0Rur7AdIlEM+kKFYDpqW05L8ZnKYYpE3Bl1OowU0+pBf93UDMnSWCzDByH9sXwgk nt7n2arsDfOqx/phUvT9H6ngEx9hCNOW5plHDK0jlUNEa5DJ/p57QRoFxkxJYyw1Zq9/ PcqtdVYnUK2BltWdbniXmGU8667cl6+oXuKy9ulGsOLb7uJx+iJX06/jbCOzxN1VazbG JTGQ== 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=nkmX7dEqkrhsofqELHNYF/5+GpoGbLah8BeKl72Gvwg=; fh=lXoU54B4PG3BEqvu+e4hDwRS4H+iFryk7AQneMOZj90=; b=amM3rdcqGQN91WPiGlEh66bccEihMEhyeJ56AvwcipdwsGgjyS96Ig1E9WwWjgqMVF u+bhm/YLz/oNY3HIYcDT+H5XSnU1LhnPMiD0tTPz2g3p4w1kLVRFjWaaMspWRamULU1m AVvD/R0Po4BuXzxswrV/eWAF/rytu3pgIc1ERw7p8UJAFqn6ZYgZuhWNXjttdHrd71nR Q9e2962YPeNPdWGyKtEeMeIfC+LQyDUjqU1Bf+FeEPsKzgLvmIEn5HhOjfHbbaGGWYbG dp5M6nLr7ipXUZ5fkemXPTRxMOUXAvVirdjA1EwRlbHJKIzJXtr7FX2VbA6zP0EvGmbM VE9g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@openvz.org header.s=google header.b=Ntf6BHMT; 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-48e89e526adsor303032f8f.8.2026.11.03.00.36.46 for (Google Transport Security); Tue, 03 Nov 2026 00:36:46 -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=Ntf6BHMT; 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=1793695006; x=1794299806; 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=nkmX7dEqkrhsofqELHNYF/5+GpoGbLah8BeKl72Gvwg=; b=Ntf6BHMTsK9psnRdaLFL690osBrLp+ATfsdoyYMudPaVCEut9/D9Ky4gSBKmS2maAx umvfc6H1FQ66ugr73X8mw+iFODKH8wBC+nTVviZ36demncoy7vQpb9tWYzX88yuWZroF 7o1X+CjvzfLhSxusCovI6LpfzYG+SzZb8Oml1lA8KF3IvA30udHERUwbqUz1H0pQYXhh 60Ike7zwPPw1qXY7wC5NjYuCv0wjFe5QvCCmI7IHgilE9be+Ohf7e8cOPNqB5gsicYKg dW2w8T7/TkOHf7VjfpAiRvoxHeE3ufuJlzHxQqHUnq9dBVrZ8Ar5kZuQRs2WNEbi+9he ommA== X-Forwarded-Encrypted: i=1; AKwUvBxFDeR1MlfnwVsjzgSKD7gLicCS3U4FzhVGTREEuTFksltV9qzYBJyaVMxqULDkzy5kTQTr1Q==@openvz.org X-Received: by 2002:adf:e9cc:0:b0:48d:deb0:f1a7 with SMTP id ffacd0b85a97d-48e649b0626mr30607390f8f.10.1793695006157; Tue, 03 Nov 2026 00:36:46 -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.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2026 00:36:45 -0800 (PST) From: "Denis V. Lunev" To: andrey.zhadchenko@virtuozzo.com Date: Tue, 3 Nov 2026 09:36:39 +0100 Message-ID: <20261103083642.130885-2-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 1/4] dm-ploop: fix pio submission racing with the suspend and resume of a cmd 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 ploop_submit_embedded_pio() tests stop_submitting_pios and then takes a ref on the current inflight_bios_ref index without deferred_lock. A cmd sets the flag and flips the index under that lock and then waits only for the refs of the old index, so: - a pio that passed the check before the flag was set takes its ref on the new index or on the already killed old one. The cmd does not wait for it, and it runs while a merge, resize or delta index update rewrites the BAT levels and deltas[]; - a pio that saw the flag set is added to llsuspended_pios after resume has cleared the flag and drained the list. Nothing drains it until the next cmd, the request never completes and a dm suspend of the device hangs. The submission path dropped deferred_lock on purpose when the lists became lockless, so keep it lockless. Test the flag and take the ref in one RCU read-side section, and wait for a grace period in the cmd between setting the flag and flipping the index: a submitter that missed the flag then holds its ref on the index the cmd waits for. Only a submitter that saw the flag takes deferred_lock and tests it again before parking the pio, and resume clears the flag under that lock before it drains the list. Fixes: b90109c12b1c ("dm-ploop: convert the rest of the lists to use llist variant") Reported-by: Konstantin Khorenko https://virtuozzo.atlassian.net/browse/VSTOR-152985 Feature: dm-ploop: ploop target driver Signed-off-by: Denis V. Lunev --- drivers/md/dm-ploop-cmd.c | 7 +++++-- drivers/md/dm-ploop-map.c | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/md/dm-ploop-cmd.c b/drivers/md/dm-ploop-cmd.c index 645c5136e7ba..d85f4d803b61 100644 --- a/drivers/md/dm-ploop-cmd.c +++ b/drivers/md/dm-ploop-cmd.c @@ -132,7 +132,7 @@ static void ploop_resume_submitting_pios(struct ploop *ploop) ploop_enable_writeback_delay(ploop); spin_lock_irq(&ploop->deferred_lock); WARN_ON_ONCE(!ploop->stop_submitting_pios); - ploop->stop_submitting_pios = false; + WRITE_ONCE(ploop->stop_submitting_pios, false); spin_unlock_irq(&ploop->deferred_lock); suspended_pending = llist_del_all(&ploop->llsuspended_pios); @@ -147,9 +147,12 @@ static int ploop_suspend_submitting_pios(struct ploop *ploop) ploop_disable_writeback_delay(ploop); spin_lock_irq(&ploop->deferred_lock); WARN_ON_ONCE(ploop->stop_submitting_pios); - ploop->stop_submitting_pios = true; + WRITE_ONCE(ploop->stop_submitting_pios, true); spin_unlock_irq(&ploop->deferred_lock); + /* A submitter that missed the stop gets its ref on the old index */ + synchronize_rcu(); + ret = ploop_inflight_bios_ref_switch(ploop, true); if (ret) goto out; diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c index 016be97caaa8..f0832fcefeb8 100644 --- a/drivers/md/dm-ploop-map.c +++ b/drivers/md/dm-ploop-map.c @@ -2528,6 +2528,7 @@ static void ploop_submit_embedded_pio(struct ploop *ploop, struct pio *pio, gfp_ struct ploop_rq *prq = pio->endio_cb_data; struct request *rq = prq->rq; LLIST_HEAD(deferred_pios); + unsigned long irqflags; int ret = 0; struct pio *spio; @@ -2538,12 +2539,19 @@ static void ploop_submit_embedded_pio(struct ploop *ploop, struct pio *pio, gfp_ pio->queue_list_id = PLOOP_LIST_FLUSH; } - if (unlikely(ploop->stop_submitting_pios)) { - llist_add((struct llist_node *)(&pio->list), &ploop->llsuspended_pios); - return; + rcu_read_lock(); + if (unlikely(READ_ONCE(ploop->stop_submitting_pios))) { + spin_lock_irqsave(&ploop->deferred_lock, irqflags); + if (ploop->stop_submitting_pios) { + llist_add((struct llist_node *)(&pio->list), &ploop->llsuspended_pios); + spin_unlock_irqrestore(&ploop->deferred_lock, irqflags); + rcu_read_unlock(); + return; + } + spin_unlock_irqrestore(&ploop->deferred_lock, irqflags); } - ploop_inc_nr_inflight(ploop, pio); + rcu_read_unlock(); if ((pio->bi_op & REQ_OP_MASK) == REQ_OP_FLUSH || pio->bi_op & REQ_PREFLUSH) { ret = ploop_prepare_flush(ploop, pio); -- 2.53.0 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel