From patchwork Mon Mar 11 04:24:46 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: 13588278 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 7BB62DF41 for ; Mon, 11 Mar 2024 04:25:08 +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=1710131110; cv=fail; b=m7A1KB9h9Sgs6V0uiVO8syyQBVMI1H2fhsnK45c4jRvznFa74m96hTIsZT46S/YjSYwAfsI3Lt4w+pW3zRZXrL90j4pDqERcJpJwhrDN6ReonYSyYoGr01PupsSpkDEPGWAa7KJfgZD7d9iVCbZzrSz4mnYmfQVv6Tpbaq2rUdg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710131110; c=relaxed/simple; bh=pvo0EiKX8AgLZ9hQQsHQ4GWCXMQL+AEmjxDv2EL01gg=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=XLTV8b1sHU7FwNiiJDfNW5eKbPsCXjN2sO+sx18weHdj29Jqiv2d2Vc00RKF5gAIJu/c8wd2PjLIGtU4MCC8PrrLNy/G8jXan+sohUqaj6BLafmTbL5XmCg6Ec9sRHkYgHEkkMw0xvWwNUsZUQJDvwmgB9E6EY56slZUR+NQfz0= 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=PVaKXJSq; 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="PVaKXJSq" 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 42B0NPOi022127; Mon, 11 Mar 2024 04:24:52 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=pvo0EiKX8AgLZ9hQQsHQ4GWCXMQL+AEmjxDv2EL01gg=; b=PVaKXJSqfQBw/p5K4RZUSxa2IxSrlIfN0ELYqV7WmOMdk+/CpM1A0g2j6Di6Ok3AK6en FwJnfieoN2fWKrfrHyWaolEZ3R4qQlQbCGH3Gvj1lCnaxupbif84dvVnrSyuGzbDAuGC TR6vi7qJmMxeE6dwkh5c3sXaQcD+sjUY7eW+blcHQI0qA+0Crn4Z8090AXxlABNdwwSa jslDz7XbHRmHaYDVzoLdROb2utzVmYsnCuQCAQZ+E+pWy35kbx2FF3RNZtzfHqDiCfBU BUfHcelOO+E9o4ZuZIBv15FXUkLY3Q07HIFSbLlTqvJS/v7GHpBVtvTs4xDhCencOaYk bg== 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 3wreb6sdau-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 11 Mar 2024 04:24:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DSEPTmvFoEZnE4uyuoogGC+dXPhAxnU39C/aQ4/vMAOysnLSDHVp6YcVvsssWv+vQ2+NErWVtU+Q0N1kFzEnJDWLGJaa9LKJ/fNnpTT7rMxxED3Dws+UolyVQc60dBHHQemooFA55nNXr4COL6Lz8FzzvQHDpRP/SmmnyGqaNs4/mzpCcQ6VfvNrvlfzEXwG3tQ7ohyZKNozmDu7R5LyJkQZ7v50w7uczW5cWvtBnJtttC9pMn1e00r6k68eiZw3cqknZQ2EEuE1vrXUHUwdevAWIIfk4DfniRHKPg9bv7zW34yCLRhQD2Fv2JcZaQo+kXmELCzREne8jYSycahAuQ== 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=pvo0EiKX8AgLZ9hQQsHQ4GWCXMQL+AEmjxDv2EL01gg=; b=SEvbv+mvlLu61WJUFYIqIY1O3DTCAVoihZ/SsxYdHR7g058CgxgWj8GlmUKjF8PihM7uUBOlwP4+wZOkQ90zqqraymnnxlQLr5CkTlKWoZ7+IIqB7yRRZ2+m+F+AJS8LfTSSVX7xgfDd5Bq7TMXZBDBsdXbecMUarPtM+onIOeFwIOYDsGI+NUl7+qxVBXzMJTg658bm3dk605cU/YdAYM97Xx/QbU0gm2rVDPqQ/SYaE2cMsgOd6ZcLaQgx4/SsixdwDZ4Vs38FnBEsxTgp/dAR4HscmN+rXi9/w7ntLDC+EvjYRgx5GILK85Fx/J24WYkFCnJzORnmkx8AQHfgtw== 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 SEYPR04MB7362.apcprd04.prod.outlook.com (2603:1096:101:1a6::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.34; Mon, 11 Mar 2024 04:24:46 +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:24:46 +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 01/10] exfat: add __exfat_get_dentry_set() helper Thread-Topic: [PATCH v3 01/10] exfat: add __exfat_get_dentry_set() helper Thread-Index: AdopyBE5MTMUlvobQIejoYD2xnrYkRJoXQdw Date: Mon, 11 Mar 2024 04:24:46 +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_|SEYPR04MB7362:EE_ x-ms-office365-filtering-correlation-id: a5e50f92-64b2-4768-dac8-08dc41832f3c x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: /wa1M7WsDBC5bX4ftJi9HBYECD/abQ6fLlBjj7Sp+weKbXA5vEiedxw1BbGZmGjyZEHEB47OpGR4254Oyam9kHYVqELz8OQOVT1fMbM5MNr+SOURsf8fB4Rhtb28vIke+l/gZMyQMPX3843E4LMfJA0c2asgSrT8DIlo1gLC9bObkEwdEHPG4HL+PTlg1JRkphByEMwiQroKkSSThypc1S2YJgy7jfuKAbMejt/nr+OjwmdjHJYfolxtHBbtKMhZUEFFSg0xdvp585RXnMgQngIgXcUixRagsuBbvuHTbLWpm5gzPaz8gmu940K7he2VKk3UK496gjw6Rn84ObDt5TiJ8zJc5cyhXieNbjAO1KTY0X8/SmyMe+gpYyoGSgSTOsrKmlFSZZso8l928AxFJVBqQaXfegC6gylsPM8mbajZNailOwlmtlIyF1lSPWUkc5BAH77OA8Y6h0NPS4vVExgzvitFiAHfL77zr7O3BQJcDuhxuKUOOXJGw00LXHnQJjtaTFNH+bZmyBoCHVMYOMwtlLagWTZdO4r+flKgFzx/WdHJ4J+8MZzxgdMACwIz7jO2u3LibwPtErmZlL2gTZqnQhj/KXr0LZPMUvllqjsAwnTzpeXnFx23MWCNy4VMAA4oWvJgLRckylvk99mX7C1MH5w79+M6wvSDrK31RpWzPqxNLT0CSwvwvE5dIrhk0UQCJiKruYqV+VaWY5v3665I2XA69d57KVOE6jtOTBg= 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)(1800799015)(376005)(38070700009);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?JqUeCtg9Z5uWBQrPKe/VF1MLzic1?= =?utf-8?q?aZo37+gKRBHEQ1BowOU/anCgSD3KR724eqWxMSF2tn1KlXoeRG882ggRucHtrBdTy?= =?utf-8?q?xhZa3/jEJA4dgTmNVizyx1HnJAllySUCAHt78dg+1+JluFLqT12dpwonaKM+6Av4J?= =?utf-8?q?T9S0VmQ0mAe8wufGHW5MgsQ3SYu5IRaD0kmC2sq/OZFArEsfbE4ni6NT/is18fM9x?= =?utf-8?q?98K9vvKAuVkkpZVqPbwYfoNHXGOirlnoIj0NFjzgehjY8Y/kKiaUx5YmcS9MwOzgK?= =?utf-8?q?LFJK2/N0qLAtUbzW73IDtl82B4lYGSDQ4m5eUdSd4sQQ9Zvno8/KHTcb1DNBcUEWx?= =?utf-8?q?MqvTpQRRK7NXEFPU0tU8Y5wdDJAwDKEZP2h5vjVgfv3u3Aj53nopcE+8nLE6Ttoz4?= =?utf-8?q?8UK75Fm/c71F5Zi/yKoiOHSkIa5yL3tEvihkKUzQk0vovGINaXSNHOyd9Kn5c+OSb?= =?utf-8?q?vycP9HVgkibeNBbcCWPi52e/GTS28553QmddxY3Ui8TdBsdqlMM0vXm484Jr1ydA4?= =?utf-8?q?AEOMq93e3EDzCCocj/2QzCiR+Oru4gy3WQHTUopPM9XbexONCI6xyeUVO8wc32HID?= =?utf-8?q?/uxv6v+6KfYiVhQzqofFfw07HsKU2MaMgGfX5+DdqSU+yZl5Allcog7wbmZKtwKRz?= =?utf-8?q?OfmyhbotQ1yxhkeERJlJFLGeu3I/bSyL7ANSjnri+4fCvETsi5Cpd5ADDcqxupuRz?= =?utf-8?q?mb05oijHiPuXQoeaE59kG8MEh3n4U0Uv6iNHbGSzytSWxXza5tsWu2X3QGgWbXHKW?= =?utf-8?q?6wxBb/5z80aY5o/NG+s3hlNhm7GF28mOXOwbl8wNF16FvBOjfatkOXk7hKfWguMBk?= =?utf-8?q?vg3kQ2QLwUh46o3lu1y+wZnRjuYfdStLY+Kclpq1rKv35D8A+hoUEw1vwKPle5LnE?= =?utf-8?q?QTeFsfgzPlLMXZEJgYq2Xocw7N0v2vXzb+cH4Yh32J8/hTjjtMubaGzqIg7USKcqm?= =?utf-8?q?jZ8oJlcO9U9muoYhzsSon9pMXoIoAmsrwgSGUvL+l/cEpTJYylGxa0d6ht2wrucbU?= =?utf-8?q?9NjBP2fQkFBKHmYqC5ziaGS+XvXj0o9rGJ51YDeHnECA/7WkWOo9RRg1V7An7aKrr?= =?utf-8?q?A6jlR0Ng6cw7ld9Rzk4JqRjP81MH0UILgcAiXsNu3/a8uVUD1z8EYG1kf7sLv+Vip?= =?utf-8?q?mdnpOhviqLu5YV8L/32/gAWuBBpCmNkAAd30fHCj5XX51reIjaQpP0gmmadPn3oot?= =?utf-8?q?kttsfXBFPgvlOyOzgpxDn5C2a1mjqw2H/z9IHPEfst0OlzwSoWI/EpB/NKiP2vgGP?= =?utf-8?q?IXXsXv/O0VATNI/5pyyylRh0aQ+On24m8qvsF+OR8FWX47mGjkI6QyiKCFttan9rs?= =?utf-8?q?/CLrcxNCAfF/9zK83z68Xk1+zzy3kceUlNhI3gIMxIkLuuJQ7rLoMrrxChE8321rE?= =?utf-8?q?Pw1Oi6fPUTr+kdDZP3uP9E63DIWSQkpKvdDPlZC9Rudq7K/cGcvE0eAnOWawGt7h4?= =?utf-8?q?LiDmPFChV5bf4VWIFufvg+qyge3BJUwOrmO28QNVF5lNEwGLMAb3XUWqJN22QKY5g?= =?utf-8?q?nO54zqP3J5TK?= 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: ZQ+7vdM1BhOzFc81OGiFZSdJX5EouNFJ9ELT1Y6zSH+43pWG1zMtkaDWogJarTGHHR14LI2FZ/xC2x970HX2l1C9b0URn6QuuwFqC55lgJdwXVwo5s1iYY2BivIR1INwdlsdBzPpl2H7mawA0kPC67m9dK1swEXPGXfsT8bEHXJ1Qt/0tI8g/4CD2m1TJzqI+2LVXFX8grJwluz6I04pu1RkQHpE0bYMDGltK2/1msh6bujamzNzL2r2xFe46Xp/TbPjWaIpCcHs8GCWDhAr/Z7txD1semXBHBvQ6y8siIslIfB3o15JJhHDCf2PEZW83j2zeYLRGA9P0oqQfNfDX8cnKPsntIY1X9erdHhBSw5YA5SaW+68XrzPKKdTqn9JRptOMUaC/jd8fwQaDKzd/izC0CpMTJR6ztued0KVIGwZTzPB+f/3U9/p9LZWVKIJy1+foN00y3+Jf2sjSvzYvYBvMLT6WO96TzEmMNMYrWP6O4My9etAZengDhfe0llCYj8fuHRGt9xLNGY6nTZKhg5g0biwaPE2n25heFK2GKrMt8wrnkzLX3Hy3RjGoaWveGJbvG5Y/Q4YyO9eXGpPmNH1W+3uUV4MQMHmYKRfUBv8KTN6mKQN3zGJAefCOQsk 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: a5e50f92-64b2-4768-dac8-08dc41832f3c X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Mar 2024 04:24:46.8687 (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: YGUZAOzMjmH+0wpMcxSSO19tzGrwVoXR7M4KqEE1SFdEWg1Au75D8Tco9ue7eRoSc1/WZjheJ41nUrgY7jV+vA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR04MB7362 X-Proofpoint-GUID: iYGzSnvhyO9MB-9M_HgO_peEOu3V_DHY X-Proofpoint-ORIG-GUID: iYGzSnvhyO9MB-9M_HgO_peEOu3V_DHY X-Sony-Outbound-GUID: iYGzSnvhyO9MB-9M_HgO_peEOu3V_DHY 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 Since exfat_get_dentry_set() invokes the validate functions of exfat_validate_entry(), it only supports getting a directory entry set of an existing file, doesn't support getting an empty entry set. To remove the limitation, add this helper. Signed-off-by: Yuezhang Mo Reviewed-by: Andy Wu Reviewed-by: Aoyama Wataru --- fs/exfat/dir.c | 61 +++++++++++++++++++++++++++++---------------- fs/exfat/exfat_fs.h | 2 +- 2 files changed, 41 insertions(+), 22 deletions(-) diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c index 9f9295847a4e..cea9231d2fda 100644 --- a/fs/exfat/dir.c +++ b/fs/exfat/dir.c @@ -775,7 +775,6 @@ struct exfat_dentry *exfat_get_dentry(struct super_block *sb, } enum exfat_validate_dentry_mode { - ES_MODE_STARTED, ES_MODE_GET_FILE_ENTRY, ES_MODE_GET_STRM_ENTRY, ES_MODE_GET_NAME_ENTRY, @@ -790,11 +789,6 @@ static bool exfat_validate_entry(unsigned int type, return false; switch (*mode) { - case ES_MODE_STARTED: - if (type != TYPE_FILE && type != TYPE_DIR) - return false; - *mode = ES_MODE_GET_FILE_ENTRY; - break; case ES_MODE_GET_FILE_ENTRY: if (type != TYPE_STREAM) return false; @@ -834,7 +828,7 @@ struct exfat_dentry *exfat_get_dentry_cached( } /* - * Returns a set of dentries for a file or dir. + * Returns a set of dentries. * * Note It provides a direct pointer to bh->data via exfat_get_dentry_cached(). * User should call exfat_get_dentry_set() after setting 'modified' to apply @@ -842,22 +836,24 @@ struct exfat_dentry *exfat_get_dentry_cached( * * in: * sb+p_dir+entry: indicates a file/dir - * type: specifies how many dentries should be included. + * num_entries: specifies how many dentries should be included. + * It will be set to es->num_entries if it is not 0. + * If num_entries is 0, es->num_entries will be obtained + * from the first dentry. + * out: + * es: pointer of entry set on success. * return: - * pointer of entry set on success, - * NULL on failure. + * 0 on success + * -error code on failure */ -int exfat_get_dentry_set(struct exfat_entry_set_cache *es, +static int __exfat_get_dentry_set(struct exfat_entry_set_cache *es, struct super_block *sb, struct exfat_chain *p_dir, int entry, - unsigned int type) + unsigned int num_entries) { int ret, i, num_bh; unsigned int off; sector_t sec; struct exfat_sb_info *sbi = EXFAT_SB(sb); - struct exfat_dentry *ep; - int num_entries; - enum exfat_validate_dentry_mode mode = ES_MODE_STARTED; struct buffer_head *bh; if (p_dir->dir == DIR_DELETED) { @@ -880,12 +876,16 @@ int exfat_get_dentry_set(struct exfat_entry_set_cache *es, return -EIO; es->bh[es->num_bh++] = bh; - ep = exfat_get_dentry_cached(es, ES_IDX_FILE); - if (!exfat_validate_entry(exfat_get_entry_type(ep), &mode)) - goto put_es; + if (num_entries == ES_ALL_ENTRIES) { + struct exfat_dentry *ep; + + ep = exfat_get_dentry_cached(es, ES_IDX_FILE); + if (ep->type != EXFAT_FILE) + goto put_es; + + num_entries = ep->dentry.file.num_ext + 1; + } - num_entries = type == ES_ALL_ENTRIES ? - ep->dentry.file.num_ext + 1 : type; es->num_entries = num_entries; num_bh = EXFAT_B_TO_BLK_ROUND_UP(off + num_entries * DENTRY_SIZE, sb); @@ -918,8 +918,27 @@ int exfat_get_dentry_set(struct exfat_entry_set_cache *es, es->bh[es->num_bh++] = bh; } + return 0; + +put_es: + exfat_put_dentry_set(es, false); + return -EIO; +} + +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) +{ + int ret, i; + struct exfat_dentry *ep; + enum exfat_validate_dentry_mode mode = ES_MODE_GET_FILE_ENTRY; + + ret = __exfat_get_dentry_set(es, sb, p_dir, entry, num_entries); + if (ret < 0) + return ret; + /* validate cached dentries */ - for (i = ES_IDX_STREAM; i < num_entries; i++) { + for (i = ES_IDX_STREAM; i < es->num_entries; i++) { ep = exfat_get_dentry_cached(es, i); if (!exfat_validate_entry(exfat_get_entry_type(ep), &mode)) goto put_es; diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h index 9474cd50da6d..800aea2943e2 100644 --- a/fs/exfat/exfat_fs.h +++ b/fs/exfat/exfat_fs.h @@ -500,7 +500,7 @@ struct exfat_dentry *exfat_get_dentry_cached(struct exfat_entry_set_cache *es, int num); int exfat_get_dentry_set(struct exfat_entry_set_cache *es, struct super_block *sb, struct exfat_chain *p_dir, int entry, - unsigned int type); + unsigned int num_entries); int exfat_put_dentry_set(struct exfat_entry_set_cache *es, int sync); int exfat_count_dir_entries(struct super_block *sb, struct exfat_chain *p_dir); From patchwork Mon Mar 11 04:24:53 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: 13588281 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 B0C23125AE for ; Mon, 11 Mar 2024 04:25:20 +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=1710131122; cv=fail; b=JcZqD/8hXpTydy+PvVuLVnkuwNJHRqkU3kL7YpfgM4JDjegM59hwxEIZ5V7+r7wHVINeUGXgyEgm55KVh4UejOSPwcjsocF05eqZVceiOy8uiH7+H2TR/T1dpfoa6dXFVuc9+Om6YYaZ5IDJnsWon52eNgEG/Uh0TbCmd08HL6k= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710131122; c=relaxed/simple; bh=6Dawln/6a0k7QjekUq6nmoqez5VyJWCkrhmjJFSQpas=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=gGhMfwxuSD86nNDd6uI25OWHkBFnyB7uXDd22tPSW8UHgWSLYnHm3P8zuu/9IhBfhGmXszhFJprXNabY/uCPJUZxklyFyJaGdbYmPQc8rqvIYP2iuRtARNcjQqCB65FJI6+cj/JodyYjF9EDWk+8cDXlInVCPoSu1frxw+nON/g= 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=XnEPw9ZD; 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="XnEPw9ZD" Received: from pps.filterd (m0209324.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 42B2SAvV008497; Mon, 11 Mar 2024 04:24:59 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=6Dawln/6a0k7QjekUq6nmoqez5VyJWCkrhmjJFSQpas=; b=XnEPw9ZDLs0WuGydYW5HMScMi0F1NKlV3aowwBBa1hgiGHql2vB5BRNcsNdNFH/r7kS4 b0rmrJTj56XYjA/O4aMK5WeWBe4+pqUtp8XNInS2/trFLAnhX2eCxgD9eci/7SG30pyv ihSOO2lSSKXdMYw6hwEeuNUi4KsHYvR72tPpDqWY6/96hQO8+z1u5E8tCo3c0IUWSN/e jVDFQhi3Re83VUCQgjZrlAmgTtOWUf0fWh5hd+iMll4kTBjqyGoXEQjUOEfRKMWMU0w8 tzxs6/VtJAQ3L2nZ6rqnedG041lKJXN4/AEB94pz+vTdOy3STeC/jyS1lFkmuWBXyqUC cQ== Received: from apc01-psa-obe.outbound.protection.outlook.com (mail-psaapc01lp2040.outbound.protection.outlook.com [104.47.26.40]) by mx08-001d1705.pphosted.com (PPS) with ESMTPS id 3wrcx79nb7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 11 Mar 2024 04:24:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G98YJsKGtVds1JPrui79PUjeGBYXHDE+Mh0YSdpSw0CK2CcEJYriQafeONceUF3JBDBMyFkVuQcJ3k6dNq+pL57nQqyZqGSPvyYP1hjP5ABPjMWYRGd6W/YOARwytLEEh58+WfTTrHrWVV1BOZJ21s0VKX6f8eQjlsqHplyI+DC6cx0p1DbEuPKPSJuAloVpIO26QGrzsUHOBufXPxtwvugUINIOHjYHFB40HOFEh2t83AitLIJmAwKvvSjNsKRqHMfUHO6kny8bXyVJfnBVJPcVK1k3vUbrlPnH4Og92HWoTyhcgu4mgG/5dyxEEBEG2+MyVADmXmNQrXxOs+LkuQ== 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=6Dawln/6a0k7QjekUq6nmoqez5VyJWCkrhmjJFSQpas=; b=djwPrudwUZLoDyqZDCQl4cFww6IpL1VDIzY9Krai0TSea/7GoaqEV5gEBsirqMVGHw/qR12JWccM3vfF63SfcXhtRrIjfKTVFtjgB5l+v9z6tw6pJ2XZibDJMS2Wr/uyTbDYa6BB9FCOvwitiAlTp8JbZb1jxFdxGjUUhfAQx/ULqPkbm26XytJGYbBl+Fu73cL+6EfOgMGDlcYCtapzc6w/6zpK1m4/zKwC8lygtRZUN8QJiMT7f7W8Bmp9/4b9mkJnQbe3pE7Lo4tSxmYPepPEanIBOchDikmJ7bODsbF9Cyjh/onTPiYRgRe/H4A7c05eG6M3da5ZTw2AsFbnzg== 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 SEYPR04MB7362.apcprd04.prod.outlook.com (2603:1096:101:1a6::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.34; Mon, 11 Mar 2024 04:24:53 +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:24:53 +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 02/10] exfat: add exfat_get_empty_dentry_set() helper Thread-Topic: [PATCH v3 02/10] exfat: add exfat_get_empty_dentry_set() helper Thread-Index: AdoLEwb3BqJ/1QsqTGuzkEKI9476vhoVrEqQ Date: Mon, 11 Mar 2024 04:24:53 +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_|SEYPR04MB7362:EE_ x-ms-office365-filtering-correlation-id: 9488a6f2-6b64-4078-e98c-08dc4183330b x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Cd33AkKfjfH5VXqBfS7B/4DdpqLnn/IqeTBcH4H4rF2EsSF96lxzdnuQddxE5VMxLrYNiYFBig77RZZ/U9HgzjDSCiaEteGgzAYw7L8aQjOqx1jP2is0DZvo1g0MjqqiEtXlOAqt1dQd7DIdJUSdhucV7Y9dhVpiHIjcCAa8SHacxodpK4rLMfyMLePhIJ35gui0SzavOh7n6NlsdAcZqhlTkkJNnZ79Yv9mz+v86BuEiDWtax98/bVs+B0InfTK5v17lB+177+OebBYDC64r4VFSiyZuBYKks24wnzibz8zn0njbVjbjpXcqZAJcj86Ml/wi0zmuqWdzTfvkpvjjphKXSuoFVhCs6Gua4I+080jPlBuPoXHqoSiF+c3TK/DBgVhyUdAzwWZzQ/kkvDRxMJdirm+HnaACBFLL+f+CzyF++ipagIB7kWa8uV0aetu4+IOcCjl5JIg0y7/186paTwevse2PQDlDz4hG8YXhyDCL5v85x8heCluOO9z8qs4pSquNDWXyRwgu/ZkMLVdmcezPnOYFUtPejX1ITvWKxvYCcO2ZTZOaRLekDka0BUHRHgXjXK3DwAVYhdjYaaoA7nP071LnjQq59bsRJVzFyrsD4oKu71B48opmNWhUMj7RmZyHZ9JMnXGQrcFFblUJdH8TWHmaze1ZIJzqA/reoR7ZuRbCZBlDuN6ksQOsUu51nlnoC4VoqZAL/qG9Onx95bTqNf4lPHr5w3u8z9AbSI= 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)(1800799015)(376005)(38070700009);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?vVyZ6OK2NAFrwmUjKBZ3z7Wf+ll7?= =?utf-8?q?VPUW0m+9dQxEXT0R/MIJAQ/8HgRqBTqvb4dBt9185eQidYbHSHGrGtAYIIZBGqLJf?= =?utf-8?q?/XBIBXTyRRbmeGkKuk+uydLSqknlmDI3cebox5jPd2W8KyTFNayi4eR22iehRhWR8?= =?utf-8?q?pVHFyItRLr28Lf3S5JrNjA/iuYwnwnmFq78loM0mtibGw3NKHjbE90MVeE2j3q+kH?= =?utf-8?q?2605H6DX7ib/abJzKs8yNc6zsc7RTz1JgQg0fr+Tm4u2qsd0/1Rx5aDen3KC1aFfO?= =?utf-8?q?UKboJKNdst1uqfqCijdTH4nFGpiUIOxXWkjUFYV6Lr0wn1y7eWx9obSOFBXqwnSnK?= =?utf-8?q?8nRmgfSEtVTo58YkdvAvTqDMw1cd8Ptk2k26SO9x7/lznu4wx3wwdVKWvkhjk1949?= =?utf-8?q?q7kdZOOR0sv9IhmAsaKsHJ/Xw7dU8N7smk8qRgvwJVlFlzkJaZq3mBU+lc49P5wtK?= =?utf-8?q?ivgIl5ZOYbIpP0hrxV2IxCTjwQe2SUJj1RtZBpmvoDRWqdcWXRMSJGjQVi/839UZV?= =?utf-8?q?Ro9ZVmXhRTBL5t+ykLI3ET8UUxuLuh5OcOl7zGosoO5HqS1j3dPUzrWny72ucAxip?= =?utf-8?q?9nxsZwDbOH37+BVPj6ttcT9Nwvnm6n7UJ/glRdh3+DBbqBwEI8IKwxkx3yjj9D53X?= =?utf-8?q?Yrk0Oxalq+xEiIhGH+8bamjex0o/KsclUVJMIkcfMqRyJME7T6jE0Ay5wzsMf87RQ?= =?utf-8?q?NFRnKoJXpsRc5O4/HnOggdnD15p0jwHXSmJA1AX27p6IvIvGXAf7w+q+lqC7r5UCR?= =?utf-8?q?yIwvg4KYs1a3mTs3iAPtntu9O67dLKDPlPW3AagxwScjBjsO9Hw4fUy4c9o8uXDY0?= =?utf-8?q?nSOOvfC8w2VoM+2BluyBMNKM6Wa5YFGjJw5eeLaoo9jgGu1hJfhnbHugFUoywJzUx?= =?utf-8?q?sVKLnMlsKFRP4tzlTfedWncZbSumiYdz6E2nwwTLnYcEdBA71DHsHwf1jjIp2xbPf?= =?utf-8?q?CQUTJDe6mX5DgumwgpjI3RnZ7Zml0t7puNcasSFluuDQ0AWYT10OFlqOXCdW2Ys8B?= =?utf-8?q?cCZ6gyn/S7hElLPEbMEOcG3w1dWWqDe4Mzawf5RoTQWkirN9d+/FVAyuXI2V3enMj?= =?utf-8?q?hcnOLnZarKEpSRfhaP0XgYk6YzKJpgaardZqPWFJvoOvnonZueeMPSOPukFql3frQ?= =?utf-8?q?I+jURNgDX4m8e4UU8aYlLh/8o5ScT7bC04QHJ4IpNOeO4LBV2mpTuxhyKJ8NtfGQA?= =?utf-8?q?EdconDus3HIKtmqXX/9Aq8uEin0HHx5ct5MEIpfEUGWvkCRmIQEWdh7NSs8PL8VtW?= =?utf-8?q?s2GV59wss9JUnd5ZMZMXKxu2K77xjOOwp7GnjlSIVDRRs3xk1qs2Y728Hnc0KI36n?= =?utf-8?q?e+xaxQ77S624+d1QHVzYKjWvcD4cauMadOlgbBTwebEc1JL0dEPnWs2JziPQ9J/at?= =?utf-8?q?YZpmXPs8SAmDP6zQfZ0SFnG9KuGhi1GTBuWP03YG19KUKvEpK+z2bbTg9zCbd5waE?= =?utf-8?q?U7wO9XsYuqlTLUWOJEhetRj2qJDLLF/aERDACpEU45An7PuIHDfBF7n52cJ6eKfoV?= =?utf-8?q?cKLVA/07JtKO?= 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: sloVQ1dnxtV5dCveV1dJvUr1HYGYPjBw0u4yzPIRy9DFIJZ9bvmbnmz0vvE0r7I1sYUciNjiBucfeQd4Bvtmxo5SbWzxHOVmZsfMxGp+gGtIVvN5LWoETJmAZypVOB6TD824XOxjtdCOmyl/gR1txhxL4aNPQyGRr4oII62VcfN7YVdheAvTbKkgCqJBxWmYy1cXfZfc/zm2u/8+8GG+MpEeXBl6MmtZJai81Nml28QZkhBldzViIugDrro1iuUxzyroCeDWYFk6R59EWP3Kbo/YaR/E7O44i+R3mgu8FAN0sSe6TZVXBIIg5e7jay4gn2UGZWxcycrK+/8YEd3QT9+3mDPo/IpzQd7WFazM1lIEcz3GMZgvHlgfht39Xwg7batSFNE20K89NA/QU6Yeh+p1T/yuhWnlQQsGxgpEClH33pElsk5yK/BtN3wwn833+oDniXAhUn5NwMkvsVjKw9KgFG6P2SeHQsNdTlVER8Hna9MLRma/T12f605WH4bXxLAdGIUGePpOP4GhpRLNqulKCuG1GDnpKeVr6yIZg7pCo18J90wESPzzUoqeChQxZAw4vRggRvfczAcz1lNqJit2U646ta8PCzXepL+PejNxQjWJwFrEz5RZc+0V5lE6 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: 9488a6f2-6b64-4078-e98c-08dc4183330b X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Mar 2024 04:24:53.2436 (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: 7011bsws7ZuFj/2jPD9Y79XADVjHPHREsSBbQSEmiBS5wGSUjvUae6etVtbXKWQt4FI30Wmfuoh428shxVtxlg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR04MB7362 X-Proofpoint-GUID: DqpbZkLFKAC4aj6a65EkA_k1849gIseo X-Proofpoint-ORIG-GUID: DqpbZkLFKAC4aj6a65EkA_k1849gIseo X-Sony-Outbound-GUID: DqpbZkLFKAC4aj6a65EkA_k1849gIseo 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 This helper is used to lookup empty dentry set. If there are no enough empty dentries at the input location, this helper will return the number of dentries that need to be skipped for the next lookup. Signed-off-by: Yuezhang Mo Reviewed-by: Andy Wu Reviewed-by: Aoyama Wataru --- fs/exfat/dir.c | 79 +++++++++++++++++++++++++++++++++++++++++++++ fs/exfat/exfat_fs.h | 3 ++ 2 files changed, 82 insertions(+) diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c index cea9231d2fda..d4b2cdd87900 100644 --- a/fs/exfat/dir.c +++ b/fs/exfat/dir.c @@ -950,6 +950,85 @@ int exfat_get_dentry_set(struct exfat_entry_set_cache *es, return -EIO; } +static int exfat_validate_empty_dentry_set(struct exfat_entry_set_cache *es) +{ + struct exfat_dentry *ep; + struct buffer_head *bh; + int i, off; + bool unused_hit = false; + + /* + * ONLY UNUSED OR DELETED DENTRIES ARE ALLOWED: + * Although it violates the specification for a deleted entry to + * follow an unused entry, some exFAT implementations could work + * like this. Therefore, to improve compatibility, let's allow it. + */ + for (i = 0; i < es->num_entries; i++) { + ep = exfat_get_dentry_cached(es, i); + if (ep->type == EXFAT_UNUSED) { + unused_hit = true; + } else if (!IS_EXFAT_DELETED(ep->type)) { + if (unused_hit) + goto err_used_follow_unused; + i++; + goto count_skip_entries; + } + } + + return 0; + +err_used_follow_unused: + off = es->start_off + (i << DENTRY_SIZE_BITS); + bh = es->bh[EXFAT_B_TO_BLK(off, es->sb)]; + + exfat_fs_error(es->sb, + "in sector %lld, dentry %d should be unused, but 0x%x", + bh->b_blocknr, off >> DENTRY_SIZE_BITS, ep->type); + + return -EIO; + +count_skip_entries: + es->num_entries = EXFAT_B_TO_DEN(EXFAT_BLK_TO_B(es->num_bh, es->sb) - es->start_off); + for (; i < es->num_entries; i++) { + ep = exfat_get_dentry_cached(es, i); + if (IS_EXFAT_DELETED(ep->type)) + break; + } + + return i; +} + +/* + * Get an empty dentry set. + * + * in: + * sb+p_dir+entry: indicates the empty dentry location + * num_entries: specifies how many empty dentries should be included. + * out: + * es: pointer of empty dentry set on success. + * return: + * 0 : on success + * >0 : the dentries are not empty, the return value is the number of + * dentries to be skipped for the next lookup. + * <0 : on failure + */ +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) +{ + int ret; + + ret = __exfat_get_dentry_set(es, sb, p_dir, entry, num_entries); + if (ret < 0) + return ret; + + ret = exfat_validate_empty_dentry_set(es); + if (ret) + exfat_put_dentry_set(es, false); + + return ret; +} + static inline void exfat_reset_empty_hint(struct exfat_hint_femp *hint_femp) { hint_femp->eidx = EXFAT_HINT_NONE; diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h index 800aea2943e2..5a5a4fd3cbea 100644 --- a/fs/exfat/exfat_fs.h +++ b/fs/exfat/exfat_fs.h @@ -501,6 +501,9 @@ 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); +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); int exfat_put_dentry_set(struct exfat_entry_set_cache *es, int sync); int exfat_count_dir_entries(struct super_block *sb, struct exfat_chain *p_dir); From patchwork Mon Mar 11 04:24: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: 13588283 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 78DFC12E59 for ; Mon, 11 Mar 2024 04:25:24 +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=1710131126; cv=fail; b=IN7KD6TNTwLQOPEPczcAo9+ehpW2mvlofDN+jgtX4XZdTYfxj2MnlrIoclPmYKa4c2iPS5qup5Xvn/LmCtHbhe4Pep8CCpQrJQVFjyphZLagjHDt50C5/oi1TmHSUpvt42WXs42ECA340fdp97gUMuuweLCcFAS1Xky6lNuJZcw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710131126; c=relaxed/simple; bh=LSseWpTBss8HB1jgOajD1UyQVm6JwpPaoMd4hyF8D0w=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=WBEiBUvScFPDPz5UETuKG6rSExULIqyaWyn7XoB5PpUOvhP43CWxYeAQr2mtZVJCG0Lb8d9myI4Fjo1P4E1wqDIkK8qkTTvxemQzKwSDeqjQ1E0TvcjGZO4CZfrdazrdsy4fjXfen6hhUS/W7E6f3yNA/HXQicng0gHmZ8NIMFI= 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=nimLOjro; 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="nimLOjro" Received: from pps.filterd (m0209329.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 42B3b5gh004320; Mon, 11 Mar 2024 04:25:04 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=LSseWpTBss8HB1jgOajD1UyQVm6JwpPaoMd4hyF8D0w=; b=nimLOjroKtZ3iXl1409TMMK12RcCfKf/0PxvM6uG5jJLZfc79PehUcJIRUO4HKtjlNvQ krg8rTF8nJN6bmiqLI3S2KIUIbHdbaLt5f9NxTj009UCusCcvi6ksxmUvhiEqM/9zllS +lYQ5dtJmlj52UK+U0wSqChd0SmpoKFSQrZGZtsJHE8jGC3crOsImw3XiNSGDBoA4zSa 2TCtjUYlw6RDNHHYOrYbRXQxHWhpj051Ve35bBYGQ95r2gpJ8pEYrzafOkTID02hNcqa JPUPHYb820FrNpT8zqVFxjKeKL9gYDiTOpFl1Ibok8eovxkfePcDIH/rvRBR7xQBmPHF PQ== 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 3wree19k8x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 11 Mar 2024 04:25:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZuaDDRBgHDK3fmOc0Sr+P3Tuhghsot+o7RbobynMvEdBW4LulyQHcTS4h4D9EtvKXrqYGejxOOpDfoIoQy6DOViDdqhFyy+oD3T2I0jqEcaadcJj46TpDMl2Ea1xuf4QYVQogBpAoOeahjmv4G9IW+3RHmjhoS1SOEG63s/We3p4VvTOuKvWCP35O9em2jGXhHPmG3q/vI/NtNM4qwrFb0GKhY4VUPSUAnD1TVLzxJ+E79ikB/Ou9m+C7rbJdg/1pqbh9CBGfBl7wM/HMSo0StEQwcDKhN/QGKRzxUohs30o2FZ143Ub3erT069wO4xQvbK3LQXjUUnjgrBl3qkTpA== 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=LSseWpTBss8HB1jgOajD1UyQVm6JwpPaoMd4hyF8D0w=; b=JcOb3Vdnl9C3qqWXMqo2dx79BO0vuQGMbmNDZPjfBbcauIk+Oj2RkCnsNXqtPzsBC1dYhu1Iii682CIz8jby9I+wqNfO6PH5+nKRWnF7mLagdg8PRyW/mFvlDRaroulE3kfwTLatEbpOFN3/xfocAgxXuDJQz239s9p4g0hdW0yM0CRcB5mCQwY2jxFQwUQyd7ODoaRBXaPvTC9fMp36hqvHhYqKZtGGFWi1MSOFqq90eCr1r9Fhc7V6/vU0653axB//7iPO12nJ4SNuKTLCqYbE9XbxKT/oeoLPrvQ8UsKOectXlge26Kc24Gm3+AHVI8qNy4yZzDtmdkj4zMOhbg== 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 SEYPR04MB7362.apcprd04.prod.outlook.com (2603:1096:101:1a6::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.34; Mon, 11 Mar 2024 04:24:58 +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:24:58 +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 03/10] exfat: convert exfat_add_entry() to use dentry cache Thread-Topic: [PATCH v3 03/10] exfat: convert exfat_add_entry() to use dentry cache Thread-Index: Adin2HOAChBhARZuQnuqPVclenHi6HLkXrfQ Date: Mon, 11 Mar 2024 04:24:58 +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_|SEYPR04MB7362:EE_ x-ms-office365-filtering-correlation-id: 7a8fa726-4296-45b7-a5c3-08dc41833668 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: trY8gC7vBepCd0gWRYzWUBzrmbQvxyR68S8FacLPV8qk3e8kn0QAO6Ir+GpWoqOU34Gkr7CFZ4eXoyTDhpwlHWJkzbFInx2P3QRk8U93YfNz5lNIato4lWXOQq0+f9xc4uMnQUKmSu0ow8YX2mr2WEgvJHU3EUY7wSAw779y3ri4EhzJkLIuKQ0nXkbAHx6an8U/Apu4Aorifd4o0ON4HwEPgXttDTfVAXO+NNmRL23p/dD63Xt23F/82LYkW243QmFMVLTAKlSX3nP+0XU4Fb8kvHJ1g9xHxyE9ft+3FbdkvkWhJdWUY3gbtoUcYibBTxBQmZjs5QaaeTroJ92wW7pP7wAoHAtepyWzKjvUzGHWDnqlEYGbt3LEjikD/6f8in27MQPxBxsPr4hWdyKjCO5XP6Z+74chJ6EhS1J8LlliVzKgLGar/iAnrLQBkjeD4wWxfvtHVbo/Opb9IoXHr37zqpvhQGBp0BNdhspv6vaC+Bj4B3MZWROmxhLiyN/JE0db6WU7UjoXcQIcaYs1su6VdDDzUeL/TgTnnq11JXMBXu7sr6iy/kVDnbsKI1rvy8MtguQKlzEvda1VaJrHBlvtbqShUyEBwUbV/ETGec1evqUYoHGzV7E/7PPuSsvCK8D43pOZnkeyVU9DtfYLc34rX0XgqrnH+UtPSw8EHALcGA8D6sI8g2IiAT3pcfrx7bgRrKq7pBqeyn+usaCYcg== 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)(1800799015)(376005)(38070700009);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?0/9AH5wVqQtOvvXxSk0xdsvHbej1?= =?utf-8?q?VhJHrFmR1X4PlqM1+igKFblUUps1OmYc+Jbg3aajjNOURTO7H0jfu0XIf+SaXjXOd?= =?utf-8?q?QZh94KpL7q7S3Jd2YpKnpZgyrinMu6XsEASeKmIuUIRITTMaujrsyH4poU7aX/ov4?= =?utf-8?q?66PrUGeTNXbOsD+yLHsNWlhhOjAVAESVvNI2Xks76evq+9azhPJ6kmODAT2cuBmR/?= =?utf-8?q?CQanrZZk5ZXDwVMtx9zgpLcXZ/ZAKGzjGAMziB3v/MaGETsphmQEaH2ZR4UKV+ZPn?= =?utf-8?q?bYrzdooCApopY5F/DjnCKgmW49iMfL2Jyy6frUfJ+kgdyBV13R3/lM8/YV5IGp9Uj?= =?utf-8?q?wyYpswXkwH6XnND3uWInuqbNrvBuL5s8w7E78NKEJNSf9ZFuK2a54ZlG2dc+aIm5a?= =?utf-8?q?zXzCzC2MV6B1JLUdUDt6MV76eXvH9Q7IruWFdFemKCUjgPZ8u7UOlJsMBrwVwesJB?= =?utf-8?q?M4JerQxoAtt+kU7r2llJ+u+vdQREW594jJr0L/T8TlsyXQJBOXcXTt46CypW6cuCj?= =?utf-8?q?k9Af8vL27ejB1Vg4jVmWESUVt7lZ3blgM3j+Dki21i5ff5iE3+cq8gRdqP+siIPgY?= =?utf-8?q?4oG3pUO7VYbwhM3yhJyHdU10eUhIzbzes2mTGorDbf6uisjKiunwqU1uFvTzquI0U?= =?utf-8?q?Og0Ub9t0iBRaF0nMZV2PHJL0f09F38ZfZ15qSzbMrUHqyQ3Jaxl8j8uhXGCa6Qrip?= =?utf-8?q?MO9m6VG0aU6w1yaxrK1uv/CJuE+Tf0uX2UwglSv8w7g0zRVFTpjXSi925leUEeeLS?= =?utf-8?q?TpRchDWOEfZYLeMRDKS5CypWvx668xThUDamAqTvTP+D68wCwKvyIRVsD9FlrIboh?= =?utf-8?q?Rg6Qx7ApUlWWhzJlg/jf11AtZmGhYjrWncA6nNFnNHlzhRL55dQ/CPnT4glGdUbzy?= =?utf-8?q?PIo6AenKEX9c0JuMTZ0Fe69S7uAzEFEWc8viPgtvssa0ADTSUuUoaaTLWcXQMCGsS?= =?utf-8?q?0OFy7/g+4DWoQJb++kSjK5skPTNPO0qoOYdXSUnx69sD/D5n53aHmB3AwT9cuegwr?= =?utf-8?q?sC6u0jemwpIsjqv5PHIVZgJ3FaSwxsqdlRYEcrKIC7Ms7fvVdqpuwQUGsMYzypsDV?= =?utf-8?q?eeRwEa9V2VI9gf9GhL3hYvp4QQfOjRIYhzcslq8c/A5HdgFQ/3IzHvTZviooA8u6f?= =?utf-8?q?6/Z5UwErI3yzh2n3uSFLWAIKj93RwLGhmZSxslnAkp9qWMebec0ih4hFElT1PTGKo?= =?utf-8?q?DGF9cAfYg0AIEGltzYXADEYkoL88QxlCV6IbEuu/tZAGj8yeJgmIWozx1cW5Oo/mC?= =?utf-8?q?bepAqC9QUyfdy5nuOhEhmPKsrYeRAlVdpeHu5kppihDoWJrNU5kFT4t7bfIuwg7rZ?= =?utf-8?q?IW86XNSxJrY8N6LSmH1ZOu0X8Fx4eOCyxlMw6vDuS0jp2/yX9vYsWVGU258hlNXud?= =?utf-8?q?WG3pPTCgpSB9w2gEwvG/4EFZWCgMK/Yr8/MR7ZYghdmWrok+MQ0f6G+obYFc4HiTi?= =?utf-8?q?VtdSJgTEKfUsYylM2pBlVPE9gTGOTuWI8SwOkfhUGgr+up5q70QBNO3a5TxdjCkFf?= =?utf-8?q?Lr+t527bYH4M?= 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: 5E1aSeVk9BKHyF3+eOaZXHMtpMtycan1bAAX+0gh+2AJwRNI25SMgP1vRiNVBD3avDcAcZBTAtdtviSY8DFx1LP9/0IhhPNWF2CAyiwHIzIeiEOn0lXWhwGRBUdtRe5GMSZPdS7mdfGgedqv6nxFPRqklON27t+MXEeDWFLof0PZrKYPcYrKaQmdV6GHNYREuoxwaFJfdDAkr6UU+E1V8MZL9q+oqm2BohWQHqzxjMASWptdgkUJEVuT06ulwFIcqcIV10qZ7sRmxr3QItpcI9i7x0iEalSYsjZGB4rYsoR41Cm9xIAMgYMawTQkLHvWhTpNssO7udEsrJcEQ45VoEUVl8xzhhHug7MDS07YQrMzWY0cfvjnYz6bPnXk1mm/AJJbmLmslVLn+aajeInbaYUvOX+/qyjUrdjprQCgq5Wn0R81gDvrHunTz2KgjcJkVu8pJPWSBSYboJIG1arvazefvWwjWsw4up0Dfn4iBlNEgsQieIvyAfvaxfTebca3HcnkX6sdEHNl60aHk9IIXGbI+2/O4tX8XzCDM3pOLqLo5FBs21FYvNKBNl9tJITyXByFdH9/+7FJXm1rIGQWnws0SuqIqc5Zc7G7cb0tkeRnnG/CF7puu9Vos4PSDrNo 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: 7a8fa726-4296-45b7-a5c3-08dc41833668 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Mar 2024 04:24:58.8693 (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: fB60+eTgGLUSH+YewbyzdXRyMj41dqW7xAlseJM4LEBGmeqdmx3Cg43P4b5QP42eU6LlfQ+FJ0ykqNzAieS0xA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR04MB7362 X-Proofpoint-GUID: qmIA_UVdtDqaZoonxpSnLUqr_cpdc_t7 X-Proofpoint-ORIG-GUID: qmIA_UVdtDqaZoonxpSnLUqr_cpdc_t7 X-Sony-Outbound-GUID: qmIA_UVdtDqaZoonxpSnLUqr_cpdc_t7 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 After this conversion, if "dirsync" or "sync" is enabled, the number of synchronized dentries in exfat_add_entry() will change from 2 to 1. Signed-off-by: Yuezhang Mo Reviewed-by: Andy Wu Reviewed-by: Aoyama Wataru --- fs/exfat/dir.c | 37 +++++++++---------------------------- fs/exfat/exfat_fs.h | 6 +++--- fs/exfat/namei.c | 12 ++++++++++-- 3 files changed, 22 insertions(+), 33 deletions(-) diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c index d4b2cdd87900..1d20abb0b39b 100644 --- a/fs/exfat/dir.c +++ b/fs/exfat/dir.c @@ -448,53 +448,34 @@ static void exfat_init_name_entry(struct exfat_dentry *ep, } } -int exfat_init_dir_entry(struct inode *inode, struct exfat_chain *p_dir, - int entry, unsigned int type, unsigned int start_clu, - unsigned long long size) +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) { - struct super_block *sb = inode->i_sb; + struct super_block *sb = es->sb; struct exfat_sb_info *sbi = EXFAT_SB(sb); - struct timespec64 ts = current_time(inode); struct exfat_dentry *ep; - struct buffer_head *bh; - - /* - * We cannot use exfat_get_dentry_set here because file ep is not - * initialized yet. - */ - ep = exfat_get_dentry(sb, p_dir, entry, &bh); - if (!ep) - return -EIO; + ep = exfat_get_dentry_cached(es, ES_IDX_FILE); exfat_set_entry_type(ep, type); - exfat_set_entry_time(sbi, &ts, + exfat_set_entry_time(sbi, ts, &ep->dentry.file.create_tz, &ep->dentry.file.create_time, &ep->dentry.file.create_date, &ep->dentry.file.create_time_cs); - exfat_set_entry_time(sbi, &ts, + exfat_set_entry_time(sbi, ts, &ep->dentry.file.modify_tz, &ep->dentry.file.modify_time, &ep->dentry.file.modify_date, &ep->dentry.file.modify_time_cs); - exfat_set_entry_time(sbi, &ts, + exfat_set_entry_time(sbi, ts, &ep->dentry.file.access_tz, &ep->dentry.file.access_time, &ep->dentry.file.access_date, NULL); - exfat_update_bh(bh, IS_DIRSYNC(inode)); - 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); exfat_init_stream_entry(ep, start_clu, size); - exfat_update_bh(bh, IS_DIRSYNC(inode)); - brelse(bh); - - return 0; } int exfat_update_dir_chksum(struct inode *inode, struct exfat_chain *p_dir, diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h index 5a5a4fd3cbea..71b931cf84c3 100644 --- a/fs/exfat/exfat_fs.h +++ b/fs/exfat/exfat_fs.h @@ -479,9 +479,9 @@ int exfat_get_cluster(struct inode *inode, unsigned int cluster, extern const struct inode_operations exfat_dir_inode_operations; extern const struct file_operations exfat_dir_operations; unsigned int exfat_get_entry_type(struct exfat_dentry *p_entry); -int exfat_init_dir_entry(struct inode *inode, struct exfat_chain *p_dir, - int entry, unsigned int type, unsigned int start_clu, - unsigned long long size); +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); int exfat_remove_entries(struct inode *inode, struct exfat_chain *p_dir, diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c index 9c549fd11fc8..07506f3882bb 100644 --- a/fs/exfat/namei.c +++ b/fs/exfat/namei.c @@ -499,6 +499,8 @@ static int exfat_add_entry(struct inode *inode, const char *path, struct exfat_sb_info *sbi = EXFAT_SB(sb); struct exfat_uni_name uniname; struct exfat_chain clu; + struct timespec64 ts = current_time(inode); + struct exfat_entry_set_cache es; int clu_size = 0; unsigned int start_clu = EXFAT_FREE_CLUSTER; @@ -531,8 +533,14 @@ static int exfat_add_entry(struct inode *inode, const char *path, /* fill the dos name directory entry information of the created file. * the first cluster is not determined yet. (0) */ - ret = exfat_init_dir_entry(inode, p_dir, dentry, type, - start_clu, clu_size); + + ret = exfat_get_empty_dentry_set(&es, sb, p_dir, dentry, num_entries); + if (ret) + goto out; + + exfat_init_dir_entry(&es, type, start_clu, clu_size, &ts); + + ret = exfat_put_dentry_set(&es, IS_DIRSYNC(inode)); if (ret) goto out; From patchwork Mon Mar 11 04:25: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: 13588280 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 18B4B11C8B for ; Mon, 11 Mar 2024 04:25:18 +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=1710131121; cv=fail; b=VMPRGDTLU7jNUf2xPcfLRpmSaVegbOTfyr01i/ryndsPFUXCfxXiLkM7+vgjDpsZrJU4Rcz2cSox4g8njit8s3yExacIlI1OgNVVUYxMzFvuSDD6nHt/CtUF4oW4B4dMCpd3UU21HaAJHrUhqlE26vgT2lLJiRIThiYLC8b1D14= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710131121; c=relaxed/simple; bh=n7KXto4Q+kMM5xLS4Aqwoi8xmxywwVMt7y1BTOOk3hg=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=l2XpF1ev67lHt1qDK4q0ui2j0pHmAeEWRLR3FnJ2cnXX6OaXv8KzvCPG5vYpOzXfvui7lpe4Xdmp94EKdrCHgPGdsAF5S/v8qdcOiWLtTzNytBQqF/c1YXj4x4C1NZPTA7oB2Wk9EIPYhb3l7IuSl6TWkXAhM7+kwxWMf6avEJE= 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=dwZD2iKX; 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="dwZD2iKX" Received: from pps.filterd (m0209321.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 42B3eD3R031815; Mon, 11 Mar 2024 04:25:09 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=n7KXto4Q+kMM5xLS4Aqwoi8xmxywwVMt7y1BTOOk3hg=; b=dwZD2iKXi719xYBmC3T5htF1Y95zUrLcE3BfQ2mzQjiaui/Z7j5DaFniCxhWViJ83GBi aSLhb7fbSC/ISRc2DZaosnL8BX+yTCEfFrHwucPxvPTEdKoBfqymjjqn183oQ+wCa3XL teq6ILypQmkb1oRI6DopVKCJPTln4ZiTQMnwst3kzevIBsl+H81RRWEIq52rgdYHy5LT 0o+rz/z3Xjd4dPL7ZBXTWChzV2c0YMhDHYGnfYnTIqxh3Fs4UvPCc3vxZki7esBYuxzO SB6Dfg+R5P6dABelCkpL2DPuElAXZBoEiVq03QoNE+kJXc9bYDwt92Gg8dBI80rnv4Kj pw== 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 3wrd669ety-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 11 Mar 2024 04:25:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kqLZ7N8H1DV7/tVHhqahoC9KDT9zhVNdbQ/CUfQIvXqcc5JBKvCOQD7t7kgHNaTvDg2h0FNslybq4HjAyA43GPnl8GTEjvZiucsGCswGMu2PMUgw2GEv+N0zU8qRyYMZN/uZ74RC/5wQN4i7fOGKhk2myR4zh0cvDiUvZYpzEpAgYkxSUAYiaRCsleK2DmJY+l35t1i5Hn6Zvduq6te6ZNn0AIKosuVVj2hSmQX/fSSqDI8J+Xp2eq2OzX1C0IYBSIBsEgxulvnSpfPwEmoJo+rjZa6YDrV0rrB8SL8beD5nx7RIz70XrQEjoNz+aKmSxkjc2lLjDN4NTZwkrZHR5Q== 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=n7KXto4Q+kMM5xLS4Aqwoi8xmxywwVMt7y1BTOOk3hg=; b=HcSa1TcGLf0MqojjMj8FV/INkR/ow3dkB9f3iEJ8pJYy57S68vggiIz0xeN/l+7BZW4loLQktdE8OcX70C0t23rVtSDgUgmLtwg5cz/8J/tQpjz0t9uOe8fNSp5hsiPaeEXhajlANUid1kP0bufppRJi/3+5q8mgUP9wjGhymVTEiO/Fr6bTJurAo7dVHP3Rq0oefsRrS2vVuD6jJy4Fyl56NtEpKM0dwDMaIolJ79A8CiIxBxiAFqPJbTFRRnrYgIh/JTTFVpU5vRB1BbwhufuLFDPmmaVuML1QsjTWVh0LqOLJFcSh729PVEWs2V1fgHe8HyPxUlXZr7qAlAxrLw== 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 SEYPR04MB7362.apcprd04.prod.outlook.com (2603:1096:101:1a6::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.34; Mon, 11 Mar 2024 04:25:03 +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: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 v3 04/10] exfat: convert exfat_remove_entries() to use dentry cache Thread-Topic: [PATCH v3 04/10] exfat: convert exfat_remove_entries() to use dentry cache Thread-Index: AdiooMwbmTYcUEcLR5WCicuFtdV3d3KyWQLA Date: Mon, 11 Mar 2024 04:25: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: TY0PR04MB6328:EE_|SEYPR04MB7362:EE_ x-ms-office365-filtering-correlation-id: 014e181d-7ed4-4d86-0d1e-08dc4183391c x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Saix5ylSFmtuFxj7jiU566PbivK28V4DAmWVnu7MVBfkppaUKoL82pRuKiZXbRDhLJF3qn9ISzWIEyMvSXUIaQ7Q95lYCJ8xGFQhP0PcRAuogi1JKKSEJjJ2HJIWaGnp1mnjD5s0/BRphWd+gqXH5MdRxbMjZmpB+t1d653u5TlH+HGP60kbpInozh0IEKDc5hfXSyOTD2WFVKa541TmtzCxpbeSHwBHndEFdwsLKKWydRet/73rlAZqoNGanFQTpZA2+CYKNpGGtQkxAAaw7ETbj74gBd8bLDnF2a5fxlDeyK5QFEtvkVzYOfV7QghskViHlap4Xa/jqp5C4wkajRS2rXioFHWV+qbdAcu0SjTogMsjTc3NUjzX3RJ3kuu6uQ9d05lFNIqwJkwGbgc0odBtY2AeQFeN1NVv/pwEr+cp5jJWJS8lnmUgNuupUGUmXkS9q6QLvmwFMxiTQXhg/uqwVPDIKqAs+8YK/OfQxAUvHniv8fd2COAps3iaAeu5mXg1j9GdeiwWZyi1eeslzqRZCAiGx69LaKMM3NwrIfSXrImrCVqxycJ+HbPLgKhI0+W3hm6v/1LKhBYBWIXqOf7eCfk1wjKw6PnRdumB6UII0lHtbWjboTDrbesN31oUyPbfg3FWnOhnnlAsp+MKBhi8GMAR76ZuLX5jHie7p2N1OiwMrZbwxiyYUIPUTF7N7d/rQEWeOZ2UgyE6LYKTZeMyWEyiPo3mXNakt6pwp9M= 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)(1800799015)(376005)(38070700009);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?Jx39acpxyzJmkHtn8AszdLbLdroV?= =?utf-8?q?Np6/aAoJFKakqmRll9zTO4zKPcVl1nD8taRvorWsv+NzL+l66bwMgWwDUUxx8vH3G?= =?utf-8?q?wy2T3KyBliAs6GJsCoQNoBDlsV7LUgSeN4aGO01V17QwSvKHvDAx1Dq8oVSxOZARm?= =?utf-8?q?gkq2BqCZ8EBAOptSh3NfsVMtLq5q4HHX/UvrK+pcW9hB/AAF0rZ+nlvV6GPqsAOvF?= =?utf-8?q?4oG2B0119ku6ZjMGzhjVblMD6Kpmp5jFPB+lqKSkHTyRRrzch8tgqoSqr0TkSxlZE?= =?utf-8?q?JgQRlg7T+YeKlR70PZ7fdmHsHKbN8K5tKodJkmBJ1uYMKuOyXhfAJ4tvRVR5Cn/l4?= =?utf-8?q?0JuKOm2V9S51Aq1zCHRyQTv+VNq9B1jLZRoPMDkIXtgNCSOR+3vVInG+Gr0USruzK?= =?utf-8?q?jBq49OsxIqrNHqE4F6a4VWed8U0gzV1NOxaD7NsQM/u0W+VG1uNM2HG0gRvhuxNo2?= =?utf-8?q?dHxm+7DVYkGG7SzrQ9I/B1RHBYpcE+irXdlSr6bp0JnPYJ1HKzFlOXlBIvMrnxePa?= =?utf-8?q?J8mmOFgtp720yyfjM78T6w3VjncoxxD19SOPBgNZeNcU88AiOhP67yTG3oNbFeeaJ?= =?utf-8?q?Pi2Q4QvpzlJtLVJauVRhMgFOWruwTT6+rf9GBFQ2fcq6MtkGyfPMluFqfvLuZLp1s?= =?utf-8?q?AV9Dv3rZOOiG0wihij2uAVKyH5F3GqJ8eWbGHaVuMS0Miccq/Fu21tT4yh3gbpZ1G?= =?utf-8?q?TvAWlx1eja6UubNxYNMIl9xZnLcNJqg7S2jZmxd1D+K8CHp7E754x9L8Qs06N1jWC?= =?utf-8?q?xhiSEKi9GxyL197QQMiJRSrBwdu0jZqgavwxQS2qfAGbm5jSHxe5WXgVyLiQObzOz?= =?utf-8?q?97dN27hppHJTx2uyLIV2i6lLLws/qTarOBoYPo0Q9fvudWHRiAnTqa+9M3uW2UJ5N?= =?utf-8?q?tGgWw1ePfGu8qOoI9ZmGKraQ73dBYu1PD13U12vmPFDvsWxns867HQ0GvOAzC7SkN?= =?utf-8?q?lyRqItp/7bocOTzVVRl1Wb3bWD6UQIDdzFEAgi6HLQ9O0ZKteB3+2StCkBc0Wkm2r?= =?utf-8?q?24KtMT8emPEwFIxX9O80LTcA2jANH+n8BYdIvJrI74xL780WrsHywlIEhEv4ezaD5?= =?utf-8?q?V6OzOLCDDF3V2Oqt7SOTSq9pKSM4WtGQWL22zbuK0cx0n8TivJSFx/iPeISQbfr8Y?= =?utf-8?q?HaLcggRYOgtg+vgtTws5iykRI2dT+wzwjy1FJHKdHP9qi5MT5MblDW6FX1Wuv8wUL?= =?utf-8?q?tSBLoypHxb1vnAf64EIsLkuGI8AAlioWYeLKt6ZDH8ZuQ08j8OpDxX8UaEwWbKUEH?= =?utf-8?q?d0eCVKr8kXxFWG/I3pgIyw/oM9isui5q9+hAOd3bX+XnqIYOcR2XwClGVHXTADIuZ?= =?utf-8?q?lp0VvnucJqHTS4GgjlTGF39jpgqDwrjFwuOu8JzqbBvhO3toLFO6xhW3028TUZnTu?= =?utf-8?q?3zGPNu4vBaEYRAcIoORHBpLUPxnHZ2AJSDrcCgRZL0ciQEZ+78ez4Ge5CyEWIrCSH?= =?utf-8?q?CXdn9yoV+h3TZt4y3xnY5FYTSt9c02G3mCgk3RE+G99ilLXVSAgl7o9gTL5q4f8MJ?= =?utf-8?q?q8AC9p9kGWxD?= 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: 4HFiDbBQo7DpqAfytbVDx7WGwYNlR+sgFtS7GQLRsQIVTVg5vF0ZEtKDqw4PMEt9H52PksDqyLRmPRGa9vmuOz2iGDKu8ehNL3akOibd7DZXXUCOxUBWL8sGNce1k5IJdSAzX6D2IhZ0SAwsg/hGK03uK7DmfitRTjS1BLyVvjkAbZr4bnkl2RTq11rN/f/r9vh3epbFlPx0lRtnJ4dHy0RlIe2Z8RPtxnkZ2s/aWHQcWdf/IyBJqcDhkXtkoC7Qx1cN7o9aPNQgqHL2CQxmI5Xjs2+KLUicH/hSQzPignzCZMVqpdImLAEWGSk3Px85wapRJw/BdTRQCIKO3lKiNrrCDDjQPmDr8sdCymZz9TSS+IZFxOacOSftc9ln3umTUfzYHZXMKojMzepFlnGU3T1reT0ciWkv9JWRHpI3GriweQ16g+huQVYvtujbn4gt48rgHbmoG0ixmo/P2O56aVEev7VuMXOE4AbfijmwFYlFMC6LDxSmMy3DeD2jSEzw4zamqct8HbfOgY/PzMFyBpY+ro5cTWmbR4axGm5A9gZDh6o+Mb1MOZtw4HQWN0KRxERq7kFDy42TFWwalx5qSQhBuu1uk/8MUi1ux4vNS9gZoMjT8mravtRRnYA6nt1d 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: 014e181d-7ed4-4d86-0d1e-08dc4183391c X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Mar 2024 04:25:03.4278 (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: BaCDr/zUkKmEr4Y6iftBaDm0lnmDloCgLGsHRdQE2H+aXyNDWHRRSX6Fjo7VgNACB3asWVVmChdQ6tAAaJqm2A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR04MB7362 X-Proofpoint-ORIG-GUID: DFGCXgGAZrO94Aa1ekzHn9cYLWBOeINI X-Proofpoint-GUID: DFGCXgGAZrO94Aa1ekzHn9cYLWBOeINI X-Sony-Outbound-GUID: DFGCXgGAZrO94Aa1ekzHn9cYLWBOeINI 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_remove_entries(), to mark the dentries in a dentry set as deleted, the sync times is equals the dentry numbers 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 | 17 ++-- fs/exfat/exfat_fs.h | 4 +- fs/exfat/namei.c | 184 ++++++++++++++++++++------------------------ 3 files changed, 90 insertions(+), 115 deletions(-) diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c index 1d20abb0b39b..d34b50293e2f 100644 --- a/fs/exfat/dir.c +++ b/fs/exfat/dir.c @@ -577,28 +577,23 @@ int exfat_init_ext_entry(struct inode *inode, struct exfat_chain *p_dir, return 0; } -int exfat_remove_entries(struct inode *inode, struct exfat_chain *p_dir, - int entry, int order, int num_entries) +void exfat_remove_entries(struct inode *inode, struct exfat_entry_set_cache *es, + int order) { - struct super_block *sb = inode->i_sb; int i; struct exfat_dentry *ep; - struct buffer_head *bh; - for (i = order; i < num_entries; i++) { - ep = exfat_get_dentry(sb, p_dir, entry + i, &bh); - if (!ep) - return -EIO; + for (i = order; i < es->num_entries; i++) { + ep = exfat_get_dentry_cached(es, i); if (exfat_get_entry_type(ep) & TYPE_BENIGN_SEC) exfat_free_benign_secondary_clusters(inode, ep); exfat_set_entry_type(ep, TYPE_DELETED); - exfat_update_bh(bh, IS_DIRSYNC(inode)); - brelse(bh); } - return 0; + if (order < es->num_entries) + es->modified = true; } void exfat_update_dir_chksum_with_entry_set(struct exfat_entry_set_cache *es) diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h index 71b931cf84c3..a8271248f857 100644 --- a/fs/exfat/exfat_fs.h +++ b/fs/exfat/exfat_fs.h @@ -484,8 +484,8 @@ void exfat_init_dir_entry(struct exfat_entry_set_cache *es, 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); -int exfat_remove_entries(struct inode *inode, struct exfat_chain *p_dir, - int entry, int order, int num_entries); +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, int entry); void exfat_update_dir_chksum_with_entry_set(struct exfat_entry_set_cache *es); diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c index 07506f3882bb..f56e223b9b8f 100644 --- a/fs/exfat/namei.c +++ b/fs/exfat/namei.c @@ -803,12 +803,11 @@ static struct dentry *exfat_lookup(struct inode *dir, struct dentry *dentry, static int exfat_unlink(struct inode *dir, struct dentry *dentry) { struct exfat_chain cdir; - struct exfat_dentry *ep; struct super_block *sb = dir->i_sb; struct inode *inode = dentry->d_inode; struct exfat_inode_info *ei = EXFAT_I(inode); - struct buffer_head *bh; - int num_entries, entry, err = 0; + struct exfat_entry_set_cache es; + int entry, err = 0; mutex_lock(&EXFAT_SB(sb)->s_lock); exfat_chain_dup(&cdir, &ei->dir); @@ -819,26 +818,20 @@ static int exfat_unlink(struct inode *dir, struct dentry *dentry) goto unlock; } - ep = exfat_get_dentry(sb, &cdir, entry, &bh); - if (!ep) { - err = -EIO; - goto unlock; - } - num_entries = exfat_count_ext_entries(sb, &cdir, entry, ep); - if (num_entries < 0) { + err = exfat_get_dentry_set(&es, sb, &cdir, entry, ES_ALL_ENTRIES); + if (err) { err = -EIO; - brelse(bh); goto unlock; } - num_entries++; - brelse(bh); exfat_set_volume_dirty(sb); + /* update the directory entry */ - if (exfat_remove_entries(dir, &cdir, entry, 0, num_entries)) { - err = -EIO; + exfat_remove_entries(inode, &es, ES_IDX_FILE); + + err = exfat_put_dentry_set(&es, IS_DIRSYNC(inode)); + if (err) goto unlock; - } /* This doesn't modify ei */ ei->dir.dir = DIR_DELETED; @@ -954,13 +947,12 @@ 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_dentry *ep; struct exfat_chain cdir, 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 buffer_head *bh; - int num_entries, entry, err; + struct exfat_entry_set_cache es; + int entry, err; mutex_lock(&EXFAT_SB(inode->i_sb)->s_lock); @@ -984,27 +976,20 @@ static int exfat_rmdir(struct inode *dir, struct dentry *dentry) goto unlock; } - ep = exfat_get_dentry(sb, &cdir, entry, &bh); - if (!ep) { - err = -EIO; - goto unlock; - } - - num_entries = exfat_count_ext_entries(sb, &cdir, entry, ep); - if (num_entries < 0) { + err = exfat_get_dentry_set(&es, sb, &cdir, entry, ES_ALL_ENTRIES); + if (err) { err = -EIO; - brelse(bh); goto unlock; } - num_entries++; - brelse(bh); exfat_set_volume_dirty(sb); - err = exfat_remove_entries(dir, &cdir, entry, 0, num_entries); - if (err) { - exfat_err(sb, "failed to exfat_remove_entries : err(%d)", err); + + exfat_remove_entries(inode, &es, ES_IDX_FILE); + + err = exfat_put_dentry_set(&es, IS_DIRSYNC(dir)); + if (err) goto unlock; - } + ei->dir.dir = DIR_DELETED; inode_inc_iversion(dir); @@ -1030,36 +1015,40 @@ static int exfat_rename_file(struct inode *inode, struct exfat_chain *p_dir, int oldentry, struct exfat_uni_name *p_uniname, struct exfat_inode_info *ei) { - int ret, num_old_entries, num_new_entries; + int ret, num_new_entries; struct exfat_dentry *epold, *epnew; struct super_block *sb = inode->i_sb; - struct buffer_head *new_bh, *old_bh; + struct buffer_head *new_bh; + struct exfat_entry_set_cache old_es; int sync = IS_DIRSYNC(inode); - epold = exfat_get_dentry(sb, p_dir, oldentry, &old_bh); - if (!epold) - return -EIO; - - num_old_entries = exfat_count_ext_entries(sb, p_dir, oldentry, epold); - if (num_old_entries < 0) - return -EIO; - num_old_entries++; - num_new_entries = exfat_calc_num_entries(p_uniname); if (num_new_entries < 0) return num_new_entries; - if (num_old_entries < num_new_entries) { + ret = exfat_get_dentry_set(&old_es, sb, p_dir, oldentry, ES_ALL_ENTRIES); + if (ret) { + ret = -EIO; + return ret; + } + + epold = exfat_get_dentry_cached(&old_es, ES_IDX_FILE); + + if (old_es.num_entries < num_new_entries) { int newentry; newentry = exfat_find_empty_entry(inode, p_dir, num_new_entries); - if (newentry < 0) - return newentry; /* -EIO or -ENOSPC */ + if (newentry < 0) { + ret = newentry; /* -EIO or -ENOSPC */ + goto put_old_es; + } epnew = exfat_get_dentry(sb, p_dir, newentry, &new_bh); - if (!epnew) - return -EIO; + if (!epnew) { + ret = -EIO; + goto put_old_es; + } *epnew = *epold; if (exfat_get_entry_type(epnew) == TYPE_FILE) { @@ -1067,30 +1056,25 @@ static int exfat_rename_file(struct inode *inode, struct exfat_chain *p_dir, ei->attr |= EXFAT_ATTR_ARCHIVE; } exfat_update_bh(new_bh, sync); - brelse(old_bh); brelse(new_bh); - epold = exfat_get_dentry(sb, p_dir, oldentry + 1, &old_bh); - if (!epold) - return -EIO; + epold = exfat_get_dentry_cached(&old_es, ES_IDX_STREAM); epnew = exfat_get_dentry(sb, p_dir, newentry + 1, &new_bh); if (!epnew) { - brelse(old_bh); - return -EIO; + ret = -EIO; + goto put_old_es; } *epnew = *epold; exfat_update_bh(new_bh, sync); - brelse(old_bh); brelse(new_bh); ret = exfat_init_ext_entry(inode, p_dir, newentry, num_new_entries, p_uniname); if (ret) - return ret; + goto put_old_es; - exfat_remove_entries(inode, p_dir, oldentry, 0, - num_old_entries); + exfat_remove_entries(inode, &old_es, ES_IDX_FILE); ei->dir = *p_dir; ei->entry = newentry; } else { @@ -1098,37 +1082,29 @@ static int exfat_rename_file(struct inode *inode, struct exfat_chain *p_dir, epold->dentry.file.attr |= cpu_to_le16(EXFAT_ATTR_ARCHIVE); ei->attr |= EXFAT_ATTR_ARCHIVE; } - exfat_update_bh(old_bh, sync); - brelse(old_bh); ret = exfat_init_ext_entry(inode, p_dir, oldentry, num_new_entries, p_uniname); if (ret) - return ret; + goto put_old_es; - exfat_remove_entries(inode, p_dir, oldentry, num_new_entries, - num_old_entries); + exfat_remove_entries(inode, &old_es, num_new_entries); } - return 0; + return exfat_put_dentry_set(&old_es, sync); + +put_old_es: + exfat_put_dentry_set(&old_es, false); + return ret; } static int exfat_move_file(struct inode *inode, struct exfat_chain *p_olddir, int oldentry, struct exfat_chain *p_newdir, struct exfat_uni_name *p_uniname, struct exfat_inode_info *ei) { - int ret, newentry, num_new_entries, num_old_entries; + int ret, newentry, num_new_entries; struct exfat_dentry *epmov, *epnew; struct super_block *sb = inode->i_sb; - struct buffer_head *mov_bh, *new_bh; - - epmov = exfat_get_dentry(sb, p_olddir, oldentry, &mov_bh); - if (!epmov) - return -EIO; - - num_old_entries = exfat_count_ext_entries(sb, p_olddir, oldentry, - epmov); - if (num_old_entries < 0) - return -EIO; - num_old_entries++; + struct buffer_head *new_bh; + struct exfat_entry_set_cache mov_es; num_new_entries = exfat_calc_num_entries(p_uniname); if (num_new_entries < 0) @@ -1138,31 +1114,35 @@ static int exfat_move_file(struct inode *inode, struct exfat_chain *p_olddir, if (newentry < 0) return newentry; /* -EIO or -ENOSPC */ - epnew = exfat_get_dentry(sb, p_newdir, newentry, &new_bh); - if (!epnew) + ret = exfat_get_dentry_set(&mov_es, sb, p_olddir, oldentry, + ES_ALL_ENTRIES); + 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; + goto put_mov_es; + } + *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(mov_bh); brelse(new_bh); - epmov = exfat_get_dentry(sb, p_olddir, oldentry + 1, &mov_bh); - if (!epmov) - return -EIO; + epmov = exfat_get_dentry_cached(&mov_es, ES_IDX_STREAM); epnew = exfat_get_dentry(sb, p_newdir, newentry + 1, &new_bh); if (!epnew) { - brelse(mov_bh); - return -EIO; + ret = -EIO; + goto put_mov_es; } *epnew = *epmov; exfat_update_bh(new_bh, IS_DIRSYNC(inode)); - brelse(mov_bh); brelse(new_bh); ret = exfat_init_ext_entry(inode, p_newdir, newentry, num_new_entries, @@ -1170,13 +1150,18 @@ static int exfat_move_file(struct inode *inode, struct exfat_chain *p_olddir, if (ret) return ret; - exfat_remove_entries(inode, p_olddir, oldentry, 0, num_old_entries); + 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; - return 0; + return exfat_put_dentry_set(&mov_es, IS_DIRSYNC(inode)); + +put_mov_es: + exfat_put_dentry_set(&mov_es, false); + + return ret; } /* rename or move a old file into a new file */ @@ -1194,7 +1179,6 @@ static int __exfat_rename(struct inode *old_parent_inode, struct exfat_sb_info *sbi = EXFAT_SB(sb); const unsigned char *new_path = new_dentry->d_name.name; struct inode *new_inode = new_dentry->d_inode; - int num_entries; struct exfat_inode_info *new_ei = NULL; unsigned int new_entry_type = TYPE_UNUSED; int new_entry = 0; @@ -1265,25 +1249,21 @@ static int __exfat_rename(struct inode *old_parent_inode, &newdir, &uni_name, ei); if (!ret && new_inode) { + struct exfat_entry_set_cache es; + /* delete entries of new_dir */ - ep = exfat_get_dentry(sb, p_dir, new_entry, &new_bh); - if (!ep) { + ret = exfat_get_dentry_set(&es, sb, p_dir, new_entry, + ES_ALL_ENTRIES); + if (ret) { ret = -EIO; goto del_out; } - num_entries = exfat_count_ext_entries(sb, p_dir, new_entry, ep); - if (num_entries < 0) { - ret = -EIO; - goto del_out; - } - brelse(new_bh); + exfat_remove_entries(new_inode, &es, ES_IDX_FILE); - if (exfat_remove_entries(new_inode, p_dir, new_entry, 0, - num_entries + 1)) { - ret = -EIO; + ret = exfat_put_dentry_set(&es, IS_DIRSYNC(new_inode)); + if (ret) goto del_out; - } /* Free the clusters if new_inode is a dir(as if exfat_rmdir) */ if (new_entry_type == TYPE_DIR && From patchwork Mon Mar 11 04:25:08 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: 13588282 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 AE2FA12B81 for ; Mon, 11 Mar 2024 04:25:22 +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=1710131124; cv=fail; b=H7XAlnHb9fr44TPuFgmgZwq9G21cAQiJx6C9veMQcsM9vN9zLLIGZ+YQlPHOosTkKT/lcP3gnVLzbuRM1j2oeSYOeDikr1qf4lV8Jdqyo6ldppi+gZK9f1KObqk2wDYAmhMfQpfHaKkbUnW/o7Xl8uNZ+HyvRK+a9PezqsiGcnY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710131124; c=relaxed/simple; bh=ClHDg9yXO96nfRqgz6SeJri1e9Wdx1wYki+b08NFJOQ=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=hS5ZeOw5uUOADY/eHd90rIRW65y3YsH1wDko/gVEEPm+IHgNa7oTz00/3dasPbuRKhCJPXoXU8Tm25L9pRfeoYA+w+h4hhi/wh1r27hym9311qk1z9l5V7oRwhZ7mCUh0y/8PK5uTe0ZIAHX9t8TBvws1XwKRcr4VMJXvbm2CPU= 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=G7CayjdV; 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="G7CayjdV" Received: from pps.filterd (m0209323.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 42B4EKVq001813; Mon, 11 Mar 2024 04:25:13 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=ClHDg9yXO96nfRqgz6SeJri1e9Wdx1wYki+b08NFJOQ=; b=G7CayjdV0k2SMobd2vvNRSYdmqYi/YkWFCH06LS7kHsWdcmacDUqWV0R6EV3EXqe3K3s 3JcDE/kFTklFVqflayjK4GmlA8Eax2dA/rMFMpjo/RJTqR2pcUmdmDFboLC/5ZtK9OJe pe+d0RotQPUc+jO4wzn0KXyN7YdKoWzLFB0PgNv895UYoxgiSVFFAr2Bhl52xdPUiITY y4z03HQxR5826Q0pB6uI1Ay8+33/DlSwcQufBKUjTR1CMZL5X/sx32FEdf1UVKV/SQgM /d9MS+65liHiNXDAfIRfTWv+Ew6h1Zye5ZZc/b0py6yOldSRobcUUh6HkB385YuRN57d OQ== Received: from apc01-psa-obe.outbound.protection.outlook.com (mail-psaapc01lp2040.outbound.protection.outlook.com [104.47.26.40]) by mx08-001d1705.pphosted.com (PPS) with ESMTPS id 3wsqt585gy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 11 Mar 2024 04:25:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HQ+hxw/ttLWfE6mSbMmzdE6c45LKWc0LqKapD/5d7EM+1gfQ8SYKuRNTzZTE9eDl5ZH3DWIwKPJAltrOE90MyrG4ag9kT7KqVGR6/qZywFuycQpjSvTP8fWI8oA2HusQuOSC9koV/X0obnYdvEloLF6ETwZmmaSH/J90V0vJUvP1i6oU06NT1hn8X+OwON5Q6qhe5lw5/rE07tTTeKl2VNrk65o9gcY+XwWkD2K7Vr1kgFl4SweONVxBr9oWeK280KRLYL7pHfI74HkdZitUp8N8TYBHhUzA3jumawPV2awwO76tzSWIBURxbYRPTyn7SbTibXOjop+KRHO/n8XvtQ== 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=ClHDg9yXO96nfRqgz6SeJri1e9Wdx1wYki+b08NFJOQ=; b=Rp1stGv3/ytjB//LrdgU4aI6zbajqQKd0kiSHNA5hsGnkavYLGgZs84p/xkqKeNt6/Beixj6Hj5Jk8HXYNM3OlagpvB+IQ+IRjsXWhZkGYmXiif23Al4O8GzSgLYFAFQGEMnJGJwCPZniQ0pLgMRjq7amgb1bN650l+qp33b3lfwtVwPpVeVmBU9of7khz/lkEhkPa5uprsqHUEy7yZETze3x+EfdlHU0+VZFdDuepWgif3Lb3GlVhFuNjtDP7ZlJa03D88YQrw7LysnECy3PDeCm3FQdU9yOlqVFGGj/h+NeUk5h1rLPWD8z2cFAL7hRCgyuzyYli1BZEffVBUumw== 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 SEYPR04MB7362.apcprd04.prod.outlook.com (2603:1096:101:1a6::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.34; Mon, 11 Mar 2024 04:25:08 +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:08 +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 05/10] exfat: move free cluster out of exfat_init_ext_entry() Thread-Topic: [PATCH v3 05/10] exfat: move free cluster out of exfat_init_ext_entry() Thread-Index: Adk2K2Rlcvd5MS9gRPmcSF0nOdraqE9PvTLw Date: Mon, 11 Mar 2024 04:25:08 +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_|SEYPR04MB7362:EE_ x-ms-office365-filtering-correlation-id: badc6590-d7f8-44cf-4f33-08dc41833bf3 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Ed+Cv9PyhXfo/rh9OZEaPl1CJBMubFghQAxZl9PZZwMScgKFRgR5q5J8YSiABNf353bhN91c1ZuE521p498a4ft3KmlnmewDkQTOMwiKeksZtEmpGrhjuHL2oZq62Dpch+OmoFnrYdOFZm7hCtxO3pseLHw/NLo6gXyirm4YWmrD/ilHUvbDn1PtUSOfnwiolSHtntIhzB2rL4BCM76+elGtfCf59EeyTSYrFmoa5PN+A3T1hhTVWOsWlDquDWQEcRVuwAN4KosF5CDOfg5ekHk8RvQby4ARWgWYNwqUdZRzhm2mtkzDWwLdFpMNlRCkU6aAJ4l4d64O7oLh4Nkqwe8rH3L1K6UD0tzZcGr6zSG4igAMzYHBqSbBeWT0elT54btgI3YnVAgr6hUvrQUYfkIaWRhxEBZwLwfHP1xVOMBNDA4gpVsyi+/BeGlvAwqpiTUqxbzwkdd2AWT4HHBSdXGuUD7PhI4ZMYJML7daxCwcXhb2hF/EOEVxhJLS0p1PK2H7dZ4jXYMcyMnbYrlz772u0tz+HJCiPKZBXyfYN6ooLJXe88QjWaDn0mzL3QJti+UzwhEdPwFWDZQKTdoAQsecS7DWzBGMhU9fR5ee+CUWdzSw4lvFxWnz0n9ZGPRGNgnZ9R8SFnwcoLFkcxMcCl5OWh+poEZvz9f+6XHIBqoSpMZ2U6Xev00wTq6Vc8Tb+zWqygBf4fHsDIA/6fMmzLY/78RD8gaGhcEgsXvBc9M= 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)(1800799015)(376005)(38070700009);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?YB/WCqXvY8mqQkJADyvyYfBFGJh6?= =?utf-8?q?1yt+UQ1IgDnWgUFDe9eSmEszMht1xF4x5dRe+o2YWmnpb9xr+/kTGHhaU75k2k13J?= =?utf-8?q?FV2btmlk8oIC4aPAKXtwHygyCdngFJMZ199K0uJEs4Y6vilH82T4M5GdZfGi7KzOC?= =?utf-8?q?xx3t1E5LWn+lPEpe4twVQmOyrIrWy2DWInzSvBgcojPlTuMvwqehAqJ1E+VP8EFhf?= =?utf-8?q?t7A6pjKeP1cfNgO/VFimosTN/5HbUcBmbgbvdf8h1SsaExMILUyKEM3Tu/i+S12Vc?= =?utf-8?q?7BUvX20jsg8F2SI9qhjVXiRkjw9eotnfLblbYgyh5zMIUDsTWVqRWtZJFo26hNXOU?= =?utf-8?q?5QDfCtcQP/CyxPc2jAHXOR82QnJEVRoxplK4pwVtaeKyKrvTdeYny7CVoxEBQG4i+?= =?utf-8?q?Lu+gcp0z6w/iMVs2Q+KbjPcHfu7Doz7omp6UFqAs8jEOl/sYppSJNZCnszYbvyFF/?= =?utf-8?q?i7srEF5NFbeRStFTokivceecBTQYjSPeNa1AC8F8iL8WmGIiTzvqMuIhy3OxOJ5h1?= =?utf-8?q?xWmGCGL70Lu9wTjAKVmgeyvGo59AqzSsSgGXpaqz3NWU78htkEsqL+zzrQeq4IcFP?= =?utf-8?q?bGonMBcrHU85iffOqF1sB/uqY9x3EXCoA//k5rRvm7CBxdC6xTOdeAWFvITIHk/Gp?= =?utf-8?q?N/Bgy//2eIEjBgeqF72Am2+HzCZvcREb+6Sv2levLr3gQnY00mZZ7QHYXgka6w/U9?= =?utf-8?q?46gvXzBs/x32Ts6HIgunuj5rKE0kHhfOy1V3b3nBhsiT30bQpNsWyTNmv2KpxdED1?= =?utf-8?q?hcraE2f2RhZSyoy0wvgkWwygQ2WJK6fldpNI8Ie5GgJ6AqopZBYPHZg2IftwnETxR?= =?utf-8?q?Fk8K/3nseMxCnyPMoOtNz7CeWe5j8tFqKkeARndCm5/nLWYKoAKokHvNsn3HyxjnG?= =?utf-8?q?xjWt52tUz81WlxPdVaPmDXEKujo3ZpsddSCPfYcN+Ach9Ll9C+hu75tRDz2oebmYG?= =?utf-8?q?LfRsri0v7Xvcm0MA5JRmO/hPaNF4uHlaCXnd87xt7eV85hj7l6+OnHnoqm4GqZ3Uj?= =?utf-8?q?ClqnX1gaSmtGH7AHqeJVQYBKH+OQhqmzcIm5gJ63wqaXZ9Lw5kV0Tu1/+ky8xThJs?= =?utf-8?q?Q+5XmwmJY4dNoVzptWP3fXzp1VgrxHCZXZMiYCMNXV7g1WCUzGsW5HL8OofgbJJ2I?= =?utf-8?q?BANq+3+kz9mavlZby0ippm0n7lN8tEdf8COBTC/YNyHFwRcjikE6JliRcex1162B+?= =?utf-8?q?GHaT+ATda7ySL3R90aOhBO0ChjJIp1xya0hqtdqZ8jHrImV1HXdXP+UqTAqlSO7oZ?= =?utf-8?q?iCxj2y4ozjGGA2ppaO3wgDrefqweVdgDa+2BwIXKkG3otnOa52apO4elzFmITp5vr?= =?utf-8?q?5043Qhy+z07o8lvrPBLsc6vZAmJW/jKdcR0NwpakB/UAaBcZME908UM+AfRDMJlLi?= =?utf-8?q?4lizjaRoRrK3TcD1thZC6ABS0bHMsPczPlmO3g+wj1CcVSmpttGH7P3Ryow9re8v9?= =?utf-8?q?qIbj4PVR0n3yh2DM7EAS8KooAdHfx/tZpIqlZU/NclYrQ4lLGxtNxxAZ4JfnIC3mb?= =?utf-8?q?odozD6h7B5WG?= 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: /zU4FfwHArnymhOTaeHd7xWwPX7YAOHaS0ZTO5uiNgv0mBiLYFyda3Bc90e/xRTeUAV/ECPhbDfCMGQiKav9ErNJKYFisNQ0r7iQDHF7pY7+W0D5UMkWqzVov8kCH5j+EFq10cvj9IiS57h7Eopu5DUNZNpwFOp8ZfOpXotH2RZEOqOYbVzbFLBR+kxm16YAS+qK0/MOcDkfOaXI3Zu8BFhk0OdSk6qJeeTV6m7AakcfrbkjQN7ei4LHlGcNEYkzcWMQaZfeiX4dVDJZ0dQf/Gv0WMRSvINiS+6LmkWc1n4s9uKnnZwid/skGqsgHhLBTIH2o4tWdcFacKJHJtAbYpeJFQ4BMY8wK8jZX3yxGRtIeAjrL6Mh0r/xUkax+lmrprEwWrz0Kr0dtXrm6jihm0mKg4hN2qepz+RonYu2d9uT291tGOeTxWK2ddLtdtjE/LuPnw5c7z5bV4svEg5oe39Wwov1YJ6qZIUfrPaV97u10w/kzWThY0cX1LHgeewkVzY6lGGt74LYcS269KOICY5eYCtc76NICAodhedo1t91UaYBYYH1Whty1jONJDDNZX2xdCg+t13wWSuc2fYdXCAZbj8e8ahPU3KEkIp9eIsG+F/A9Y4PEp59a5qQkX1w 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: badc6590-d7f8-44cf-4f33-08dc41833bf3 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Mar 2024 04:25:08.1907 (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: e408ZoIR0yGgzSe4key/M/nw20gysCGrmeWRQEQZ+xW8Ov2Cn3g1uB/+5Zbkx9wpUUjLQ3KZVoCOnoiJVgUMwQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR04MB7362 X-Proofpoint-ORIG-GUID: blP-OX9SnVJOMOHOcGKX1uUVjkL8GIp4 X-Proofpoint-GUID: blP-OX9SnVJOMOHOcGKX1uUVjkL8GIp4 X-Sony-Outbound-GUID: blP-OX9SnVJOMOHOcGKX1uUVjkL8GIp4 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 exfat_init_ext_entry() is an init function, it's a bit strange to free cluster in it. And the argument 'inode' will be removed from exfat_init_ext_entry(). So this commit changes to free the cluster in exfat_remove_entries(). Code refinement, no functional changes. Signed-off-by: Yuezhang Mo Reviewed-by: Andy Wu Reviewed-by: Aoyama Wataru --- fs/exfat/dir.c | 3 --- fs/exfat/namei.c | 5 +++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c index d34b50293e2f..85a566c23811 100644 --- a/fs/exfat/dir.c +++ b/fs/exfat/dir.c @@ -564,9 +564,6 @@ int exfat_init_ext_entry(struct inode *inode, struct exfat_chain *p_dir, if (!ep) return -EIO; - if (exfat_get_entry_type(ep) & TYPE_BENIGN_SEC) - exfat_free_benign_secondary_clusters(inode, ep); - exfat_init_name_entry(ep, uniname); exfat_update_bh(bh, sync); brelse(bh); diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c index f56e223b9b8f..be6760297e8f 100644 --- a/fs/exfat/namei.c +++ b/fs/exfat/namei.c @@ -1082,12 +1082,13 @@ static int exfat_rename_file(struct inode *inode, struct exfat_chain *p_dir, epold->dentry.file.attr |= cpu_to_le16(EXFAT_ATTR_ARCHIVE); ei->attr |= EXFAT_ATTR_ARCHIVE; } + + 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_remove_entries(inode, &old_es, num_new_entries); } return exfat_put_dentry_set(&old_es, sync); 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: From patchwork Mon Mar 11 04:25:16 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: 13588285 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 5EFEF14296 for ; Mon, 11 Mar 2024 04:25:33 +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=1710131135; cv=fail; b=eMyio2mCavQ1YH8yGlhsFF17wdsswCVh4DMRt/Gpx3co6FBEOxuwgTrD53R6F3BqQkXNBtFVgpfAl/um/ubZl4y/vdb5YsXxwY2AzltiksgDG+HsSXuS41gBnw3UfZ9QyFOxT7DKYzyNKDTIeWDOBUpdBbLHynIa6hY2WelLR9M= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710131135; c=relaxed/simple; bh=3/6cH/wDJY98age2+HAFkkM3uEcunfDro76cGhZcCkg=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=OJ9DEI6PebOCc3tihFRFCfOiUn6toYrhQBYnTx77UXIuwya4fcFjqvIxwQjIblFbtCC+AjIJuHh4nYM99KHlFov366RMst+I1Y1FF0bcMJM+8cT2wgI3SJGxEaJvxDwbTh+MtQmPWNWvT9JuWROHvkZ0IZdiGtHxCF0DD2gKHlg= 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=GRfbg2+j; 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="GRfbg2+j" 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 42ANjEgS021524; Mon, 11 Mar 2024 04:25:24 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=3/6cH/wDJY98age2+HAFkkM3uEcunfDro76cGhZcCkg=; b=GRfbg2+j24h0zzcDsWddtsnVSDSkun1AbpFT2beqEGJwhSTEdSWJL/WwLaYO11cNIxLf tjN9qYv+BZHQ/WKe0EwfABSD61QTxSiLqgN0HNsg+mXJpD5sBuGrsPyTz8FFYDG1hr62 WCvJ2E+DiWTV5FfpHyvIvPn2NRASB219Q97dInwkEU7cAML9hkjHSwug1z1DLXy7J2La d5MZaX0eSKZrl1e3jRLa4YA98bEirgsL2dH4YcoL4TTQnf913Zm6cDQkiincVrXTVPyk eP8YBv3yrQzBotCCWcx6SgBjsJjBCSirdzVoMgO0t7l0c1SAQpdOX9IvXxc7H67++O3T og== 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-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 11 Mar 2024 04:25:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W2qa7geX54anvjzvJddi+lqw+DlPf34XJDFVJD2QBhCwfBRG800DR3O5bF9uiBc/x2SDhwMywUFwR0bx9kRyU6LVXU8TxsHUeiBvnh1SBBhaz1Qv+ROisqxh20N2s7YgWnR8SNFa+vPA5GS6zm4b1sUGfX9bYG5EfxPLzsqOAk0Yo4Az65DYrT5tAQSaE+Hxiby7qS41wlkyTb1Y4JU2wN93WWyEWxxBDMPeL5qYeo/kJzxs/9XsPTjDG8VfiAcDWIv/wWgijiIE0bvZ4NKf1rC9o2AAgLp91EAPzUwNq1ZNlmlXVIL3kuq+Rqg/hY+b07ZxKEtwWTcU0QViCFyG/g== 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=3/6cH/wDJY98age2+HAFkkM3uEcunfDro76cGhZcCkg=; b=L2sW0BJEbJFz86lt2ReH3PJUrpB+r+LO4B4/PRPkwfHiBvkL2qF5g7WTwaSiva9p7rjgL9gBLwIlu5i7PXn/D+rlVL7s4wzoB0VxEm9JRGcnE/LFrPdmUVlrMwuXWmjix0Kejqg32ptoFUJtHGvFQaQLd50zl74Jdza+D8cxaSbRCIgyShjdj1QXN++7kmVG7wIVswScgw6cmdoNIm3aOzLVPTFX9zn56bLtC5vokcjB2lc0qazj1gotpKCbzndVAzqfQT3dG2oFk0ZYeclejGAO0oypgjP2o6KRpb99YmibG4t2Pbn5Sw2XeKFf5cEnrXr9oPYk/tum4eKBfRkPHw== 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:16 +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:16 +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 07/10] exfat: convert exfat_find_empty_entry() to use dentry cache Thread-Topic: [PATCH v3 07/10] exfat: convert exfat_find_empty_entry() to use dentry cache Thread-Index: AdoLF/aVR4xCnm2LRwWLHBiF9Ra8ZhoUtfpw Date: Mon, 11 Mar 2024 04:25:16 +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: 31f63688-bb11-4b03-a8ee-08dc41834106 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 2jtiMrksGZpnm4+jifJpaIjoPI/BK2LTWVZKbeFmxOeHzD+Nxs05SuGBFsTN2yU3oCFb0jgniPK/FjtyLwcyLh3dBjOXLOzzuHQT4xCdusbFSVc8Ueab4cBGXxup7C/8HQHdnDHwcueh7Rn5uVhdKF8vxP/uZFV/JcDk3dig455asKOqWGu+T0p/3Dxb5hhsTNcMFoyqqZIZU+rlj7n5aYyoq9aO202HKsJvE93MsQJFxEf0NxIm3mobPCxU11tjft/Aoqs0MeE49CFYV+xkTsg9FqGYQthKjiE2zK5/JkZmjw/QijWWnQsGIlWwH/QIBzlx+gV1CLAM9V//1nljpJGHXNvmv4Ssa79FP9HanDZXfDEm0VLGGJzte2oH3QoVhH7ZuqZ0nmWRENuR6Vm1nx8EcSvxWFv0FCVR2w2SQw6ASFqlO78OVEiMXzIdoWO8kwB8av+GVTg/MiS4v5UasJ0ydUrsHiOHpO5pMD45LJ+hULzKM7gx0Nh47Kd/Zm+25F01ST48Xq4rAyqrmq9i34pxgm+xROpxmtassGU5nnX+EUNqBc3/6QU7Whzzd4pJFEdifXsZFtI45pAie4SkdLjGKprevQgM8eHaCxU3pZufrIKzTxzF/D1jHis0yxdVprr3LGWMSkKnM3ZbHSwas+kBdImzFNoUYJ6z1tJIyIPVtsvaTYTC3U2JzD02XpITNIQKf0hucL0WIDDw0PghOg== 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?ZwerorGbuSwAeTf8EvSICxAvXZz7?= =?utf-8?q?nOjRHw0Yt14o6ZDRg9JpssG+MfhsfusL7SmIYREd7DLKZB0wn64fRQ5XtMWhiTbo5?= =?utf-8?q?p0sNKNYNTijLrICMRhQlGOKGVOyRQoOQOXoeCc1nMlWK3KU+oo7K86cD76c2f2krs?= =?utf-8?q?2zMsM5v5dY+MnzJezRuqC6rQeXIarH/qGCVca6xADxNM7AuS4rcc0wqCbkSvU/p0U?= =?utf-8?q?aptMzeKy8Ds+hHF3ws0hY1bawvZk9qw3k0rGy7JS3Ggk/muts55ReFXX/Mnc3yS7f?= =?utf-8?q?y7QKw0AL1+Hyp+0JJ1qSjTmfwFeVOfm4liDpKlcKj1dXRjGU90T2MWxtL1DCcN2XF?= =?utf-8?q?66ODcO1iUslZA9JcIgurIL5ASBq4IUVG63v1I/gR+fw1KEHTbgpHKJxeW4WlJxaY7?= =?utf-8?q?kh/7pPZSKLV/QV2A8HfK2h6eOhnZ0juwGmZ5ow4g8Ix40gYCNDOhqd0H6dxrkmf8n?= =?utf-8?q?rxd2A8unWp7ShIubPDQUrjTRbstJ+7/CyJwDBQBDqrB2t3zlKtdyYOaxov3Jshy5X?= =?utf-8?q?k4LzmQn2sipp1z4NjZQzjVxR23fWJLvKYGJrO8jN7S3Bxro91oBnq/E6vbqEtfTjO?= =?utf-8?q?jUZmJNYo3pJzysfdqkzapeddCRcAJ/7Q/8zTyKKaG7/yd2xEqvkc+b74dF/8I5HWd?= =?utf-8?q?FFUJBu7CbAhAo4XX6KqO4A5i8h11QCacQVBTnpXx59Uj0o/ruA0MIlYkkKbLbEQzb?= =?utf-8?q?+6M4CPOJdQS2qtqsmRTpKT/hO7RfW11FlGZMMzmR/VFu4wrxvj1s8ybMVpKpSAKZc?= =?utf-8?q?PE6zMyTqoD9dM8K0RMNh2qdAO2+Y94vJhedh5nGprRYDPJQVi5UWnwSS3skaueC2H?= =?utf-8?q?VnyyMKvh8b740q9/kTx743qTCcz7r8xPeKIGhBz5FRGIuYvmVjUn2xKqMQ8/aXFX+?= =?utf-8?q?87lgSfaIPCZZ/3zQz7SN2VGYJsIZbX14NqPLglvCK+XrWxC0CNWljnLCSINwyRFft?= =?utf-8?q?DdQerysrydhpe+a/qkSiyuOlnPCnv44o2F1kJsL352ZA8/tNSbZ8geJkJSv3GdNYv?= =?utf-8?q?T0Z5fU0shbtGghLa0Xmv4ju9h1XODkQP8Wbp36BFA1jBWCiOI/MGhjQJ9qX4g67hw?= =?utf-8?q?YFp0XCsAmcpqI4X7aCzmNO8/pCc5ZjOHIQBgPuuqvAEfrJmGWFg8606yzeVbPJVRX?= =?utf-8?q?CnF2pcpWpGYW5yRe1Vio7I5Ib5gwhfj6e2lkWV9wXdvcmIYGDS+GHYmJ3NKeiY91k?= =?utf-8?q?45q+8h7KOvnhTchp/s5TlSLX+4lTwBaTu1DM4mDW+nnr982oDdx8oLwcGa2thiQ5G?= =?utf-8?q?jvhuJoTtCjvhIb/qKngr5um3y28LQE5/ssFoD49yqEzcFBVX/pAKBEPXA/GUbuUrZ?= =?utf-8?q?o4Rkh9YLZgTWlLbUNVEvUgcRJ33foch+mgse6Ihj8D2O31QHIyDE4Y8iedUWfhQab?= =?utf-8?q?M0kqI03EPeNXHC+1qK9bF+idgWwrXkyv356RB6pLbBylRRGdYUfYs7/G4HJx/UQSp?= =?utf-8?q?7n3dG+rHutYAJ8r15vPxeFr3nY4WTvYpxX6//FV3bOGLc+wurQgN4SKPT5XKfwElV?= =?utf-8?q?rmov0EOa40OW?= 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: cKgDsSvIxdJ3nqz0yCBSB1a3f0p8ngNf/bf5RKO29ozCeq60qBzt7OhjtbfFfdyZmeN1rFgXvZX2L0LBaKZPkuHTDnL8eE+rICTqaHiSVH4OxN3mqfeUWCLEdVULJAsnWos0NXgXE6rjd4YHWfVGf/N/nh2Fz5aI6DKQxWTBWdYU6eOs5eCQ2PRa/g8jLP3spPvG1l9O1Ph6gK8Da2ESLuFv/x0S3ngQYDM9o86b+eP7nZfUKff4EvgX3zAqU64OyGLtQz/U1hR9TZKho8B4+kIVStAi9RMYGf7BPWT3xxGwX6IkXTl5xfoz6OICmmGzkwuzEA9XupBVAq+frrph4lR1SRAX38Ucn2PGkWK8/VEo0yaeH8ABIej48d/EzroQYmFNbq/wOl7zYO7Lrsi8bL9+lAcBgFf5bCcf8Mzb+Kq8NAhbC6rbRvgK6LvNrE3auwrZxHV1Yv7dK5dScLDByY3X3HfThSXoRKQaBHSu479rlTtt1TR4pVPcFSjsqvNHYOSZ6LdPlUE38l9E2TNi1rEOuWnEJKCaj9zEfB7c8RKaTHildaTj9e9fgEAeF6yF9dHFhJ1SbE8DVvFeQRE1Jr9eNINnGX0sFtR4ajybTE/V82N9lPX0xwSL3zHO+0Xt 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: 31f63688-bb11-4b03-a8ee-08dc41834106 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Mar 2024 04:25:16.7050 (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: 8ljqLt7qB9NpnhG0yTOlpw9FQiJcBR9YHsgdXrLEBLxuzcEwXYyYtQ3fmU95xKbhKKRI+epRh/3k8Cn/w6xPLQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR04MB6635 X-Proofpoint-GUID: bz6bUWWDR9yjHfSuSlGRdsIj1tTkSgz9 X-Proofpoint-ORIG-GUID: bz6bUWWDR9yjHfSuSlGRdsIj1tTkSgz9 X-Sony-Outbound-GUID: bz6bUWWDR9yjHfSuSlGRdsIj1tTkSgz9 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, each dentry traversed needs to be read from the storage device or page cache. There are at least 16 dentries in a sector. This will result in frequent page cache searches. After this conversion, if all directory entries in a sector are used, the sector only needs to be read once. Signed-off-by: Yuezhang Mo Reviewed-by: Andy Wu Reviewed-by: Aoyama Wataru --- fs/exfat/namei.c | 126 ++++++++++++++++------------------------------- 1 file changed, 42 insertions(+), 84 deletions(-) diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c index 2c6df4f966f5..79e3fc9d6e19 100644 --- a/fs/exfat/namei.c +++ b/fs/exfat/namei.c @@ -204,21 +204,16 @@ const struct dentry_operations exfat_utf8_dentry_ops = { .d_compare = exfat_utf8_d_cmp, }; -/* used only in search empty_slot() */ -#define CNT_UNUSED_NOHIT (-1) -#define CNT_UNUSED_HIT (-2) /* search EMPTY CONTINUOUS "num_entries" entries */ static int exfat_search_empty_slot(struct super_block *sb, struct exfat_hint_femp *hint_femp, struct exfat_chain *p_dir, - int num_entries) + int num_entries, struct exfat_entry_set_cache *es) { - int i, dentry, num_empty = 0; + int i, dentry, ret; int dentries_per_clu; - unsigned int type; struct exfat_chain clu; - struct exfat_dentry *ep; struct exfat_sb_info *sbi = EXFAT_SB(sb); - struct buffer_head *bh; + int total_entries = EXFAT_CLU_TO_DEN(p_dir->size, sbi); dentries_per_clu = sbi->dentries_per_clu; @@ -231,7 +226,7 @@ static int exfat_search_empty_slot(struct super_block *sb, * Otherwise, and if "dentry + hint_famp->count" is also equal * to "p_dir->size * dentries_per_clu", it means ENOSPC. */ - if (dentry + hint_femp->count == p_dir->size * dentries_per_clu && + if (dentry + hint_femp->count == total_entries && num_entries > hint_femp->count) return -ENOSPC; @@ -242,69 +237,41 @@ static int exfat_search_empty_slot(struct super_block *sb, dentry = 0; } - while (clu.dir != EXFAT_EOF_CLUSTER) { + while (dentry + num_entries < total_entries && + clu.dir != EXFAT_EOF_CLUSTER) { i = dentry & (dentries_per_clu - 1); - for (; i < dentries_per_clu; i++, dentry++) { - ep = exfat_get_dentry(sb, &clu, i, &bh); - if (!ep) - return -EIO; - type = exfat_get_entry_type(ep); - brelse(bh); - - if (type == TYPE_UNUSED || type == TYPE_DELETED) { - num_empty++; - if (hint_femp->eidx == EXFAT_HINT_NONE) { - hint_femp->eidx = dentry; - hint_femp->count = CNT_UNUSED_NOHIT; - exfat_chain_set(&hint_femp->cur, - clu.dir, clu.size, clu.flags); - } - - if (type == TYPE_UNUSED && - hint_femp->count != CNT_UNUSED_HIT) - hint_femp->count = CNT_UNUSED_HIT; + ret = exfat_get_empty_dentry_set(es, sb, &clu, i, num_entries); + if (ret < 0) + return ret; + else if (ret == 0) + return dentry; + + dentry += ret; + i += ret; + + while (i >= dentries_per_clu) { + if (clu.flags == ALLOC_NO_FAT_CHAIN) { + if (--clu.size > 0) + clu.dir++; + else + clu.dir = EXFAT_EOF_CLUSTER; } else { - if (hint_femp->eidx != EXFAT_HINT_NONE && - hint_femp->count == CNT_UNUSED_HIT) { - /* unused empty group means - * an empty group which includes - * unused dentry - */ - exfat_fs_error(sb, - "found bogus dentry(%d) beyond unused empty group(%d) (start_clu : %u, cur_clu : %u)", - dentry, hint_femp->eidx, - p_dir->dir, clu.dir); + if (exfat_get_next_cluster(sb, &clu.dir)) return -EIO; - } - - num_empty = 0; - hint_femp->eidx = EXFAT_HINT_NONE; } - if (num_empty >= num_entries) { - /* found and invalidate hint_femp */ - hint_femp->eidx = EXFAT_HINT_NONE; - return (dentry - (num_entries - 1)); - } - } - - if (clu.flags == ALLOC_NO_FAT_CHAIN) { - if (--clu.size > 0) - clu.dir++; - else - clu.dir = EXFAT_EOF_CLUSTER; - } else { - if (exfat_get_next_cluster(sb, &clu.dir)) - return -EIO; + i -= dentries_per_clu; } } - hint_femp->eidx = p_dir->size * dentries_per_clu - num_empty; - hint_femp->count = num_empty; - if (num_empty == 0) + hint_femp->eidx = dentry; + hint_femp->count = 0; + if (dentry == total_entries || clu.dir == EXFAT_EOF_CLUSTER) exfat_chain_set(&hint_femp->cur, EXFAT_EOF_CLUSTER, 0, clu.flags); + else + hint_femp->cur = clu; return -ENOSPC; } @@ -325,7 +292,8 @@ static int exfat_check_max_dentries(struct inode *inode) * if there isn't any empty slot, expand cluster chain. */ static int exfat_find_empty_entry(struct inode *inode, - struct exfat_chain *p_dir, int num_entries) + struct exfat_chain *p_dir, int num_entries, + struct exfat_entry_set_cache *es) { int dentry; unsigned int ret, last_clu; @@ -344,7 +312,7 @@ static int exfat_find_empty_entry(struct inode *inode, } while ((dentry = exfat_search_empty_slot(sb, &hint_femp, p_dir, - num_entries)) < 0) { + num_entries, es)) < 0) { if (dentry == -EIO) break; @@ -515,7 +483,7 @@ static int exfat_add_entry(struct inode *inode, const char *path, } /* exfat_find_empty_entry must be called before alloc_cluster() */ - dentry = exfat_find_empty_entry(inode, p_dir, num_entries); + dentry = exfat_find_empty_entry(inode, p_dir, num_entries, &es); if (dentry < 0) { ret = dentry; /* -EIO or -ENOSPC */ goto out; @@ -523,8 +491,10 @@ static int exfat_add_entry(struct inode *inode, const char *path, if (type == TYPE_DIR && !sbi->options.zero_size_dir) { ret = exfat_alloc_new_dir(inode, &clu); - if (ret) + if (ret) { + exfat_put_dentry_set(&es, false); goto out; + } start_clu = clu.dir; clu_size = sbi->cluster_size; } @@ -533,11 +503,6 @@ static int exfat_add_entry(struct inode *inode, const char *path, /* fill the dos name directory entry information of the created file. * the first cluster is not determined yet. (0) */ - - ret = exfat_get_empty_dentry_set(&es, sb, p_dir, dentry, num_entries); - if (ret) - goto out; - exfat_init_dir_entry(&es, type, start_clu, clu_size, &ts); exfat_init_ext_entry(&es, num_entries, &uniname); @@ -1033,18 +998,13 @@ static int exfat_rename_file(struct inode *inode, struct exfat_chain *p_dir, if (old_es.num_entries < num_new_entries) { int newentry; - newentry = - exfat_find_empty_entry(inode, p_dir, num_new_entries); + newentry = exfat_find_empty_entry(inode, p_dir, num_new_entries, + &new_es); if (newentry < 0) { ret = newentry; /* -EIO or -ENOSPC */ goto put_old_es; } - 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) { @@ -1094,19 +1054,17 @@ static int exfat_move_file(struct inode *inode, struct exfat_chain *p_olddir, if (num_new_entries < 0) return num_new_entries; - newentry = exfat_find_empty_entry(inode, p_newdir, num_new_entries); - if (newentry < 0) - return newentry; /* -EIO or -ENOSPC */ - ret = exfat_get_dentry_set(&mov_es, sb, p_olddir, oldentry, ES_ALL_ENTRIES); if (ret) return -EIO; - ret = exfat_get_empty_dentry_set(&new_es, sb, p_newdir, newentry, - num_new_entries); - if (ret) + newentry = exfat_find_empty_entry(inode, p_newdir, num_new_entries, + &new_es); + if (newentry < 0) { + ret = newentry; /* -EIO or -ENOSPC */ goto put_mov_es; + } epmov = exfat_get_dentry_cached(&mov_es, ES_IDX_FILE); epnew = exfat_get_dentry_cached(&new_es, ES_IDX_FILE); From patchwork Mon Mar 11 04:25:22 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: 13588286 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 4BF5817BA1 for ; Mon, 11 Mar 2024 04:25:39 +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=1710131142; cv=fail; b=AaY4luvCUlVzqLJfAdcwMizPtahvjSGXZBzN0llV6IKdgyHxLmDSVUsSLqfu04QLFIQVybeGVXzMR2QQsbdWYHbCbDb9qV6KaIvCfULZOSBAOqZ9vcSkZTqyVV2DRHae0Jgov8Vk4cq/fLAZ62PftqVh3EwYU97tLvbj4LdTTh0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710131142; c=relaxed/simple; bh=wjmzE3N8ZLCReZ+zcGvb7uzyCcTV2KO5e7dqaEhiDp0=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=eWh8g9ZzRGoIIk33n41Nw6np1wp9OsJuXhjJbLw6AYX40BWPr1YzHP0DwCsrPNvMsPBNDn3Bxu6UUfroQHh42pv9PT4jrGyP5V8Kh/DJ5TdKwF1bohlReJ6ARTl4NEPH4js2kerjWw/5HSypOG0SY398krebVYHyxlTjdKCtJDw= 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=J4BqeUmf; 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="J4BqeUmf" Received: from pps.filterd (m0209324.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 42AMVSlA006255; Mon, 11 Mar 2024 04:25:31 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=wjmzE3N8ZLCReZ+zcGvb7uzyCcTV2KO5e7dqaEhiDp0=; b=J4BqeUmf07wPdnhbYw7/WBXmSzT5N2y5vIK1PnX84fr6WlZ2p+Y2KeECTpskHWrkHh7d nnGBEDKp5IIHQFVMMM7TgGfoIQ79cz8llKb/lJRlhMmAdkxIa+Nj919SsZEV1BwIAjTH lLLQ/UQAlsqJgaaM+5oljXT2evrbKT/SR7tuPC5EOKhCl0PPHe0ur5Fb2mKqBDxWS3oQ 3J3drLZLzvGmw7Ir/ZM0JdfKR3Llx/5H3nmL7x5fRCqVQnr0JYwLcRuVhpObeFDazoYd aoC7HIPROHgTdXOic4dHxfazJBu+yHebbHX+Iw6SN8NFolxrf5i1vKLtVw2RJ7ZlvfAt nQ== Received: from apc01-tyz-obe.outbound.protection.outlook.com (mail-tyzapc01lp2040.outbound.protection.outlook.com [104.47.110.40]) by mx08-001d1705.pphosted.com (PPS) with ESMTPS id 3wrcx79nbr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 11 Mar 2024 04:25:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m5M72KdCETWGrdW2eDARsZ0XAahD1LphJyXQobpfPU7aib5JJBYe54M+ug4lkvof4mKScxrxGIHf4alu8bD7TIZH0kRdP/0RGA3hcRv6QCKAVYaui2dlph8p8flLHjvUg6A20UXLooB4z1j37dgrUDOqgegwf0lvab/9p4gpq0hP2Dab8lN1fMO1tjeVDvDtgfsB3jXtiEZ12QEki7HhjuFLUF+cmTWeH7/eaSQjfsIcgLsnw82sK/4M3Qu1aPZC06feSO+3nsfQEQrlSPoJLFdLqyJ7H1KT2Ni7YxubpDaU7WyeQGK8vgA6UGcmid2xtdIgRr14KnltQDkLHKvU0g== 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=wjmzE3N8ZLCReZ+zcGvb7uzyCcTV2KO5e7dqaEhiDp0=; b=m/tJuHntGofTsGXUwDAqsv/E4Bl+6hJRKxAeC8CFJ32IxfRKDYg7hsb0VdqGSHL/a/s/jI2KX2HEyIZTnjNmWKSxpn2hGdueA948mTQ7smYaFgyxhqGpnZfhxk0wnORb6LcN0VUyfTMyIqmVr8b/bUPXY+PBwWUyTLK0G85m9+01PPaTGz7mtKE4Udp7MNvVXVqcbIEg076NHsh6G18E8510lEQwC6bhqmFneolzjmduBkR9/PPHf1bcCCIe31TAJQ2cBchoxc8Hcewn8E0zioLfLAdg9+gr/LcQAT69AGigSE5wdLuMLBSZ8ZZdC4VqP6lkIStepBbGoeBya2K6rw== 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 TYZPR04MB8020.apcprd04.prod.outlook.com (2603:1096:405:b0::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.33; Mon, 11 Mar 2024 04:25:23 +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:23 +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 08/10] exfat: remove unused functions Thread-Topic: [PATCH v3 08/10] exfat: remove unused functions Thread-Index: AdioqVU2cw34s+96S16hkmg3u1B6mHKwcanw Date: Mon, 11 Mar 2024 04:25:22 +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_|TYZPR04MB8020:EE_ x-ms-office365-filtering-correlation-id: f0a367fb-c2c8-4f7a-210f-08dc418344c5 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: v3DIurtWohdRlpOfHzrVDFMlqwOUq9Naut8Hs4LfuI8IA3cqaVMnWI9SHkqHk7jQcXymJ7NsMOC2BwTKh6L+MlRy/PV+7OycyBnPAQazlRKb+5XSjoGnMRHbty7pMNfVKpFZ2puA1jOOfgkec5RtZxe0PBWWxXPr8zQGZVwzjE0JMfYz4o8ycQoj7BsOh2v5q55XftjVf9xA0yGG7snZnxrDS+FitIhxcgeqQyvqMnvksElgPTEM2irDAYdFrkdo7J11P5FCmpqLjhZSYOaA210xD/uVGVmBObkIdk+izFDZ/1zgzLMC2vguL0lOK286b6rOVupeg1lLDUAISdaBrM+f+01AzxcbBdPWxY5gxTvvwZ6795dWX5G+ZBksSsQPygdQEWRfYxqbAKFpVLdwEGf5P3gvCmfiknOm+8w/eS6ah3qSHGagENXTOcdMW4YrAsoifTB+FzwqYG0ywckboyy5qNpYV8aL89vT/qlqRN+Uk7bwgfhCvT8PbzeFSqmesbr0TLs/1OKcLNwdu3u/DPBjSFi5nDJdCPMxvWF4uEezO2QaJ3A2SG/RuCSSXtiF4JVkumhd3ZaUwPgvNrgKqF45wLCFM4kFjkC6NqMC9Dgv8cr3s0+mHbiQv6MwxhdFebKDFfxVoMUT/Bl6PPB1/i6KlI7Ps3xIWtiwNEBXxhICacoFmJSFcEEMSKJj4s6aSr5eir1JDC0+I0dfwwqWHLo/+19W/O6G0CcvuAep3NY= 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?tHnloxq4UPsHFoHq57g59VbAo1QJ?= =?utf-8?q?3eGhKY0g10nEGN2UEzF1PC54RLamCW/J5IAbds4vL7AXQ0jh0/Zf7O0f9aPjfa7nx?= =?utf-8?q?P4Gz7ewe1CQkaKRqKnBKl5BzbsKh3s/zoCK+PbsgnGjjse6/pXyTor5+/Uhq+SyIq?= =?utf-8?q?29x5DOAYs7cqp26fMlueXh3GjO59cIs1+UNMXmEwiZ6NNrpyhvkhwiQ6E+5mZFoUz?= =?utf-8?q?EaRb4tQrfwuqIGmpmCrXVp83u0hN4kvNzDoorzqRGVmUKILy87E50EHTXKlAfi5PX?= =?utf-8?q?OxX6enHLgWeZd8MCb0H5oRTjNxnMplgL1Sd00wdI1EkgBaa2XOsez2VhJh04spBXG?= =?utf-8?q?pEFeyCqaZPbhON/gx3Sz1QRycLc1Ty0MYG8UFeV1XP0Fxm7imXI5BUSJzy/78gvxv?= =?utf-8?q?Z+iJCp7vK1LAsvyuGCnwJb4uc55SbHZYn4bJNhRrzG8hyq2QxiahuZxmgAtMBhIRz?= =?utf-8?q?Rig9pa9InYbX3Nk/7MiG3FvFgc4gCNr2c100sj9w0GmIR5WX8iAdLqQYOo4E/uB8r?= =?utf-8?q?77YpiTzACTQ1sZ9VXFvv+hlH1Ryvm+0JMNykq6o0Scnmxgzn/N5mAA/V/YS4pdP3j?= =?utf-8?q?h6WwPwTQWsxAVvvSXEHOoLWANXx6i9nTgHa/f8ktnF485AuMnDXctezzfpHeW+Bo5?= =?utf-8?q?YVFyHX/2xmtdL5v7ge2znkCpadVx2Q1SZ+lETzGja/usOPhvR1MpRE0bt7ImZQLtk?= =?utf-8?q?E286Ikk9He/yqT+BlJePhyHYlbZrWONJSY7VhBrwljifZxlTJHunJkj7Hu44Jp8Ba?= =?utf-8?q?TVOo6ZkdaEzNXLPQ+Se6sGPcC3Yemr7InZKSHaSikfkRmGPgIMPaMOwKqhw3AhqmX?= =?utf-8?q?X/4A56rHVo6zPIN2ZlUle8rTYNUXjKA2oJ1cnTfXTpSHwfOUiKiRPjsgTFroPyE/u?= =?utf-8?q?8swsye7ce7e0wHDwTVdomAXO8voQV2Rxhrfqt8N3XhmAsI+ebHHE6tiS0ZB2jMUZj?= =?utf-8?q?VZuCOtDjLVMt504sD9w9LANt4ZkZ+7FegrL4sddEielg4uCRWAZw9YvVlq1T9WjNw?= =?utf-8?q?WWIK4qBjJb3A5/w5FD4YwPrTAFMydiFUmc3Jw4W4rEK8jq53Iwl06ax2oKM4z3Il/?= =?utf-8?q?SvdnLzDW8Y0n/pMDJDVGsXJUa2wwKfyK1o55Rn9jQPKUlL0B03LAjmv30UG5U1b/I?= =?utf-8?q?hbO6XcreqZ+92wdJKBYnvLpWy86yw0VcphN2IE8sSOHQYnyTjnL+ZnIyPXwpTl3gk?= =?utf-8?q?sfJD7HpW7UQ+XYat1CTDB715U1XqHZB9EhfVzMiYc6NuRPNCdVt71KaUoFB0SfI80?= =?utf-8?q?3NUvysVMpVHWvkDxPP7utLL02mltZST8ZMYXhoxlMxBsfAyLVWDnRbZ2/PSjFTV/y?= =?utf-8?q?KLL70w0O9b+CthRLSCxJvSQdUYUFFKbV/i6e20p0TEqYW1V4kecCCSp5Z+5PG9Ys+?= =?utf-8?q?/7x+5CPwaTzBHcX48Ni/1w32XaL54+Wohn3lfFS2chnvq1PuHtkkdo8qjTwlGKBBE?= =?utf-8?q?qCVPCEcoGovwW8r9J0fplyGEWKW3kQ1WnrjiXvl2x0EiB06oKr0QH1Ao3I+fZxml9?= =?utf-8?q?qjGAXn/Fh+kO?= 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: YN7QFVsDanMnm+8GrtRZ6g9ItMtLcla+NQXlRfEzgJ4ZcS7GD7uMXpwF4F0GOYHJB51SFRyq+p8cSlr2cmyBRyIviNvZ5Ue2o6ueDpWw1SdSz9NK5nZL7BBrx8uvAgyW5x+GAcT3Lups6HsR/blN/m2IksmBKxxpSFBGd2EyMkpRH47Mk4yku74/hKBEhm9+l9KFLYimU5ALYU1n/7RTMprC0cM5bpQggfzkRBxegHqTjrJjIOXC1R+n1zXLqaO+4p1jUZ2+59kYv7GxljekVuOoDJ9BLnMR8pxcdQhtbtLFuQGbRm1wRLfJBb8H7NGDt3PXDjKD/Za9tLJo2eXt5UTK2J9FGn7eWoUM31hss2qNEeDh+Gw57Lgg3kUhdZ5tbAtW/SIAsb1Si821FPvl4+6fYCH1Dt1ZjewF9mLWUuCG1w63loXm4TOMHtT0XBtOIrjQdhem1IQ9cKGE39Z4jNqjCxicvidbiu2BvnqA4rz2Shcgvmr9XW5oYAm0q2FSsIOjQRZNT2U/Sj+8u9JkbCtSgzT8MO/RU5aYl+9y/LWK6Dk34V2DmwxcRBVNb8r8dJGT2/+YErrRDklN18JATp8LYANIi/40noRt+ADzX8q9Xu4LndxWRXBLS4lr3vZF 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: f0a367fb-c2c8-4f7a-210f-08dc418344c5 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Mar 2024 04:25:22.9845 (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: qIzz7Qer4ZcimMnlsYfmRrVQRsNMr/RSKToecVLWb/QVzv9SnQUPpKstaGwcpjLvtjSXiVcfo1DOTSiJTDuOOg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR04MB8020 X-Proofpoint-GUID: L5NOUtah5FfwEZ_65ClgOwh8N2NyXBur X-Proofpoint-ORIG-GUID: L5NOUtah5FfwEZ_65ClgOwh8N2NyXBur X-Sony-Outbound-GUID: L5NOUtah5FfwEZ_65ClgOwh8N2NyXBur 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 exfat_count_ext_entries() is no longer called, remove it. exfat_update_dir_chksum() is no longer called, remove it and rename exfat_update_dir_chksum_with_entry_set() to it. Signed-off-by: Yuezhang Mo Reviewed-by: Andy Wu Reviewed-by: Aoyama Wataru --- fs/exfat/dir.c | 60 ++------------------------------------------- fs/exfat/exfat_fs.h | 6 +---- fs/exfat/inode.c | 2 +- 3 files changed, 4 insertions(+), 64 deletions(-) diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c index d43dc5f0d375..49fe6b71e957 100644 --- a/fs/exfat/dir.c +++ b/fs/exfat/dir.c @@ -478,41 +478,6 @@ void exfat_init_dir_entry(struct exfat_entry_set_cache *es, exfat_init_stream_entry(ep, start_clu, size); } -int exfat_update_dir_chksum(struct inode *inode, struct exfat_chain *p_dir, - int entry) -{ - struct super_block *sb = inode->i_sb; - int ret = 0; - int i, num_entries; - u16 chksum; - struct exfat_dentry *ep, *fep; - struct buffer_head *fbh, *bh; - - fep = exfat_get_dentry(sb, p_dir, entry, &fbh); - if (!fep) - return -EIO; - - num_entries = fep->dentry.file.num_ext + 1; - chksum = exfat_calc_chksum16(fep, DENTRY_SIZE, 0, CS_DIR_ENTRY); - - for (i = 1; i < num_entries; i++) { - ep = exfat_get_dentry(sb, p_dir, entry + i, &bh); - if (!ep) { - ret = -EIO; - goto release_fbh; - } - chksum = exfat_calc_chksum16(ep, DENTRY_SIZE, chksum, - CS_DEFAULT); - brelse(bh); - } - - fep->dentry.file.checksum = cpu_to_le16(chksum); - exfat_update_bh(fbh, IS_DIRSYNC(inode)); -release_fbh: - brelse(fbh); - return ret; -} - static void exfat_free_benign_secondary_clusters(struct inode *inode, struct exfat_dentry *ep) { @@ -552,7 +517,7 @@ void exfat_init_ext_entry(struct exfat_entry_set_cache *es, int num_entries, uniname += EXFAT_FILE_NAME_LEN; } - exfat_update_dir_chksum_with_entry_set(es); + exfat_update_dir_chksum(es); } void exfat_remove_entries(struct inode *inode, struct exfat_entry_set_cache *es, @@ -574,7 +539,7 @@ void exfat_remove_entries(struct inode *inode, struct exfat_entry_set_cache *es, es->modified = true; } -void exfat_update_dir_chksum_with_entry_set(struct exfat_entry_set_cache *es) +void exfat_update_dir_chksum(struct exfat_entry_set_cache *es) { int chksum_type = CS_DIR_ENTRY, i; unsigned short chksum = 0; @@ -1239,27 +1204,6 @@ int exfat_find_dir_entry(struct super_block *sb, struct exfat_inode_info *ei, return dentry - num_ext; } -int exfat_count_ext_entries(struct super_block *sb, struct exfat_chain *p_dir, - int entry, struct exfat_dentry *ep) -{ - int i, count = 0; - unsigned int type; - struct exfat_dentry *ext_ep; - struct buffer_head *bh; - - for (i = 0, entry++; i < ep->dentry.file.num_ext; i++, entry++) { - ext_ep = exfat_get_dentry(sb, p_dir, entry, &bh); - if (!ext_ep) - return -EIO; - - type = exfat_get_entry_type(ext_ep); - brelse(bh); - if (type & TYPE_CRITICAL_SEC || type & TYPE_BENIGN_SEC) - count++; - } - return count; -} - int exfat_count_dir_entries(struct super_block *sb, struct exfat_chain *p_dir) { int i, count = 0; diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h index b43430aac69b..0dec910177e1 100644 --- a/fs/exfat/exfat_fs.h +++ b/fs/exfat/exfat_fs.h @@ -430,8 +430,6 @@ int exfat_ent_get(struct super_block *sb, unsigned int loc, unsigned int *content); int exfat_ent_set(struct super_block *sb, unsigned int loc, unsigned int content); -int exfat_count_ext_entries(struct super_block *sb, struct exfat_chain *p_dir, - int entry, struct exfat_dentry *p_entry); int exfat_chain_cont_cluster(struct super_block *sb, unsigned int chain, unsigned int len); int exfat_zeroed_cluster(struct inode *dir, unsigned int clu); @@ -486,9 +484,7 @@ 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, - int entry); -void exfat_update_dir_chksum_with_entry_set(struct exfat_entry_set_cache *es); +void exfat_update_dir_chksum(struct exfat_entry_set_cache *es); int exfat_calc_num_entries(struct exfat_uni_name *p_uniname); int exfat_find_dir_entry(struct super_block *sb, struct exfat_inode_info *ei, struct exfat_chain *p_dir, struct exfat_uni_name *p_uniname, diff --git a/fs/exfat/inode.c b/fs/exfat/inode.c index 0687f952956c..dd894e558c91 100644 --- a/fs/exfat/inode.c +++ b/fs/exfat/inode.c @@ -94,7 +94,7 @@ int __exfat_write_inode(struct inode *inode, int sync) ep2->dentry.stream.start_clu = EXFAT_FREE_CLUSTER; } - exfat_update_dir_chksum_with_entry_set(&es); + exfat_update_dir_chksum(&es); return exfat_put_dentry_set(&es, sync); } From patchwork Mon Mar 11 04:25:27 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: 13588287 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 04CA217C77 for ; Mon, 11 Mar 2024 04:25:42 +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=1710131144; cv=fail; b=JLso+cdeSIJmBHLIfGj+Dpq7Kt5YAf7RM0nc+DfNYB6sNDdGxf4Dnu3S7AT6AKa2wxQ4IabPBEE2qczzWWM9SjRI/QUVJGl/DL/2bFhe+te7qPa6HittF8QCinKNoLShKxNWvh/B/iqv/JdqSCgJxDygxO0XkUPklKnwUCaRLT4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710131144; c=relaxed/simple; bh=/4u/TY6uNxij5w/Kj9dXl++kd71MU1xXNXwr9AXACS0=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=oX+eJ2x+uWDLlIM9HO++3/tBnvpkXK6Y+2ZgTlkYl84Qyl/A9LOeYiN7L6uHNQK7UPikKGwtdYAIrCIxAyAo+EAlk2sxvSp+aUPIFynwQyau3RhlFSoqOOURpKAaQt7R8MChH3NkH3mTvXPtE/iGwEGQXg9tuwlRlPxZukJqKXM= 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=J0kohaBg; 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="J0kohaBg" Received: from pps.filterd (m0209326.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 42B0MdoW032336; Mon, 11 Mar 2024 04:25:33 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=/4u/TY6uNxij5w/Kj9dXl++kd71MU1xXNXwr9AXACS0=; b=J0kohaBgR3iN+vQzKjcfSYLKewC/zv8s6DM0F8HYj3H1ng7IFbB8FFjndC7RtGf1wZne kL+jF7pDgrpT+0N12mU+aYpiJkTT2CpPSD5obaCFofALMS/5eycLBvqUoVQCPGKzB5os PBevQAAWkEyzWicH7ipmt5ZJkZsQKj5Q3t20sWWguak5QpR3qVjTLgWgg0xLkP1WHBML 2szQNWKmpuPw32Ozb/NoM7On9l1TV1sbpf6VGYcBdsTTeXQBEjWnhhlxtqm715B/Ion/ 1AiO+G6pEHGsYFl3diQHu6rhDYVwU4e6vupRAUgQ/+dgKoJptpgagLjNBADl4ctVOshT yw== Received: from apc01-tyz-obe.outbound.protection.outlook.com (mail-tyzapc01lp2040.outbound.protection.outlook.com [104.47.110.40]) by mx08-001d1705.pphosted.com (PPS) with ESMTPS id 3wrdyk1knh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 11 Mar 2024 04:25:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jRJAmt+rmhlh3NTkBjrkxNqp1DbbY54dq5f1G6E+YSMF9CdZtA3ElglVwXcVdYyyhgHUttJbKL2OhUrBeQkgJ1Wz26KQ/+Wy3ZPp7oYSZFXnfTbp29LDvLYS/XYFWYUtVCbY7OrsZwFK311eJKKJnhGtcJtwBGP+dEA9xmINtFl/4UwgEDFQojtRFUt2qrTtuVMJvVIBcgBZSGBC758D4AQ1cLJ4x/38G0udKFwlxdeEQ+5T01dP58k/4KfppkDtDTADA8bYA6yWq2xq29c21JvCNUF5J+f8sLKxI3ftFOjag+YiZ8KBICL2ZutYwVChyH7XaoPaiyi1ZPbRJb9sag== 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=/4u/TY6uNxij5w/Kj9dXl++kd71MU1xXNXwr9AXACS0=; b=hEnJkOCBZq+yB9+1cg0bs7k1NC50Q/Y1TJXvopZg4Fmlmdee6VgkwRN6fbkE4JY2RPdPYZgJ8qHLeK9O800aLcyBKuaqjLl6UcNG8giKU3h7MYONQCKop01LH/aZ49FiTsKMGkLI29saADwqdTvIJy2kgmViuBrIgAiirSzR0dpgHcLfQ/+Lz+dUEktKBSX2MYaqH1FcXdG+G8Sw6yprkxiSV4DupvF3r142EdZ5SnW0CIgDW64Dh2FQYbrjKkM6lV77ctlkU0EzQVC/YpYvp5NQgeM6PAoCSnQ2nSFVXAkLVa9S/Wz12UHFllO51ToIHj78WaoS2exsUb4h/1Hg0w== 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:27 +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:27 +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 09/10] exfat: do not sync parent dir if just update timestamp Thread-Topic: [PATCH v3 09/10] exfat: do not sync parent dir if just update timestamp Thread-Index: Adj0JkwXPMQ8nbBQR7SEkH+NN01tmF/RPSvA Date: Mon, 11 Mar 2024 04:25:27 +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: 1e20544b-576e-44ea-177e-08dc41834744 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: G66UK8I6qd5iA83X6TVwnr7/o8z/DKmvsDfUpuo2q7fIBh3vl+fsJcU8jEFFCg7mkXoeF/UKebukPMbuxbEiaQ4FRcTaKbKhVot1KAMr27alKhdlPN8B14VqphcFZWPGKHEyVvZ7PVZD/UKqb6c7bpMZG/5Y0Q1H017MvVclDV6pWhFnVjdg7nT6YqgJ2aoy6KZnw0vKKcB+1uygrtiMd6ZQD0FWnqzbxh/A2WlCr8vnWORys6hmU/GJRKeSUkyJgnrL1nw4WexmBQS4BmjmgOR34ADtRmxlHODLCe7csd8K+zjuqbY0CGANr+9v7QcOp3Io60XM6P2sMa1rpSgYm//YeP55G/39Zed6nfowzW5yYAXjEqQF++lVE2AsBXjkzT7kicAxYKpiPETFmJIq8iaOXjXKLw/2oJdXSDWtEDSHMr0pWUSDuZg4fcbMa3Y0uMmE7agj9+O8YiSbZ9Id4s9LIlRrdz9gjdbehInMbduY35AKTi0ZAZuSJ35t0Gs4cC46xcwVqByLC7Lk5CSZqOoWx30LIECyv5fT6mngayMKOOm6/gm2ZQzmU0/D8nrZIuhBG54YyW2ObNUmcdfTILzTZjFLnhf2Qcde+60hcM5GZymSxK7GuavMCWARqYlQZI29iGjInScIR3JkTq9S4TDkDUlyoDUNqAS0mqU6kfM5HP9morOGggEhO7wvD2sIRYWOw0ghAbLKBk21vSb9og== 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?YKAUicZXCj1pz1Y8pna+PlE0zc4u?= =?utf-8?q?Rza6X5iTUV4IyBRpqrWT8EswbbzOvp8/8f5Y3qA21z2/uUAYzKPBWzy/g/Xh6pwXu?= =?utf-8?q?Ig96jPH/o3Po/OFTs7vyowv045AAIF9elbk/4ft0taw+4aDVWEQUO4ywJw4VkMS9L?= =?utf-8?q?w9QTdam7+aqdQDey44DPw22rFPyghyQE32OLQUxB29kNiiAKDHBuTi5xklIPIt0IZ?= =?utf-8?q?BTNF6k1VCs7KFYyfTb+76q9uGmP/fHWUl9w698gV5HfRrf5pDFC5vrtnQ+6wF19G0?= =?utf-8?q?KlpXTz679MUkIPsEFGWm2CQ+bzpURCJwCC84ShW/Nl3beE7spURrmK3igqINTG/+t?= =?utf-8?q?mDptqrRyXsre3hSIzsS9cJtU7tGqK/OGgmZaTLtVORue5ojQkINiCgGoAyObqu7HB?= =?utf-8?q?+Tt4hUb7YJiaztAPWwEKSYHX468svL2VQzM9e2DPAqKPZ5/nueczGoc/vQOYkLBQC?= =?utf-8?q?JSpyLYyq9qByb/iCsy1remnwmYslnLos1cv6Dg4sA5ZdzHMFN0aFyUSmypUIOvPQt?= =?utf-8?q?3kT/PW/ZCHSTw2arEd+0WHt1SCTTmpTGkpEmH5GW39a2jld8uYVCYYlkOp3WUaexZ?= =?utf-8?q?7T7IH9ocF8rA0X/qRbnapu1a3MXdTJ2I0zL8CN0Yt2eASTBCfF0r/2BxNpXaoLnDc?= =?utf-8?q?jjRR7JmdnW/9A3eoGoBu1tt8c8rzn6qYu5OX0QfPjfRF8/kU8gsFcQs2bGvIlWV20?= =?utf-8?q?pgCYKRjMLeQzo9aBm+vlEna0v+DuIRdeIWAxs2ffjLjBflbxT4j+i+XTn+/vHBOq1?= =?utf-8?q?7cMESVHeBD7MhSq2c3RIiFliZVb9swyrdltSeM7gugO5srry/wtMxOJfQZ4twsdJw?= =?utf-8?q?WLoKVsHid8QpSvyOYYrqH+wMlUe6hHj02QkEHWxo2C+t9lbN7jUVtMtsNb+ycmT9I?= =?utf-8?q?A3UAvTxRl3S/AJsqXZxAUx4xHOwSEBgJRI5l1lSv8el9shuHSSvwfacx6qDFRRs6q?= =?utf-8?q?yOUDykWrKx1FU6DWSJZSSCc1FrcU1i5D+q1YdGxKDQVAT3YiJ5m0j4r+M6gsB4glQ?= =?utf-8?q?MtEiRWC3qdoT9QWqlDCJam8TYIP148rD2Drv8oxqK6Amg6W9CUbp1fhUohJwnt9pH?= =?utf-8?q?AQD7PgW1H5xnes33cxZAj6ONyLptiQfr4eZ0ZrLbAoQzrYiP1ePDHWFYpd3nv3ZmH?= =?utf-8?q?2iUKxEXzeKN8ymb/rUK0r55PTzINTNoEt2/d941APGpaHNSnqYPDB4vOfWP2IL7SF?= =?utf-8?q?Yyy0ZXI7UTNc6qOpScb4J8j4jp3YcW+18keba3yMW6e056QOFagFiaGLK9RIRz//E?= =?utf-8?q?2TOO/Zxw/L4J+erOsCt7yisvwc94GVYAj5fat/qxhQlpf7Q8/QgA62MFA2iE0DaDf?= =?utf-8?q?I0/PgfAs5hhVKZePYHAvtkuLAlkbAaL79jU65HFJl/p4ZXSGgqmQkh2NQoLyw2JKb?= =?utf-8?q?28nGV4IPfrSi0Ge9BO1Snhms4gpR7/hTFg/mcYHNBfwU49+8tJ/IackQf0V2asnvg?= =?utf-8?q?AHXDAxZ1Sd6adWJuu9OAJXVFIuGrsb9M+QFa3uj8tvXb2kGRQlV7E51stD2AZ0T0i?= =?utf-8?q?zkgR0nWiEBP6?= 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: yy4TVqdmtswfRbmXii4PYglhlmC7PeQxbNur3XDXtlBOBPjvvoyMs67jhd0TFqEzBLl3jwcsdv3KFUo8E4yN7jsvy7VYaaA49bpQERYPM0aS52Vnro5AV7hpgqgJHlsinyPplRJ/JyTXOxcviFmDMuKUu7SNkaZs7b36cft0TXlAL8rc1L54lykPscOXUxEh/Qp1VUEzJytHLoSQSv1of9O2c2p3KdKKhfKphkVSjGYe7E3xeB4xlxA0gdL1m6WncD0XFLe67x3WdoosVac+iTEYW8+1fMl4AN9VbaGnvafeOOwLR/r7q9tbtAWLn3onAGGGM+SbJCj1m5Lqy0elRN558hivHVWQNe8WZ0GBkyQv07PMhwZ70zLxcTtIm7ZliO5ryFKTJTYaQcJfe/0UdhpDsGisiabiEOqAKr1bXAaN2BOnzX27NG7+edspxLEnJ4vJ9XMKqAjvXVVLoUCiLEbhsdXN4O7IE7c6saAER34cH03P3fJ1T8kLx1SqgS1ORFrIR4VVwUA9uW5n7qKhex0o9jKMP4RvFw2VPiWfLXDUvsg1vF7zaEZ43qqr79W7B1u7lvHK99VrG7LyPUIOmUka8XXhmNklJGyzkurKKh+Mz6+O0AIYYVaim+//qDGt 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: 1e20544b-576e-44ea-177e-08dc41834744 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Mar 2024 04:25:27.1882 (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: hyEfyLTI0mhu5YJsMfJ8axkBhR3o1Pxodi+8sSLmLuWTDwTYq6U+J0o1CZj2ykAaE316883KFxIoo1nXVEXALw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR04MB6635 X-Proofpoint-GUID: pO9LMEOPQV3kl2RJ-m8l_Rn1H6__I4XY X-Proofpoint-ORIG-GUID: pO9LMEOPQV3kl2RJ-m8l_Rn1H6__I4XY X-Sony-Outbound-GUID: pO9LMEOPQV3kl2RJ-m8l_Rn1H6__I4XY 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 When sync or dir_sync is enabled, there is no need to sync the parent directory's inode if only for updating its timestamp. 1. If an unexpected power failure occurs, the timestamp of the parent directory is not updated to the storage, which has no impact on the user. 2. The number of writes will be greatly reduced, which can not only improve performance, but also prolong device life. Signed-off-by: Yuezhang Mo Reviewed-by: Andy Wu Reviewed-by: Aoyama Wataru --- fs/exfat/namei.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c index 79e3fc9d6e19..b33497845a06 100644 --- a/fs/exfat/namei.c +++ b/fs/exfat/namei.c @@ -547,6 +547,7 @@ static int exfat_create(struct mnt_idmap *idmap, struct inode *dir, struct exfat_dir_entry info; loff_t i_pos; int err; + loff_t size = i_size_read(dir); mutex_lock(&EXFAT_SB(sb)->s_lock); exfat_set_volume_dirty(sb); @@ -557,7 +558,7 @@ static int exfat_create(struct mnt_idmap *idmap, struct inode *dir, inode_inc_iversion(dir); inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); - if (IS_DIRSYNC(dir)) + if (IS_DIRSYNC(dir) && size != i_size_read(dir)) exfat_sync_inode(dir); else mark_inode_dirty(dir); @@ -801,10 +802,7 @@ static int exfat_unlink(struct inode *dir, struct dentry *dentry) inode_inc_iversion(dir); simple_inode_init_ts(dir); exfat_truncate_inode_atime(dir); - if (IS_DIRSYNC(dir)) - exfat_sync_inode(dir); - else - mark_inode_dirty(dir); + mark_inode_dirty(dir); clear_nlink(inode); simple_inode_init_ts(inode); @@ -825,6 +823,7 @@ static int exfat_mkdir(struct mnt_idmap *idmap, struct inode *dir, struct exfat_chain cdir; loff_t i_pos; int err; + loff_t size = i_size_read(dir); mutex_lock(&EXFAT_SB(sb)->s_lock); exfat_set_volume_dirty(sb); @@ -835,7 +834,7 @@ static int exfat_mkdir(struct mnt_idmap *idmap, struct inode *dir, inode_inc_iversion(dir); inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); - if (IS_DIRSYNC(dir)) + if (IS_DIRSYNC(dir) && size != i_size_read(dir)) exfat_sync_inode(dir); else mark_inode_dirty(dir); @@ -1239,6 +1238,7 @@ static int exfat_rename(struct mnt_idmap *idmap, struct super_block *sb = old_dir->i_sb; loff_t i_pos; int err; + loff_t size = i_size_read(new_dir); /* * The VFS already checks for existence, so for local filesystems @@ -1260,7 +1260,7 @@ static int exfat_rename(struct mnt_idmap *idmap, simple_rename_timestamp(old_dir, old_dentry, new_dir, new_dentry); EXFAT_I(new_dir)->i_crtime = current_time(new_dir); exfat_truncate_inode_atime(new_dir); - if (IS_DIRSYNC(new_dir)) + if (IS_DIRSYNC(new_dir) && size != i_size_read(new_dir)) exfat_sync_inode(new_dir); else mark_inode_dirty(new_dir); @@ -1281,10 +1281,7 @@ static int exfat_rename(struct mnt_idmap *idmap, } inode_inc_iversion(old_dir); - if (IS_DIRSYNC(old_dir)) - exfat_sync_inode(old_dir); - else - mark_inode_dirty(old_dir); + mark_inode_dirty(old_dir); if (new_inode) { exfat_unhash_inode(new_inode); From patchwork Mon Mar 11 04:25:31 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: 13588288 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 9D42E182D2 for ; Mon, 11 Mar 2024 04:25:43 +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=1710131145; cv=fail; b=RR3j/FwilTeFJI34YBotBlcvAyLVg1PRR9jY2Th5OOlBdJFMysRsVn/tiVACPgRKzgNn4R1CHfyEZLqG8UP6eOlt5yut/7L5tAT64aWgPFvWWOm8394J7e2WVzjhGi1xHCgttfOcv10DdBPbjbD3ygvqjD0/Uj4VV9XnslFVk/g= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710131145; c=relaxed/simple; bh=Yzb+w1u1OfVmDuaSY0BjFftuB/fbJOqOOoUZEpAHqdE=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=eLo4uV63+fe34TghLFd9ouzK5lqYNDdbitMx6SvVsWROfPuCCM0ieNUBAIxenY7pcJrfDc2iQ0KWsCrOMpPAbllRR4V5SblvNOde3AZ3h3x/rAxQ9+oA4RclR9kp+q7rXigm3sCejHz55DUK/Ge3ScLXF7aPyILd/OsphelLGr4= 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=CZVYWJY5; 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="CZVYWJY5" Received: from pps.filterd (m0209326.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 42B0MdoX032336; Mon, 11 Mar 2024 04:25:34 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=Yzb+w1u1OfVmDuaSY0BjFftuB/fbJOqOOoUZEpAHqdE=; b=CZVYWJY5Ohto8e2T5X2pX8kITCdPfYX6BkGmBf+kFAcjfRjtpltO6ODOP0u0omvRgaL2 Fs2vp3etJtSKsikCOtcxjN6RNhqZRX2ofwqMxaFa5WUt3bFS5ovozfoqQ63CtlgliTk6 qDZDhUvvsosvhhDZHViQ9Lsp4v/fJ2i39bZdO2X/cabz5XQIRpvQPazobztFBiH/gl7d apJQ2pRAlFtBn/nJ9EkkpxM3hzZNBscY0s03kJ2KhOqmNVPhevTwOeTY42DAakCvVUKb YnA/ZAH8GuhoqtGsfJkH+TviiTyysCBVJfIYo08V7JPERn9FQzMH43pzUswY1QFNtQbN 6Q== Received: from apc01-tyz-obe.outbound.protection.outlook.com (mail-tyzapc01lp2040.outbound.protection.outlook.com [104.47.110.40]) by mx08-001d1705.pphosted.com (PPS) with ESMTPS id 3wrdyk1knh-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 11 Mar 2024 04:25:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fMHmug9rUXJyWqQd6RvGGEZkivopjTe6AwgibNyf2IXlBFgyVCISh/mA9EymaKmsrEND1OKz3CK7EYvC3EGlW01xSt+aBEnXEo0RztAALb3bn7iUuSR4f5GO+lNYoiMxBr3MO4MbAT9uQX0zkUbbhEj0MWkt3pmXpQMBwGQtf4zeSlHVjJZjgju9E1hWIs2X1W6uGPc5b3Tu5fFydEU5zB29Wdvg8tK/jev/O8BHpPDwFErrjNsj9ETH6IE5wyMC8v5VF3NC1nLJGvc+i/Zb6gBYXdwC+d/cBr4M9dbMNdevWBKdWSzSt4y9H/qBnlPSWwewcU9KcCS6SbQVq4VEsQ== 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=Yzb+w1u1OfVmDuaSY0BjFftuB/fbJOqOOoUZEpAHqdE=; b=hGx5mWotJpAAxoBUp3SpuEfaQU6XaA/S9x2uiDdHG+fe9Uwp5RzQ5v80gnA34zCal6IeS+ZL0gYh+0SDsDIhlDsM/bGDopr/z0AR/ZPA1RF8jACivm81bfpln8Tq91J1q7WiZkzOj+OY1XrZM7ip/IaJEWQ0qQJWC6r92BgE1rmSaFmLI6qux5O5XYjN5XnWevhX0qU32xSsPY2irY5rOizaoWDtw8ILkBzMMXqVSiGeUdakCjoTK70bgE7rcc2cXgBingHx738D+cY50srV6qgS+5P7Nit6VF51hygw+pKt3N3+0X4HEE0KFiARdQQoA0TjCAFIrnhQoTSipY7oew== 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:31 +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:31 +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 10/10] exfat: remove duplicate update parent dir Thread-Topic: [PATCH v3 10/10] exfat: remove duplicate update parent dir Thread-Index: Adj06Ci11I/FwWfHSMqug1ChQRO1bV+gzWRA Date: Mon, 11 Mar 2024 04:25:31 +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: a5cd984f-e090-4224-2606-08dc41834998 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: zVtuYKwcvTAf+e0gpuSg7IpqACERKFqk/UGAFuN27Yh3Bx8FhTzrQN2UhQTZpOk9iClc9po3gT+j8tyBTnAmzVkl96ai5T3ETiIji9FbBtTrNbehIdaJ8wUo+DkRP+mkbXW8Bf4lFYEvYkX0i6q5FIzZC1SVhMdN5hFD6wW9J2dPEEgLPE1/MHmsPI75oNLTsWdcxqtbn9tnuuBk/1pNvd7sKFUqtpogX3j2cwf6YoD94wc/67oTFUtBP79YWH8zB7l+PU1UJZyJ3jyxzpvf2PYhCfVXAgjRTkVcGaQkUpwhOFIRUqllYwouqV1SwSxfxz2gNXBIk5dSx4/QGSoMtRpPAjlQ9GKHwPSIkn0gjgySzekSVvBUtgFaOrQVCpxs8rQjOVQZUEX2XYYTz7rg4My9pjzBfZ18GSV/KMM9CNwlSnZuhT2X0/Jl1nJHp+LlqbE/iPqSewY+RYuSLvKfofWiFkp9co6vVbwA8twI5SGEEimOn6uzRpPIShOtvWkMuPGkiXcoka2C/7qFVSrLVwuUL9Ky1ynfVHnj4c16AKw9kU+2XEww6afFvCVQMtQnuU/c097xbulJg30LmueB/JvJxFeDKl6u/bvRw9fqcrpbUTrHAjNWSvst+PLLW6zBYo6qgvBii1yxR8ATIFrF84A9PvNS/PC+ON0NA8mMMkEU7BvRPFkSP8E/d4MH6wFmh4eso3dwzejKkZZscuzGpg== 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?Xq9Nj9TpMEPsEXYUW0z54NF7zBAo?= =?utf-8?q?txZW+Tv8CZ7x/4y7DuZh9zPH1/JPwmpmQEd3imE+hLN8S8juEcsKd+BgIFuyKn3tg?= =?utf-8?q?Kd/DZ1hFsqZjZiIh560EcVcpUMG/izLrkRGmHIWTjgxHRLRC9RmsLXNQttQCi0oeg?= =?utf-8?q?mVnnJgp2KvwendnWz0e+RzqHL+RgN03gDQqhlDg9rkEYbURBm5f+c7aa5hagEqBbr?= =?utf-8?q?UqlbE4++qbyPPxjngoHP+LXgVCa70kWGBtDkczPzE6tDacftPw7t/K6XX/3bpjeMc?= =?utf-8?q?1uMc9itHikGqKDGJ1RzYVtjtYvP9q0ouC4o6atEhK8NsaUmnFU0cDg/wLh0tjLSLw?= =?utf-8?q?TLfkZT9k/tCHkhZhEmDW84AsCDiPLqMB4/kBGCYVecW5BJqD+DQCejZ4zqFq/EKDh?= =?utf-8?q?XPT4LPlxGrrSiUTc5H/0tYUuTwn1xI0eTpsrHnTmCUvEiBTPNNmSUHUr4gA8V7iXr?= =?utf-8?q?FrOluizAW+dcoW7KA6pgh+tHPWeIUUy29D8LUAQfWOj3s1zg9jlLpCm/eM6RKaCZ8?= =?utf-8?q?3lVX26WznHR9CLcq8huTRwlMm4hEjqedhyucTopDpfeJx7u9nqZqh2d3IW61HIBxe?= =?utf-8?q?RhKh/20fo46v3XDKDqVvFWuTK+7q2US34w+Li3jhHd4kmglR9JM3QD1opDbOEarMP?= =?utf-8?q?AeO/SGjsjIw7+oU7pFIt+B3/LMO/BY0HnMhTHAj+/PtEFXwv7WczZWxjuSrxlvy8m?= =?utf-8?q?S5KDpYtjDzseY8MHcu5+J4YZzOUWJQpZmyG0ycc47Mta1FzNoU2ZIOWdURuLowMvk?= =?utf-8?q?cM+lqNXIcF5IaGukbbvflJxQEkIxJ+CmNddLkoSLBhVJukKu0N22n4YdCngw/XokL?= =?utf-8?q?RSkvYQkUhOKCRiLU5NV196YNae0aDH5YcU3NKpDtS0KoNTbfhjx9Bo4OHpVDX3CYG?= =?utf-8?q?1AMHfFMmBrYj2Rv4ku0ImYSYr85Prt78Xeq+Uxx40aGknKmgUkdsnpm5sR/5DotqG?= =?utf-8?q?rK0OZxm62rsIlnebsR0GCevzcVVP050lGR5UNR9mckmZQLVDSe2cI2a/7EuPVhrTj?= =?utf-8?q?KniZEUi2BMVPMnF3pR+9rYD+vB5FII+cPeYk9H06yk7+T2dpAfCOI1W+Kwtcab5QC?= =?utf-8?q?oq6Qamle1cUqBCahWeyNNgriOmGJy+qG+oJz5DujUBnku1DAVJ2dRYB0pohQgN2Ma?= =?utf-8?q?GkeHtXo0QpJlbi3KcRjsGTIeTxuaLBCmEPSut1mDFW5uSXz4HQeZy967PdhGA/cqp?= =?utf-8?q?EddYrIOW81xPcYiSst8CP/8gvDiLPEMUXbepF9yzxYwvCQNLZO5VbhevdMlv2aQA7?= =?utf-8?q?MWCcEwGRsR+CiWIH1Sx0l1QMX2m3TRKucE+TrSSWCuiUKcxUDs4XyOLWHHnfL3/fD?= =?utf-8?q?4mKbPEp1r6Di4UWrYYWVDPc6wyALncyXoI0QZ3Sb6WKN1ZvY1IH/DG+s4OXYj6zQ3?= =?utf-8?q?RS4Z4BO0ZWWvL4a8zSvs6yOYDQs+hxtoB8zHI/SZdCG3YVaEHqk+VCMiUWQzERXqJ?= =?utf-8?q?YYlLrOCstzE1LUk0x5WMw67Nzted5neb88bICXfuJYyAYrlK5r3voBc9qzdmzisz2?= =?utf-8?q?58wlMxBsxCQ0?= 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: QQQNwnE08O12OwmGyjOdgqmyKkyN6C0zHAmlcdrBTBklA0/U+azQW01JXGh+MiLuvIHQ1swAJyER06MGOiKPoeKidGOPcH0zsIldNVASjhLc2JK138Cuzb9F+uovUP/mxCedsBM1dhIk5b+KADhe9wDvR6jFpTk3/bigYhKF92MTw71ZUyIM3aqwJK0NogMlG8AP/aRPnL09v1w5ASVTfsPQJJYuyLiRDpSc26g5LtN1SnZ2UnQFJZWKp0Quaeo83M1gxjvXx7lFRrW/ds88TswuTGw/MG2DqloFSBFPqScZixUcL3gc4tzW02sTMqB/U12u6PfTGoxl4y0xjqsHVCRtpm5/fkJsoufx08BbPOHKxHDBFbjvmyWvaZ4etgQLtqrf6BwwOvEChYJ46mdqmfh/IBUxBIxQ5KzaCBYS4JKsZU/vLi4jO6KhPmR3XBmdehjNJPQC2QqJMPBEFmbmI36c0F06rwNYH0x5CMWhOVydi5jn97Y70FndGWevSqz37K4AsyLh+JnTSk26FRHaf2tp4K0nzSIUdhIhRa0TT11Fo2V2f66wBqMD+yjkPgkzhFXXAeAn6hluXcPa48mTDKoLmGNFz0lzqEViS+7w1/KWiZXfXn/2YeIlqXeJj3wD 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: a5cd984f-e090-4224-2606-08dc41834998 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Mar 2024 04:25:31.0604 (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: M9v6z40WDuecgdnXjSeePtTwVzZVmfuc29nMX+6c3yVNiAK9rSpwMpp1NjjJkZXqmWRPpzTlUsQbjwhKmS+YDg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR04MB6635 X-Proofpoint-GUID: 72oXybfPp7ky4HPb2-fxHbUQ0arDBjlq X-Proofpoint-ORIG-GUID: 72oXybfPp7ky4HPb2-fxHbUQ0arDBjlq X-Sony-Outbound-GUID: 72oXybfPp7ky4HPb2-fxHbUQ0arDBjlq 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 For renaming, the directory only needs to be updated once if it is in the same directory. Signed-off-by: Yuezhang Mo Reviewed-by: Andy Wu Reviewed-by: Aoyama Wataru --- fs/exfat/namei.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c index b33497845a06..631ad9e8e32a 100644 --- a/fs/exfat/namei.c +++ b/fs/exfat/namei.c @@ -1281,7 +1281,8 @@ static int exfat_rename(struct mnt_idmap *idmap, } inode_inc_iversion(old_dir); - mark_inode_dirty(old_dir); + if (new_dir != old_dir) + mark_inode_dirty(old_dir); if (new_inode) { exfat_unhash_inode(new_inode);