Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp5353451rwr; Mon, 8 May 2023 23:35:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ41BkA7cj4ZHcaGHBUjLQ6v5s3HzE0cv43uTuFAOCzWl0isWdUjy0fdQMSI7UKGjn68I+vM X-Received: by 2002:a05:6a20:4658:b0:f8:7372:66c0 with SMTP id eb24-20020a056a20465800b000f8737266c0mr12176903pzb.26.1683614142596; Mon, 08 May 2023 23:35:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683614142; cv=none; d=google.com; s=arc-20160816; b=jERZS3xVVNBiaNmZnN0H45BSgfRxlM9W1O8c7SdJiiAZ+hojRkntCQ4QpqDWQXK4uE l8RnW/1zsBivYfaaY8oARrKmHA3W3aUeJMtGkOfAkcZrZVnb4TpDxDv8YdrnCcISlC8I XHT2D0OjnXbTKp+hJFwfRg43s9GAuv+v5Sx2VKSIeyeLkno/Su8JdG4GjBGu67MY33DZ hq++Jl77x8NXysKECoQgdwshR4Efx10YRpf1bZKTMvQrh3ifM2dRp6CgAe/ogG3f4Epb u6EUmjLldTTbe2qc/UHKKrvbFVBMJGdRo7fzgTkNXsISjPvYAw7kXSYKt9sWD71xeyYL 4xaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=rZMKKsu16mHqDmBwDEXPax0+msUVKwadkrTOsSG3wGs=; b=IqJHLrllD9s7zWaFebPn6f94Sgrempqz657ZoMFiNu+HWw+Uo+3wPjxPmPvgSn1SSp foy0UG3ksKF66CvYIhquxTiXFfz7wOWAyKyM+D6icIcK6Jt8XxTgZUtbC9Ka7S4ZOYT/ leMxczAcB+KmBa7iHE+9OUJPWKAAWjM0EtWMc9g6gKmq4G/GwKmakoFhw5aHHZbCK4gD hfkAVvFYEzK7jRNKB+hs/z93euCTwaZ80Nu85aQcb1KB1w+9FxxyGZNQqOzfNWjPhND6 lIYMXFhJjWxZqjHrVu59Jz/jzI5UBWQ3MRX2rU7CMI+NIVx15fdaXM5AL6dSXEWv9Ol7 yVGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=LJ42r1AU; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k7-20020a635607000000b0052cb36e0bfdsi822064pgb.429.2023.05.08.23.35.23; Mon, 08 May 2023 23:35:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=LJ42r1AU; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234856AbjEIGW1 (ORCPT + 99 others); Tue, 9 May 2023 02:22:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234859AbjEIGW0 (ORCPT ); Tue, 9 May 2023 02:22:26 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25F8F9012 for ; Mon, 8 May 2023 23:22:25 -0700 (PDT) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 348NxChU005868; Tue, 9 May 2023 06:22:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=corp-2023-03-30; bh=rZMKKsu16mHqDmBwDEXPax0+msUVKwadkrTOsSG3wGs=; b=LJ42r1AU0ZNeIcw9JazpxeeLLUO+sq2kOHhibjc0GVMqmCP6DjTqyWNZJQEPmMssqM3a 3Gy/gppa+MblP9mcx3KsUxGU2So8oSrLMG5S/Qc2VZYwiZTSri6JsI8giFz8k6N55zrO bMZzuWGTA3esktm2U/9ZkDqQMwZAgYas/DkgMrajnGahnVzGMY1tBzoeDWZ8fqbkxG59 W/FBPXXrfjQQX9VGw2PqvXud5zCpTu5gt3akrVl6aDx2pXlMBY9QcxnAi9nEe5gHJfmA zzYTMHO7PNEY8pSELai8oGcqYUQpxuNL0lg5HggTy/OtBpROT7aFPei3VQ3NIMlV4Pf6 Rw== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3qf77d905s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 May 2023 06:22:21 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3495ONdQ001677; Tue, 9 May 2023 06:22:20 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3qf82v6nr3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 May 2023 06:22:20 +0000 Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3496KZbL002883; Tue, 9 May 2023 06:22:19 GMT Received: from sridara-s.osdevelopmeniad.oraclevcn.com (sridara-s.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.252.75]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3qf82v6nqh-1; Tue, 09 May 2023 06:22:19 +0000 From: Srivathsa Dara To: linux-ext4@vger.kernel.org Cc: tytso@mit.edu, adilger.kernel@dilger.ca, rajesh.sivaramasubramaniom@oracle.com, junxiao.bi@oracle.com Subject: [RESEND PATCH] debugfs/htree.c: In do_dx_hash() read hash_seed, hash_version directly from superblock Date: Tue, 9 May 2023 06:21:29 +0000 Message-Id: <20230509062129.1478823-1-srivathsa.d.dara@oracle.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-09_03,2023-05-05_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 adultscore=0 mlxscore=0 bulkscore=0 suspectscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2305090048 X-Proofpoint-ORIG-GUID: _XqvdA6z30xSwooFZJc6lVPpyIxVDENU X-Proofpoint-GUID: _XqvdA6z30xSwooFZJc6lVPpyIxVDENU X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org debugfs hash command computes the hash for the given filename. It takes hash_seed and hash_version (i.e hash algorithm) as arguments. User has to refer to the superblock to get these values used by the filesystem. If the arguments are not given then debugfs computes hash assuming both hash_seed and hash_version are zeros. In most of the cases this assumption will be different from the actual hash_seed and hash_version used by the filesystem. In general user will be in need of hash computed from hash_seed and hash_version of the filesystem. So, instead of assuming hash_seed and hash_version as zero when the arguments are not provided, read these directly from the superblock to simplify the task of user. Example: Before:- debugfs: hash -s 524e5394-e2a3-43fa-b192-79720b1fe3e1 -h half_md4 file1 Hash of file1 is 0x4a8d8c94 (minor 0x17a37f43) After improvement:- debugfs: hash file1 Hash of file1 is 0x4a8d8c94 (minor 0x17a37f43) Signed-off-by: Srivathsa Dara --- debugfs/htree.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/debugfs/htree.c b/debugfs/htree.c index 7fae7f11..2d881c74 100644 --- a/debugfs/htree.c +++ b/debugfs/htree.c @@ -316,7 +316,12 @@ void do_dx_hash(int argc, char *argv[], int sci_idx EXT2FS_ATTR((unused)), int hash_flags = 0; const struct ext2fs_nls_table *encoding = NULL; - hash_seed[0] = hash_seed[1] = hash_seed[2] = hash_seed[3] = 0; + hash_seed[0] = current_fs->super->s_hash_seed[0]; + hash_seed[1] = current_fs->super->s_hash_seed[1]; + hash_seed[2] = current_fs->super->s_hash_seed[2]; + hash_seed[3] = current_fs->super->s_hash_seed[3]; + + hash_version = current_fs->super->s_def_hash_version; reset_getopt(); while ((c = getopt(argc, argv, "h:s:ce:")) != EOF) { -- 2.31.1