From patchwork Mon Nov 18 02:01:58 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: 13878021 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 34D9D33E7 for ; Mon, 18 Nov 2024 02:02:13 +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=1731895336; cv=fail; b=u53j2Vdve9hqagiPEXZPlFE2c7+gzXJ/syE20/gEBduerspM5Mq9TFOMQESV+6LfgUpds5SWntqnvhu+kMcuuiG7q3ig5EsU2zBY4RaMyAOAWJxuKQ3h5in83lmeObglsQ59zMT5ccrtvgLQCBhbtF0ePPGKvZEhzIZgeJly3M0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731895336; c=relaxed/simple; bh=Vcda1x1I6Ld/dIrWnPI8SRG3HDFKEQ3PfkHcSfc5KpU=; h=From:To:CC:Subject:Date:Message-ID:Content-Type:MIME-Version; b=VnSGvnJp1pH2FHpX8CTO2ow7nPhUixdMyXiCDWOUhso34ZM9r9UFfNBjmWJaS6iAmNw2H+cMRfdz8uOK+0q4oaKg9HV964cNM2o68Givjd/i4tysfsG0I/kEQ6uZPkdrpzaQKwMbz5kyEkxodA7rhom/EqGUsNBo4nxCWC/KgKI= 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=DXueErnV; 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="DXueErnV" Received: from pps.filterd (m0209323.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4AI01e38009889; Mon, 18 Nov 2024 02:02:04 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=Vcda1x1I6Ld/dIrWnPI8SRG3HDFKE Q3PfkHcSfc5KpU=; b=DXueErnV3iLuCNMCzGgpiZH2LYjwPRAz37USajNW0WN9e 1tPMrbRcmB3obO5bcZPLirHAzxKhzJLfH+U2lcXaWs5oAnn61P4GbHpi7Qma7ASa bFiesVqB+OCLAPy94qY5LHMxO6Klx9qcNNdNVRoU7WkkUDvr0IOTOSgg00EpQOlB bWhoY45YXHCCWl4m8p/1Xc/12R1fFFGPEPRi6cl/a5JKGV3/Ho9nuV57OHuGiX1n aS7PW3WHIolyQ+CKQjc/lQ97/re9ks9uYIthTICN4FEIYncOg28HtkZWCbIF6E+L tKmBVjmJ0l6nHIxIHtdwNwrB0Optyw6uCkkIIF6ew== Received: from apc01-tyz-obe.outbound.protection.outlook.com (mail-tyzapc01lp2048.outbound.protection.outlook.com [104.47.110.48]) by mx08-001d1705.pphosted.com (PPS) with ESMTPS id 42xm9p8xen-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Nov 2024 02:02:04 +0000 (GMT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PKPFnxADQGlOuOlqOgm5DgQqekt/BhtfBEMPXbqbU9qknU0cOXNVhX1MkFVItGSch8Xnmd/mo2ygg5Q2PH9SNJ4UDtm71sHk6TC6g0DW3GREE77ojyF7wXl32XaZ0emMf+Ijit/hn3dg0GJnoHk6vB1zfW0CXBioarpkwzGs2zbOQ5vkLTn2aWh0oMy/JJwLLcz8rQicIOrwNjMKv7rKwW9jL2Rf/h1iAIZEmtWVV8a1mL2yYzIfBED28s1OgoJjQ4UfP+nvf048bcsECyCqaqsNoHdMSUaqxOxROR96MVF58fZDS6U0i6bWJvV2bvs06aaG6nWAR0T/ORY1ln3B1g== 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=Vcda1x1I6Ld/dIrWnPI8SRG3HDFKEQ3PfkHcSfc5KpU=; b=g7LYwz6/uNbzGJEXWzgFddDsT3m4PMOicXoeiPIj7byY/Nmi0q00MSLwgoXGLBi/Jc50BMMcgef45fAhnlkzCKRAheDssxI2rphvk2OE9b4UwP90OalsXaq2IR2Po9q78euRIRYVrwhyCRTV6axadLTMH36JlzHRmcdXy+lrK2vjetZxWyS2CKCCQgAG3nWWlmWcyNT1HJmVS/GfDSfE/9xLzRn/PO/ycCWfAmrfpEb05SiQruJJ49trAZ6Ae+xEM5sGlO+ZQcYfKy4v+7mv/QCrdJLDbCqEya/metl8pf1Z6OPhtL49XsewC22y/xeu2fIhujR82XV1hbMHTxOifQ== 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:01:58 +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:01:58 +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 3/7] exfat: add exfat_get_dentry_set_by_ei() helper Thread-Topic: [PATCH v3 3/7] exfat: add exfat_get_dentry_set_by_ei() helper Thread-Index: AdsFm7o69pSeu2bAR9KHr0tMBqa1WgzwPUxw Date: Mon, 18 Nov 2024 02:01:58 +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: 9a1f4db4-1d77-45e3-8e1e-08dd0774fc19 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?UlkjWu559ktHmuGX6sAdnJiHBr7pDmb?= =?utf-8?q?NrLAIYk+WVP1s91U2HsIMjbdWN8WLxcTwfHNvGycj0nOrZfcCUG2csRrZV22iYsTi?= =?utf-8?q?q68VF95N2VtZhgQfO+fidb3s/TySB9VWTDnKnTL4dCb1AlH0/dGgI/P1WeO/2l2mU?= =?utf-8?q?84YJzINmRap8ElGwx8B9BKRV/C158phO9uLXX88YScj2ky6yFGBGNMvXbOg7flxTf?= =?utf-8?q?U0N7gJ0kNZSZKWz3bRPUcyPNEG+2h15UjtCXlwMaeJc2CdpI2hF/Jzp5m6jBT97LP?= =?utf-8?q?TRWFxSzY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jH55wDbxvvlgouBWJ1k8ObhPrkGZpwhE44sZEi/wnRhzJhuD?= =?utf-8?q?jb/uJe7eU/liknTpp/AMsw8nqPYgvMo74BMaEuu8oet8CA6zVPz/iZtnar3d1SSvW?= =?utf-8?q?kQiKCghknMbDTbqQCaxYCUQkfjcpKkmOoZmXz186Md9SWGSjbgzd8Qrw=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?WoEM97MN+s5BgQzhXR5EJUShMq9N?= =?utf-8?q?npf8Z4gSPDThvLBF0sWN5qpKOgXuC4PEW44EkFJsvdupr4o9mci/fRH9L0mKPLTAI?= =?utf-8?q?0e+Dib4Jf8LC0HHcILqQTM81AI/1u52G23nnokOtuOQITDHltTJDU/PA7D8/FFs9q?= =?utf-8?q?CrgreONt+89yyIShJ9tJCwmm60Y0899FENffwN2bA0aXSXRGVOy9ZXsWxmPE+ScbX?= =?utf-8?q?4uYBFyNyNyP3lvGUE29CsyJeHJO7iw3X2ZttGABCGKCH4kHIb1iADz+GD4J8quaMz?= =?utf-8?q?5EHqxJybN8p1groC87zz8fZZ8pZ5plrobtTtoykWZIK5Eogejg7EAWi8Rmpg0m4rL?= =?utf-8?q?0krK9AJeycosNp4kjbq9vugz2pfp9cfUMhrPhb5RXh8kt66NaQAMhiRGhFhA63aG7?= =?utf-8?q?bXpvAQJScX8UYUvKpbfnD+Zx7BULd4EVUVMGvAi3dExUOfomETKQELrkgDyFGnwhY?= =?utf-8?q?9fTH7zm9B5fUu9zNkmXX5BvXkW+uXlwqccYpM9pCx8nd2mhLHpHwG2KWa6cYrlGhr?= =?utf-8?q?uQndNppX+vmYiu97a8bbEjaz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tm5o613FvdulcQi291fqdvVJ6CJdVbh3qi?= =?utf-8?q?U+R46TB8teD+Cra5E3vaAMID3a4oY49L2/WD/bcqSgubTivNNrLxtJ/Z9O7biik/D?= =?utf-8?q?9i09qlidvnKe?= 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: 9j1ZWytZgnmMbl1SEIAcwgD9jTS0rh3bRkE9ymFDfRKRgZApc1Hv+ynIE62pmdIqBqmNSGekHPImxpYQd7CtmsuBR5qhIbGGJ29kLTiDlX4ZC9hm3s5jnz9CcYMLOjZNShIf4n+uSoKZoiEHfSsiGRurJELN0R2c40QG3J8BpJREIUDonh4LruXshHsWfA5dL+Znw4mA7Gj3gjZQp/2xLZWoJE+HukiCFZSqp16UQe+cWomdKhp6QmaCoczYOY4QtoJ98TfxdCG2IOa+6WrJnaTmA/O4xM6mLrhsm8HguYnIYhadcH65FWoAzxk+EmdN+2pzT7478MfDffrRSOZN4U5ogshIuM8mf56z9WlHL7J+1HkeaPYeUiT7zFeVgu4K2Wvx+NCp4c4kQ+jHEEhMOggziW2lHj96btuVq+Ri4Xm7c/xUZH87BWpqrbdAfgeiLmf4Dyir5uxDzE7TwnfEmve1sYdNz8E5cMMn3d8xwrStCDDfjoxREbEJgXQptWh/YsziaWonA6bkJzfctpSkaqGJBA9XxyOUMsOUo41Jzd0zKxz/f+A9aQSyE6R4n3YR2S9tKqXY0MmUf40HXguT4gCJkXFzkaYhwkcV1sMIXVrmhNiztugfQZ4MIM7mKTad 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: 9a1f4db4-1d77-45e3-8e1e-08dd0774fc19 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Nov 2024 02:01:58.3256 (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: A/PqV6jxFIuqMOhvSY7nlc/nfRUGE3e6heFmqiXGp3e5LmzP2rUhYwAC1bZsnGXAXDAxq/oo1yciLUXJVbv5Tw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR04MB6119 X-Proofpoint-GUID: cwl9lXU8ys0ukQX4ZA6aZIdgpDiY2fWb X-Proofpoint-ORIG-GUID: cwl9lXU8ys0ukQX4ZA6aZIdgpDiY2fWb X-Sony-Outbound-GUID: cwl9lXU8ys0ukQX4ZA6aZIdgpDiY2fWb 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 This helper gets the directory entry set of the file for the exfat inode which has been created. It's used to remove all the instances of the pattern it replaces making the code cleaner, it's also a preparation for changing ->dir to record the cluster where the directory entry set is located and changing ->entry to record the index of the directory entry within the cluster. Signed-off-by: Yuezhang Mo Reviewed-by: Aoyama Wataru Reviewed-by: Daniel Palmer --- fs/exfat/exfat_fs.h | 2 ++ fs/exfat/inode.c | 2 +- fs/exfat/namei.c | 53 +++++++++++++++------------------------------ 3 files changed, 21 insertions(+), 36 deletions(-) diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h index 3cdc1de362a9..28cc18d29236 100644 --- a/fs/exfat/exfat_fs.h +++ b/fs/exfat/exfat_fs.h @@ -508,6 +508,8 @@ struct exfat_dentry *exfat_get_dentry_cached(struct exfat_entry_set_cache *es, int exfat_get_dentry_set(struct exfat_entry_set_cache *es, struct super_block *sb, struct exfat_chain *p_dir, int entry, unsigned int num_entries); +#define exfat_get_dentry_set_by_ei(es, sb, ei) \ + exfat_get_dentry_set(es, sb, &(ei)->dir, (ei)->entry, ES_ALL_ENTRIES) int exfat_get_empty_dentry_set(struct exfat_entry_set_cache *es, struct super_block *sb, struct exfat_chain *p_dir, int entry, unsigned int num_entries); diff --git a/fs/exfat/inode.c b/fs/exfat/inode.c index d724de8f57bf..96952d4acb50 100644 --- a/fs/exfat/inode.c +++ b/fs/exfat/inode.c @@ -43,7 +43,7 @@ int __exfat_write_inode(struct inode *inode, int sync) exfat_set_volume_dirty(sb); /* get the directory entry of given file or directory */ - if (exfat_get_dentry_set(&es, sb, &(ei->dir), ei->entry, ES_ALL_ENTRIES)) + if (exfat_get_dentry_set_by_ei(&es, sb, ei)) return -EIO; ep = exfat_get_dentry_cached(&es, ES_IDX_FILE); ep2 = exfat_get_dentry_cached(&es, ES_IDX_STREAM); diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c index c61fddb9b23c..f938299e749b 100644 --- a/fs/exfat/namei.c +++ b/fs/exfat/namei.c @@ -766,26 +766,23 @@ static struct dentry *exfat_lookup(struct inode *dir, struct dentry *dentry, /* remove an entry, BUT don't truncate */ static int exfat_unlink(struct inode *dir, struct dentry *dentry) { - struct exfat_chain cdir; struct super_block *sb = dir->i_sb; struct inode *inode = dentry->d_inode; struct exfat_inode_info *ei = EXFAT_I(inode); struct exfat_entry_set_cache es; - int entry, err = 0; + int err = 0; if (unlikely(exfat_forced_shutdown(sb))) return -EIO; mutex_lock(&EXFAT_SB(sb)->s_lock); - exfat_chain_dup(&cdir, &ei->dir); - entry = ei->entry; if (ei->dir.dir == DIR_DELETED) { exfat_err(sb, "abnormal access to deleted dentry"); err = -ENOENT; goto unlock; } - err = exfat_get_dentry_set(&es, sb, &cdir, entry, ES_ALL_ENTRIES); + err = exfat_get_dentry_set_by_ei(&es, sb, ei); if (err) { err = -EIO; goto unlock; @@ -915,21 +912,18 @@ static int exfat_check_dir_empty(struct super_block *sb, static int exfat_rmdir(struct inode *dir, struct dentry *dentry) { struct inode *inode = dentry->d_inode; - struct exfat_chain cdir, clu_to_free; + struct exfat_chain clu_to_free; struct super_block *sb = inode->i_sb; struct exfat_sb_info *sbi = EXFAT_SB(sb); struct exfat_inode_info *ei = EXFAT_I(inode); struct exfat_entry_set_cache es; - int entry, err; + int err; if (unlikely(exfat_forced_shutdown(sb))) return -EIO; mutex_lock(&EXFAT_SB(inode->i_sb)->s_lock); - exfat_chain_dup(&cdir, &ei->dir); - entry = ei->entry; - if (ei->dir.dir == DIR_DELETED) { exfat_err(sb, "abnormal access to deleted dentry"); err = -ENOENT; @@ -947,7 +941,7 @@ static int exfat_rmdir(struct inode *dir, struct dentry *dentry) goto unlock; } - err = exfat_get_dentry_set(&es, sb, &cdir, entry, ES_ALL_ENTRIES); + err = exfat_get_dentry_set_by_ei(&es, sb, ei); if (err) { err = -EIO; goto unlock; @@ -982,8 +976,8 @@ static int exfat_rmdir(struct inode *dir, struct dentry *dentry) return err; } -static int exfat_rename_file(struct inode *parent_inode, struct exfat_chain *p_dir, - int oldentry, struct exfat_uni_name *p_uniname, +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) { int ret, num_new_entries; @@ -999,7 +993,7 @@ static int exfat_rename_file(struct inode *parent_inode, struct exfat_chain *p_d if (num_new_entries < 0) return num_new_entries; - ret = exfat_get_dentry_set(&old_es, sb, p_dir, oldentry, ES_ALL_ENTRIES); + ret = exfat_get_dentry_set_by_ei(&old_es, sb, ei); if (ret) { ret = -EIO; return ret; @@ -1053,21 +1047,19 @@ static int exfat_rename_file(struct inode *parent_inode, struct exfat_chain *p_d return ret; } -static int exfat_move_file(struct inode *parent_inode, struct exfat_chain *p_olddir, - int oldentry, struct exfat_chain *p_newdir, - struct exfat_uni_name *p_uniname, struct exfat_inode_info *ei) +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) { int ret, newentry, num_new_entries; struct exfat_dentry *epmov, *epnew; - struct super_block *sb = parent_inode->i_sb; struct exfat_entry_set_cache mov_es, new_es; num_new_entries = exfat_calc_num_entries(p_uniname); if (num_new_entries < 0) return num_new_entries; - ret = exfat_get_dentry_set(&mov_es, sb, p_olddir, oldentry, - ES_ALL_ENTRIES); + ret = exfat_get_dentry_set_by_ei(&mov_es, parent_inode->i_sb, ei); if (ret) return -EIO; @@ -1116,8 +1108,7 @@ static int __exfat_rename(struct inode *old_parent_inode, struct dentry *new_dentry) { int ret; - int dentry; - struct exfat_chain olddir, newdir; + 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); @@ -1134,11 +1125,6 @@ static int __exfat_rename(struct inode *old_parent_inode, return -ENOENT; } - exfat_chain_set(&olddir, EXFAT_I(old_parent_inode)->start_clu, - EXFAT_B_TO_CLU_ROUND_UP(i_size_read(old_parent_inode), sbi), - EXFAT_I(old_parent_inode)->flags); - dentry = ei->entry; - /* check whether new dir is existing directory and empty */ if (new_inode) { ret = -EIO; @@ -1173,21 +1159,18 @@ static int __exfat_rename(struct inode *old_parent_inode, exfat_set_volume_dirty(sb); - if (olddir.dir == newdir.dir) - ret = exfat_rename_file(new_parent_inode, &olddir, dentry, + if (new_parent_inode == old_parent_inode) + ret = exfat_rename_file(new_parent_inode, &newdir, &uni_name, ei); else - ret = exfat_move_file(new_parent_inode, &olddir, dentry, - &newdir, &uni_name, ei); + ret = exfat_move_file(new_parent_inode, &newdir, + &uni_name, ei); if (!ret && new_inode) { struct exfat_entry_set_cache es; - struct exfat_chain *p_dir = &(new_ei->dir); - int new_entry = new_ei->entry; /* delete entries of new_dir */ - ret = exfat_get_dentry_set(&es, sb, p_dir, new_entry, - ES_ALL_ENTRIES); + ret = exfat_get_dentry_set_by_ei(&es, sb, new_ei); if (ret) { ret = -EIO; goto del_out;