From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.218.48 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795890308; b=JRmlEPsHYW3BG74jjwqY14UKYwdwBIK6itTnsya0PBx9Lmmf0I8KFOFRUdMmyTVAJ57P O1JE0IlOZEz9FWItxhOZJnoKyjr9m9gYHwBOhBkkzRIhLG+AHd++wDsiBYalObg24mfBR kASUn39oDLSC8KFbyN5/QGUC++A5pfl65+oh0ov+LirunorMkhwTLMb/7y1/NPxMOQ6tr mdwVKuYrp7IvPCBaSUBCybYSKrumDBs1lt5t/+ndJGS97+WmL8zorSO6O6jKilQQI+vjb cyhoZVSpygANvDaS24ZKKtcyLk0qt6vIJoDWSrXKD9707+Ieu+GGp/4GUrxafeRqVVA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795890308; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=JjZvUf82y9vf8OCsTFYPdKKFu/SHURcTDli0h9dQsHI=; b=nZO9Spwycvp+z93r5cdB05+/ccBzwKW7m9JUDGNF4Xj73+dxnJ5RT/w+ef+U4nbghEhW dZSImo1k/4Ctz3aDTI7+J6HtwD+UE6JpqIJy9m4xZtNm3tzyf1+3kAabqZr/guWWikLqP Uchqv60oFAz0sFdJgsZLPJHLew+COpG63Yj7cxZxBY8ze0I+QCghA9HVdLYN5V6XC2BgO BG3iGrTn2nirqk6dB3p/Gida1tC8c6nbGDxqnvSmCb4zXn/Xb2Hh2uC+YNrM0VWP7ZgIE IjNjBK+XyK9gxu+wAIy9tOrcWWGSNkTWMrrH1j0g1Ede5WJ9JO/TUz5Qu/MyYzwZ62w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=UTIiXWrC; arc=none smtp.remote-ip=209.85.218.48 Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9576F606A31C for ; Sat, 28 Nov 2026 18:25:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9576F606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=UTIiXWrC Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-c4d21051042so535730866b.0 for ; Sat, 28 Nov 2026 10:25:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795890306; x=1796495106; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=JjZvUf82y9vf8OCsTFYPdKKFu/SHURcTDli0h9dQsHI=; b=UTIiXWrC3TnYwR/OfwBy0LZsWnRkasTFlwx/NjsTT5nNMsM6Vb5AEHBhTG0iRjNIf9 mVSNCtwyNLKlWUqGJREA1LolhpEDHDTd0scc/tJzDhWJdoEK8hk0qk3eH6vxD/LFDBUR /V2eu7TkCy6HK9Z4wOXOhV0GYAlCZw6ODqjQfxHBhV7XzQ502vHLiL0j4qCWssGtGAou M+Mh+lc2A+1XAC0jMj3e1hY9qbYw7mWD6RPsb50lOdt6dGkvFgJIyzJe7P01Yr0osEee 62+o7ijuAZMYoz7/SNJjt06XNrIHXmOUrBCMEcnP0tjhT3QHWjrJC4VPNVlkIdon01HY hVyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795890306; x=1796495106; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=JjZvUf82y9vf8OCsTFYPdKKFu/SHURcTDli0h9dQsHI=; b=l+7fcB1Z4cEVJ80PpJy9zfFD0735G5dA5MDz/+NaO4qhwAoWii0VhNIekFpZWHhqAz uBrofHm892ml09KBN68Yqn6CFmE0SvBHQHbAO0IXIoKSNIijRx5X6x0EsPwqC9hVgg/0 U+t26VvQ7B3DvzMUVODHIo+YFQ+G8WpKHrnWLXBXHQQazvxwwJgcmRR/R+xch+GOiTDz Ox5Je1CzqjcBgiXZKnkbQxKGNcaHyZWlPG3QgRMqs+trwYlbDvmZRDpnXWXMTQEL79gr Z5VlJxHF1GffLV/JwasDJTHWtb/n5I6GOfH7IeWtqEf39FG54onr5uvSJscHpsMyVj8l MohA== X-Forwarded-Encrypted: i=1; AL+hErFiaTk7WFjUjIo7B9siVL+2cPEBUJfetoXCYjx+5IkghOF6qFlHRG3+vG1uEqci5sJjel8W0QkS5NEiMOQ=@vger.kernel.org X-Gm-Message-State: APuU4Z9fM9V9XnMjhWQl/Pl9hCQtSYG0xOSBGG0fpM+7VC+33Cx0AeyP vIJy5z0J1TnXk6nc4tXq41ZhpRrlLbjIOCTWfn4MSVHeQ6q55I/L0SiS X-Gm-Gg: AZFdTZfXSmHC8hsF2i95wj5GofSnwGfo5WwHe2H+hqOa53bNsUKzzrQiBMvaVMYr13/ Vu2jibgP+dSq/8Qo64OlAK6t7xfhxCHgyvPtu6dlJgIlLe8bVJXGJM/HBmbkQuFLGUO94m2sXqW CEoQVXqhwUPqaIQRveSyZnKlmmAo0yxFYJBtDRuiEpAkcvCBa69Hn1CvR1aLV8t+V50lM5xaqAB SnmhyO6VyJ2X3A3q3XaJgzyEXF+jVHgZ+iNKFiSKmJoYUx8R6d6Qq8P1prE0bcKM4HotUbcsDIF KzpHYaqVnQR5P2+IS/C7GTi2oz179ViCa4SsDKe72k/59IbgYF0WqpiwO7THsi+L01UoMwhfiNy FeDeYTaVOFj0TZx5Z4IDdYnKMHM0MJWiNXTrL+vTZEwzj4R1wgYkN1gDfYvXDdbecNVSKxRLd2s zPCDOGFza7o32u98yhVgdy2w6eWzjcst/UYJ415eeFFvwbQAnW7j3glMvzG49cJonMt6DXMMAxy InzQWz9cw7Wc1PqdlcYX5z5IbkRupKB6sFTnK7YnUWOWyvcs7pn/4/tlQKYrWvL5dUX0kjRg57S ZenxfwT267Vp1j6vM2KipZ4WxiDFgNIBtukAnPYVqtksJNQDBkiYvn1k3D7jn81koKFdD62VFs/ 3iQ== X-Received: by 2002:a17:906:397:b0:c41:26b8:c49d with SMTP id a640c23a62f3a-c513aab9965mr1801011266b.38.1795890305789; Sat, 28 Nov 2026 10:25:05 -0800 (PST) Received: from localhost.localdomain (87-205-122-125.dynamic.inetia.pl. [87.205.122.125]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c513afe01a0sm999074466b.68.2026.11.28.10.25.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Nov 2026 10:25:05 -0800 (PST) From: Kyrylo Biryuk To: dm-devel@lists.linux.dev Cc: mpatocka@redhat.com, snitzer@kernel.org, agk@redhat.com, bmarzins@redhat.com, dlemoal@kernel.org, hare@kernel.org, hare@suse.de, linux-kernel@vger.kernel.org Subject: [PATCH v8] dm zoned: keep polling for idle reclaim after a reclaim pass Date: Sat, 28 Nov 2026 19:25:03 +0100 Message-ID: <20261128182503.1466284-1-illofspeed@gmail.com> X-Mailer: git-send-email 2.43.0 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit dmz_reclaim_work() re-arms its DMZ_IDLE_PERIOD poll only when dmz_should_reclaim() returns false at the start of a pass, or when a pass fails with -ENOSPC or -EBUSY. After a pass it calls dmz_schedule_reclaim(), which queues the work only if reclaim is needed right now. When a pass ends while the target is still busy and has enough free zones, nothing is queued at all. Once the target goes idle, nothing re-evaluates dmz_should_reclaim() until another zone allocation, a "reclaim" message or a resume schedules the work, so the random or cache zones that filled up under load remain occupied. Seen on md RAID5 members on 27 TB host-managed drives: after heavy writes the random zones remained occupied for hours on idle targets; the workaround was a timer sending "dmsetup message 0 reclaim". When reclaim is not needed right now, make dmz_schedule_reclaim() queue the idle poll, so the work stays queued after every pass. It uses queue_delayed_work(), which leaves already pending work alone, so the other callers (zone allocation and the "reclaim" message) neither postpone a pending poll nor delay a pending immediate reclaim. This change requires commit 9bb1d14877f4 ("dm zoned: back off when reclaim cannot make progress"): without it, keeping the poll armed would restart the idle -EBUSY loop described there in every idle period. Tested on 7.4-rc3, on a scsi_debug host-managed drive: after a reclaim pass that ended while the target was busy with 33% of its random zones free, the unpatched kernel ran no reclaim pass in the following 600 seconds; with this patch, idle reclaim resumed and all random zones were free about 10 seconds after writes stopped. With three such drives as md RAID5 members, the first two write/idle cycles reached all random zones free 23 and 13 seconds after the start of each write, without a "reclaim" message; without this patch the first cycle did not drain. The planned ten-cycle run stopped after cycle 2 because trim did not restore sequential capacity. Reviewed-by: Damien Le Moal Signed-off-by: Kyrylo Biryuk --- For 7.5. This was patch 3 of v4/v5 of "dm zoned: fix idle reclaim busy loops"; it was split out after Mikulas asked to separate bugfixes from enhancements. The two fixes went in as v7 and are in 7.4-rc3: commit 9bb1d14877f4 ("dm zoned: back off when reclaim cannot make progress"), which this patch requires, and commit dab527d83462 ("dm zoned: do not reclaim a random zone into another random zone"). v8: split out of the series, rebased on v7.4-rc3 and retested there (the test paragraphs above have the new numbers); no code change. Damien's Reviewed-by is from v4 3/3 (2026-10-13); the code of this patch is unchanged since then. The back-off fix underneath it changed since v4: it now also backs off when there is no zone to reclaim (-EBUSY), so with both applied an idle target with nothing to reclaim runs one no-op pass per DMZ_IDLE_PERIOD. The Fixes tag of the earlier versions is dropped: this is an enhancement for 7.5, not a stable fix. Hannes, on 2026-10-21 you replied to v3 3/3 and suggested simply rescheduling with no delay at the end of dmz_reclaim_work(), because its start evaluates dmz_should_reclaim() and re-arms the poll anyway. That code was already gone by then: v4 (2026-10-13) had moved the idle poll into dmz_schedule_reclaim(), as Damien asked on the same patch, and he reviewed that form. It avoids one extra run of the work after a pass that leaves reclaim not needed; if you prefer the unconditional reschedule, please say so and I will change it. Also tested on three 27 TB host-managed SATA drives (single-device dm-zoned targets, 998 random zones of 256 MiB each, as md RAID5 members under dm-crypt and XFS), with this patch built out of tree for 7.2.10 on top of the two fixes and compared with the fixes alone; one run each, kprobes attached throughout, the drives behind a SATA port multiplier on a Marvell 88SE9235, with two other drives on the same controller being zero-filled at about 218 MB/s: - after a reclaim pass that ended while the target was busy with 31% of the random zones free, then 600 s without test I/O: with the fixes alone no pass ran and the zones stayed in use; with this patch all random zones were free again within about 260 s; - ten cycles of new data written into 32 fresh chunks followed by idle (on the emulated drives this test stopped after two cycles because trim did not restore sequential capacity): every cycle drained without intervention, in 2-4 minutes each; with the fixes alone (and with the stock module) random zones were still in use after the first cycle's 600 s; - idle for 300 s with all random zones free: 29-30 passes per worker; - 300 s of single-threaded random 4 KiB O_DIRECT overwrites with dm-zoned's free random zone percentage at or below 30 (at most 309 of 998 free) in 66-73% of the samples, but at most 299 free in only 2-10% of them (fixes alone: 22-31%): 2,925 writes, 99th percentile 0.38 s (fixes alone: 2,395 writes, 0.48 s); - a target suspend with the array running, removal of one member's dm-zoned target after the array was stopped, and a "reclaim" message, each during a full-zone copy (one occurrence each): suspend and removal waited for the copy to end (10-17 s), the copy under the message completed without error, no hang or kernel warning; - sha256 of all written data, read back at the end of the run: no mismatch; md parity checks of every stripe of the suspend/removal test and of a random sample (about 4%) of the other written stripes: no mismatch. Not tested (this list covers the two fixes and this patch together): the back-off under write load (every reclaim pass of the overwrite test copied a zone); single-device -ENOSPC back-off without cache zones; recovery after freeing a sequential zone; the effect of the cache-to-random fallback (6 copies ran while the two-device target was filled, but its own test could not establish its starting state). Reboot and power-off, on 7.4-rc3 with this patch loaded (three scsi_debug host-managed drives as dm-zoned targets under md RAID5 and XFS): one reboot after the targets had been idle with all random zones free for at least 25 s, one reboot and one power-off right after a write that left 1-2 of 6 random zones free on each target. All three completed (1.6 s, 1.8 s and 4.9 s from the command to "Restarting system" or "Power down"): the array was stopped, systemd-shutdown detached all DM devices, and the console showed no warning or hang. Whether a zone copy was in flight at that moment was not established. The Assisted-by tag is gone, following commit 1e035297ffda ("docs: remove Assisted-by references"). I used LLM coding assistants for root-cause analysis, drafts of the code and changelog, the test harnesses and reviews. I reviewed the code and changed it where needed, and I am responsible for this patch. drivers/md/dm-zoned-reclaim.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/md/dm-zoned-reclaim.c b/drivers/md/dm-zoned-reclaim.c index 152cb878811..3a4e3a6e4ff 100644 --- a/drivers/md/dm-zoned-reclaim.c +++ b/drivers/md/dm-zoned-reclaim.c @@ -643,7 +643,8 @@ void dmz_reclaim_bio_acc(struct dmz_reclaim *zrc) } /* - * Start reclaim if necessary. + * Start reclaim if necessary. Otherwise make sure that an idle poll stays + * queued, without delaying work that is already pending. */ void dmz_schedule_reclaim(struct dmz_reclaim *zrc) { @@ -651,4 +652,6 @@ void dmz_schedule_reclaim(struct dmz_reclaim *zrc) if (dmz_should_reclaim(zrc, p_unmap)) mod_delayed_work(zrc->wq, &zrc->work, 0); + else + queue_delayed_work(zrc->wq, &zrc->work, DMZ_IDLE_PERIOD); } base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3 -- 2.43.0