Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795626162; b=a/zW+n+KD9m9PUcNJm0QwyGhOC+KG8qwEQ7mrM5OPawwAA/B7HMMVFYFaWUWSztZvn3w T0ERYMUpYttOjhKUXCWgpIBQIg3/XCL2UQUPWbo24yzBGM6cIW6d0t5PVPTtZDU3vJSsg U1PT29l/kW9xs9PJVhua3Qm+8QfdB+Vr5YqCKoETiWwHkw8iKm8s9f/Jm535a4FjU6Pqh 6tZ54/0L2MuY0kb1EwHCN9iysoIm6REDDO9Rv2asuIKcKslxri2QPDZz1GcQmbXRO1u/D cuy+zxSDSuJ7eRI1sPHpDljBpSHSpMSZ+1Cckhjc2AI/9mwtUh2blVgXN/kc8dhqmjw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795626162; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=XCykAeXVeilP/qwzf18HrVL0VTmep22+/7+5r1gyLjk=; b=mSEvEycnhSsONPjZ38x8Ofcz8BE5P7NCvlA1OYtbNTTrklJPNzJcBZjz/o/LiOVvnZuU pmmGPcFlAWz188WPPlnq0cOzww0dWpJplUlXNABYc+H7QEldHs+EwsHCusnhWCuKmdLJQ uySlAz5OPmmT1reIIh2rNS7WNmod/ebno6P2F2DhzaxBL8fe0BoUTlSGTMDQJ/WqZ6oab LbAkF3ZvB+yC+0T3tZb/hNEMWMRqxpDSghzLOUAATN7y27kDHh2de/1pGQzTRO4Yg4tcN UEexYVDzSUjEFxTGa+jWgbz2C8p6/NEN/m75vAit9Z2kV7nn/QL1XSx/D/vmo+eAoFw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=Lvy+wSRv; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7CAA1606A31E; Wed, 25 Nov 2026 17:02:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=Lvy+wSRv Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5032C1F000C4; Wed, 25 Nov 2026 17:02:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795626161; bh=XCykAeXVeilP/qwzf18HrVL0VTmep22+/7+5r1gyLjk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Lvy+wSRvHItxH38yCWek9EzYSdpfxogjL5OmVFupUXycw9DmAMBgugjriaeGguLxC SN3ObTPamb5NtJWNPfczgzUumMIVw3Y8sLI+r3RuB1oeUn0pV/GB/qS9BGagY7iLRK f0J75KIWNHeEMnMXrEyg6x8KYkyAAWVJj/kOctCc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Damien Le Moal , Hannes Reinecke , Kyrylo Biryuk , Mikulas Patocka Subject: [PATCH 6.12 708/816] dm zoned: do not reclaim a random zone into another random zone Date: Wed, 25 Nov 2026 15:37:36 +0100 Message-ID: <20261125143905.566526338@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261125143849.205329330@linuxfoundation.org> References: <20261125143849.205329330@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kyrylo Biryuk commit dab527d83462a618d99bfc96370ce45ae3428706 upstream. dmz_reclaim_rnd_data() falls back to a random destination zone when no free sequential zone is available and the target has cache zones. When the target is idle and the cache zone list is empty, dmz_get_rnd_zone_for_reclaim() selects random zones of the zoned device as well, so a random zone is then copied into another random zone. That frees nothing: the next pass picks the next random zone and copies it again, for as long as the target stays idle. Seen on a two-device target (256 GiB regular cache device plus a 27 TB host-managed drive) used as an md RAID5 member: after a full rebuild every chunk was mapped and no sequential zone was free, and the idle drive kept reading and writing while the free zone counters in "dmsetup status" did not change. Only switch to a random destination zone when the zone being reclaimed is a cache zone: moving it to the zoned device still frees cache space. This depends on "dm zoned: back off when reclaim cannot make progress": without it, dmz_reclaim_work() would retry the resulting -ENOSPC at once, and run dmz_check_dev(), for as long as the target stays idle. Tested on 7.4-rc1 together with the previous patch, on a two-device target (a 512 MiB RAM-backed regular cache device plus a 1 GiB scsi_debug host-managed drive) filled until no sequential zone was free, then idle for 60 seconds: the stock module made 877 random-to-random copies; with this series it made none, and each pass failed with -ENOSPC once per DMZ_IDLE_PERIOD without a device check. Fixes: c5c788595292 ("dm zoned: start reclaim with sequential zones") Cc: stable@vger.kernel.org Reviewed-by: Damien Le Moal Reviewed-by: Hannes Reinecke Signed-off-by: Kyrylo Biryuk Signed-off-by: Mikulas Patocka Signed-off-by: Greg Kroah-Hartman --- drivers/md/dm-zoned-reclaim.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) --- a/drivers/md/dm-zoned-reclaim.c +++ b/drivers/md/dm-zoned-reclaim.c @@ -290,7 +290,13 @@ static int dmz_reclaim_rnd_data(struct d again: szone = dmz_alloc_zone(zmd, zrc->dev_idx, alloc_flags | DMZ_ALLOC_RECLAIM); - if (!szone && alloc_flags == DMZ_ALLOC_SEQ && dmz_nr_cache_zones(zmd)) { + /* + * If no free sequential zone is available, a cache zone can still be + * moved into a free random zone of the zoned device, which frees cache + * space. Do not do this for a random zone: moving it into another + * random zone frees nothing and, on an idle target, repeats forever. + */ + if (!szone && alloc_flags == DMZ_ALLOC_SEQ && dmz_is_cache(dzone)) { alloc_flags = DMZ_ALLOC_RND; goto again; }