From mboxrd@z Thu Jan 1 00:00:00 1970 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=1796191400; b=WZ5Be1jqvSusH40LS4Mmzuo7Z6y4xeZ5UlQHnZjKAaOa3EgkQWfNmxDareSAthEipq40 ouv18C5MMc5N+VZhnuOHd5QWjCSTvyRc5Qgr6Cj3/YYcJ3pfU6SsL2E/Tvbf6myVtUPhX SOr1zCGPVcDE/jogtx55nGqxXN3TTlQCGQ6GnepLn/664dUp1BeuN/KJreUyvCWzMghrc /8hu6n7DPza81Y7tKYdzAgVaTX5q4+Jod0o064UeBX565K2wtyQUDA2SYX5dGjEjwFerP qOwCRW0BK8lP+ADLailVKlWR8smxke8G83b4DcVaD/LdkvwWrUHVzOvp8T2RziyONGA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796191400; h=Received:DKIM-Signature:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:Content-Language:From:Organization: In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=QV8ZclUOrHbHwaQFaH4KXWLzk4jZFRswO6yg9K1fQeE=; b=WFLu/ymF9x2Mz+tTeN+tsPhxxGBMM08V1nZanBSkyfa6eiwHvKj47mrpo2wx+1qKJNIo L6R2uP9TG54Js3zVpTqgtdCO7RgOZwoBzhNTCmixh2qdfb/0jLEskUGkofpMM0IY7L+KZ JP89k70WHcq/Je17VEtBfllRAXCjHC7qDU0rji7xWJBrLG0k3Wmn99Ngkoki8MuHN4JN7 n109J12fv8tI2b0EvI1V9YtH1cQ/U/9JojRF72nt7mTpKbxg2Kx9HJnhGDTrIfE2wynEE ez8kFoHc2mXt/BU6SCNbTtJ417unMDkfp8yAMCksDUFgduBHRq6RkwEXz5S3HYdTnJw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=NQqQQP2s; 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 69C22606A31A; Wed, 2 Dec 2026 06:03:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=NQqQQP2s Received: by smtp.kernel.org (Postfix) with ESMTPSA id 761B01F000C1; Wed, 2 Dec 2026 06:03:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796191399; bh=QV8ZclUOrHbHwaQFaH4KXWLzk4jZFRswO6yg9K1fQeE=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=NQqQQP2siEKaGTqcIE0RBE0zfP6xgRPtXaxLnLvgmtQ+DSATGH4qRDzjFpEqPfJ9l FEW9ACbghrpTyDkRgEv8WkqOOn5QuySpX/rxdjDLfTG9eEtCvJxqEQk+pzRcj83XYt Ix34J0mKUseWNi/9Z1s4zc204ycvLDEJNMw7nRxRNPFqY+TzFnArlXuy1nuNh4sNnU 5Pn8qjuo+4GOkJ4JAyYiG0PuFQNeWskkZvmp3nRoswHb3POOskDRbih2XPY2zzzbjz QkjG3WIgVDzgObzjiLwX/p0Zp4ZsEipwpqWuwoWz57IHV7TFZVoFjkqAqnLjHvnvdk xjByDGV0KkHMA== Message-ID: <17f0e9c6-856b-4814-81c0-388743e0fd58@kernel.org> Date: Wed, 2 Dec 2026 15:03:16 +0900 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 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 3/3] dm zoned: fix the search for the secondary superblock To: Yingjie Wang , Alasdair Kergon , Mike Snitzer , Mikulas Patocka , Benjamin Marzinski Cc: "dm-devel@lists.linux.dev" , "linux-kernel@vger.kernel.org" , Hannes Reinecke , Dan Carpenter , "stable@vger.kernel.org" References: <20261130161425.3535695-1-x-professor@outlook.com> <20261130161714.3536812-1-x-professor@outlook.com> Content-Language: en-US From: Damien Le Moal Organization: Western Digital Research In-Reply-To: <20261130161714.3536812-1-x-professor@outlook.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 12/1/26 01:17, Yingjie Wang wrote: > If the primary superblock of a volume formatted with dmzadm is > corrupted, dmz_lookup_secondary_sb() fails to find the valid secondary > one in two cases: > > - After the first iteration, sb[1].block is advanced to the next zone, > but sb[1].zone is set to the zone that was just examined. Unless > the superblock is in the first zone that is searched, dmz_check_sb() > then rejects it because it does not appear to be in the right zone. > With 256 MiB zones, this affects volumes larger than about 8.8 TB, > which need more than one zone per metadata set: > > Invalid superblock position (is 131072 expected 65536) > > - The number of random zones is used as the limit. With multiple > devices, the metadata is on the cache device instead, and nothing is > searched at all if the zoned devices have no random zones. Commit > b38c0ad57f8e ("dm zoned: Fix metadata zone size check") fixed the > same problem in dmz_check_sb(). > > Set the block and the zone together at the start of each iteration, and > use the number of cache zones if there are multiple devices. > > This depends on the previous patch, which rejects superblocks that must > not be used for recovery. > > Fixes: a92fbc446d1a ("dm zoned: convert to xarray") > Fixes: 34f5affd04c4 ("dm zoned: separate random and cache zones") > Cc: stable@vger.kernel.org > Signed-off-by: Yingjie Wang Looks good, with a few nits below. With that addressed, feel free to add: Reviewed-by: Damien Le Moal > --- > drivers/md/dm-zoned-metadata.c | 13 ++++++------- > 1 file changed, 6 insertions(+), 7 deletions(-) > > diff --git a/drivers/md/dm-zoned-metadata.c b/drivers/md/dm-zoned-metadata.c > index 91cc8d28e524..687573bbc091 100644 > --- a/drivers/md/dm-zoned-metadata.c > +++ b/drivers/md/dm-zoned-metadata.c > @@ -1125,10 +1125,11 @@ static int dmz_read_sb(struct dmz_metadata *zmd, struct dmz_sb *sb, int set) > */ > static int dmz_lookup_secondary_sb(struct dmz_metadata *zmd) > { > - unsigned int zone_nr_blocks = zmd->zone_nr_blocks; > + unsigned int nr_zones = zmd->nr_devs > 1 ? zmd->nr_cache_zones : > + zmd->nr_rnd_zones; Please spell this initialization out after the declaration so that it looks nicer. > struct dmz_mblock *mblk; > unsigned int zone_id = zmd->sb[0].zone->id; > - int i; > + unsigned int i; Declare this together with nr_zones. And here add: if (zmd->nr_devs > 1) nr_zones = zmd->nr_cache_zones; else nr_zones = zmd->nr_rnd_zones; > > /* Allocate a block */ > mblk = dmz_alloc_mblock(zmd, 0); > @@ -1139,16 +1140,14 @@ static int dmz_lookup_secondary_sb(struct dmz_metadata *zmd) > zmd->sb[1].sb = mblk->data; > > /* Bad first super block: search for the second one */ > - zmd->sb[1].block = zmd->sb[0].block + zone_nr_blocks; > - zmd->sb[1].zone = dmz_get(zmd, zone_id + 1); > zmd->sb[1].dev = zmd->sb[0].dev; > - for (i = 1; i < zmd->nr_rnd_zones; i++) { > + for (i = 1; i < nr_zones; i++) { > + zmd->sb[1].block = zmd->sb[0].block + i * zmd->zone_nr_blocks; > + zmd->sb[1].zone = dmz_get(zmd, zone_id + i); > if (dmz_read_sb(zmd, &zmd->sb[1], 1) != 0) > break; > if (le32_to_cpu(zmd->sb[1].sb->magic) == DMZ_MAGIC) > return 0; > - zmd->sb[1].block += zone_nr_blocks; > - zmd->sb[1].zone = dmz_get(zmd, zone_id + i); > } > > dmz_free_mblock(zmd, mblk); -- Damien Le Moal Western Digital Research