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 1A6008017D for ; Wed, 4 Nov 2026 18:56:38 +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 6A4ItSY0026184; Wed, 4 Nov 2026 21:55:28 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6A4ItSY0026184 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=default; t=1793818529; bh=3XT0rRD0JQmhpkvPhPlbxwTLzchRU29dpHsAmP/lFu8=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe; b=AVwfwN406h/2Odu/r/ldXfBnhh4YI2MVuk1J2gsZ8UgVTmetCFmWlghsfLCoPmQ62 zc0aKn6OdtCIdcgE42vOKrWKgHkiOJMIVyJBEGvIUOM/+uI/nPuhrVmvqaCDxGZwXU b9cxqbP15tbJvuMABT1dJNbKynYPMPX5jZE2aiWTnLY5d9D6WWeF2FGeg3pv7F+Hqq wmHDjd++DB0k0Wzf/92fGJBpgZIoJygHl8p3T7Qk0erpaUtmwOAOkujeNTRS7wvN+z gB61T94RBKh19EA9LwYlBdRahJd/UisxY9WK/TJB4NkLZhkz8bHaGdm0lV1IBVczL0 MUdcuKh6PLTqg== Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6A4ItOVx026161 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Wed, 4 Nov 2026 21:55:24 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6A4ItOVx026161 Authentication-Results: mail.openvz.org; dkim=pass (2048-bit key) header.d=openvz.org header.i=@openvz.org header.b="Lv5NKM3Q" Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4a1fa972b4fso6400835e9.2 for ; Wed, 04 Nov 2026 10:55:24 -0800 (PST) X-Forwarded-Encrypted: i=2; AKwUvBwc72a9Q4HZyuhVlTpOQOoxeTXLsydNUwaxrCNvdyukz8I/NOaYHVJmZbz60PauuhD60tMxcQ==@openvz.org X-Gm-Message-State: APuU4Z+Ot0SsIytNzg4Rf6fDPptfjpXIQYup02RGJRvo/gppmle7CRwc Kj7H+4eJ8rw8hX18DLyWu/4PB3eEwsV0AkE6v3GoAIfZ2ygNnw17/OggCAOTNXIrEkBybg/rqDt Hv7GQQ407xXuVPGccGtsC3FBCxcRdiGmvaqCe7jK1zoAP4MA9VTNK7w== X-Gm-Gg: AYBFou0hNk2gKFfiJ5qMYHMiiTlXwfyEhUzNT+SbIPHRf1PaEGcLeMmrybDs43520Tm l+LjY2NRWUwbollSqluRx1lIjtXh7tOIOabYDIq5Mws4OZ+wuyKFqX7nCiVA95nOghmPAdGwagM 88jS3ARlROpOO1l+pDRG6BIge67ctlanW8DSfUn/abQvzYadvCUrhaW+K36Ayh6PZmaurewc9w+ xeZI11hLGwBb3QznDfQqqYyyKd/ewJ/2vUj2LoiHliGrI5xOhQ1Pifxsas2i/s+7Brh1Tho6juS 3NZKlobcvg== X-Received: by 2002:a05:600c:6992:b0:4a1:a2c0:7b73 with SMTP id 5b1f17b1804b1-4ac18992c01mr378565225e9.30.1793818523978; Wed, 04 Nov 2026 10:55:23 -0800 (PST) X-Received: by 2002:a05:600c:6992:b0:4a1:a2c0:7b73 with SMTP id 5b1f17b1804b1-4ac18992c01mr378565015e9.30.1793818523493; Wed, 04 Nov 2026 10:55:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1793818523; cv=none; d=google.com; s=arc-20260327; b=TsxJMdF7Tn9WHRiGZ5TMeXQmFj+hhH3br0dyvzeiXPMDJaSJ7lNzaeY4XCqtktzV/N Jrpl/UehQJn8v+43SgpNLUOMgaiDTaiPFsA47S8vFDfDy2tdeeZXgdJooJ37v6Afc5qY perGr6kPDPuYjHDJk1q1Skp1jgi9WfBjRnnW9xSJTx5u7fWYjn+jGHfcP9zonGXSh8/H QKpwpddARMtQwtsvRijTmVccXsRutKcqaLG+jcO3bqxigvgRwrLzFOdAiI2R4WM00t1E 8XeOVhZySPR+J3LXh0FnOqFt7pTx7SKwwcfOrlKRkgo3PC1wnHWngQ0PsIqCPgVGI2t6 klTA== 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=DZlFOWBc0nL26YOBlAMyIIrXTEBFmqqzndjo15/JcFM=; fh=1YCkKUV6xt4NVsDDWo8EpXKKedOcRI9tyG0DCLN9iqk=; b=DNfI0dRnkKzjDI4O50so896sKAzU9MkS+saxj5Hxqt3gwT35NSJTDAEqKnmn357g3a tjJkn8UPMBkYXTGlnX2O2F8yHDmA6Ihchq1nMPy5RBK/dJEkyw96N5WP1OEzVRU77NpD 1qlEYMMbFV+IakTYxKjI6MwCBbilEMW0UIe3z52QNpLgNrJ2XPHLRgT5Uk/6yeFUrNV+ 6sKxMf9VoMTFKh7N0fK1KYEsqxC8f7KyzTQ+C6ru1VUG3uahkxZJ0ysuWPvGbS0rz0kQ zZEnaWkaBUMiy3ByGk5uY/tw2xUsMSHkhyWz9xKjtQ5ZQZ9myWO5qvfRGsV5zmdPFS06 XH8w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@openvz.org header.s=google header.b=Lv5NKM3Q; 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 5b1f17b1804b1-4b43ad332ddsor5497295e9.1.2026.11.04.10.55.23 for (Google Transport Security); Wed, 04 Nov 2026 10:55:23 -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=Lv5NKM3Q; 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=1793818523; x=1794423323; 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=DZlFOWBc0nL26YOBlAMyIIrXTEBFmqqzndjo15/JcFM=; b=Lv5NKM3QUNgXyTpSyAB3nw+mhOZLpIEjNgk3qzN5NYTZP0ChFr0d14vqjb33lpFWmG jhDzM2a6sq094uvcYztwfGuIUwZEEPQSPZeyKw4Q4Oxf5A9qjrw9M5lNRnYag5pB+zzX +0vHMy++ovO4JmtKZ+wut4iy9B7qHwT2G6DFpLs7DJIhBHWwAyiVn5oy97peVe7oMIQX xDtEwuwct8Yaem4rg5Cjznzs3txSiGst/tg9dQZef4hUrd4p+VRidSebNbh7WqlVsMp3 xsTp+dWz1uvBixvA3cknhKSwV25+abhenwk65AZvjzEg7wJK1Uxu6LZsdcqgNOy0Twt3 5BVQ== X-Forwarded-Encrypted: i=1; AKwUvBy0mPdLGenQstLWUeUcCNn8UG8dqoSXwRQI+DNhshuk6KTHjIR2X+AVevoEo/q0HoU7iPrxFQ==@openvz.org X-Received: by 2002:a05:600c:6087:b0:49f:f099:6fb1 with SMTP id 5b1f17b1804b1-4ac17753befmr374980605e9.15.1793818523018; Wed, 04 Nov 2026 10:55:23 -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.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2026 10:55:22 -0800 (PST) From: "Denis V. Lunev" To: andrey.zhadchenko@virtuozzo.com Date: Wed, 4 Nov 2026 19:55:16 +0100 Message-ID: <20261104185519.1870488-2-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 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, notify_merged, 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 Reviewed-by: Andrey Zhadchenko Reviewed-by: Konstantin Khorenko 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