Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp469775rdb; Sat, 17 Feb 2024 18:36:39 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW4Mpkvmok9jkniD/jRAx/zzbDZSxeAcJXDdzyJCfSXfrcqjcMdIhGiCRMSLn4VcoDnOc38S/KntuzYS1igmuxV1MIZ7f14cITqAYf+3Q== X-Google-Smtp-Source: AGHT+IF6P7x2wupJBj2vOP56/js1oCm6gGy6DmWuhkg4GOaFLSYp+8tU+psBtbh6VDZMoPAzk9fg X-Received: by 2002:a50:cd58:0:b0:563:e5e0:85e1 with SMTP id d24-20020a50cd58000000b00563e5e085e1mr4762240edj.25.1708223799134; Sat, 17 Feb 2024 18:36:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708223799; cv=pass; d=google.com; s=arc-20160816; b=U3dRuU1+0hsfEGTDsoCDSgFflIkrIP3W7Aw1lPaCNQCYEYK5mE36jRnJLAWJOXn5F9 7lf3NWKsuADn0Czk/FC3a+c4GM0hUY/f1SxD7nxw9/GJeLYmf5YumYblB4x6G5p6QcAH xUBU0+TndhZEpQyBXG73FDdf1BmEN6u47nx5fsGIaTekLBQ51mKPYuNuGNN5R5QyNUId A+S3v1vf976Lz33t6Iu90zJDcJ+OR29lmKp64faYqVrnnzLZBehHkHfDLYqiPGMzr+TN Jzwk0F3jpmLhzzn93s2V+BdpeG8SR2vrandsly7Irb8D6YBozTjflxwsBd41dCMOti8I KIzQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:in-reply-to:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:user-agent:date :message-id:from:references:cc:to:subject; bh=824wdeCVTId/9JER/XOb9rCbzhRp9ITmFr2cbhC+eOc=; fh=H7l9Wh7MxDQOXtGqxsg755Ey4KVQgSPpTlcMeb4Nkc8=; b=AOh1rVvpEfln99bzpNa3ncLNS+FfDq1qFrNht7GQVBaqStkeRajbe0dvWgLCrbeIiK SN6E/ZwG5+nnFL7k838hwLt97bEBLdRFyLdtwmqy3cxXmqpTBqlukoGBWrfYBZ5QkQKf zNY6Q6A8jR7uPdUTf0rhGFFP3oqiiAMU1yaUOUTdBLxBzvfBJXZJw9H14b0t4AD5Vrqy oqSdoC322mpbQnsJP1XeSXCM3RswRThQH5ytmSEc8gHH76vb58t0RCARQdztfrfEHtoP wW2gX0dyqFJ5oTS4YNezL063NXEyIT32jAkdbr2cRKHggvo+r5lNu7Clv9XSeINSAQ5u dAOw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-ext4+bounces-1263-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1263-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id m20-20020a509314000000b0056440aee7c0si454157eda.32.2024.02.17.18.36.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Feb 2024 18:36:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4+bounces-1263-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-ext4+bounces-1263-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1263-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id E09241F21CD9 for ; Sun, 18 Feb 2024 02:36:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 056A915C8; Sun, 18 Feb 2024 02:36:34 +0000 (UTC) X-Original-To: linux-ext4@vger.kernel.org Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B84CC81F for ; Sun, 18 Feb 2024 02:36:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.188 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708223793; cv=none; b=nY0WbgpVJiloN+GrRCXh5F6bEOPiTm1CNaid+jzSEDID/2B6LGFAJvZ+pwYRZ2K81BR8+e551MnZaktfRgnPQePlnE5rsihZkMFdmDDxmC9fhv7IB7RFunqZhMIaM0LyoUEfFQm3+NqvUyaxUraE9xoikFRF+GhUmEgsENCNe0Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708223793; c=relaxed/simple; bh=/zGdM83v//sphRScl5OLUS5tiZ5NdqDhM8Grzm4+cMo=; h=Subject:To:CC:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=nq1MI6S5PQeEw+/keVjxp8SQz9wD8AvDtQMiQ7Dmv3SFrg/BN9UsX2IVxNAMSShr8O5SZ5NRoc+IGEaydCy788UyYk1yyUJTo9hFbBCFAS/OfKXIIJOkI2Yw7pR7k/ZEfjvzNG15f8rmrivPIR/oYchV5EzpLxcCULd/7ZVAuP8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.194]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Tcq5z04fgzbcKq; Sun, 18 Feb 2024 10:16:07 +0800 (CST) Received: from canpemm500005.china.huawei.com (unknown [7.192.104.229]) by mail.maildlp.com (Postfix) with ESMTPS id 76A8214011B; Sun, 18 Feb 2024 10:16:41 +0800 (CST) Received: from [10.174.176.34] (10.174.176.34) by canpemm500005.china.huawei.com (7.192.104.229) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Sun, 18 Feb 2024 10:16:41 +0800 Subject: Re: [PATCH] ext4: Verify s_clusters_per_group even without bigalloc To: Jan Kara CC: , Ted Tso References: <20240213101515.17328-1-jack@suse.cz> From: Zhang Yi Message-ID: Date: Sun, 18 Feb 2024 10:16:40 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: <20240213101515.17328-1-jack@suse.cz> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500005.china.huawei.com (7.192.104.229) Hello! On 2024/2/13 18:15, Jan Kara wrote: > Currently we ignore s_clusters_per_group field in the on-disk superblock > if bigalloc feature is not enabled. However e2fsprogs don't even open > the filesystem is s_clusters_per_group is invalid. This results in an ^^ if > odd state where kernel happily works with the filesystem while even > e2fsck refuses to touch it. Verify that s_clusters_per_group is valid > even if bigalloc feature is not enabled to make things consistent. Due > to current e2fsprogs behavior it is unlikely there are filesystems out > in the wild (except for intentionally fuzzed ones) with invalid > s_clusters_per_group counts. > > Signed-off-by: Jan Kara > --- > fs/ext4/super.c | 10 +++++++++- > 1 file changed, 9 insertions(+), 1 deletion(-) > > diff --git a/fs/ext4/super.c b/fs/ext4/super.c > index 0f931d0c227d..522683075067 100644 > --- a/fs/ext4/super.c > +++ b/fs/ext4/super.c > @@ -4451,7 +4451,15 @@ static int ext4_handle_clustersize(struct super_block *sb) > sbi->s_blocks_per_group); > return -EINVAL; > } > - sbi->s_clusters_per_group = sbi->s_blocks_per_group; > + sbi->s_clusters_per_group = > + le32_to_cpu(es->s_clusters_per_group); > + if (sbi->s_blocks_per_group != sbi->s_clusters_per_group) { > + ext4_msg(sb, KERN_ERR, "blocks per group (%lu) and " > + "clusters per group (%lu) inconsistent", > + sbi->s_blocks_per_group, > + sbi->s_clusters_per_group); > + return -EINVAL; > + } This is almost the same with the code snippet in bigalloc branch, would it be better to factor them out and reuse this hunk in both branch, just like the check e2fsprogs does? Thanks, Yi. > sbi->s_cluster_bits = 0; > } > sbi->s_cluster_ratio = clustersize / sb->s_blocksize; >