From patchwork Mon Mar 18 05:22:03 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: 13594978 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 5D7AD21345 for ; Mon, 18 Mar 2024 05:22:16 +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=1710739339; cv=fail; b=WVmlajT8TfZ2hHOn6E3hPpOXKj6Q5DmdvRFOyaQ+S3UKmzicF8YHeSlMVLGowpnzpKYdCMQBmuuiGtonId7jz8lk3Y1kQQfUw/Esane+YjDZAGlYVNIgxhSYUgW7/GsAqu7q847seE4ynRV8SltH1txBq2tRRrAvXegKx5FWFYQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710739339; c=relaxed/simple; bh=UJuS2nJ7FyYC+Nja/UCSoqDNYqSpbvt7NR6UfoR8eLI=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=mfSBnTz1jJMHhgKKws9W51rzpuuywpjQW1IK+f5/i59KsjNKDfJOiMbP7veIc6ody7OB5FoQQLt1E3+zoM7dCkXEi9ANd7u/v2KQWOn/p+vr/k6F8w0m8pEwpggIYkj58n4vy98ftoYcVnN++XgWTWfb4PSdgHIRWLbRFuPT0/k= 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=QnjxGIiY; 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="QnjxGIiY" Received: from pps.filterd (m0209322.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 42I4i96q027621; Mon, 18 Mar 2024 05:22:07 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=UJuS2nJ7FyYC+Nja/UCSoqDNYqSpbvt7NR6UfoR8eLI=; b=QnjxGIiYqEGvVl2RAau/BNhaRVokjigvN2cPeCwZm9Y/EOidBadQ1rNyZuzO7zPiUuje c+Kb++isXjXZV9vjE9zQnzpujZsd4s3X8fVmUOF1y58PMHSlN599BUmKqTEpiU4WbzOc kPSp4hSg/82aLOg3a3y7AMETvcNYILkvn5teCrHkj6VoOf4TT+pW2Cb7PAW+8HUh5rWQ YP7XkEu6zeu6i3WJ4l+ONk5MYHMobl7H1tnIze+rCQuwcBskuJ7a3pyc4faUNe7Pt0g2 L7A4IE0kmtFkpLZ6+N22XAZSYoQKXoDCaZlKCAc1IeoFbIXxReC+rBhk6clLcxXhnom8 NA== Received: from apc01-psa-obe.outbound.protection.outlook.com (mail-psaapc01lp2041.outbound.protection.outlook.com [104.47.26.41]) by mx08-001d1705.pphosted.com (PPS) with ESMTPS id 3ww2769h1q-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Mar 2024 05:22:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fWxt3jbQlvoLRDMYMO0zbCDe7Vt6h+mb4KFUqgn0K+VRox8tClInKSum/zpMdqSeUsUnfML7xUfpMkwiaAcaeDAv23Xr+yFD/fgtnY5LEMteuvSLQ6H1g128G7t+ub39srFjXdRvmxAq4CPF8S2nJrY7HVwQyVLP0wcFFccAVG+VaapvSLZaeaG8AhJIwV3dk/iZIrKQVQQbF5GuZQ74kjFsZqp/jbdgLFeqdZ/Ukzs2HpXPpvhvjd7f80PsKHV5TOaiTz7YzBQlhptu+kkQfU2XinaRvca2wEce7gCT2dC1S9JSZ6jQLRvXarzSstVC91RtoCYKMcfmz6zzCW+BQQ== 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=UJuS2nJ7FyYC+Nja/UCSoqDNYqSpbvt7NR6UfoR8eLI=; b=ZoP/+uK8iUuoljw7XWd24V45+S79h0dXgvL6+dv0qx5UislDHP+pvqnbYgot75CT9yNk/1dU0kJ81aPnU5yn6S3i7qSKOIeaOFjh4RT+dTQuR8xn3vCDRcrGdCqZG59+I+OXL41iLI1aFLpxf4RIqIcXTXEhkakPMZ58AOgyqrF2wGdXd3S42v1nTzL2Eae8MgDKB4U3BstWH7y2BKPq3VCkISGe02WwsALhWBZhw/0aivUtecRfhuOX65dbJhntC3c5jQ4kT5jBT0R0tSulB/yo1FrslhKQlXo0xvfKbDp0Eye3unoCga0NnWqCbRn5OLSIxO+LXax2VQZJwBO4PA== 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 SI2PR04MB5895.apcprd04.prod.outlook.com (2603:1096:4:1eb::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.26; Mon, 18 Mar 2024 05:22:04 +0000 Received: from PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::7414:91e1:bb61:1c8d]) by PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::7414:91e1:bb61:1c8d%7]) with mapi id 15.20.7386.022; Mon, 18 Mar 2024 05:22:03 +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 v4 06/10] exfat: convert exfat_init_ext_entry() to use dentry cache Thread-Topic: [PATCH v4 06/10] exfat: convert exfat_init_ext_entry() to use dentry cache Thread-Index: AdiopzuU0qp5uINBQASO58AHYsMdXnQS3oyA Date: Mon, 18 Mar 2024 05:22:03 +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_|SI2PR04MB5895:EE_ x-ms-office365-filtering-correlation-id: be62b945-aff1-43f0-9cd4-08dc470b58c0 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: AHfj0ddo0m5Ovy4yEjBBgs9XdbvWvFurDQbjwI0SW1GyjonyOhUcBEmIQsaEsXuooFlAAhLOWaMLmkMCSUFOZ6pFgVjRkrOIiUKMNUb3ceIAF4AzeaAdYEHmv09G7IVxYcyOhdi944rNCexh3uDUZSteFtEkTT/12+y9stYB49QBxDj0gSb5C+GtJAC4vYxzQ9CV+30PXBpYQ4sL93ZCz2uDMz3qihdzgPqsAqXFQYkeIJVcoXXFhr7ywVUcu+jUn0au3ymF8SH7xShRkkZPgopQCE5sVnRjKgDwWYUQLCwPAsUBiSEDeaLTHrFtZvvZzK4uNuUDh7mewaCJhdij8jU2Q/DY+RuyFDwkPm3MUePfnpWBTVDRIhPZyYnQmnM4lj2ge7chsbM8cvvlKeUh99wu7C5UjoCdDCJTr1gq3JnkNx4O2iodYWwby5LDV4dpoSnLM5sXCsr00uAejRZQ8NzcLYAkLfgHFSrQlPUAP4YaMjCS7sRKEalxnQT0osd6t9ogb7RtlGKcRBw8Ofb+1GolVRk16tt6strRKDTOksZAknv6sTaVCidwp4JSSUS0XRhm8ej2TPwQtEdm9/Wa3lu0g4GHa3OS/ZmoiDI7o1eSk+IEyuU39Wa7kxahR/eHigdoZToSnmbknVfd/mbK74w+B86g3JwPovOlvlwYBi4SNrzgL2Y0ZB7Hr0cT9bQsNvXkUEzwzlgt5rwIomYeVg== 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:(13230031)(376005)(366007)(1800799015)(38070700009);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?6wejKt5nlwUD1ovj4f6A9NNLOrRD?= =?utf-8?q?EcTey+q+GwwqevFwqPzJQByvn3cbQZ+ALqpeu8YVZYKoRWaVTFsZ8Byjr276q7vN8?= =?utf-8?q?zBN6Fxzv+NkLVN2UgIADKZqkcfWFO3TCy9Z3VxjF5ImYbh94/ZWzTJU1dOX/VfDEI?= =?utf-8?q?nhpE2XSdfIMlt3tDgLXJE6aLgy0t9ig2CqZIsBq2fyN4BXzJ1fo5TpKK6WCDDrNnD?= =?utf-8?q?tMBjBNUNmWp7rssOa0EK1nZGdP9oqwmvhqIsd86sIk8xA895hpEIgz9sF80Asj/Z5?= =?utf-8?q?DxcnRFqcPIRgO8u6zRx5RPCyojwqqgIdXSwxXoauWAPJy74yfiFIGiArwkfw/j955?= =?utf-8?q?NqsnBKaO2zXKoQtoJAXPTK83BYURpa5epm0iMdVz/bKPURuAQZ4i0AqhMmlIeWUry?= =?utf-8?q?c8Yuymj+STDofeFw/2wHLRkp2ui0vharYnRWL9WcwECJ7RsTwDV4gGbEGj80Ksf9f?= =?utf-8?q?6TL9gcqcqDqJYU2Ps1KB5laHp+lK59PtbowwybwJmUc5IxWowsiVkYVNmXKgZCR4r?= =?utf-8?q?qZRdHf+tPjbaJpvxfNotnW961RRr60BUi7DpmceCM2Jx3MlSFnRo4FKnMH4cMQoZB?= =?utf-8?q?iIwmPhDOIICxNOxxmTdSHfD1CvrOX2QZFpIlvSJSzv1sRV7FqFdUG29c3ztzjGVxm?= =?utf-8?q?ZMNDPWb8MBj+5VZ6bVHjNoGP/tIFliZcYcmaHipRNKvY1WrXNAaBI+k6v8N1wB4Le?= =?utf-8?q?KMCJcyhokbf3IwU3i3Jd7nVx3xUczNbtOCj4fqD0r8T9Jk2REFbp96c6i4h45bt8D?= =?utf-8?q?Tdvd9blIUEsPvRFiNmmQaZvjphRwFOi3B4XlkOdBs3J0mH8E0k28Ag+FFyC67pzdD?= =?utf-8?q?LtuwkP8NoU9TP0sP46lFGRY2EPGO5oZCN9kCVvgSFPpoatOoR2Dr9WzvkLZMJ0Nk8?= =?utf-8?q?e4N0ioYR116xdCbQtYRme3Obgg0JIBU+g/J5o/B9T0foNbekOxY/ajVQnGrZ1ouOC?= =?utf-8?q?uM3A7oXhnWyhniSaZ8EVlTU7al3WUvuBVCNBroFUrAQySv6n2kptnS2933nbgoZsr?= =?utf-8?q?q533J3GiATK9umcDbsUkRcf4Wj6CA6Ri0YhkRNYKRkAxKgTY5/QmGJN/JoD6REeSn?= =?utf-8?q?+/flR5AEokXXJDJJuKltKteo0MmplWKzCnkT9Xwn3rTCqOnt79ZgVCPOZS55mkqR7?= =?utf-8?q?UsJn/grGs5CVXJoOnvqCLPRhZ1Zzd1b5bzqZpNLtx9AqNp4lQki8mu09C1P2/vqMB?= =?utf-8?q?2LvqFvkPNjiIKUeLjs4+rfc0GMvmMuCBXUGWlQ2Esf1wLcxGO7KlMawc7XqszKm5E?= =?utf-8?q?P2MEl61HZIftv2XxTkQcSGGwAtujPJkcJu5fzwyE2+r+pUmUcnEHW2IKq+QPzYZYw?= =?utf-8?q?Hn+4a1TfRiIibo5WHK5YsjdXRkL07bvMt9mkah+kR/veYy7Y0HOsobfHyHEPaaqxg?= =?utf-8?q?KSw6p/bCTCxdmHgICI2ybRB7QyjA4HcM00ldDnXids/ZEdJsboRM8GG+CGMNABNLq?= =?utf-8?q?rhdTPpwcWazbeR0zq8KQeq4IrRwNRXG1mUW/xz5qJ8CFgiqAnxkRCwhNNDpAtLFYe?= =?utf-8?q?4n2qz+ctrAjx?= 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: wSjjEqtyZIDmTpBIrG8H15VPr+vnGZga6ioYJ2ox+/Jq7RZyOaprfnQZ31zT3f6noEhqkR8tGZF3DMDmMnwaALAP0/fz0kGYp0FHplIsOTeNnzZ0UZPmy1J3X+TnZkABzOILfBRqZsT4UgDG84GtoPwVSsI4Zclrp9jaB1fX5T/NQoCKXtX7y4N/4GacJvTATSpzqjOZzCKx/L33eKZ57DMl968t6b62Ta4uUMhskGoSNcq0uO69/55IxiJU29vh4yZk9uPjOZEqUezS0n5PxAz2bfKTLj/dB1e7jahM2fghgq1B963/r3MeldDieJL1Opmvn68A0+7aHxJ0idtyNYn1KjM/3+RJwphwoaHroN1iRxe6+wNe3FkZMxNiFc1rY+p2wYbQhHdH5kKipIdPhobLOeZEQbjU72ojJEbZLRQ0yqeYAN5BT8bn9FDdZKJi01PXJ4RIpT4dv0EalE6neKLit1ro/+ERpRcu8p96yDv2xx5BW5a+XzJRSdiuQMKVNZGKp3vvm2Na2EB3+eMKE1AJ8f6kleQ1/T4axhRMyh127507cxMmYWwcdbkfSWmckrw/QEM8RnBnaklmsSe5xUXWZbq5Y5znkhfeBxGSP/vTZVoUDmqdHd6LgsUN8kUo 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: be62b945-aff1-43f0-9cd4-08dc470b58c0 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Mar 2024 05:22:03.8405 (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: YqKLDOztSKoSJTZkhI1Z8Oa8uPvNkuz4GK+oipsJB8jv0+cQabfcUXZFz1WRiOTgRG4hXMVwYCrRgvlt98eu1w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SI2PR04MB5895 X-Proofpoint-GUID: sn3S5G9E-MEaNbu19V2Y4TBCQaZL2K5n X-Proofpoint-ORIG-GUID: sn3S5G9E-MEaNbu19V2Y4TBCQaZL2K5n X-Sony-Outbound-GUID: sn3S5G9E-MEaNbu19V2Y4TBCQaZL2K5n 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-17_12,2024-03-15_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 Reviewed-by: Sungjong Seo Signed-off-by: Namjae Jeon --- 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 0008d4681d29..df39e245671d 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 83ae84a657cd..1cc91476b9c5 100644 --- a/fs/exfat/exfat_fs.h +++ b/fs/exfat/exfat_fs.h @@ -483,8 +483,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: