From patchwork Thu Dec 28 06:59:47 2023 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: 13505643 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 A7A8063A8 for ; Thu, 28 Dec 2023 07:00:06 +0000 (UTC) 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="UOBjIGtQ" Received: from pps.filterd (m0209327.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3BS5Zm6E006154; Thu, 28 Dec 2023 06:59:54 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=e/fmn8Oc7Uk6aa9doDzB5jUc8QNrahgp1WZDl/3KkTg=; b=UOBjIGtQVSf1HCRxi2dk+qEgVkYMmTuuBbVoBWE3qOUP11QNBKUCdIbLgW7CBR6TJUSF Yfju58GvL8qRXRWk+Pvn66u4x9OVQAlOakN3tTfOGVNcj8kKlLx2pJRln2as1gB5udCu 4e0UJV4M+ka7eBl/+JvK5cuVCbmD9XTmWF6TZ36OFfh6Kj2CYtu0hezFPHE6ziSaxHH1 ZnP/4iJKNX24GCCBFmKT39WZuMbR/+5T58MHY59vUWCLbxFTM05gsASzFeHhdiZHSGZP gXXxQvQuC+pqUS2xfipk5elfQhxOtQtsvNtVRPlZj5f+H6VuJyijJoIMxYHG59Sg/Nof 4w== 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 3v5pe249dg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Dec 2023 06:59:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X9gmLlD6D+QXdDgY6GB29Xghhh2zBqJlIKwwC+xbdgJQrXaD9GOadK6ja4qqZtNGRxObBBt1sb3noJkr8zXY9WnjnVy9feRTSrD3QIJtUQKUTJLespPXI+0SgTfEmYwApyrK05lFdolX9HthCZ/TJa+lEjlZtOfiFPtA++l5bW60bg37pTLrLXYREH/srC3iZEfEqrz3+NNsiP2GtXVQLnLspwPEKnntaVRy0jjcK5g6TO4zyI7AjJrdk54jmTcq/KBVQPcfJhHYMLKYUl/1lGv8Wkjdi3LxuB6lle9SFlNut9Kt211ECOW4/I+bn+WR5HCbbDGa+dY1KRAkP5RoEg== 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=e/fmn8Oc7Uk6aa9doDzB5jUc8QNrahgp1WZDl/3KkTg=; b=YIFejYuTtZzR1mp2VBQflbZKeQ1bXuX+XPBvtJcY+VMxvT0XqE9s9372Tcwicq2Evs29aWZRa+70di/Pnd75OfsgIwN3gG7Y1PWEWs+iimQGUV/U0f5JPFdrgRTMeBND30BcTSrswa44aeoaHMSPELFb4+2WhBcoDgXf0T2Gtng5NSir7I32gWn42up1wtIG59MfgvIEOXuEpPpmoMcyvADtleb5jwrq5iDwo7zKw9hikzQNyG6puVrnVUnPK1yIeqvYQLAdBF8/m5nDJFRTQgv01ySjS/mU5EnLC+C5Pww9rWxd1XSUJWGqLhcjWDd+JzxB7Iz7OvHdpdNjRsidGA== 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 KL1PR04MB6878.apcprd04.prod.outlook.com (2603:1096:820:d5::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.26; Thu, 28 Dec 2023 06:59:47 +0000 Received: from PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::5914:6fc7:b79d:7e34]) by PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::5914:6fc7:b79d:7e34%7]) with mapi id 15.20.7113.026; Thu, 28 Dec 2023 06:59:47 +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 v2 06/10] exfat: convert exfat_init_ext_entry() to use dentry cache Thread-Topic: [PATCH v2 06/10] exfat: convert exfat_init_ext_entry() to use dentry cache Thread-Index: Ado5WjOA+wdiwp54SsOXB7UOjr9FWg== Date: Thu, 28 Dec 2023 06:59:47 +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_|KL1PR04MB6878:EE_ x-ms-office365-filtering-correlation-id: e440ec61-1c8f-49db-e35e-08dc07729454 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: xFoy+I1e2mrLRx9oXSRnvyls2Sx7Om11JioDkIa6NAAYwIsIOXyUBKIsa/jWVtnSgi3G0A5ueD/T4ofCLxo7Mw9pPKRkrZAXodcKTdwQDgAaE9l5ESBpIwDXeLnKk4zIiJvX33LnmaD4a0DdhmA4xQwxt4hX26Rpoeo04/GBIv8k6Zj5dKeQAlcZa09UKN9er145OgJFyweE3NsxayYt36U/SgbkAWeWQuIlZZ8N62ozoNwpGCui9bAofAXI50tVTMQp/juSa1j3x1g9aloR81Q/DmCQCS5h4DBf1wB7cmB6tMAOGsBFTz0/H5eacaE0K1Jrht/hbq/9WSnvMSeMOXHI7Dta58uMWswqmOBzQAD3XkU6l1XJD5qrBAotSGl91pOd4v3YMhdel3nGW4DL5kIVcVmEsyclvg37D5Rg+YBUe81r6rxx9WEnga4XC9MwsNX6LnPlyWuKyftKgoBgzAC1SPbZw2KV23YGiPRFDG36+VtHukhTYDyT/RYWdtH8XVkSpundHX+maHcoJk8lQDEBUbrLl31XUiN8skIsMUgDV1BPkFZJReVfY8vJJg7xucYrCAj2Cq7VZnWGT3fdqVamgkfAy7VOuowyKflYvE+2yh6SivEfHPYb8fWHUvhH 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:(13230031)(39860400002)(136003)(376002)(346002)(396003)(366004)(230922051799003)(1800799012)(451199024)(186009)(64100799003)(33656002)(9686003)(6506007)(71200400001)(83380400001)(7696005)(478600001)(107886003)(26005)(38100700002)(122000001)(82960400001)(41300700001)(316002)(54906003)(110136005)(66556008)(66946007)(66446008)(66476007)(64756008)(4326008)(8676002)(8936002)(52536014)(5660300002)(76116006)(2906002)(38070700009)(55016003)(86362001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?ZCS+K/IzA/+xpSM5WfA0QUjHHBTO?= =?utf-8?q?xvVN6G1DSIGrdLxfcZQNrHJWLFqjmBjFKp+xyy7GfDol38rm4T21IFGxwQ+emotns?= =?utf-8?q?uIf6WvfvdkftYWkt1b+D74QHklOVFw0qd3psgwzr+Uc9R8USjSlbx1HHzjy71eAIa?= =?utf-8?q?knUlBwqdVk1m8v3uMWbd5Ge3JYSudqaw8N1ObdT7AHQeTY6GZxak7BjhMgVUvPYjY?= =?utf-8?q?Cr3Yj+/IFC48p3GNSu09krWrjlDt2nNalggcqqCn/Pie5ZH+MUkp840chZPhUM9Gz?= =?utf-8?q?zJlAfYQ8ROBbwyeiZw2uSH7dOkzwlB4818tQesRaZWcZ0lsrSqHcWOfHNWEZUTnqd?= =?utf-8?q?7D5W9kTwnSHF7a1UM3FMqx4HnRpEURUQ5ZIYw9T+e/a6APmtXc6y/hBX104F6I8jL?= =?utf-8?q?YSvVQ+7z6FfuYDujUA7gMH6JMmXp3GQoSRyzOv9C2FV10JVL3lStOSufG7x3Lopp7?= =?utf-8?q?vmnVWU+60tApVxaqdXJvYqWU51w88iva5kvQG/0/VhSSoMtH01W1rLpEbgyTFBk+U?= =?utf-8?q?Zrh69KFRNLWOpfKopj5paCdHEyzSUpjo1lLUAF9EGZSOntuogU+JhmWwcgAJOlRTJ?= =?utf-8?q?xyZENvlsU16qds76GhN6aT91IJJ6pKquc2NEeLRugXhZUA0R88W6dqW2SOglFnQDd?= =?utf-8?q?/6+Y8M9df+xiQIcJDwmddSme0vQWCHhkAgw9ddJZTpiIF/ocSzDLe0BQlIQsrubFh?= =?utf-8?q?xuAK2W6ISE/bOTAt7Z0D/yo2PqLVxcth1C5z3YZ9TX82ulhk7/IZby8zlQWfmzabB?= =?utf-8?q?R7AnKHiVO1XnVjM2ZBHeEqTDdkvrEPSb8OS/OcwL5dfvJneCoC4FlshYmhxsyg9ph?= =?utf-8?q?2XJfIOSPU4LMgwrMYHSpcf4QJAJR3En/sWavRj10nGV1DvRGsfUJvkVpV7TWlcBNw?= =?utf-8?q?xK7hifJaNiVjXJ6vty6B8Sm8+ixH7qvs2+/FDmq0g74r1b8xxuYV6uDVV5S+Ya/LE?= =?utf-8?q?1wYq1Xyp3pgk0qFUELKC6IWpsAQRfBQJinkgXXOrXQHEmBsardO9F4h5TLAUixC+O?= =?utf-8?q?W/XKsJTZu7V6TjFPiKiyTHITh5wbn0Ep9xpA+gB0mW4otmhEnsL0oHJ7W/xLZpv61?= =?utf-8?q?cff4m2ceg0TKSF66pNcE8tbZqMpE7H0wvcBSIi/2eU0xCrTMvCyI5LHZyMxgGmGW8?= =?utf-8?q?LmBzGXhBV1PNDFsaiS30hG3oVKUnWZV/GchpWgkaYdHx/k4ahbuBqu6DP9zAQ8KJJ?= =?utf-8?q?hb1iYS39xC0f5CAwmRidzQEV1w78qUbU3sV8y+Qmw7Sp23mCsXe/4aDD0YDpq21xZ?= =?utf-8?q?d+7GaXqvQaVM1huOAGJa+Qo6Gg4TOHqCHoaKtrcoOY1kOOOogDBMkzT+Ij6Hdf9+A?= =?utf-8?q?Fteiimlzg3qy5JmaFQA3BKlKh+GJGOYOGHuoqu/sp2RdL4ezrYyUGtnS+fddMXAid?= =?utf-8?q?Uc8hsqP5p/oWmNj0axGr/ltJzKtKvaeyleY7ou9o4gqyGdcsNNndM0mbJeL/qVxVd?= =?utf-8?q?oFE13Pfrked0zt8oPw2X9RawQr1+qT20fAwZ+d1QS0xG0pC1MPWwAVZDOhNItiYFi?= =?utf-8?q?R1sel8YA4fmb?= 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: ZSSqCvZQ70QM+CxpuhnCL7Vv2AC9nRXZU+toxkNKxUn8e6BaV/LKNbTZvNhZiFgqizosgWDv3tSv3mHbwl3Y/HYB+Ynxjone7n2UQ6aBGuhQqMTZvkd+hBxqGwIm2xo+h/wAozVPjLV7IBZF7PTsWcTiWNF7+6WN2rKB+nGqQN1QPfJ9PRaqijyJoejREGBQKcGZssaIENOV6sSdgBSACJNdudzyPWgT5Eo40k+/klSFlgvrwd4Q7InEdtuEu00Fu3GdPIPjoLTTBPt7pN9Mg/GtH0v85xjnY/n1PcUmd1HQGoUMmV0Xrcl8vpvv3dIiKaRHqv+XnJd7HKxlSnnVFmh2uFi+PLCFIK7f7xJX4zFdTARd1CZpFZ8ENjsDh6C4uCqXMaU03V3X1CZoBsfxxap1/N8Uwk8ug2m+AAS5eTJWN3fj9HljiH/0kfUIRMY+TOq8HufgvG5vBTg2mUQFmvlwSLxP+NTZR5hfyCg36pBAAzmjDX7DSvfoPupkMFRXhg9G8twpKCTCLiCOrLvv1ce3mxUr+cfIEZliXp4hMAZX3Qu+U2EmJ1truqV9L5Mqlz5G4vC+G4B7yrWOCjOAJy76APwrWvhiwBVyE0wxHJFkOZNH8E+wK4b8wcmzm5r5 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: e440ec61-1c8f-49db-e35e-08dc07729454 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Dec 2023 06:59:47.5332 (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: XY8pzEyJpl21hYI9fJgIWvHkaxZL0kJ1EXvrYy2m9O5kumznjOY4cqINeNKNLuNKhn2uix06znV010N/QzEShQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR04MB6878 X-Proofpoint-GUID: CwTpJo-HaUIxp9UsxMfpqSzSHxTtfcmN X-Proofpoint-ORIG-GUID: CwTpJo-HaUIxp9UsxMfpqSzSHxTtfcmN X-Sony-Outbound-GUID: CwTpJo-HaUIxp9UsxMfpqSzSHxTtfcmN X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-28_02,2023-12-27_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 d3767679745a..f123c1c2a4a2 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 fbf76a8b5d88..b1c85f6ec90b 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: