From patchwork Mon Dec 5 05:10:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuezhang.Mo@sony.com" X-Patchwork-Id: 13064134 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9DC8CC4321E for ; Mon, 5 Dec 2022 05:12:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231545AbiLEFMR (ORCPT ); Mon, 5 Dec 2022 00:12:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231648AbiLEFLy (ORCPT ); Mon, 5 Dec 2022 00:11:54 -0500 Received: from mx08-001d1705.pphosted.com (mx08-001d1705.pphosted.com [185.183.30.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E04313F10; Sun, 4 Dec 2022 21:11:30 -0800 (PST) Received: from pps.filterd (m0209321.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2B544ADq000617; Mon, 5 Dec 2022 05:11:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sony.com; h=from : to : cc : subject : date : message-id : content-type : content-transfer-encoding : mime-version; s=S1; bh=sgu6yPQ8lCayHzTODsx17It8x6n3yW2mxMZFTeqPLqM=; b=ZdEpSbvRQZbidrd0Y8HwuQt6QRwMLTWNH+bcq27NNYptiGrgCRSu2OywfX1O5WpRIxhD FHj1+WvIbbxOpO9Y3FV4r5lfdrIOhh/gsr3vYAkrw4kZ6khasmvMb68jkm8oWpI1kHSL nHVWG0Y/JfsljG7dDCkk6Q3Hy9ik5JyS5MeJObzVtlwYayisdU8GQ7eU1kx+/1NYF4KH j6xvYjU2FSCQnNov4+NmDImuQYnB8YMX/xGPiX9eiX0pqp/lp1mFrki7g4jNzSsY2iY0 GIoFEBVZEmGc4lMQg39hIIfaSqIv7OdZRHxx611DBuIf/wXPbyAO87MDjJ8C+QfSPuKD Qw== Received: from apc01-tyz-obe.outbound.protection.outlook.com (mail-tyzapc01lp2049.outbound.protection.outlook.com [104.47.110.49]) by mx08-001d1705.pphosted.com (PPS) with ESMTPS id 3m7ycb1aj8-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 05 Dec 2022 05:11:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aNlwVsL0tpWDC97+lMCR+DIYqUAlmyQPXtatzyhONEsCtTk6ePEZLr4lhDlCbaW9+5W608Hp6dYYkd7GC0YvhaAiSUs1VwESf1yxI6nzfWUlS0TggmC8XF2nc9Fq+Z4kb5vpV4MyUScNh91AXvc/UL7mvIdCNEZ1nUdZMc44QIzJv5xG1NgCzuugsxIcA2bp3C4FFWHUQBKSlxtApUOWCyyRWQP4nmBtZo1c47/s9rxu1iwtUe8+To+IuItsDzTOE7dgW4GoHlMa+5eVLSevbzvVW/Q1zKwehr6kVEiwnwRYZvdQ8wY64FKdFh9OcNKGdcQeKrwVNoWJi6+H9ydmyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sgu6yPQ8lCayHzTODsx17It8x6n3yW2mxMZFTeqPLqM=; b=F8ofg05qVNuhUi0HqThynO1rLmoItAaeNbHwa6U+K3ifCs4bo6Ggt6q2BzzJ+KbM2fKHtug9WMUOYbx6BVNJ7koS7HsCmcu/o3tVFgZLkDrCayJ4r6AENZNOCP3hCGihszh/wt7Vz2xlRFYqZrt6ekv//X8z1cqEHqlFnNZhWhSAG1ehW0DswU05Egz3dq+So+pB0TOccbt6nKCNH7fPWwvkzHHcZ1ex+ucN/MOQ964pCkoNe8j6VGPWgsvLBHKqWff6oeIFWouUViZhAe5F+cyKEGoPzKLfcr8pA4EWK+wrsSMS33H6pbgzT3aKsA9ZWyQDFD8gGgZT05TNitLVrg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=sony.com; dmarc=pass action=none header.from=sony.com; dkim=pass header.d=sony.com; arc=none Received: from PUZPR04MB6316.apcprd04.prod.outlook.com (2603:1096:301:fc::7) by HKAPR04MB4035.apcprd04.prod.outlook.com (2603:1096:203:dc::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.13; Mon, 5 Dec 2022 05:10:00 +0000 Received: from PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::c689:d665:b3a2:d4de]) by PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::c689:d665:b3a2:d4de%6]) with mapi id 15.20.5880.008; Mon, 5 Dec 2022 05:10:00 +0000 From: "Yuezhang.Mo@sony.com" To: "linkinjeon@kernel.org" , "sj1557.seo@samsung.com" CC: "linux-fsdevel@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "Andy.Wu@sony.com" , "Wataru.Aoyama@sony.com" Subject: [PATCH v1 1/6] exfat: remove call ilog2() from exfat_readdir() Thread-Topic: [PATCH v1 1/6] exfat: remove call ilog2() from exfat_readdir() Thread-Index: AdkIZagE89nZwe4ETVe4ZwLM5E9ACQ== Date: Mon, 5 Dec 2022 05:10:00 +0000 Message-ID: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PUZPR04MB6316:EE_|HKAPR04MB4035:EE_ x-ms-office365-filtering-correlation-id: 2c122c58-b7c9-403d-43c2-08dad67ef5b8 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: rYDqkSuVYkd6EVySXyn+ShRUV4063dZUnoVFoK/D2TF+4FOt678RLKKb3kh7PcHJW6ooLJ0Xp5gVIqDNlI5p9qZHEgVJMNzvIHBqMimn8cJa40ybvcUCLu3J3FM/6zf+p52vnN7piwP7NdzeOyJv8ND0iE+f2J6neKgHmFxEzJXFxEWPJSSEcbF1jXUSG4FCUFtX/GAUfLWw9IHDQt3kWB75QAfAaD9hWJ8DTwx5n712xELCk1JPZHNgd5sfYLyIvVojdL9xfqDNfFi9ONZm/DdPhTK7rqO179quFkRNQTkqxVaubXHPY9OqdCFr9Fgu63I/D3SR137tovG4PrLaehQ37idhok0bIEUiga16vUzWurlqzfNFO7DY1cDnYf9aAk24uTRekDi7AyWnalxT2f4fCP9sf9cEzmoaEjbaf0jJ83ZeDmoynOsppULZVrGhs4HR7BRRrtyrxBRhGIOJfubZoJi0NzSvWdOJ0FH0C4sIdLnuSz2+KDYNhCfNE5yAd4rpeQy5NSiXuME4wY2bB9eFGfvwNcysdWv9Az+Dzku7BICm31dxVvfgqtAi7Z28zui4cQpmiTi7WF8E9JEv0J1azsdtEm1CiQvJkgt9CevK1XcibFSC4rm9Q5d6JPk0o+evGn8H+VG7ZvyIz3lyeC8E6JkAkJ0k/cRCN9HjHU3IVpHUB6/XMRIj12GAddrHFWJa4Z6kZfU+lOIMcpp7WQ== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PUZPR04MB6316.apcprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(376002)(136003)(346002)(366004)(396003)(451199015)(33656002)(82960400001)(2906002)(122000001)(41300700001)(8936002)(186003)(52536014)(5660300002)(38100700002)(86362001)(83380400001)(38070700005)(55016003)(54906003)(66446008)(110136005)(316002)(66476007)(66556008)(64756008)(71200400001)(76116006)(4326008)(8676002)(478600001)(107886003)(7696005)(66946007)(26005)(9686003)(6506007);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?JvlwP5G1bm1JJtIJOqgNr08FD6pq?= =?utf-8?q?FSPObTe1UWsZUEwR9WqRhTi9bVzPStn8mTHK8RdPBM9JgCLd4rS0x291M2zzn48iB?= =?utf-8?q?S9oL+u8KaaYiI99L/RIGUw9TlKbzXcNj6+nxErtEtGeHaeRS2jXmy/1cUMhwEi+Ua?= =?utf-8?q?qCdLGInz4CQ4v0esvCgnKDgbJ/CR+BJJemq+KMLycspncaQr0WMB769M16XZXc+Hn?= =?utf-8?q?V49kcMVCZ73YOEEok+eKZR8C8MOOlT2B8HNPRTCHSwYlQSInjSIxy4sS9tNAjTIyY?= =?utf-8?q?fUQttvCsAw/9hCd4v8pQBIYP3N4dtkA4Dk3U5S+Jg/PPMGB/pAvYGnDAg4IMa6Ffd?= =?utf-8?q?4QCv3vpHJr6VD2WL41kt3eBdWTXGgVcJR5hWEXdb042UYLYPrSrpRJ8PbfddIcpWr?= =?utf-8?q?nDKnFzGcFdHcX4ShBAZcO61zSH3SceIMVb0sMcmYaJW+UJ/FlNnZZV29k20QTkrzy?= =?utf-8?q?7Dt7QTU9f+SIZp2tmTTn4g/scM4ir0qt69q7mAfNGyanChzxQ2J7lNSK+k507OIlB?= =?utf-8?q?F5L9T02P+wdA31qkXUQRSy+/x5mKmlEsb0wArX55Np2MhBAqFhiFddmKuxdkvZjFN?= =?utf-8?q?m1XlhfzBW3MhT+72NDkDFaWAKty8Qg+H0l3PbORP7OgLZbuEr5ohVE9YSm/cHqzCk?= =?utf-8?q?wxDA9ppreB+zhQR3ccrIw7icxkSi8U/jVEGAVIYmnqF+lCapDUqN+Pb1Fn4F3BefH?= =?utf-8?q?K2hKCsWtKsvZdiyxAxKBaGlmxNhl5z9bNQv2B3EF4LM+zSCIGj07C7r3Wl+bfAURA?= =?utf-8?q?wQE7kaXAZotdIoUGG345jFYDd6HyIoMHeAAvkcvCaupofuKO6rUPJ440+d5bEU9FO?= =?utf-8?q?ac1xzDNQUUba+lIpfdPvtpbA+6/1Uq+4w/FEdBGniRu2Xsx9tIYo5HLyvyP2yNqYl?= =?utf-8?q?DmYZcE8WUi/mgH25Jo+UNN1xB6p7SB1A7L2KW+HZTS9abva4WCYIlQGMoU8Tg8CK6?= =?utf-8?q?fkQgelXyHjBKycKSg8JQrphrw++kH+Sog+0yxacA9my/OkKM1HMs6xvxknMtVVBZZ?= =?utf-8?q?ykaw6FC5cjDFSEyCPgzz3Yphm2aEQ8HrgszLD6wbLpBkMCzhshZTgpvhc3HDnRv5f?= =?utf-8?q?V9bGOq8bSiKH5KU6ceyO/tiHTdGhjbAI/YMO8ezsVMAuXBANgaN6snJqY6kWbK9Xi?= =?utf-8?q?ptsHVnCgdgiSuRvMzS6P4EuybRg9REXCXsKlDdJneJn6WPbArNJyCJwI4tePRoHKD?= =?utf-8?q?iZ3XIqhV0ofJ+qKMD7SYcI+4Q7oROVrARDHJWgxue+eMGw9b3lwHkKBxKW66abfZR?= =?utf-8?q?VbStVnEfXhSky/+LtDPhcsGwt0mxMVm4BAP3TI1RYTnZk/j8cYvbik407rFRMnzpx?= =?utf-8?q?RhI0F2RZq8yqAALG+FTgvOI5TAMfVPbj5bzpoWzmNYA3S8QjUui1Zt9hjYBUFKoE+?= =?utf-8?q?PAJTruiWRtQVCkqvnNh6J5ptFZNlyq4prIKxWUYHITgKGuuINGswsA8L1E/+iObTO?= =?utf-8?q?MmnaBhOaUHr3fOch1XvUus2j904q3eHajN639d9QHOkWBfK5h5zhm7z7oDXx28t9a?= =?utf-8?q?/zuqxSYLKVFs?= MIME-Version: 1.0 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 5qF60nQq3jhlvZmweg8VeO7NsSoDqf+sSHVHZRMHpD7rLQBPnTtqzZm1T4zofip03dlEi4Tx2oXO8v92Mb9sQ6x6cMu+MubratWcB+s6zNNWqeO3dZT4VVvj53sST1HjhGrLs0gq86CG05nWUydbGF8qzoVKwxlS3NQbDtXNVYzfnsVK+Yyn+35VIOL2GjN51CpMAPiwIv69bxweBbpoZO1uqatkgtZwy5oGqqvYg6sctSjcdhA/o9MR/pyT7gFpMoJzMfyIGBGVhpHTmBnzTn7Ioa73aTecB/MdcfGsEKde8EqE2dRFlJ6eJIOfr+qqAauCmzsCzB3MpFRE/wVOTXXLtC4wqpaUA9j0p8GPp+d7FEfImoE+jGVVt/7FVHn3lQWbBduKBJhDnQ232Xt+s7Rb6QJ2FWsNq4CaDnTii7TUl9Q4CTkCyfsZRvYrJtFbuIbYL/45I1SrgzgmYsWZJXwKKOsjHe7ujrRHF3/6H0iUsLok1bckiBSLXbuyCxs71Cr+w9SkPJX0s/B97MyV2BP1uakDOJIia+ZVJ9Q1kmczyzhABDqfx3XqxOv209y1dl4KwKEA+IZbHVX2zfGjA6AaMnsCtaDE60RKYNokXVICSfNqux94Gh5iSsl1rIk5g2cBdSXStdEu0r8+JJqzBzgjN0vXEzFTeNhsq7vEqevPl20jdy+6A9KHmY1C/aSkcVWn+cW+P6M6uG2pRPUOm3J4lG7M5DDaE+GNjXJVZJuZ7yKsP2s+iyGieZjM73oa3H30eYtYy2JI/Iurawb7My/ca5+e1KLk4phb+OQyC0q+MtmM2sHdHw07VIz+q18lyLoZi/3BKC8LIgyReALZnCIwLYbR3l+ALkWZowv/eqrM79KLqrF48jELP8MWheiJ X-OriginatorOrg: sony.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PUZPR04MB6316.apcprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2c122c58-b7c9-403d-43c2-08dad67ef5b8 X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Dec 2022 05:10:00.2595 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 66c65d8a-9158-4521-a2d8-664963db48e4 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: my17+UVvlbVWw8iGR9BffwN7cF5eYUguTixFZz72hYefoxyt1Rr5biGQbIMaUheK9F077MKWrI6v64fQ2y5e+w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: HKAPR04MB4035 X-Proofpoint-ORIG-GUID: 6RS2H4Y59rOtN1htMyceAIpqss5IQGyi X-Proofpoint-GUID: 6RS2H4Y59rOtN1htMyceAIpqss5IQGyi X-Sony-Outbound-GUID: 6RS2H4Y59rOtN1htMyceAIpqss5IQGyi X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-05_01,2022-12-01_01,2022-06-22_01 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org There is no need to call ilog2() for the conversions between cluster and dentry in exfat_readdir(), because these conversions can be replaced with EXFAT_DEN_TO_CLU()/EXFAT_CLU_TO_DEN(). Code refinement, no functional changes. Signed-off-by: Yuezhang Mo Reviewed-by: Andy Wu Reviewed-by: Aoyama Wataru --- fs/exfat/dir.c | 9 ++++----- fs/exfat/exfat_fs.h | 10 ++++++++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c index c05493fc9124..397ea2d98848 100644 --- a/fs/exfat/dir.c +++ b/fs/exfat/dir.c @@ -61,7 +61,7 @@ static void exfat_get_uniname_from_ext_entry(struct super_block *sb, /* read a directory entry from the opened directory */ static int exfat_readdir(struct inode *inode, loff_t *cpos, struct exfat_dir_entry *dir_entry) { - int i, dentries_per_clu, dentries_per_clu_bits = 0, num_ext; + int i, dentries_per_clu, num_ext; unsigned int type, clu_offset, max_dentries; struct exfat_chain dir, clu; struct exfat_uni_name uni_name; @@ -83,11 +83,10 @@ static int exfat_readdir(struct inode *inode, loff_t *cpos, struct exfat_dir_ent EXFAT_B_TO_CLU(i_size_read(inode), sbi), ei->flags); dentries_per_clu = sbi->dentries_per_clu; - dentries_per_clu_bits = ilog2(dentries_per_clu); max_dentries = (unsigned int)min_t(u64, MAX_EXFAT_DENTRIES, - (u64)sbi->num_clusters << dentries_per_clu_bits); + (u64)EXFAT_CLU_TO_DEN(sbi->num_clusters, sbi)); - clu_offset = dentry >> dentries_per_clu_bits; + clu_offset = EXFAT_DEN_TO_CLU(dentry, sbi); exfat_chain_dup(&clu, &dir); if (clu.flags == ALLOC_NO_FAT_CHAIN) { @@ -162,7 +161,7 @@ static int exfat_readdir(struct inode *inode, loff_t *cpos, struct exfat_dir_ent dir_entry->entry = dentry; brelse(bh); - ei->hint_bmap.off = dentry >> dentries_per_clu_bits; + ei->hint_bmap.off = EXFAT_DEN_TO_CLU(dentry, sbi); ei->hint_bmap.clu = clu.dir; *cpos = EXFAT_DEN_TO_B(dentry + 1 + num_ext); diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h index 324acc57d029..37e8af8042aa 100644 --- a/fs/exfat/exfat_fs.h +++ b/fs/exfat/exfat_fs.h @@ -101,11 +101,17 @@ enum { /* * helpers for block size to dentry size conversion. */ -#define EXFAT_B_TO_DEN_IDX(b, sbi) \ - ((b) << ((sbi)->cluster_size_bits - DENTRY_SIZE_BITS)) #define EXFAT_B_TO_DEN(b) ((b) >> DENTRY_SIZE_BITS) #define EXFAT_DEN_TO_B(b) ((b) << DENTRY_SIZE_BITS) +/* + * helpers for cluster size to dentry size conversion. + */ +#define EXFAT_CLU_TO_DEN(clu, sbi) \ + ((clu) << ((sbi)->cluster_size_bits - DENTRY_SIZE_BITS)) +#define EXFAT_DEN_TO_CLU(dentry, sbi) \ + ((dentry) >> ((sbi)->cluster_size_bits - DENTRY_SIZE_BITS)) + /* * helpers for fat entry. */