From patchwork Tue Dec 13 02:36:52 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: 13071667 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 B2B11C4332F for ; Tue, 13 Dec 2022 02:38:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234377AbiLMCiY (ORCPT ); Mon, 12 Dec 2022 21:38:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234314AbiLMCht (ORCPT ); Mon, 12 Dec 2022 21:37:49 -0500 Received: from mx07-001d1705.pphosted.com (mx07-001d1705.pphosted.com [185.132.183.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 701121E711; Mon, 12 Dec 2022 18:37:14 -0800 (PST) Received: from pps.filterd (m0209325.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BD05pfX016439; Tue, 13 Dec 2022 02:36:57 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=erQJDY38kNphiUmalOhmkX5pNhQbMS+d8y/d/68M3lN6eHV1PBtKZ8e++1cEvEUU9MuV kR30f8ztj375OUufB7qahpDcgWXYOP76PxnaLv7LCjwm6duJFNjsEny89NgWAaMZvFrJ pp3Ld75AYUHsIUs12C+Qi59UJkEykPl7AyU65H2HWm+6WAlTMwzhVU2y2myTn9zO59Gt CvlPCE6jWDVUMOj10yDOlMkYHbYU7uB47MC44/0px27MAYwqYojIRokwHutCX00C2DUl HGn+0721opeogU8ouGvSvHsrstazliSbol4k5AnWfPVvz8zlkttbZn3R8bHjtHCk3TaQ pA== Received: from apc01-tyz-obe.outbound.protection.outlook.com (mail-tyzapc01lp2043.outbound.protection.outlook.com [104.47.110.43]) by mx08-001d1705.pphosted.com (PPS) with ESMTPS id 3mcfbytma7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Dec 2022 02:36:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MPTNL/UkZJ7oFJKkz4nDYDqF1qp8HzIjirpPdKLRK9F8j3Il/1q5S2ija3SnH9o3Y4gNlJppipfCqiSF2KsjbSHaZ2DgTTkapn87l2e8P6gy/OKcjexZCWt+jY52SGlaloUqddv9ODcOjmYA3oQU5KSsewQwrehteayo9ua7mfW9JcDZg+GCm3DhhKNTm2ennTZbuUDpKqohfAvUt02rCAyvUtY1VKdnnEvjj8KrvaUxSJnVjko2hX2rMGBqgapspLxZ4PYTiwstqMlXIh14T+gpsWr4kj3jRIVCo39pPHcvq7YkEOHuh9Bu+DTXDiB94tbyW0sbhsrUWJwE8b1pxA== 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=hNOGIOEJKqZXsOWeBu8sZc7MzD3kpi19CbkXv0CkeWIVHvbEjOk/W2jUPsB94fyKgJxgDqAvTJIDOgNw+p7+qnQrdnTmMQtHShztuTseQmUvaSQBwENISiCStbrPd269d+kK1ndOHYR7xk7THdnzv3mzZ3bHgdZWBDTtEoAO+HaK287IsALKxOaP8Uk+IQIhzceMLDaz02tKlIpXK/OkwvLYWyTcCFoH/LQ/Js2C2O5PcVA9NBWBCHdsv+C0i6qNsspy7tQv4EhhwWoKs3HWzyxgBeS4Lp4VDsROBhik0DXw364k+yx/ecEfjQILFQNFK1U1IJriwxxTMvGYAS7lUg== 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 SEZPR04MB6948.apcprd04.prod.outlook.com (2603:1096:101:e1::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.10; Tue, 13 Dec 2022 02:36:52 +0000 Received: from PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::c689:d665:b3a2:d4de]) by PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::c689:d665:b3a2:d4de%7]) with mapi id 15.20.5924.009; Tue, 13 Dec 2022 02:36:52 +0000 From: "Yuezhang.Mo@sony.com" To: "sj1557.seo@samsung.com" , "linkinjeon@kernel.org" CC: "linux-fsdevel@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "Andy.Wu@sony.com" , "Wataru.Aoyama@sony.com" Subject: [PATCH v2 1/7] exfat: remove call ilog2() from exfat_readdir() Thread-Topic: [PATCH v2 1/7] exfat: remove call ilog2() from exfat_readdir() Thread-Index: AdkOmXOzasUmLwpnSf6xtnBDY8gbaA== Date: Tue, 13 Dec 2022 02:36:52 +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_|SEZPR04MB6948:EE_ x-ms-office365-filtering-correlation-id: 9d89c779-51b4-4f02-189f-08dadcb2e479 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: R/qawWOmNP90qSJTPwlxQJQTII7D8o1tdGaepBDS3B1UdxmPlscu9RVlKoZXFCCFiFkKvW3nHLKPTvmvrquhRGM+EakOPO0rJy4mwN8Zu7Q+8ozpGm9H7zTolGrILF2qru4S4BE9f8SOR30NKO5aDfj5mZUIvHjYsuowGtkvVikO53TOIQS+y6Jl38FHRfP7r/JLWHrY5UKtNKjGMw8M1H5o3rrobZcWlDoZRjXm+gyKhGlFvcaB8nN67BTVNAtkIyCnqoyT1kiRdt7VwObRFcBHeU5mCOiNqsdbMNJoDUm4w1U9oJ7IBfw2mSSy8v1ipv+/kj63mcNjxFxAVNmMnAAOy2TIpy6ceqVnu2ZlQiWgGaeAaxkMpvXQ1/jDMaSNbdpUwNsZjaj7G/UGVuVmfNiqCLJtKOgL06GyPf8UMY5n8ChYGKfxJdVsrtrD0WeJanbOFdgUKXaEbLbX27LJD+FX4Of+T+MiYVtDlOIVxLm3LfQAP6ROyhwJsJIkxIN5GkxYHhr4DCrRkrEM+pi4U9HY+pAUiRp+2xPdZrwg16diQludZFSEqsK2ibl2jfOG2BPV77L/0TMpul7N2u3YPSFjAxaD7IapQYVRh1085EimXvMobXBXO92Ny10scELbgJqoC7yEF6SC/+roJ/n42lpzgUp2scyp5sF4eCext3LqzOHd5sz4Rvs6Zxkc1k+h9HPsUeXKwnv/2jKrLDd8ww== 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)(366004)(346002)(396003)(451199015)(86362001)(82960400001)(38070700005)(2906002)(8936002)(4326008)(8676002)(66946007)(66476007)(66446008)(64756008)(66556008)(5660300002)(122000001)(38100700002)(33656002)(83380400001)(478600001)(110136005)(316002)(54906003)(71200400001)(76116006)(55016003)(52536014)(41300700001)(6506007)(7696005)(26005)(186003)(9686003)(107886003);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?RWrGlgYLfaPwsnK2uhbmZSXY5iRp?= =?utf-8?q?gG0yWJbkPGg79n4y9JA9kJgcqhx7owtMoN/nSDkbfrCrH2ODNyMku0ewja+7FOwar?= =?utf-8?q?4bRgBg8ibKBYhQ0F0IfDPJFsRyFOuwZqN/++hEAxvZ+aYYxIGqgZqDZbOaHHHmesn?= =?utf-8?q?PWnBP/4xCup/RmevRbtw229xjHwUuqRVmATghSgFda5ZvfivKHrWD2CfQZVFbSybJ?= =?utf-8?q?yONuzAwOswhUe7vUT5x4OUywGjaaLkpMFLQpALBpRNlijIS1G52hNWyJ+gbMPvmfZ?= =?utf-8?q?VE0cR0v3oJFQu5MRDvwYkL45uy/yQqdSMmfcFgygDs0w0607e99GANhAY/Sc9/C7l?= =?utf-8?q?IQBsnyLPRZRViOhH7EtVVM4BEyIDOxI7euK6gfK6HsLV+DLgac4hlthF8el2BBZGA?= =?utf-8?q?uvi5XhK2I2xJrdp1VNRBTfEzaxHztngf0ahcGqACTF1cl3GYRUoiLe6ywWa4Mu9nW?= =?utf-8?q?ChPR41lhDuDeOkueVuHr8nkwuzj01lelt6ErIGx1AoylAwEbKwyFuqiQSw8bFq2jp?= =?utf-8?q?beg7QVldUPmJhZykNLU+dZPov4dpFWJODeF+CGQ8iBFkN++5u4/tkOCTtu/wgOWej?= =?utf-8?q?4uRBvI1W5NKLQLyEzrQWA7K4j1z+JmFaUfZ7TW9KYorCQ65DJTMYcvn9R1gQFT4ny?= =?utf-8?q?t/H9zqC3LlCuUrEkqiqsoNrW5NE0FgGkSOD5lzopXX9I4RNEGaQuaK8eXr2gc5MG4?= =?utf-8?q?UaGoHjuLICAOs+h8zivd1tuyzxnDPRCm1h1M/CAP67TdYx0jSuJ1nXwUzz6NJhCjT?= =?utf-8?q?fcIoQ+mkBKmmsD3Fa6xDl50seu1IGeQD+Rc4uWlmrh3OhtTWojNGENGghkdS5tKKa?= =?utf-8?q?KPWdXrloifZrYcu2NzhqwXiWM1pWBwk3FrPJR2W74LW4RijaAohLKDvgihXJLvUCb?= =?utf-8?q?08GEA6bNp38YNRkHxtGZ0+nKNEQskiRiqHqE70txkvnD+Hmq3isVzMS4c29nO2E7d?= =?utf-8?q?nu02TtPRT8MPqKDLGMuqpDYoEh8ApPqeicAW3CkMC3t0K0zwSgJ5wfJRTlpuZdf9U?= =?utf-8?q?5tTfYrbJDN9zGlb1/aVuqjOQwC3CG9YV5gUmgo3ovmQaDWrB9TowSrpmltLiGMnSa?= =?utf-8?q?4jNQNY04vYi8Vm7TmgVcG7M4eu8ny1VkrkLTip1Tbsj11pYwV85gqih2PjilpNEwe?= =?utf-8?q?2vWCBETTL6sgMlUHgSHip/k5ycZocP1ksfjh4B8bhkoEw4ibdeovA7qhTJ7XjNqgm?= =?utf-8?q?fzZJ+ny5KUjS7Rck5k5Ch9yiljIV1RNeHto6fDQ9raK2S8jnTqizkUSwPHSOT++ah?= =?utf-8?q?2Cu2VKMn21iyp9KL5nwKVCfKGY6kO/cCwu5Cc6GQfA6/keBikW873Hv7KRt632Oy+?= =?utf-8?q?WGe8B7BD6tPC6MxN6/A6UAosrnlDsOpclDctyfsZ29ptJDiSX51huyzdKRpS5b4Q3?= =?utf-8?q?Msxr4Nj5M8YQiCzbqzNqYFsQl02DbW6zi1CPw3LYNcwIpj5OUKRuPUEkOjOGWuPtY?= =?utf-8?q?GwhQOOlipiEqrWKEi+0IvvdUGQRN+p+OXkdgv6ckOSdmH1xJozoo7/vqLFbxhPUzv?= =?utf-8?q?HGYySMR41rYu?= MIME-Version: 1.0 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: 9d89c779-51b4-4f02-189f-08dadcb2e479 X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Dec 2022 02:36:52.1308 (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: wF3l+p1JpQY7pRkT9TnVtI7TPJ9m7W5h548HkKWyeT0poPCsspAUqfAjC+SJ88mLC4nePLKUAlpo2twpzHyplA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEZPR04MB6948 X-Proofpoint-GUID: jefesoyQjk3DZS28J8mm9URqE8fRskkR X-Proofpoint-ORIG-GUID: jefesoyQjk3DZS28J8mm9URqE8fRskkR X-Sony-Outbound-GUID: jefesoyQjk3DZS28J8mm9URqE8fRskkR 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-12_02,2022-12-12_02,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. */