From patchwork Wed Oct 30 06:12:12 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: 13855955 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 E3C981D0E35 for ; Wed, 30 Oct 2024 06:12:29 +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=1730268752; cv=fail; b=s/CwCJ2rd493Swws5PnUU0eTBtFhdB9z8UKEMyxlKZKWfpBymVISyZbJRgNLGAoL676TsuynyEROfKlNf0+FL19poPL1zZoTP5H1g+zbowc4rNBEtscqa9BrV1AV1ywffY4kFlSy9fmvbG4mxZpWTx0cF4dpTRpA8j7kyURQjZg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730268752; c=relaxed/simple; bh=PAltGoQnS/uJ3gLMNB0n6W3IUryu2YBytgVKdUCzYAw=; h=From:To:CC:Subject:Date:Message-ID:Content-Type:MIME-Version; b=cnSPa29GCgQmrdhR+OM6x0g5ewWeihl8L5hJL7JlUjpRlGYXMO6fwvhDn+31JUh3KlnCmyjd2hmoxRiB9wnf54bHogixNhXvR3Ds/FXuGlSt3/Iu9qZfJz32G7avLFhVQmCmZ7l4ryLHAUxSvQ7ZQdB3+8IexwWpioDbHdPWxVw= 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=TqVhgKew; 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="TqVhgKew" Received: from pps.filterd (m0209324.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49U5pfSR030520; Wed, 30 Oct 2024 06:12:19 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=PAltGoQnS/uJ3gLMNB0n6W3IUryu2 YBytgVKdUCzYAw=; b=TqVhgKewD/3zpcOp3jC+wogCwDgJCgLTPef2Y9i9nk6S7 3ODQ2/k/YLSk0GE6axy/Ek6L7/vgluZ7Y3xPeAZB3YlOBds1GMW6tunrmFYvlVM4 0zpJaSv23YjlsIkbQfR52n2d10/93B2s8qGCtZcwJbbKKa22gAyfcOv6ZlLGogRg 9lQunskNBOVlQ+LRAfM6pMIYBm6PkgSCAJswQzl0bbYyT7nKbe1RAwIpxGeAN0wr VFdKX8FUQPGe/lfFmqa7DRRIUS5V+Db3Wr/eYuE6nJwWBbZAhTHEC/CCX6nwwxk2 vfLi6Vxl1xS2Z6Egvwf28qrYXmmtPjJ66j50TnWGg== Received: from apc01-sg2-obe.outbound.protection.outlook.com (mail-sg2apc01lp2107.outbound.protection.outlook.com [104.47.26.107]) by mx08-001d1705.pphosted.com (PPS) with ESMTPS id 42k2ypgkbr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Oct 2024 06:12:19 +0000 (GMT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QK/y5vcYxffRkze4FO9lAWEWH+CcR6aFkroKEMRy/rgPoybA4ZrE2ECjAuuFbDL9zfXjmt9uLNit4e3yvBZcHUZ+loh3BbIaKQLxhyHrb9MC59G2xTQg6vNMuCNGBWgw1UFfJI0PRLh268o1BqMfCCJYMPfMVa4N/ELwOLof6iV30wXUqKzbzOxzVcfuDi+E/YEjdUE/BRC+xHND+PVoy6aFH0KRg25IM9hQIJUA0rEFBDeyCDItXHNIhijyMLxxJ9wGhDWJ8c5dX7NGoiozQseMW5irGfkYwQnj8j7mwfeR1hH57QtxtOOBrv3zkA+6X2wv2xWM/n9B8puU9N9Buw== 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=PAltGoQnS/uJ3gLMNB0n6W3IUryu2YBytgVKdUCzYAw=; b=d9xA8bPaR/ckVm3GhVKi9kNkT3JU0k0EbS6r9CKreObr44g2DCCxGRo3VF7k9ddLZx8A0tZiRkUpYb7F25qPpeHOV9fwhHnh+JF9wPy8/cyq6wRFhUT2S1b9lsiZHVhU5hfvGArdKLZTF0Ne29lpumR6TsaXZ0pcicZb0PTidzs+7rkXiPo9MDLbc2uTZQ0IPsmRfmxJCQDGsi2O85ccuWpMdkH6fINCiA0OP8KNNCpU6ibMW+2l3os7rDYvVzA7rw7XSJGxME4hzSFapcKIs55tmQJc63HUWRHn/EdvXpP5Y9P57NRa4cHLpUqGki8WE0f8MJLGoVgAHkExFIZFZA== 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 TY0PR04MB6268.apcprd04.prod.outlook.com (2603:1096:400:266::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.27; Wed, 30 Oct 2024 06:12:12 +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.8093.024; Wed, 30 Oct 2024 06:12:12 +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 v1 3/6] exfat: move exfat_chain_set() out of __exfat_resolve_path() Thread-Topic: [PATCH v1 3/6] exfat: move exfat_chain_set() out of __exfat_resolve_path() Thread-Index: AdsFxBC7bzWlHqpxQd6l0nhCVt5kHgkzZmJg Date: Wed, 30 Oct 2024 06:12:12 +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_|TY0PR04MB6268:EE_ x-ms-office365-filtering-correlation-id: 84eb2a53-edf3-4883-610f-08dcf8a9cb74 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?G4tZ8E4Y1Ev6JPzB0wc4JKnjaNlYN3Q?= =?utf-8?q?mjhE4hPagUNqxBPX4OhlDeod1ud32Fkta/ZwkEcpt+ViYSQrhbij1AIJuODicjQt4?= =?utf-8?q?7M6sAsYxmyxivvpqMlVIbIo9xJ80DwaXIbUx28I6OzGS4m4oCSacidf9PbggTmiPX?= =?utf-8?q?HwiFaScBIyd1qVUlhCjr8dSA6KwrkaN1Mj5tm4w8znAwtL5me2XCdC4kX67+Xb+wH?= =?utf-8?q?33WTCg3yQwLbwsfIOaqRqiggopl/G5ck7cViV2YttMoKKv8ZmcS3V6UgSLk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?= =?utf-8?q?SKL9ZKH8TAkqOlk1VsK0T3D3+a0umGVCanOWv2oBV3Q5fS6WDeTuy63E1zGFD8gLU?= =?utf-8?q?DvsGaNFbtMBmktb2q143ADaizTWXPlmT5izkI0t4tqfIQNrxVuhwCuaM9mGzeghUJ?= =?utf-8?q?pxrMvogH4r9GU1ZmZvPn+l3XJmECbreoGICy4cpJk37qsC580jqpZT7s=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?e/tw114EliULUWCL1b1aG+coy/2N?= =?utf-8?q?dT+bTRzRZqKoqmLl1yb30n9/tummObHNUfjUjEOSAxRPjcN0VPOyMgCl+x3OBB7u3?= =?utf-8?q?nck0K+jxAu898a7qwe0gwCe9PTwbPim+M5Qsdlqo7qWB18V9AvhX5DpK2/9VN1fXV?= =?utf-8?q?8SvT+EcPSMs0M2Pzb3toeSwreqE3ZcE8/ell2NUoBWNMb8Ld1rlD0ANq90ajURdrs?= =?utf-8?q?ItoglnK6bYpROkI8mIrYkFWaQC1WQVPhHTXnyQmZZmn1IcVvC3xwJDYZ126Er7ZK5?= =?utf-8?q?TPJjZOvolSwnSfDZnd4z//ToQbtRVBJLdugOJ8iN+JiFqokbSX7cboZ8h4d+tIBl4?= =?utf-8?q?R7mAlmwfhtjy1ob4m2pktqIX6DmQAjOZbVN+xa/ZtJInlazDk6QcZ2fAlW3IFqD18?= =?utf-8?q?yw0kaPuK4zi4114nW7F0C5okHC/X9V1RJ6SZxAe/PseUGmRGQtxXy5xCP1ojpagFS?= =?utf-8?q?xt67pFwaIJtQT8NI8foHJmmMFYlVRshC2yJ8IgObbMheRxIncmzmf2S5zIWdRU7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utf-8?q?gZecn+fATWA77xolZsVSYHIrUl3FM5Ztyv9qZMQx+E+Z+ftGL+O9rQC+JnKmj3UE6?= =?utf-8?q?VodJhV/xRfLRZ7inJBX35kq9MiZwlaRL1Vizg4O2wkwFa0bxBNvGSKk+Kra3FZ9pB?= =?utf-8?q?3KxL5AQGGmYW?= 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: E3t2HDmX3NJFBUyxJDBcI3ZG8qsJbRqkr9LboLZ2faTsYDtvuOAsvFv3UO4APihVSCXZlVMoP0LLtEZTcHFnsle1lEwK3ZZJWqn/8rlV9r7ogz37Q4qUkwDU/jcaGbwLbk7+TksqbENVOnV5mTzAEKxaiwsnsQ9d01Y73YSyoMm/bQIPB1qvr3rWkdLzpVvtYpcyTUovxv6PioAj8vIsd/ikos4kx3GOR6ZmZfstE3yjrVxi6CPtEm+xaUmFYPgxapabpUBkdg/xEtVrXWIDr8I/Bjf3yJNGCwhApoC3SDasglPvL5D4tNDVzP/MAmRnGJBesATNU5+imwN3aSFLfvIiNQ3M246IuiefAAXpqdk0VHtjRD6mIJPj2aCB5+QAHDx2J2g38zTfBb83Ej+alw9Iagq/OymeZgzzZc8mxQ4alHD/nIhKxPhMy+tfsnpyQOPVlcweDXw1EM7keEgM9t/VrF3uof9D6mfnQSoHOB+eDIr04BBqj/sYsIg9XhNCnqX9QnvXDHpTca5NM60c7qEnbXc1VNp0Yew5urF4rpq3SNzSjhjVhtJdPyeiX1DLukbmUz69xXf0MogQnzFNzZwkUFN9EuCYrWro+dObPVO9Kry4g8EAhL9PCew6L6rG 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: 84eb2a53-edf3-4883-610f-08dcf8a9cb74 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Oct 2024 06:12:12.6287 (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: oy8NgNnIlzneQ7F343+tT/i4OX80BrfKclqDBdIZb5o4NRESvfhACIp05OVs7pnO7ZrvrXo2QH4BzqcRLsyeCg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY0PR04MB6268 X-Proofpoint-ORIG-GUID: 2tRcmSBz27EvuzWlMOi5huVOqRKeFjtx X-Proofpoint-GUID: 2tRcmSBz27EvuzWlMOi5huVOqRKeFjtx X-Sony-Outbound-GUID: 2tRcmSBz27EvuzWlMOi5huVOqRKeFjtx X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-30_03,2024-10-29_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 | 53 ++++++++++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c index 050a936efbcb..90066d8ec9a0 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; @@ -976,7 +974,7 @@ static int exfat_rmdir(struct inode *dir, struct dentry *dentry) return err; } -static int exfat_rename_file(struct inode *inode, struct exfat_chain *p_dir, +static int exfat_rename_file(struct inode *inode, struct exfat_uni_name *p_uniname, struct exfat_inode_info *ei) { int ret, num_new_entries; @@ -1002,8 +1000,9 @@ static int exfat_rename_file(struct inode *inode, struct exfat_chain *p_dir, if (old_es.num_entries < num_new_entries) { int newentry; + struct exfat_chain dir; - newentry = exfat_find_empty_entry(inode, p_dir, num_new_entries, + newentry = exfat_find_empty_entry(inode, &dir, num_new_entries, &new_es); if (newentry < 0) { ret = newentry; /* -EIO or -ENOSPC */ @@ -1028,7 +1027,7 @@ static int exfat_rename_file(struct inode *inode, struct exfat_chain *p_dir, goto put_old_es; exfat_remove_entries(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) { @@ -1046,12 +1045,13 @@ static int exfat_rename_file(struct inode *inode, struct exfat_chain *p_dir, return ret; } -static int exfat_move_file(struct inode *inode, struct exfat_chain *p_newdir, +static int exfat_move_file(struct inode *inode, 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) @@ -1061,7 +1061,7 @@ static int exfat_move_file(struct inode *inode, struct exfat_chain *p_newdir, if (ret) return -EIO; - newentry = exfat_find_empty_entry(inode, p_newdir, num_new_entries, + newentry = exfat_find_empty_entry(inode, &newdir, num_new_entries, &new_es); if (newentry < 0) { ret = newentry; /* -EIO or -ENOSPC */ @@ -1083,9 +1083,7 @@ static int exfat_move_file(struct inode *inode, struct exfat_chain *p_newdir, exfat_init_ext_entry(&new_es, num_new_entries, p_uniname); exfat_remove_entries(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(inode)); @@ -1106,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); @@ -1150,18 +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;