From patchwork Mon Nov 18 02:02:05 2024 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: 13878023 Received: from mx07-001d1705.pphosted.com (mx07-001d1705.pphosted.com [185.132.183.11]) (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 08F3726281 for ; Mon, 18 Nov 2024 02:02:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=185.132.183.11 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731895344; cv=fail; b=LoH8OE/WQ+Owrxm0yWUvgVQKeMeLTsEQgT0gJ1+BbKhMVHGaX4QDzYmjeepK1bIpgk7h9GLDelrNb6Qn9/8/rQzqZAMAF8K/tMJWwaKLAhTH4HA5kwrVaE4Q7UJMZqfU/0fHLWfx5RD9ldesdQh27lzkEp7YkrQLGyMBY4nM/JY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731895344; c=relaxed/simple; bh=EpJqZs5fJoojSLuWK+iwXV+v39pseaE48qG4KwBnZYM=; h=From:To:CC:Subject:Date:Message-ID:Content-Type:MIME-Version; b=Mcf3srEgxcps+5rm2gsXrFiSeGMB7rrL6x+pFgSlGtvPBhpVkTm4nvTwzCiTVhUw9NIqHrTy65n2i7Vk7PU/PxTkkuEviGQSyODZY24CqWkgIDvH0vJPjyq5E6YiXoQnYJIBEoW7kDW5SNI+iKoEV8nS1TuGtVg6TyvZ2Pe52CE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com; spf=pass smtp.mailfrom=sony.com; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b=eNOz65T/; arc=fail smtp.client-ip=185.132.183.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sony.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b="eNOz65T/" Received: from pps.filterd (m0209328.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4AHNwihw018091; Mon, 18 Nov 2024 02:02:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sony.com; h=cc :content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=S1; bh=EpJqZs5fJoojSLuWK+iwXV+v39pse aE48qG4KwBnZYM=; b=eNOz65T/Nd91VaglX+r1kUo9VwSRE/1XbYBMDKVB67Myu CeHV+abj/pyp9xUMsZa/YsXDLLaJfUr7JyH5IT1BoJEa0Opo4aWkI1YG2KbUbv5I 21zXvzoINsoVL24eo6lv+4JeTNEYUVT/tfJfIKkWgwhrKlOLcGwU9s2lwRHLF3wD AweCO1MVp7YnnWHYl5Hu9vxu3+uzzSsLkoRanaZuUQLpIoxPoPEOZq0o69RNf9IV J5BwG+CY9qDhb2aUZKxmDg0AqTJ1dI8DQfgoCRs5YexmsduL5KvQ6nhvRCiQANrq qvA1HiGL6sL8PqXgEVbWnNclHVLXGwUU4F5wh2iJg== 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 42xmjgs3jg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Nov 2024 02:02:11 +0000 (GMT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RggLQky+30WCBM1EdsbYH6IHAfLempeoFBL0Vrx5p2Ybha5heZtXTucP44T0iaTwhOiCZ4SUmAknUC6FKdyXg0e8p0vZ+pHKsJrSZXfnZeejpIXod0i9pMrqfAm4qb2WauEyH1mcqp+NRewdhokhYskA6MLgtqX6veYMzvkt/YvTycMnCo357lVLYgsj/NAi7Nym5DZrmZrrzP1BYwJHGucQ3nDIxbm9/CmAofmyfH/pdR4wD3A/KHA8tFAtxBYwpwWldD3QrvTMjzPTSkX4xjo2lXcX8ObY0VD5AdeddOvliVszP6yz/wMJDYUim7uwxkcv0p5OkCPX99K1Itl63w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=EpJqZs5fJoojSLuWK+iwXV+v39pseaE48qG4KwBnZYM=; b=TqCX/t5VajlyCQqY++f9jkcqiWLxgecdiGmP4IGQyo3mlVzEKk8yuJLYeyj6DN3oP4Q5mS+/CghHcWiCh/GA9WCmHR/61CwCgu/Instmnpg+o62gWqmMb/tHoWiWoVaeFexZ5MFcm3z68tjrX53cg6iEx57aL78mc+OF1yVkgj7UMj3f50ubieeHxKtISRq8NkQxqAsMh9z52o6FYqXKKAmeWSy/CMkffTII/C3sWh2sv/kgdz1jn+EKLg4yEwLn1c9lRhad1tx0E90cz2XDTO/1yAJzesFda+EFXs09nFh4ZoP9CqEqTUGqipAnApXM4vek2PGVbUeogmrwBu0oJQ== 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 TYZPR04MB6119.apcprd04.prod.outlook.com (2603:1096:400:258::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22; Mon, 18 Nov 2024 02:02:05 +0000 Received: from PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::409e:64d3:cee0:7b06]) by PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::409e:64d3:cee0:7b06%4]) with mapi id 15.20.8158.013; Mon, 18 Nov 2024 02:02:05 +0000 From: "Yuezhang.Mo@sony.com" To: "linkinjeon@kernel.org" , "sj1557.seo@samsung.com" CC: "linux-fsdevel@vger.kernel.org" , "Wataru.Aoyama@sony.com" Subject: [PATCH v3 4/7] exfat: move exfat_chain_set() out of __exfat_resolve_path() Thread-Topic: [PATCH v3 4/7] exfat: move exfat_chain_set() out of __exfat_resolve_path() Thread-Index: AdsFxBC7IXbbz4laRpe3GmeqAxN27wzmLUQA Date: Mon, 18 Nov 2024 02:02:05 +0000 Message-ID: Accept-Language: en-US, zh-CN Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PUZPR04MB6316:EE_|TYZPR04MB6119:EE_ x-ms-office365-filtering-correlation-id: 83a10b76-a682-43f9-a04f-08dd0775002b x-proofpoint-id: d8690225-876f-412f-87c6-a7cb45557a4c x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|1800799024|376014|366016|38070700018; x-microsoft-antispam-message-info: =?utf-8?q?3Eh/z9w8mUcEgiC/ZlR0O+phaAjW1nT?= =?utf-8?q?4/nJDTtDwb85jSod4i3y/UF4bfY2Hq90BPODnDZXObpdRWCGEafPzVOQWn8bw2s35?= =?utf-8?q?kLxa+WlG3Xmz3d63Alk3BWlKJN+5YjQLsTdQfjZrtTfOHzdUuA4CTFvpt+khryNNL?= =?utf-8?q?YV7aPD6vMRqwI+d2j6ou5w2O2U9/FqzWtM/b9B70Uu7cIHICCdNqWYmh74LT97zQa?= =?utf-8?q?ym5l6G3vptjDJ3QABzhh9O6PsOIvMCFNHdsZB/A2Vrim+MU7UQusLqrCRA+0CIGv9?= =?utf-8?q?tGNHY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rb8GhqnTpX6GJaOnNHqkxOee+t2vOD1Rh2wKx4aRsY3Otn3H9RmGEbvNwXa?= =?utf-8?q?NAw4tnXF001A5E4Gfq6H0WmOBSnFpACKP8GTclBggBt02lclbsbrg7PXNIDhXheeS?= =?utf-8?q?/3lRhTOJT5Zdqk2eaQZ3WpAQbdKOoW/NRc4Rv3AIuNeNCIBQsteQd9PE=3D?= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:zh-cn;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PUZPR04MB6316.apcprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(366016)(38070700018);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?gZqvD0fFZw7bUsBobphy9yIewwFf?= =?utf-8?q?nW+s/2fpCYeOOpbGi0g7yNWrlpmz9p1e/I80LJ86jAIggcf6cxASD1YjZClCUoJWD?= =?utf-8?q?OVLCuLuFchAyuc/xdV2mCHd8LW+oEzoomZNcaYdEPvXLam1e3yrB+e3lZpXcuTO0s?= =?utf-8?q?v5Lots0jr9NwMFFqUCsQNjDwwvnjM53KTedBUSx62/oTHsEbKHcroZYhRPFNAhXAy?= =?utf-8?q?Ylt3UkZbX1UzY+NLaSYuvmallklQHnzS2m3MLkNRvh1HXvjxm206NQEBws1jbNjJ8?= =?utf-8?q?O0S4XK4lbDKKECC4KNSiVxi/6w50A961JeMNTdkSyP6FnWiH1hzTekd1NZH/PNt9Q?= =?utf-8?q?6EMMWJMI3+pPqjShQ/86hbSc1IwTnW7sdnpme5ExPaOoGN95egROJE6mLJ8jMNla6?= =?utf-8?q?NcbaPojmg0fxEfckzMLQTR2CiT06buL17BTgBCiDsgTmGSu2dBDGUrCmuJJ4bXR8d?= =?utf-8?q?Xul9f+4kuEWjZmLwv7Xce7MOSEgYps2SkEmOVP5k5GVp7bY2Ud5hPrOBdRHayUgkc?= =?utf-8?q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?utf-8?q?HT/71Smx9dW5imBJk7lLBpXZm+PFLP/2xNGXpu6/M7vEURD6/BwKvX/ho+O++qEKX?= =?utf-8?q?UtbQwvmGpUFyxOvlP+t+L9kYWGoE/KxAmXVMH4lozkG7rhG7qBXZAXTUhmVnggiqt?= =?utf-8?q?SWwWxedFmpU4?= Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: b7dJ0ap7UZ/n6GbUD8vaoGgHVMasZHzZrg+3Lwq32srcUlCGzspkDsudNd2A3opu43+5n52rV7EWqTtkc3I4CoSoof4MNU0p243uWX/TtutWVRjCn9XyQiZs+D6oT0SAmY9A1AZ0rwwPY6sCKVGaqqCu4nz8W9fww3o6UiTw011EZgDgy4ear64wloHwVQ/69aoY4ZiPnShKoiznMFpKrK4isRaDya/wUjBQ8DPJQUrfBNnZ9XmUJ8Ox8hEzNPMT6vN0iclK54y2m87xPwbzsgMfr2DywNE6ZEQZnoibYVdoxqCcczSsBSOrRMnP+Ajw7PA08yfPOMDBadsWJWTQ7iLxaMlk0eAJRHQTNzYbOQGOWOiVA8al31/fHsYqjrq+MiVJXfCUFxItjmMc8tHU1PcydMWpj5v+nnNzwsXfm7LJpmZy+i4pbuDY4QwQicSNAHRnuPVzdS8sqAuIPXNyCfRenG5QcPi7VxCbkxLYvqXkshl7DlkU4ziq0I6lj6+k+x8M0Wa4VLBFDWsXiK1DQ6RT8vfgCEg/0Z3dpt9tW4gNcyYzen50QCNSDFLZnCQXMn7e+M61iv2p7p48JwdxC14ICy5fVCkC3dd0cCtBefvmNF+VBXMNOMawQn4KAMC7 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: 83a10b76-a682-43f9-a04f-08dd0775002b X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Nov 2024 02:02:05.1508 (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: JSbIB1phigPBrHOLqGaaNpU3yKZQa4aUOyK2bkQFTlfV9/7CMZMKgvmknHIqWoMB5kEKxa1lToMY0q8ghBi/hQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR04MB6119 X-Proofpoint-GUID: fqP0vYVvVOxg1RsG6cwtwYSRjIa-32hb X-Proofpoint-ORIG-GUID: fqP0vYVvVOxg1RsG6cwtwYSRjIa-32hb X-Sony-Outbound-GUID: fqP0vYVvVOxg1RsG6cwtwYSRjIa-32hb X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-11-17_24,2024-11-14_01,2024-09-30_01 __exfat_resolve_path() mixes two functions. The first one is to resolve and check if the path is valid. The second one is to output the cluster assigned to the directory. The second one is only needed when need to traverse the directory entries, and calling exfat_chain_set() so early causes p_dir to be passed as an argument multiple times, increasing the complexity of the code. This commit moves the call to exfat_chain_set() before traversing directory entries. Signed-off-by: Yuezhang Mo Reviewed-by: Aoyama Wataru Reviewed-by: Daniel Palmer --- fs/exfat/namei.c | 60 +++++++++++++++++++++--------------------------- 1 file changed, 26 insertions(+), 34 deletions(-) diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c index f938299e749b..d6ab4fa008c4 100644 --- a/fs/exfat/namei.c +++ b/fs/exfat/namei.c @@ -311,6 +311,9 @@ static int exfat_find_empty_entry(struct inode *inode, ei->hint_femp.eidx = EXFAT_HINT_NONE; } + exfat_chain_set(p_dir, ei->start_clu, + EXFAT_B_TO_CLU(i_size_read(inode), sbi), ei->flags); + while ((dentry = exfat_search_empty_slot(sb, &hint_femp, p_dir, num_entries, es)) < 0) { if (dentry == -EIO) @@ -385,14 +388,11 @@ static int exfat_find_empty_entry(struct inode *inode, * Zero if it was successful; otherwise nonzero. */ static int __exfat_resolve_path(struct inode *inode, const unsigned char *path, - struct exfat_chain *p_dir, struct exfat_uni_name *p_uniname, - int lookup) + struct exfat_uni_name *p_uniname, int lookup) { int namelen; int lossy = NLS_NAME_NO_LOSSY; struct super_block *sb = inode->i_sb; - struct exfat_sb_info *sbi = EXFAT_SB(sb); - struct exfat_inode_info *ei = EXFAT_I(inode); int pathlen = strlen(path); /* @@ -431,24 +431,19 @@ static int __exfat_resolve_path(struct inode *inode, const unsigned char *path, if ((lossy && !lookup) || !namelen) return (lossy & NLS_NAME_OVERLEN) ? -ENAMETOOLONG : -EINVAL; - exfat_chain_set(p_dir, ei->start_clu, - EXFAT_B_TO_CLU(i_size_read(inode), sbi), ei->flags); - return 0; } static inline int exfat_resolve_path(struct inode *inode, - const unsigned char *path, struct exfat_chain *dir, - struct exfat_uni_name *uni) + const unsigned char *path, struct exfat_uni_name *uni) { - return __exfat_resolve_path(inode, path, dir, uni, 0); + return __exfat_resolve_path(inode, path, uni, 0); } static inline int exfat_resolve_path_for_lookup(struct inode *inode, - const unsigned char *path, struct exfat_chain *dir, - struct exfat_uni_name *uni) + const unsigned char *path, struct exfat_uni_name *uni) { - return __exfat_resolve_path(inode, path, dir, uni, 1); + return __exfat_resolve_path(inode, path, uni, 1); } static inline loff_t exfat_make_i_pos(struct exfat_dir_entry *info) @@ -470,7 +465,7 @@ static int exfat_add_entry(struct inode *inode, const char *path, int clu_size = 0; unsigned int start_clu = EXFAT_FREE_CLUSTER; - ret = exfat_resolve_path(inode, path, p_dir, &uniname); + ret = exfat_resolve_path(inode, path, &uniname); if (ret) goto out; @@ -601,10 +596,13 @@ static int exfat_find(struct inode *dir, struct qstr *qname, return -ENOENT; /* check the validity of directory name in the given pathname */ - ret = exfat_resolve_path_for_lookup(dir, qname->name, &cdir, &uni_name); + ret = exfat_resolve_path_for_lookup(dir, qname->name, &uni_name); if (ret) return ret; + exfat_chain_set(&cdir, ei->start_clu, + EXFAT_B_TO_CLU(i_size_read(dir), sbi), ei->flags); + /* check the validation of hint_stat and initialize it if required */ if (ei->version != (inode_peek_iversion_raw(dir) & 0xffffffff)) { ei->hint_stat.clu = cdir.dir; @@ -977,8 +975,7 @@ static int exfat_rmdir(struct inode *dir, struct dentry *dentry) } static int exfat_rename_file(struct inode *parent_inode, - struct exfat_chain *p_dir, struct exfat_uni_name *p_uniname, - struct exfat_inode_info *ei) + struct exfat_uni_name *p_uniname, struct exfat_inode_info *ei) { int ret, num_new_entries; struct exfat_dentry *epold, *epnew; @@ -1003,9 +1000,10 @@ static int exfat_rename_file(struct inode *parent_inode, if (old_es.num_entries < num_new_entries) { int newentry; + struct exfat_chain dir; - newentry = exfat_find_empty_entry(parent_inode, p_dir, num_new_entries, - &new_es); + newentry = exfat_find_empty_entry(parent_inode, &dir, + num_new_entries, &new_es); if (newentry < 0) { ret = newentry; /* -EIO or -ENOSPC */ goto put_old_es; @@ -1029,7 +1027,7 @@ static int exfat_rename_file(struct inode *parent_inode, goto put_old_es; exfat_remove_entries(parent_inode, &old_es, ES_IDX_FILE); - ei->dir = *p_dir; + ei->dir = dir; ei->entry = newentry; } else { if (exfat_get_entry_type(epold) == TYPE_FILE) { @@ -1048,12 +1046,12 @@ static int exfat_rename_file(struct inode *parent_inode, } static int exfat_move_file(struct inode *parent_inode, - struct exfat_chain *p_newdir, struct exfat_uni_name *p_uniname, - struct exfat_inode_info *ei) + struct exfat_uni_name *p_uniname, struct exfat_inode_info *ei) { int ret, newentry, num_new_entries; struct exfat_dentry *epmov, *epnew; struct exfat_entry_set_cache mov_es, new_es; + struct exfat_chain newdir; num_new_entries = exfat_calc_num_entries(p_uniname); if (num_new_entries < 0) @@ -1063,8 +1061,8 @@ static int exfat_move_file(struct inode *parent_inode, if (ret) return -EIO; - newentry = exfat_find_empty_entry(parent_inode, p_newdir, num_new_entries, - &new_es); + newentry = exfat_find_empty_entry(parent_inode, &newdir, + num_new_entries, &new_es); if (newentry < 0) { ret = newentry; /* -EIO or -ENOSPC */ goto put_mov_es; @@ -1085,9 +1083,7 @@ static int exfat_move_file(struct inode *parent_inode, exfat_init_ext_entry(&new_es, num_new_entries, p_uniname); exfat_remove_entries(parent_inode, &mov_es, ES_IDX_FILE); - exfat_chain_set(&ei->dir, p_newdir->dir, p_newdir->size, - p_newdir->flags); - + ei->dir = newdir; ei->entry = newentry; ret = exfat_put_dentry_set(&new_es, IS_DIRSYNC(parent_inode)); @@ -1108,7 +1104,6 @@ static int __exfat_rename(struct inode *old_parent_inode, struct dentry *new_dentry) { int ret; - struct exfat_chain newdir; struct exfat_uni_name uni_name; struct super_block *sb = old_parent_inode->i_sb; struct exfat_sb_info *sbi = EXFAT_SB(sb); @@ -1152,19 +1147,16 @@ static int __exfat_rename(struct inode *old_parent_inode, } /* check the validity of directory name in the given new pathname */ - ret = exfat_resolve_path(new_parent_inode, new_path, &newdir, - &uni_name); + ret = exfat_resolve_path(new_parent_inode, new_path, &uni_name); if (ret) goto out; exfat_set_volume_dirty(sb); if (new_parent_inode == old_parent_inode) - ret = exfat_rename_file(new_parent_inode, &newdir, - &uni_name, ei); + ret = exfat_rename_file(new_parent_inode, &uni_name, ei); else - ret = exfat_move_file(new_parent_inode, &newdir, - &uni_name, ei); + ret = exfat_move_file(new_parent_inode, &uni_name, ei); if (!ret && new_inode) { struct exfat_entry_set_cache es;