From patchwork Mon Mar 11 04:25: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: 13588284 Received: from mx08-001d1705.pphosted.com (mx08-001d1705.pphosted.com [185.183.30.70]) (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 A6B5D1428F for ; Mon, 11 Mar 2024 04:25:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=185.183.30.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710131134; cv=fail; b=EN4mfnvYqUgZFClj5A8+Gh9ClVrDNyEDhvce4eJu5GaO+OuX58kxWyA5P9tlap7dVkbHbRR8EV2BeyhQgKRWE9RtwN5bRvLF8ugbaul3Xr3iJm486k5+Bw77m7HXkfnZHXUWH5ark/FUj4/ZqQoAJXK7bB/ekxtijO2V/TlgrUc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710131134; c=relaxed/simple; bh=4F/hLbgcBh1HmZ58e9N6Yxd43qAtm8Z1VIaHOpmcZxo=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=CS1M8gX8guu8GKaeizOiveWRwMNqR8HabB6XPx3/EOfWSW6lfxHdeQFUW5ZJsB7iW4iAw0C+BQs+tGZ9frBkCbqBDCxJh7SkF+6yF2RgLABAREQlargwkUdluSRPh2YS6DCi2JbE+50hDtYczO4DiWpW/IOQ26qxEUIe8exoZCM= 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=ip5A8F5s; arc=fail smtp.client-ip=185.183.30.70 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="ip5A8F5s" Received: from pps.filterd (m0209318.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 42ANjEgR021524; Mon, 11 Mar 2024 04:25:23 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sony.com; h=from : to : cc : subject : date : message-id : mime-version : content-type : content-transfer-encoding; s=S1; bh=4F/hLbgcBh1HmZ58e9N6Yxd43qAtm8Z1VIaHOpmcZxo=; b=ip5A8F5spxeifu2AlW3qYODd46Yfdd2XSccGDxyWPq6kpEvmtDfA/1O1By8qgnilN33C mfn/hSY1D51X2wE20QJ3GkOoWn8EuMh3VW3XET6a7X0Iz8v12M1WlUSWhRYaqF0qrbIp 1XxVb8A6n7eRasydcW2GwkijLlboy2xvhpc27XIlbsYldL5HlWsrldgljuS52buk5ioB iRaxnedrDOReI01K5qBXXh2A+oBImyzZn6PP6N6yPILrLABUyS1O0mzsfCsS7tvY3iH1 luq6pOuW5S3mMjw9KcDYkfEF1JAmWjbTJVe+6Lr7BKiwREzBU6DR8T/gmPtFnSs4T/Pq hw== Received: from apc01-tyz-obe.outbound.protection.outlook.com (mail-tyzapc01lp2041.outbound.protection.outlook.com [104.47.110.41]) by mx08-001d1705.pphosted.com (PPS) with ESMTPS id 3wreb6sdbb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 11 Mar 2024 04:25:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CtAKJlx0P4rnCMOQzaDsmzPUQOzG3+iZWRKidiopY+hVLRVRawqOB7XGYYlVlX3jlHzE9BxWcuU8KTVkSBWBIfz3rdFGmxethxmMhZWEXlhI2Mb7eFzLv5wwEvBMv5lLbsEERZ77Mw5J2DHtndlswYEcn2ULOYqyOrTeP2Z/uHEd4G/UWvkinie4DzTJhwW5NNuYC1riGB2vskvUVYg0zbPiYgWxN5UNBv6GojBUQM8slYHs9cQYPc0cSKcFfbbZ+F3L5Qh73zBr164iO9gZv+Qnm9dkuJEp6ueXrnC9IWOY2FziNs0q5mGN7JYUBWaMHBAZsIwQ0O8OJDBKRyrrCA== 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=4F/hLbgcBh1HmZ58e9N6Yxd43qAtm8Z1VIaHOpmcZxo=; b=IOWcMNEFx3aVFxeqcNEFGmFb/8s895unHp3DFqJoqWvnTMSx5P4FahaBAi9jgz82cQCVMKWeKJ/KWxyZ+xA/tPyh7fqtENGPVlhyBUDWaa4fzRDvOyoWuZnQ0GJIztbrWiE8N0YFUZTBwL7Ssw5eicxzrGjRziU6Pngkyz9d47vmItBPQO4sRS6nnEXu+Be28TPq+vY/SGsxf+16PaCgX8/I7g0olG5e/XtsK4hF0bMixoAoSCZC56aQ+LDhiHu4CPoLdNJ4Lvdl1kPmKvn5WAjg0TsrkbteZDZg51eCelFcve0kiMKuWj5lpmef7gjZYsSpg/brZZ5Tzd3VnwNTHw== 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 TY0PR04MB6328.apcprd04.prod.outlook.com (2603:1096:400:279::9) by TYZPR04MB6635.apcprd04.prod.outlook.com (2603:1096:400:33f::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.28; Mon, 11 Mar 2024 04:25:12 +0000 Received: from TY0PR04MB6328.apcprd04.prod.outlook.com ([fe80::c5b0:d335:658e:20bd]) by TY0PR04MB6328.apcprd04.prod.outlook.com ([fe80::c5b0:d335:658e:20bd%7]) with mapi id 15.20.7362.031; Mon, 11 Mar 2024 04:25:12 +0000 From: "Yuezhang.Mo@sony.com" To: "linkinjeon@kernel.org" , "sj1557.seo@samsung.com" CC: "linux-fsdevel@vger.kernel.org" , "Andy.Wu@sony.com" , "Wataru.Aoyama@sony.com" Subject: [PATCH v3 06/10] exfat: convert exfat_init_ext_entry() to use dentry cache Thread-Topic: [PATCH v3 06/10] exfat: convert exfat_init_ext_entry() to use dentry cache Thread-Index: AdiopzuULnFJWabWSJ2OyIjpu84yEXKw2X9g Date: Mon, 11 Mar 2024 04:25:12 +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: TY0PR04MB6328:EE_|TYZPR04MB6635:EE_ x-ms-office365-filtering-correlation-id: aed51585-8651-4e12-ad38-08dc41833e87 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: dKber1/Kdnea26YMO6e9l2frFe7wDxun32TINN49FCN9vzsxUPbhx/DdaGFQEfrh+dsE/FS2D4r9dRx8c94WKO93W2zBPAKjBrJPRLV34CIIRs2HebU8pKypQuPwjwVwvdogQ9+In7AQoOAu57BmiiKSfvSUEte0KVZxiDcienRpW811IzNysni0yAXE78amKyHFQVKuSRlNgLfIpoiLkPJ4aovFOK5lWp5O/b2GdrOh+4s7JQEIdXYNII6jtSZCAKfH2lRI+mAYXxEumaWJo61lOSAEBjpMFbiVTmZRvUVj2xrdmMnLeIo0MwbngLNE+q0OUYohVbEiB8sqY7sKNQzoNcDo2L18aTea0a1UrqLPLofAlsmt2xWIiHa86DsX/SP8Ml6S2oZ6WlEkvR8/2pnRzByoVenLLAKH/mlQ4urdh3+02Q1sxgHaKd1K3rWohwepiTT6TuJkvJLPyhxrHNDMszsAVf4wHlwJjCTV9E0zH1wg+QrhCxgMKHlvBjSRIAGhXIsZaM1WL82Hmw4/MKnHUpQqugs6CFx56PKhCQgMSWpGCyvQadCKi+CtDCyZ4bPv3C9STJRjiwanmAb8O1KPCtTwp1M7uCsdFnalw7Byzkmf/KHJF12ohE6qPVzcZCKoTfdx/DWtSdUp6xgqxXrzKqsypDghsvrmdmZdB7MWmmItM4HxUjfNvhZfN1xrVy3zZs4hvWMNoqT5GBUGCg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:zh-cn;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:TY0PR04MB6328.apcprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(1800799015)(38070700009);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?mL+9k6kMDnnB8QczZ7X8UUdBiE7r?= =?utf-8?q?SEqheopF/odJfma68nTX0x5our4FHWg9/raMwj3c/2VBuICu8uMWPELItSaTLFrbU?= =?utf-8?q?bTRFcMTgIVmsikh1C9FOf2ikT1wjxNvW5JekzJgMwGg3l7fdj6aNUpMCW9eU0v9Et?= =?utf-8?q?TOISFtsxuLYCWQwoncKROw7Gi+3Pdnx+rPIHFXsHo6A9GrC90cIn7LzbveyHUJO+3?= =?utf-8?q?9GRBpGOl4w+XrNjb9KA3RJR5NhBtxrRwXMHdDLeob3JCP9fZuym1ht5Zc7hUoOMUF?= =?utf-8?q?w572mNhf7FsluYVY3XeVbRqCKAlmWBvV4qjgzBhsUUCG7Jt/zFVzigUMR2wnG5eaY?= =?utf-8?q?e9mNeNLDxUmK4dVX9hWnZY8kitPj/0abl/itouXhaJaAGECjL4oOGHNUFGAIzOEIm?= =?utf-8?q?jBlO//D9+SP/mkwRPClisR4vdP9QEfeOjK2/En9B+/UCjHDoMs/+MMgl7uiGcPwMT?= =?utf-8?q?nxjxR7PnHCODnEjkOZmQ3wAHyLjNm87O1NsQOLPoLTVr+tyaWcsZOmKKe8nthMmoa?= =?utf-8?q?gUr3tJf4EKfBPwDhXt5uejmbotIIJKAqJFozfZc3ks7s1Hoq5TnZPoijHJoJpxLs5?= =?utf-8?q?UA005sh0tADJHYL3PUWQnzKLIBeLxqF4Y3DcP7tCElX0DsEJXKlA2UpDXIi5nWObF?= =?utf-8?q?nhMdIk9I0uMEFneUo8guFRXH9vnmvUz3qQVlULyc3b24iDFiQPB4mdxICGVehd3bG?= =?utf-8?q?oQ6gEgzsnk+NmxSe6SBx0EzY+mEkcCrN5PXEcUwl3/0RNwHCKggFXO4V8soaTWbtj?= =?utf-8?q?0uoKAUVnqryP3rd0X+IBuynULK+rq7EVbWUPpEfQaU1hrcXYdpq5JDaaLKDZTQdOs?= =?utf-8?q?nwrlU+DrsBag+2X++m1j91Iane6jcbTPwa5uc5S6O5soAoLpzbL+QHzemGdtRrKEw?= =?utf-8?q?jE8xg3v44nsgVavskq9z7iRShjbGtSPsMp9iYM9rjQzX/ZkkSKz/G1oAW6HXegvJu?= =?utf-8?q?/AHI0oLQ0sc5u1E/4XmGVoej7i2JVSwejQnFINevC+CQQsx4EyZXoSGdcQNroyHEE?= =?utf-8?q?TNz2K6eDUCnnyEvk6D42lYBEvFgzb+YzvT62cxO2uDF9v3Ux0lwIETLXmM9CtlTR/?= =?utf-8?q?EDUbYnqL60yd91lcHdde+ysnEGlEtX4cBX+tqajVVtyae400cmDRZLWVe0ZmBg4/Q?= =?utf-8?q?+pcL5v7nFXBIdz+tmSK6siWkWKMGaN0VhhV/B0/1BrrCT0PaT3GcKt1lSQMy7hihI?= =?utf-8?q?G7GlkXFswHrCsK6trDPvLrs4eeG+O4gTYXiyD7KAHIyyVcg3iylGcEZMIZ4S6nCTr?= =?utf-8?q?qpzhvUmBio9ZE+9s7VTw4Io8jvSDCBy21L2QUJIQGvyfHcpOIuqTNgtcGw3wOHSZG?= =?utf-8?q?eZQBAKO3jGwxJydbf7793k3BNxD5B8ODdu7Auhqt7ShdnXMKk7PdmOrFFbaeYo9Uf?= =?utf-8?q?JjA5zJsDIgngg72/VpLNuvggtokFfRGwMX+CAEnkV9Oh1rGknvNixgQEMdBRMAOYu?= =?utf-8?q?GFJHfOSpUYAhXp57pfNqdfjqZVfjSuuxSB15x7Ri+jEWAamTfO1d7yLb2zMKBvXya?= =?utf-8?q?DiVUD02e6cws?= 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: aoqwz+BOffT2Ht8SHxfoMUzUpydwiSfyVt49FIvuv0EWLC8CASg6YFsG1kZ4mpU8n/zwA7jTjS2CfoNFfrK4vZEtNjIUDm/KFIVZM1Curwp//zsynCH9MF2Ipm0Q63qV4XI8XinfIw0eFgVkoRgEvcpvbADE220ujk1tfpGxe29sNaMdPyxo8FL5A2CruUqPQVfVtgzb411b3FuaVVN/5ZNVIVvcy+SzGiI7c2F56bRBU5nOJRlhpJgdf7PB6x6XNNPV8FziffLHGKxmT5sI8Iu2ON4TrySn7boAlKNuQU6+bQIuK1ES1ZjZ+/3TY+kaBcWXFRRauoDDTW2qKY84ooOu0SMmPNNgohIV4J1Z0IQhH+rZT75SS3b5wO3JYkPSJaFR8gCZ6f80JJmBICGXfW5HLJ+dSI4K5BeO5vADOgkDVSeC94OS0uTWA34jWyLRJkbXtKJRxdx9iiW9HgTRg4OqhGmNVpMCYHjKEGG3Y+/N27v2eSrM+YsZ4NlNPYmQr2kiYtYG7nSf53/VbEijxWta9rTP2d4dq/CPUzx5rvxU4tL8vFPA5kCKLU6QeFhQhNK8+RDnf0NO1bXx49yK+Rkm4JyrrouiXYRzkkjwy1jgSC8z4OwoY0SVNZ2EzVir X-OriginatorOrg: sony.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: TY0PR04MB6328.apcprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: aed51585-8651-4e12-ad38-08dc41833e87 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Mar 2024 04:25:12.5063 (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: ZQCvjMmsjwc5CiL6Oa04sSJIVHWGcc3U2WQjA07snWxK/abwgB5lMVJcAwWddCQMUhEHIqBkJnKKk5WiqgwsYw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR04MB6635 X-Proofpoint-GUID: ekz3J8BXdE8SFhO9-QkPJ-U2nAuEPeRP X-Proofpoint-ORIG-GUID: ekz3J8BXdE8SFhO9-QkPJ-U2nAuEPeRP X-Sony-Outbound-GUID: ekz3J8BXdE8SFhO9-QkPJ-U2nAuEPeRP X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-11_01,2024-03-06_01,2023-05-22_02 Before this conversion, in exfat_init_ext_entry(), to init the dentries in a dentry set, the sync times is equals the dentry number if 'dirsync' or 'sync' is enabled. That affects not only performance but also device life. After this conversion, only needs to be synchronized once if 'dirsync' or 'sync' is enabled. Signed-off-by: Yuezhang Mo Reviewed-by: Andy Wu Reviewed-by: Aoyama Wataru --- fs/exfat/dir.c | 33 +++++--------------- fs/exfat/exfat_fs.h | 4 +-- fs/exfat/namei.c | 73 +++++++++++++++------------------------------ 3 files changed, 33 insertions(+), 77 deletions(-) diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c index 85a566c23811..d43dc5f0d375 100644 --- a/fs/exfat/dir.c +++ b/fs/exfat/dir.c @@ -532,46 +532,27 @@ static void exfat_free_benign_secondary_clusters(struct inode *inode, exfat_free_cluster(inode, &dir); } -int exfat_init_ext_entry(struct inode *inode, struct exfat_chain *p_dir, - int entry, int num_entries, struct exfat_uni_name *p_uniname) +void exfat_init_ext_entry(struct exfat_entry_set_cache *es, int num_entries, + struct exfat_uni_name *p_uniname) { - struct super_block *sb = inode->i_sb; int i; unsigned short *uniname = p_uniname->name; struct exfat_dentry *ep; - struct buffer_head *bh; - int sync = IS_DIRSYNC(inode); - - ep = exfat_get_dentry(sb, p_dir, entry, &bh); - if (!ep) - return -EIO; + ep = exfat_get_dentry_cached(es, ES_IDX_FILE); ep->dentry.file.num_ext = (unsigned char)(num_entries - 1); - exfat_update_bh(bh, sync); - brelse(bh); - - ep = exfat_get_dentry(sb, p_dir, entry + 1, &bh); - if (!ep) - return -EIO; + ep = exfat_get_dentry_cached(es, ES_IDX_STREAM); ep->dentry.stream.name_len = p_uniname->name_len; ep->dentry.stream.name_hash = cpu_to_le16(p_uniname->name_hash); - exfat_update_bh(bh, sync); - brelse(bh); - - for (i = EXFAT_FIRST_CLUSTER; i < num_entries; i++) { - ep = exfat_get_dentry(sb, p_dir, entry + i, &bh); - if (!ep) - return -EIO; + for (i = ES_IDX_FIRST_FILENAME; i < num_entries; i++) { + ep = exfat_get_dentry_cached(es, i); exfat_init_name_entry(ep, uniname); - exfat_update_bh(bh, sync); - brelse(bh); uniname += EXFAT_FILE_NAME_LEN; } - exfat_update_dir_chksum(inode, p_dir, entry); - return 0; + exfat_update_dir_chksum_with_entry_set(es); } void exfat_remove_entries(struct inode *inode, struct exfat_entry_set_cache *es, diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h index a8271248f857..b43430aac69b 100644 --- a/fs/exfat/exfat_fs.h +++ b/fs/exfat/exfat_fs.h @@ -482,8 +482,8 @@ unsigned int exfat_get_entry_type(struct exfat_dentry *p_entry); void exfat_init_dir_entry(struct exfat_entry_set_cache *es, unsigned int type, unsigned int start_clu, unsigned long long size, struct timespec64 *ts); -int exfat_init_ext_entry(struct inode *inode, struct exfat_chain *p_dir, - int entry, int num_entries, struct exfat_uni_name *p_uniname); +void exfat_init_ext_entry(struct exfat_entry_set_cache *es, int num_entries, + struct exfat_uni_name *p_uniname); void exfat_remove_entries(struct inode *inode, struct exfat_entry_set_cache *es, int order); int exfat_update_dir_chksum(struct inode *inode, struct exfat_chain *p_dir, diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c index be6760297e8f..2c6df4f966f5 100644 --- a/fs/exfat/namei.c +++ b/fs/exfat/namei.c @@ -539,15 +539,12 @@ static int exfat_add_entry(struct inode *inode, const char *path, goto out; exfat_init_dir_entry(&es, type, start_clu, clu_size, &ts); + exfat_init_ext_entry(&es, num_entries, &uniname); ret = exfat_put_dentry_set(&es, IS_DIRSYNC(inode)); if (ret) goto out; - ret = exfat_init_ext_entry(inode, p_dir, dentry, num_entries, &uniname); - if (ret) - goto out; - info->dir = *p_dir; info->entry = dentry; info->flags = ALLOC_NO_FAT_CHAIN; @@ -1018,8 +1015,7 @@ static int exfat_rename_file(struct inode *inode, struct exfat_chain *p_dir, int ret, num_new_entries; struct exfat_dentry *epold, *epnew; struct super_block *sb = inode->i_sb; - struct buffer_head *new_bh; - struct exfat_entry_set_cache old_es; + struct exfat_entry_set_cache old_es, new_es; int sync = IS_DIRSYNC(inode); num_new_entries = exfat_calc_num_entries(p_uniname); @@ -1044,33 +1040,25 @@ static int exfat_rename_file(struct inode *inode, struct exfat_chain *p_dir, goto put_old_es; } - epnew = exfat_get_dentry(sb, p_dir, newentry, &new_bh); - if (!epnew) { - ret = -EIO; + ret = exfat_get_empty_dentry_set(&new_es, sb, p_dir, newentry, + num_new_entries); + if (ret) goto put_old_es; - } + epnew = exfat_get_dentry_cached(&new_es, ES_IDX_FILE); *epnew = *epold; if (exfat_get_entry_type(epnew) == TYPE_FILE) { epnew->dentry.file.attr |= cpu_to_le16(EXFAT_ATTR_ARCHIVE); ei->attr |= EXFAT_ATTR_ARCHIVE; } - exfat_update_bh(new_bh, sync); - brelse(new_bh); epold = exfat_get_dentry_cached(&old_es, ES_IDX_STREAM); - epnew = exfat_get_dentry(sb, p_dir, newentry + 1, &new_bh); - if (!epnew) { - ret = -EIO; - goto put_old_es; - } - + epnew = exfat_get_dentry_cached(&new_es, ES_IDX_STREAM); *epnew = *epold; - exfat_update_bh(new_bh, sync); - brelse(new_bh); - ret = exfat_init_ext_entry(inode, p_dir, newentry, - num_new_entries, p_uniname); + exfat_init_ext_entry(&new_es, num_new_entries, p_uniname); + + ret = exfat_put_dentry_set(&new_es, sync); if (ret) goto put_old_es; @@ -1084,11 +1072,7 @@ static int exfat_rename_file(struct inode *inode, struct exfat_chain *p_dir, } exfat_remove_entries(inode, &old_es, ES_IDX_FIRST_FILENAME + 1); - - ret = exfat_init_ext_entry(inode, p_dir, oldentry, - num_new_entries, p_uniname); - if (ret) - goto put_old_es; + exfat_init_ext_entry(&old_es, num_new_entries, p_uniname); } return exfat_put_dentry_set(&old_es, sync); @@ -1104,8 +1088,7 @@ static int exfat_move_file(struct inode *inode, struct exfat_chain *p_olddir, int ret, newentry, num_new_entries; struct exfat_dentry *epmov, *epnew; struct super_block *sb = inode->i_sb; - struct buffer_head *new_bh; - struct exfat_entry_set_cache mov_es; + struct exfat_entry_set_cache mov_es, new_es; num_new_entries = exfat_calc_num_entries(p_uniname); if (num_new_entries < 0) @@ -1120,43 +1103,35 @@ static int exfat_move_file(struct inode *inode, struct exfat_chain *p_olddir, if (ret) return -EIO; - epmov = exfat_get_dentry_cached(&mov_es, ES_IDX_FILE); - epnew = exfat_get_dentry(sb, p_newdir, newentry, &new_bh); - if (!epnew) { - ret = -EIO; + ret = exfat_get_empty_dentry_set(&new_es, sb, p_newdir, newentry, + num_new_entries); + if (ret) goto put_mov_es; - } + epmov = exfat_get_dentry_cached(&mov_es, ES_IDX_FILE); + epnew = exfat_get_dentry_cached(&new_es, ES_IDX_FILE); *epnew = *epmov; if (exfat_get_entry_type(epnew) == TYPE_FILE) { epnew->dentry.file.attr |= cpu_to_le16(EXFAT_ATTR_ARCHIVE); ei->attr |= EXFAT_ATTR_ARCHIVE; } - exfat_update_bh(new_bh, IS_DIRSYNC(inode)); - brelse(new_bh); epmov = exfat_get_dentry_cached(&mov_es, ES_IDX_STREAM); - epnew = exfat_get_dentry(sb, p_newdir, newentry + 1, &new_bh); - if (!epnew) { - ret = -EIO; - goto put_mov_es; - } - + epnew = exfat_get_dentry_cached(&new_es, ES_IDX_STREAM); *epnew = *epmov; - exfat_update_bh(new_bh, IS_DIRSYNC(inode)); - brelse(new_bh); - - ret = exfat_init_ext_entry(inode, p_newdir, newentry, num_new_entries, - p_uniname); - if (ret) - return ret; + 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->entry = newentry; + + ret = exfat_put_dentry_set(&new_es, IS_DIRSYNC(inode)); + if (ret) + goto put_mov_es; + return exfat_put_dentry_set(&mov_es, IS_DIRSYNC(inode)); put_mov_es: