From patchwork Thu Dec 28 06:59:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuezhang.Mo@sony.com" X-Patchwork-Id: 13505639 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 C5F544411 for ; Thu, 28 Dec 2023 06:59:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sony.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b="DkBPIYgd" 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 3BS60Exs009678; Thu, 28 Dec 2023 06:59:18 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=AeFOmNI8RD2KZy8g8XvMr0Ah4yzcDkE6Xm6jc9YnrHc=; b=DkBPIYgdxPLsD5xuZACraEgjUEiOqwbHMT0YBVA52pMulFbn7wozg7meOorUwAmzq6wV 2SWTOTdQRiFI/WCwcf1zUa/ha8y5/Win5qZPdF81SrddVwEIoPT56IhHkc3NrGYez2yN qp/923kjjxlRieh+HwokRn59L+buJ3VWewv3pySBY9+MOIZVQViZH7BLOq+HOvy/S6o1 TaMU6R5SAvmBAsjz1tx1Tao26hSlaCbQeIu7ZKb8pW0DepSTCtWO2w1lV1auWzcvq65v RksHsAodHykoeRMbAe7M1HpZnATQWoBx7nDpce74t0Wo6XvfsfW7iv9k8pOsfX/pGXuD XQ== 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 3v5nrhv9uv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Dec 2023 06:59:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jR6gSSvEOs2Rx4x0tqw1UiQVMsybnn87SaAS4uvnpzlW0YpxosbLPGAfEC2QmMuZhbZqbmMCeZVG5ldd8OMd2aN0W31zFDiZ3/DSzPz7M6i4lAlRRHn3+/mLtEePtVxrPrWyXo8NSokTDZeUey8lgLWFGcZRyzBMJkWH4EBmyNsgbfMJj8CoQKUK0C8xoaQ7isIptyqIlxl4AZmEZo7nR6aOBBC26PASHt0m4bkuzQFDJpRg4q5G2JeFrML2sgBvoyu9p6HskO7s2EnG1aJqbwt1shcFvelSA1E/WsncC9gZSXge02+I+YkehUx0bwqwik5w20tsbMCfvp9b4wJI8g== 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=AeFOmNI8RD2KZy8g8XvMr0Ah4yzcDkE6Xm6jc9YnrHc=; b=iZCyI/uMx1vefj4tcaxXc3feQX1fe82O0tcaA4VVkoXpORrJh/9eIAhmJIQyOadFfb/TC5Tdl/X56qBXatXXw1ytLrdT1M934tiBcpgA8AcoCV7FpQ+22kXmXz7gqythwKVYRy8RKpzalPW/zF/ng8URl/mmlNnH3Bwgx+ieOKTQrqk1YNFNLWEICI9v/yr3oXqFDbX1uhK7jua2COR91iY2YM1I30vRkq8zT+IR7wVTtwjjn2tgtTyi7eaXobqQWs5d/nlWQukiVNRJxFmDLF0XLoSzKxvobxcAR0RjEp479SvHZg9naWaCJqtSLlYlnoU+VSQqPpmM9a0mtv4dqw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=sony.com; dmarc=pass action=none header.from=sony.com; dkim=pass header.d=sony.com; arc=none Received: from PUZPR04MB6316.apcprd04.prod.outlook.com (2603:1096:301:fc::7) by KL1PR04MB6878.apcprd04.prod.outlook.com (2603:1096:820:d5::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.26; Thu, 28 Dec 2023 06:59:12 +0000 Received: from PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::5914:6fc7:b79d:7e34]) by PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::5914:6fc7:b79d:7e34%7]) with mapi id 15.20.7113.026; Thu, 28 Dec 2023 06:59: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 v2 01/10] exfat: add __exfat_get_dentry_set() helper Thread-Topic: [PATCH v2 01/10] exfat: add __exfat_get_dentry_set() helper Thread-Index: Ado5WOdBS1LltrR1Q7KsnyYhMVF/uQ== Date: Thu, 28 Dec 2023 06:59: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: PUZPR04MB6316:EE_|KL1PR04MB6878:EE_ x-ms-office365-filtering-correlation-id: 165accf0-b458-497b-1724-08dc07727f6d x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: V58gN6SYd5/pm6GTm1xKKp9xjrcxUdCNjDmNoBhIbaWk7MjdCFpjqHEERfDgmCRyW+JydqqJOqLjrtW9lgIfOpQHt+6wXUymfLboF0tcqk0A+AAVAlunDiRfCZ04nETFGsR+0XeSTb9m2du726GDmdmZzHrszVBuXG8B1OYI14AY1AxeAliYvNORNDOdS9d9fGsnGoNDOhQRqshVZ9u0P3LYP5EvqUe3g50Qqr4HW7dgQnqBwHDOMijolPrFmcmVlhmb1dqQ9daFyDD/kIpHNIOHQpWut1887K1Y6SjVv8lrUx2oMjlV207l/9ONDAZ+SsFXL3QA4+5DKuvE7QQnBNALCUX8L7LTKxLTR4EJ/k3AxFic6dVm45iJfdmLmgmk6xWTlzCpGK/V6wwifTmcmaCT1Do26BkE2OpmUjRuN1FRHVqmef6cQ7jsh0za420DhDess+LkD1Ff+9oDi8t+SHGznDsWisbZ9yXJLVB5pdARELRiwrJoHhFR/7sq4e9OP7y9ODDjt75eabP3l5OK9eiOZA/g5iQn3cPiSp1PKD4C4Q2SmCIGx7yh0+nzn4EkrPyyi/FCRDzgEXI12zhjHLa8qr9ovUkySzRk305Eze0uB3BKUemBNFzUGchjjtrL x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PUZPR04MB6316.apcprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(136003)(376002)(346002)(396003)(366004)(230922051799003)(1800799012)(451199024)(186009)(64100799003)(33656002)(9686003)(6506007)(71200400001)(83380400001)(7696005)(478600001)(107886003)(26005)(38100700002)(122000001)(82960400001)(41300700001)(316002)(54906003)(110136005)(66556008)(66946007)(66446008)(66476007)(64756008)(4326008)(8676002)(8936002)(52536014)(5660300002)(76116006)(2906002)(38070700009)(55016003)(86362001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?e0BxNnfSWB5NQAZ8C6uQswEUhQkK?= =?utf-8?q?IdhYI1mnW+g3Js/dskH0c2lmu6hx273vX6UOlZmg9na2Il01Dc6r1EOYitMrXFCVN?= =?utf-8?q?I/9N1IJo5L1aMTFFQE5gxe35AvBqxdoi+FS94dcoBG6DGG3MPWc0qdFCljesMj0RQ?= =?utf-8?q?rFkSzoQm6mZ4vSlxLXABDLMqeIMEMLjwbt2ymvHd+VzBxenowOyOIud7FZLfQWVh8?= =?utf-8?q?qRa2dPI84u6gNJ6zJbQiarq+4/7pHBTsXb80NsoR1x0HZt67qOnODg6THUt2iv4D2?= =?utf-8?q?NcjkrVGlqdp5Dh4kgad+Q70cAdBXcQ6NLe5EPrWSk5u/v4bDrsQQZAZruEhpQs6PE?= =?utf-8?q?jXMr3MggILuw0c5J2WjHoRjlbHdP2VHpAWud0iK3Rj5giApFBK5NIE5n8SbvNW4JX?= =?utf-8?q?PRcUpbRadvVYviuicXlA6ZOdklV8/Q9qCRU/owNhKhVVn/4YqViKlG6Thw4xN62gh?= =?utf-8?q?FJNaHiCmQMqE3hF3fc4GzHMBxKvVp08l9QliKugTrs5XFlViVv5+fzVi0EiCXrhhF?= =?utf-8?q?q1/YRXB8D/pZq4r//KRtsgYuLsm5RBcGXh89QMA1Qfd/gc6bgGWReiupjgBSkyBKR?= =?utf-8?q?j5vVeBuGwigWGMZnmMQiXp406+aZ4DDQjxOMPTbOWxm/WMdAj120G7kTE6zwq7yj3?= =?utf-8?q?6TGVsyNmkLqF99865SqzNPbS5Ql84s9lL6/1Y1vKirP6yjx1HPrx2fnoaELOvsPyJ?= =?utf-8?q?vcyY33LGZO143XTWwPKuXc/xjEMcPMz2DjwlqmmxYcVqw5JwTzvXAFIRkuyFVf1ZP?= =?utf-8?q?S4tcIsE+aqXZgDfhvWz5rj2uzlHtetQXA707mvKWCRjOa3/cTXjm76HuICd/YnpPY?= =?utf-8?q?IPP/MeFldVPEczLPBElVdAEPhwJTA8uO9ORC8bYdHRuMTUynsI0c6zckzRI17CZQa?= =?utf-8?q?LRzL1+nODb6lN6ko1HDd3FSMVohtZBWp38+glVfRHd1IDavCWavnypT1PAC5tJI/z?= =?utf-8?q?htzrminRnZAWzqpQFXtgJTmHtecvU4Lxm6Tc6X4aAYrWAAL5ZEwkN9GRg+e5e+RXN?= =?utf-8?q?vd9eLpkZwrH9uOGNEjHaMs94biuY5ubWy6kpsRy9Oavu+TPF7sYkDHOK1E6mCWFXc?= =?utf-8?q?f5ckPtzf9loL30PPVEPzwnRFF/tNdh7h04vi29eYeI8TS71jX8gk4kol9lzoUBffF?= =?utf-8?q?XH3GBHvM6ZSDQppk4kWAhm8KWmNtRBBfku1tFi7rIW/FEiEi086re+0dzyZI3pnwt?= =?utf-8?q?2QxiQ+bnbhJvF+CFRDfKf5A21aBp8g0EmJMdZuhL/z7xUDxoyaPwYYnp1NW9+SgZY?= =?utf-8?q?Zg7zsWVqkebzflVSU3EFQerhL4/oSu8uiD9BuQFZCLKLcr4vXqxZK8hn5yiuXovg4?= =?utf-8?q?vGRERMlSLJimZIEgVGKHUPwekE8USwScePXDTe4SQJC7ZDso86l6hVgmuCJ9ZcOmI?= =?utf-8?q?gFo2VJIEMsts438EUYtlIL4LtKu9gOI0Weq/6b26xxm079ouM35NfgtXUOUCzR/nf?= =?utf-8?q?qswbc//5NrsTF854KR7IHu3WsyhPlqVkCPMIuI/sExVFDevDhLu+BlWu8m89tDIA8?= =?utf-8?q?goekObBp7SiC?= 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: kKkC8Nf5FYqDML5vpjKdOHP/GvkXrkPwlYBbi1eSpTFHsEleH+oVTmwBdT3PLiWBVn9verLzppOi3kBFOBzZ4VMuzhengq1p17HCeknFZIMLcir6t2g2FlGuAGdMWF8iZ2N9+1+Nf2K0clAcGaCmUeJGeBuIicdCFkocDKRmcDRqikY8YZgemnkw6OeI2leu+cAnjfOqXpzl7iIWxCCT2VLboLQRnyIhC19j9uMpZE9Zniy6r5cmEIL/HXQwfc5s8zSJJuIzDMU9z2kG7PNgir+MPIYPNNWpUHter9I1Spk2a0/HAKJvorrIELDaup0N53D3ughUmI1lyHssxnjxmGfwl3NCJrGWF5F3ImfMyKhrm3ZTIEj/lufIy6PtuJ7M6/SMruyjVZrAj+SAEt/YgZdGuydPKWNHan5ZxDmcZY8gDQVd3Grgy4UlUb2jJKi8jUbWjeW/N6sM4CaBnEdVRBJ9Hg2bmoMId+TUZkaJ96hd1Jf44ms11rmOlGn7FSFh03n93rF8TwVHOecIXg57Mk+ZB70GA1aktHxCdkHA11EH5dexMuE0cpvZgYfMbQ7wRc6UX06RC1CbiSZEYhoRpB4fTsavzebZ/givZy7K7jhKPWaayTryF1MfTmdXbyEj X-OriginatorOrg: sony.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PUZPR04MB6316.apcprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 165accf0-b458-497b-1724-08dc07727f6d X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Dec 2023 06:59:12.4708 (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: buSiZvcwy7J9pAn3MJeIAbXBAZMWYwnXb5PmE236WyFzaP2zhgJ58HSS0OaDg40heyFsy5nicSgubaqSOSsghA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR04MB6878 X-Proofpoint-GUID: IqOpDK5RABb8jlXDBcjLp1MaZiuFb2W8 X-Proofpoint-ORIG-GUID: IqOpDK5RABb8jlXDBcjLp1MaZiuFb2W8 X-Sony-Outbound-GUID: IqOpDK5RABb8jlXDBcjLp1MaZiuFb2W8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-28_02,2023-12-27_01,2023-05-22_02 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 e3b1f8e022df..d6c4b75cdf6f 100644 --- a/fs/exfat/exfat_fs.h +++ b/fs/exfat/exfat_fs.h @@ -501,7 +501,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 Thu Dec 28 06:59:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuezhang.Mo@sony.com" X-Patchwork-Id: 13505638 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 525D53D72 for ; Thu, 28 Dec 2023 06:59:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sony.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b="JJZddn5F" 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 3BS6U2Aj009401; Thu, 28 Dec 2023 06:59:29 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=5ugyRy1AFcODDRZ1CCVGKkPQmTrClcdKuVI3SqG9oJE=; b=JJZddn5FuYHaivVg0sEeAysB4Am4mKFz9TqmJa5XYmNvu0hgppaaNDzIOBey+ksoibNE CL9zi5LmNv2VJmT7cf/eREncWEfAaxt66+ul57j9QluWL6iOzk9MFYGCcEgnaPtme1EI AQZXQWxs8cTBy3ui7pM90Yj/0d5WeyAm2iRo2gZQufS2Ql7TGMajDTISZ9ImAjftps8E q/qNYoN1BAgLYZJlbzkPNOM6N6z/iVhtdVYhii7zDhXbKOYUxytcorV5ZB4tPdvBT4ST FHttq6dG+VCAnYfK2mYQ86jjhtGTlZjjVRm/woF1pBjNR82gpkhbeGl8dUuAXjj8YWnb Vw== 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 3v5my4uvag-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Dec 2023 06:59:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BDuo5dSD4lvd3xxu5jDVhs0Jd2LMk5NUXud7EEIvaVFIy6JoQ1cFB0t8PwBrVBo/KLVnbAc578feBVhL8J3qb8TUofu9W906tuWKiFQ9EMS/zpGyWtwtlRn61a1UodC+fYnzGKaWkO0H+Okh78ryG72KjnyNrP7oTI0xhN081KIz3GJZx8jKo0HlT6Zihn65fNtpAStZ9i8pr0XWPrGX4uQmQ1EDYzBNuY0zvWo/AHl7HNsTJBxGFpjlOxsJv8gPK0BZRxSY/XCBaVvcJmsY1fpSZ/2gT1PhNH+VoF9SBMz6oCmeQ6aEGDeqfZDAlzhmR3tf6jMGhnU9MO0S+tRt4w== 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=5ugyRy1AFcODDRZ1CCVGKkPQmTrClcdKuVI3SqG9oJE=; b=ahFBEU+PA2+gm9ExmrIdZ9NhakqNi7IdLOUlKsOkg3pCTSrJoewa9TgYFEqLGoz5Emy7POMSNSLOGHMvAhIRRCk5GgaMs9n5CXX+/8JZ+vKDAxYTG4fL6PA/IhdMfElvF08PlV6nDuTir9KETtwRXH2v7ruRI6xnOvt7rB7S5mb9e2uE8YbPDTHOWliJHEmAcpZAZBCkfe70e/Fr3Yh2agrstyVYAvW/cwriI2odVnDvKHLLRZlrKmM/Hkr0dbb9ZG2fXcgBy/ak9wJ1HPj8C8SOIbXZpE2j0sC39BKiOJb2eC4XwAXf93nwx3w2tVmY59AXnG/GRRF2f6xPtnPuqg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=sony.com; dmarc=pass action=none header.from=sony.com; dkim=pass header.d=sony.com; arc=none Received: from PUZPR04MB6316.apcprd04.prod.outlook.com (2603:1096:301:fc::7) by KL1PR04MB6878.apcprd04.prod.outlook.com (2603:1096:820:d5::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.26; Thu, 28 Dec 2023 06:59:20 +0000 Received: from PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::5914:6fc7:b79d:7e34]) by PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::5914:6fc7:b79d:7e34%7]) with mapi id 15.20.7113.026; Thu, 28 Dec 2023 06:59:20 +0000 From: "Yuezhang.Mo@sony.com" To: "linkinjeon@kernel.org" , "sj1557.seo@samsung.com" CC: "linux-fsdevel@vger.kernel.org" , "Andy.Wu@sony.com" , "Wataru.Aoyama@sony.com" Subject: [PATCH v2 02/10] exfat: add exfat_get_empty_dentry_set() helper Thread-Topic: [PATCH v2 02/10] exfat: add exfat_get_empty_dentry_set() helper Thread-Index: Ado5WSoMFJmHKVpOTLmXDrw3gU+2Cg== Date: Thu, 28 Dec 2023 06:59:20 +0000 Message-ID: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PUZPR04MB6316:EE_|KL1PR04MB6878:EE_ x-ms-office365-filtering-correlation-id: 3bab8acd-d61b-4f18-1910-08dc0772845a x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: UUnHA5+ThB/pMl8oMkigRAcq+iulAYcDvDao8LeWvaLP9MRjiQWq+hpBlSLahBFOk3ZQWLIPv8geJQKW2zF9IZDf4puZlP9cLMyjuePaJQM2tRXbPKTS3qk6gsRgk4SJCkLBhRgbk5E+hmPJDtSalbYiHiIJs+2uLEEU7J6vx5mQN1qd/DP5UQwYZVDGGMhmt8446LQtQ4CX5TVT+G/vrA9IFT+1cr9wq6jyINQe+F4cxeNP0kr7av07OffW7ESCF/zjOSJ+UuIyegektzicWOFuXxAwqMQHKqFzOtxtycS51EwXIozf5lAVMn97JasUwnpJ1EO/F3PxQMFYxLRm4M65Rtebo6WvoW7joP1DoP81Xv/w1SNvyxPAnU+1Jxk03gds5V7xL9QKRKa2Ycq4H5tSvaBmLs9IclcqEL/yU1gJRheCwuLkTrOtX1o3t0p2Y0UlIRErEERr2ORFYIi+dWVJDiL5XXm+lzBqEC/25vqQpQXfpZ2eGQ50SojIZRVqXEtvXlO/7/7mfqduDGirKFUSNsx3dcBGASDfazDci5LU6OdPZ5Trp4UAAvt9OaDT0YLWX5bmfRSrC1jbPGhlsESRdE7xhUcEVo2ZrkaMXTlcxSFhP9SvBvMzv3PcZqgr x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PUZPR04MB6316.apcprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(136003)(376002)(346002)(396003)(366004)(230922051799003)(1800799012)(451199024)(186009)(64100799003)(33656002)(9686003)(6506007)(71200400001)(83380400001)(7696005)(478600001)(107886003)(26005)(38100700002)(122000001)(82960400001)(41300700001)(316002)(54906003)(110136005)(66556008)(66946007)(66446008)(66476007)(64756008)(4326008)(8676002)(8936002)(52536014)(5660300002)(76116006)(2906002)(38070700009)(55016003)(86362001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?hQ7ZsWFVS4MbtMkMwWhgVJ/Ga3Va?= =?utf-8?q?X/9wWKwg51rqPtue2lgSiGmXxjLc6c++BnA8OUkTqckCnJBGbDaTTIa2cFcrDaqmZ?= =?utf-8?q?hqYTuhw1e8P9XvdlTH1k+ZX3p+B7DeSogeVuaH94c2b/gnabsortANiExAxEhdlM4?= =?utf-8?q?x9bCNYRpdng+BRFC1REE33+TSG39+lJtmfAl9FovENBWq/ABukg0UAtbzk1fAQYXK?= =?utf-8?q?1v+REjWfscMS0llr2tDUUHgR3IysqBqxMm+Sronki727KZLlua31C0K+O2Sb5Ky/p?= =?utf-8?q?vBaiI+2gYApcWJwp0FDJyxsssaME+HrcwNtIX1kNGu5eCQPKT27PICBkZu7DR52s3?= =?utf-8?q?0f/8JzT/cs3eWYLSL49CqkjmDNmn3Xjfl4jSzk/IGvjCr5CkXhRu46CgR0qyO8Idu?= =?utf-8?q?EpfP0OmIMbSNNzGuqDDibBhTDj8QMaU7LhSchqmO5uUHJPMI7tMTNzUfglOQXczmf?= =?utf-8?q?/OLmvqto2cqsqsza94l14sa/GIwg0GSAarwdh8SFOzxS2fE0Q0jh2kSkkkmkvTsrz?= =?utf-8?q?fqWLrOoivUmQq6s2bVsmsKlCxk2FQdB0B/l5qZIwOa8wh1Gy1DVvpEOvf+Ohrgkft?= =?utf-8?q?14TCGSDM64LVFz2nO68Mx8Q13iaxRYxu6GPmbvbDl0D7O56DAaTYwxNoZQb+X/OAi?= =?utf-8?q?Hj39F8qtlznoPOwVpusbgHeA/jgFHyPrlP+Wclk/42d+AwxbWn/kpoG4KMwYtia5p?= =?utf-8?q?P6jVeDChyzHSa28/uVlLbbe6kQmCTwGks8OpVyEoDVh8eivDKzJ+MeRwCVMjKBSXJ?= =?utf-8?q?XcoaFbqKjSNYOx/hmTdhpf2YUeIBn0JO6VIZxV92Nd5KMyrudRkxBDrSRSTgOUUee?= =?utf-8?q?2nc1Yz4uGA9FV8DerT8Lw9FkR685PQld7JxGN7NqM0br4r3CHIlAILPEsdMJy8YWm?= =?utf-8?q?+eA4soip/cf6FK5Qdc2Qj+KyT92Jf7t2V7LjBLsEIsZUs9vpZyNyw460t0h4/O+p6?= =?utf-8?q?PGwLtsWY6X4NVskeNHgTfFK6/y4xkWrs0txdhfyFLP49qxJGhmB3SPzj5+o5Zisue?= =?utf-8?q?gpI+FJ1H4P0pCd7nPBAv0B01f+JRR0LNiBAsFgkfAAj1pMblJYy395BIsUpxnbQ8r?= =?utf-8?q?5HNqITxFHQU1/dl5c66sgT682c7qK3U74o0ANNtuV8bw/caoohg5VuNOuX1KBtkfV?= =?utf-8?q?Dm++HsHD+ust0A2y3byEg8jNq6mjFSuKCc3Yd4/SQKmyvS/2q5xDMJjuOAsK8KuBG?= =?utf-8?q?OvtgubPHmZtERCM8q0UB1Ov1qQMC4x37lqs++WUknu6KNGIT5Zt7kkq8YmR/gP2IT?= =?utf-8?q?zpZqmT/E8fN24cGeZR6r1Tv2FtI2YH+sEDXwu174h2Eequ+aXc41QCwupSRBFs/K7?= =?utf-8?q?uwRingxI6PSlHPyLmb4izBpfWJH3rpwdyvMV2yJf1LtVutpjN3lcFaI/C3U0cx4dR?= =?utf-8?q?xOzcBORkcIjyeMM7noqdZJ8f93ZMxCn4YDKUWUK1jpM9cNjudhrgLCszm4lSawYW2?= =?utf-8?q?qIEMDHNshkla5pqR+uK/XMYH+Z4tUSzv2TvCDcsZVsorqqKC14DBSwJJb4h0V5iaO?= =?utf-8?q?E7MEXmzcs7Rx?= 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: jwZkYPfTurb41ztsRvRVatM9pju8zPkQlmaFPuLhABZHU0C8Dq7fYBAb3H/bUc8QlPsY0YGnaHzN4LMtIHuXZE81GzvhqdzCGN88vbRsXTnnKsZnQ0OK2m9luWA4lCRiObFNXDbnMnyYsaJh6uBXiIcvu+75pG/hjJC4d+QIGZ7wCIm8Y2KHU5+sy3labnu6PPUMObp1ihyHCDNkzkiK31Lr+RHRNrV0+OA4gbwJuQCshelJZpcmRgFzaobgJN1CZda+pac1q5urRMvL6f2SdrYsqaIqel8DmE8Hzx6x4TCE6bU/EN6cga7OB8/7Xi2z/bYwKn9GcMav3E1le+YnjP0rQzI/n16a0ueCoMcX430VdBwMwACxvDJeFi7axnE59KyF5dzYiGolaJea15QyXprDrumYnvxK4TxB4csa+RKvrwzzimTLoy+P10VNoGKvhzuHV9GupHFGry0hFGvO5Cpw51UA4Q7qDheKYHNqEmWoSsJQcE5N6VUpsbQYB0GqH/SWRpqZmgLwOF6jSlx6XfRXeg6C4IT6FZIsMRFTp1cr1l0nsShjmkb0fdjRK8JYF/tlB11+M5LL4Fw63vhMa4ihjw9PWVcVR4enwIHZYcetBo+LPgogudMG2x9mmo/C X-OriginatorOrg: sony.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PUZPR04MB6316.apcprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3bab8acd-d61b-4f18-1910-08dc0772845a X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Dec 2023 06:59:20.7720 (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: 03weZQEyLg1tcOjcIlOVX0873FB14blgO3Qa0BiXD0nXLkdmk5klq2rPVgL1lIQITYFc4mLQQRcrmaSjdl8THw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR04MB6878 X-Proofpoint-ORIG-GUID: rh1ECNr0qvzJ3wVpdruqU3jqo7E_S199 X-Proofpoint-GUID: rh1ECNr0qvzJ3wVpdruqU3jqo7E_S199 X-Sony-Outbound-GUID: rh1ECNr0qvzJ3wVpdruqU3jqo7E_S199 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-28_02,2023-12-27_01,2023-05-22_02 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 | 77 +++++++++++++++++++++++++++++++++++++++++++++ fs/exfat/exfat_fs.h | 3 ++ 2 files changed, 80 insertions(+) diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c index cea9231d2fda..a5c8cd19aca6 100644 --- a/fs/exfat/dir.c +++ b/fs/exfat/dir.c @@ -950,6 +950,83 @@ 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; + + 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 out; + } else { + if (unused_hit) + goto out; + + i++; + goto count_skip_entries; + } + } + + return 0; + +out: + 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 d6c4b75cdf6f..542136b14a2e 100644 --- a/fs/exfat/exfat_fs.h +++ b/fs/exfat/exfat_fs.h @@ -502,6 +502,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 Thu Dec 28 06:59:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuezhang.Mo@sony.com" X-Patchwork-Id: 13505640 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 7ABE75380 for ; Thu, 28 Dec 2023 06:59:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sony.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b="fmtAALpK" Received: from pps.filterd (m0209319.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3BS3gfMp019601; Thu, 28 Dec 2023 06:59:35 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=9aEat5jpRfNCXPHqsxpidsDdlP+cU+rq/gmZBV0mvXg=; b=fmtAALpKz9kpPOsoZR55s9vSjp0vHsTV2sGgI3lxCijR4qD/dbT7vuphha60/nTju1Uh Gfsuq/yja904q9q3hPpWxX7aL2tiJJkEASkuRG6YZzsHpE76sFRgiQD1j4JceeO5ffOE g2s8qQjDcIER7RNxwmsdvSmf1jl0NQvnEdMp2Jn+PPTcYiWr3C8z1RQAw7Et96z3BA5+ KaCun1ST1LBqyZYVlgoign8v6A8K2bd7j+mpBi2jhnAtoql97FReLSzq33SiDeihTQPo 5UDEvS+2mH0XoQzWevQ5U+v4l62vgTL5pc2A+t9ekTjl16vF1h6C5Y9GyqqZFk2wUduo FA== 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 3v5qxtbseb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Dec 2023 06:59:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LgIsKTeL0c+JUyqgEfq6DxbcZC7JTebnzPf9SD+lhFbAFw40i2cFiw7U8pRGvSbU/n78gAWatDaHD9UP4xcUZ2sab5He/yJdjdCQ3o+gk/rviH0iTmWE156KYKD6gdo/zBDH0UQ+g/cBooGaIg7EZwrwYV2ym57hrbTAG4rK9fQ4DPVrZdAHKNCtHTjiCM1dzmdLZf+N8252h9jdSRIbQ64+SDif0A3cW4xH9WFeqpGGaUzKQAvrYMPBe5GMwO22vX3Nc3LEFhBGC1q75ZqKnxg3cgo0jJFcE089F7EJLd6alGz2+Z+ToYiQCDc062sHPuyq+Rd66jLFlqxXrXOHcw== 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=9aEat5jpRfNCXPHqsxpidsDdlP+cU+rq/gmZBV0mvXg=; b=W+cNoy1QZhPjAJ0lPl+bEZ56vBH1s5do8/IJt2qjtPvxUFJ22kPiS6x4oLD06L45LXqB37L+zUf/okSAX8JB9XJl+DFeSJwdMe2BXetWp60aRnVTUZ07/XzG26QIHbNQx3BTmjCMEhEobbvfOJWVcE5Q3JGP5BYYAgORtG4hFB2qztMJHltJsIDsMukCYhW+fc6X2QX75byvPI6S+SOBppq3ByEa4Hmw+sq67VTPzf7DGp1S+uZy0GkRO1HW3GDojBPfRUn8LZf1/URTX5V1PnAq+JhscjgOrp7ZqdnXMAGNvu2ZxX10Ma324obaizC1Nc0wytBrCOmjXQmaKGTD0w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=sony.com; dmarc=pass action=none header.from=sony.com; dkim=pass header.d=sony.com; arc=none Received: from PUZPR04MB6316.apcprd04.prod.outlook.com (2603:1096:301:fc::7) by KL1PR04MB6878.apcprd04.prod.outlook.com (2603:1096:820:d5::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.26; Thu, 28 Dec 2023 06:59:29 +0000 Received: from PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::5914:6fc7:b79d:7e34]) by PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::5914:6fc7:b79d:7e34%7]) with mapi id 15.20.7113.026; Thu, 28 Dec 2023 06:59:29 +0000 From: "Yuezhang.Mo@sony.com" To: "linkinjeon@kernel.org" , "sj1557.seo@samsung.com" CC: "linux-fsdevel@vger.kernel.org" , "Andy.Wu@sony.com" , "Wataru.Aoyama@sony.com" Subject: [PATCH v2 03/10] exfat: convert exfat_add_entry() to use dentry cache Thread-Topic: [PATCH v2 03/10] exfat: convert exfat_add_entry() to use dentry cache Thread-Index: Ado5WWe+YqWTBtMuRk+HhqyeamrfBw== Date: Thu, 28 Dec 2023 06:59:29 +0000 Message-ID: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PUZPR04MB6316:EE_|KL1PR04MB6878:EE_ x-ms-office365-filtering-correlation-id: c413ab52-5c95-4afe-23f4-08dc0772895f x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Prn3cQUrphXhP1Ha3pnAny24I3Tbts0fH5L9ngzCMjBUTjgISoHLxufdMXRXO6GZMDK3GGdQUHBrpKymd5ktCLflqxW8gAy8LOWH1yenW6eirIM062vzmq5ryCd/dOLl8Joku+gXOR8eTozSKMK8pttQjG8oVvRpjO5DAlnL+heA3sxMn+VbgruKxMxDR0n7stTW/Wlz7Oc8/6+Z6ID2JPHuCj1R65oc5iFyHtjofiEJ1ZRGX00ZfOUls3pGSzTIWNwxvM35v1K/zFOTn+iE2/uEEdTtFgWP5leM87jdeQejxilI6pJL3XZThwHfZKrAaEX8Izju+eNJCIDWGk1K+osbQ4s+clccuvH0+IK7abpRshB+1v054CGuAhghSx47oYAqcxrSCCsKQ7Bl0QsgRjo8D46x3ofn/pdKXn8/nZrPtT+qQUHI2bF9cr80QFuI7eYJHxtBUBPNZUDy+omF2mpCZNd/ObFEA/1Y0uqOx46x2IElX4vfjqEm3tK3Wqk0mEO4ks6wyNXfC57ApXGPT9NRwqKxH+S8PxPwUMO/VmMHTqJG8BFLYyHzOCgqIZBukBQKy+dMxh/k2hTGbiCSOcGXNhDjRzYZOlcvl0l8nyxo2XgIYFCK1bMZOP5SlnhR x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PUZPR04MB6316.apcprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(136003)(376002)(346002)(396003)(366004)(230922051799003)(1800799012)(451199024)(186009)(64100799003)(33656002)(9686003)(6506007)(71200400001)(83380400001)(7696005)(478600001)(107886003)(26005)(38100700002)(122000001)(82960400001)(41300700001)(316002)(54906003)(110136005)(66556008)(66946007)(66446008)(66476007)(64756008)(4326008)(8676002)(8936002)(52536014)(5660300002)(76116006)(2906002)(38070700009)(55016003)(86362001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?eV5qKp94oeW6lZ0mnbbWYTtUDUaK?= =?utf-8?q?cn9TPD7cVxtA5kp7xBuzlQyBkQVNJVD0O3Li1wAp1gQ/Fs9Ji1KjX4kMgYEF3ehDY?= =?utf-8?q?5LxDAWDG1sSukTz6+JSt8/US6KD0BD376GmkQqk491vGnOz2wEy/C7qUBKnueyepw?= =?utf-8?q?aNAGq8qUuyWbIi41aRedDaVvv5t5RLITK4Vv5Fc9w48I5WC7NitMoQVQWYeUs2AJ4?= =?utf-8?q?faiebOSz5Iiz6RCf8ZacsESjASBjwJREvMn5dKAHOazKmg04eAA29bFCdIOhvTsrc?= =?utf-8?q?lMlmi/1sNGt0hJUv+ze1hHP6HVnAksUjpeErKfZAorGIrbbhhoNTntozs3RdLIZyn?= =?utf-8?q?8vPNLqM3sRI3Kj+hcokf02/YlQlfxXuhXvusH/nLrH2AKbxaz/xk1sLG3f9TiD7uI?= =?utf-8?q?d4QrQMtm/cHofTsEgS1Qwl1kWlttkAzwMB4vGoyIbNkK+nzIm5kt4xxH5YyQNJUY2?= =?utf-8?q?A+Va/c6mGz/69HteT+H9eOPgHsXCF5Hy25T6XEbJ1taj+UkZpiWJ9fpoQosCnUwJG?= =?utf-8?q?E2V8F41oahvQ6VrNIY6dK5klN9HiMvaEkJmTVvJOVyQYzpt1M6PqPDLR5nJRh4BWC?= =?utf-8?q?lIzhtfOsnHgpkvbFnTO3llMcZqRnzcvPg2DnsLOZRJwowVyyT4xYyhW4bGcOVC3oR?= =?utf-8?q?fU+4cUOCUHM0rsK0IjAkS045T9MB5bBefjDTTwbeSOmJ0BiT4KE6C6Q9OXRDp7Dr8?= =?utf-8?q?ajdd4Bm5REvKYgD6lEM96Qo46lQ6/HqVSLEiZFnSsSvrrfhrPuR+fD1QUZnTEJ7ra?= =?utf-8?q?yuURhrCwc9G/zB3iBIurCrcydvXb5WQciGj4phiCViHfDBvW7kHsKW7y/6hKnVDJE?= =?utf-8?q?oHhWAJhFzVegkS2U84+wKK/HAJ0cOu+JBWQf7juQjHuTdKC7L7bHW7LyYdnLlxRQk?= =?utf-8?q?AcJPYzpj4a1IfyK80/mXgweMGkRXqg9H0BpdyNbVp67sh1xPf4NXjTNCHnn7bPInA?= =?utf-8?q?4NYbegMhrxxyFToxkPMVyMf2mA0vOiTX2GycCUVyVGOmVoCCa9IBZfAS3ufZPxl+8?= =?utf-8?q?H8bkxPMbpy06gy2lUrX/nYnapGunYC4sOV23wpOr/mkKsL6tHEoYDbv+M/8NySOgt?= =?utf-8?q?VTsYWzN6qpAdM3oLn5KGnmBT/IEJG65sP0mobgfFeOZiGG9SfeYCkOm1IRdBC87+C?= =?utf-8?q?Hn/dgerDBcnwF0bVWVbp8tSdFatLZw+5UppdBC4i2IzMrCWZRlGpJ5dsDjkrkqLXr?= =?utf-8?q?A+VGCGvZyyxgFe+HmUNkjjKvnL1kVcp6cn0A1tQAygj/GPxMFamRYx82ZTvCFcfhf?= =?utf-8?q?le8QlaqhECev97D2OKe4izqKr6nK157sPB6wOK2iaEqzH1sEl2BLNKxVOPeTtjrLi?= =?utf-8?q?M8yy18j4yx7egeMS8cPmgZ+UHsZrf53JEY61X38LTRTEp87AP8OFTLuAEiLenUxKF?= =?utf-8?q?EKB3bv6AFEi4dw9v6CoiNIP3ju2uvKgMui839darXYN0+84FFlr0abFNKtvq3GDNw?= =?utf-8?q?a8H7BNpXJqhAB9URM4atp78FqXqEvCD9M/GTeBmPw6T2MxAH52XvYLuVUp6IbJS5j?= =?utf-8?q?tEb9GbhPwLfr?= 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: PCngojDGt0mqf/IrvwLII8AR4cWvcXCMaetMNMaiUOD1NuG7UXwRd7O37eoZsu3fY6xOXvbE+e5X7HEbzi++Kw2ZEmSlVzCSfOHoIyxdsVqBzXQzAMZ6pb0jXJd7uhe3S/gDZwedOKBou7j7/lQYwCLSe3KlLnf4Ve78WTdFBnUass/Q3xXqXjOGXqf1NG3YqpkyYgJjgWt73ZIbOMZ64E8qH7BWAmIg8nXnRqbDTOsmr/6839b2Z7DTJQiJATLjtS6/sbGawx/i+r2B/7E5b071SV8aVnuJ7En19WLppEgde3+B6MchFNldEDv12yoYmFZy805NWUDcgRG6SowJ74nGxvBT6EAAhi9le8T5pX0VfR/dX/dtMDbkBYDMO3o5+g7AKLmhEF9nN4WEgQyrh18tGVasJ5lCuvJ/U7pjtjfYryhrSGwLVx2eB6yv0S1WToUTLVDH2wuIbkqPMCzk1jzjOXWmmBV2ct+YSsgEPj8wpMDJ2McFEAzYVHScLIJKHj+J/aNHUszkxLgAMVOS5nY5VWMT+n7Bdy/eW6RsjwikQvthkuv6aLiM3EW9kdAC0p6cFVUkME/NnngGOt6o7+ik79iseYvKZTDKdU5iZyKtDRpcev2ysPnYwnl9DFyy X-OriginatorOrg: sony.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PUZPR04MB6316.apcprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: c413ab52-5c95-4afe-23f4-08dc0772895f X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Dec 2023 06:59:29.1827 (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: xAyUSpEtLcpTish3wM1DIEEZT3bOGtNNunmKuX7uG5kJun0LY7eodv1jxWh/67jzCcunAurQjAg1F3YUwYOq/w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR04MB6878 X-Proofpoint-GUID: di4rX-cnHdT_nmLuzjt4w99uaH9_HSQB X-Proofpoint-ORIG-GUID: di4rX-cnHdT_nmLuzjt4w99uaH9_HSQB X-Sony-Outbound-GUID: di4rX-cnHdT_nmLuzjt4w99uaH9_HSQB X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-28_02,2023-12-27_01,2023-05-22_02 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 a5c8cd19aca6..42f96ee6b9d3 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 542136b14a2e..b77cf654750a 100644 --- a/fs/exfat/exfat_fs.h +++ b/fs/exfat/exfat_fs.h @@ -480,9 +480,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 Thu Dec 28 06:59:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuezhang.Mo@sony.com" X-Patchwork-Id: 13505641 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 CA0A553BD for ; Thu, 28 Dec 2023 06:59:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sony.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b="qDWojZUO" Received: from pps.filterd (m0209319.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3BS6KLiZ020276; Thu, 28 Dec 2023 06:59:45 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=PcMrvaLz/oy/f5T3szZONUqzCICAyANO6MzG09/4IEc=; b=qDWojZUOQKmkHkU1ExKXKOqPjehvlOpCdH2rjVZM/QSyji74IAqeSiH08uTrC+DE8dWa ybYJx6TynGtnbC84SwugtNkb1ief9uG317o/fF1MqZaH41x5j33mh1Y7cYxFF0Hday5N bdV4vy5ewL9LfPSMh3WuAwodd+7M2iu+dxdYnwu5J9Otk0a7RkOSSMso6Fnu2IfqgRvM 1Ty52sqzgyXzndsQSffipSpTiPnVlkqyYT6WNidtAJVDb48yQnqrO4WJCtbRYLKx+cEe xw0ojRB1SlF+p7VW3HkBUPxpFTmFrJDk1hGM5/CLlXgMgJnJUXpkmXtTjQpUWZT4mZpw MA== 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 3v5qxtbsed-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Dec 2023 06:59:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Pq/EIPzD/m/NPLZN/ACIFnhNujr7jCcChXdEN6uYduAGomlXR2Ki10mtb3nrvh/4pyNGsk51KUttQKV9rs0OybrIfuBYELd+IAAPDkli0DlsK8MG5g23tqY2aoM1/NM9I763KE/0rnqTfaAB6NFWxCRsGMfPH7tl2lVi+GNTMuCbBLzuWTmdfikil3FL+Llp/tCMq4BrtGH1yDqM2zQ3hCHktG0cHvmRXDb3GdupwWCxgI5BvpvpZjlFOMimC+KSamYvTW7rAlV0lSWzVFMV1f8bIFaZWm5234SIK0l/74rumS8bzBJ4dwPyRkQOYfNhxSe+r62wHVrk5qXvuxZQnA== 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=PcMrvaLz/oy/f5T3szZONUqzCICAyANO6MzG09/4IEc=; b=HyDcF/Em63F5L5O8S9ygY0MPb9HA9E8a6MNzBge6NrnwDAyy2siEikVAsQCKWkh+vvRHdMhSbuXiJuw1vxS/6X/kGGD3YGE2/M0iSBZzztErpQwbVud99yTvG3enr6j5U0MhwOeCN65EeElXUuQFBO4YcBWO9bkTZH+gEluQQYqj+tz3jqt49DwlIRm+WdVcazOm++jWYr0cLFzblptVVZCk1YpAMt4KXP3VlhqfjyKutS1++G8K9N09zWyP8UEx5F3aoWp+0LGu60/uvkXsP2FAAOapheVUqBoFNypB99ffJjnvLFPSmZVBR3u20BmmELvgeetzCC7rlzTsIdGO5w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=sony.com; dmarc=pass action=none header.from=sony.com; dkim=pass header.d=sony.com; arc=none Received: from PUZPR04MB6316.apcprd04.prod.outlook.com (2603:1096:301:fc::7) by KL1PR04MB6878.apcprd04.prod.outlook.com (2603:1096:820:d5::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.26; Thu, 28 Dec 2023 06:59:38 +0000 Received: from PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::5914:6fc7:b79d:7e34]) by PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::5914:6fc7:b79d:7e34%7]) with mapi id 15.20.7113.026; Thu, 28 Dec 2023 06:59:37 +0000 From: "Yuezhang.Mo@sony.com" To: "linkinjeon@kernel.org" , "sj1557.seo@samsung.com" CC: "linux-fsdevel@vger.kernel.org" , "Andy.Wu@sony.com" , "Wataru.Aoyama@sony.com" Subject: [PATCH v2 04/10] exfat: convert exfat_remove_entries() to use dentry cache Thread-Topic: [PATCH v2 04/10] exfat: convert exfat_remove_entries() to use dentry cache Thread-Index: Ado5WaqHqlmx2w9PRSW0rtb1X5kIww== Date: Thu, 28 Dec 2023 06:59:37 +0000 Message-ID: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PUZPR04MB6316:EE_|KL1PR04MB6878:EE_ x-ms-office365-filtering-correlation-id: f634df37-24aa-4651-cc88-08dc07728e8c x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: lGZtz3g1Y60Xi77UN11GEkk3s6AR8Dxvkmj3uiDWwuUo7l6jGxlNTtV3y+225/daKg9TuOuwjeBgi4+eznesdbG79Rt5HZC+JSV/A4PBMpowuVPyoxvfaUQv3K7y6NyGIaCfvIC2xwbsaPJTOQiWA/STeeA8cYJgc6GOpEqzdwJZC+nfBtaoGcjNHyX9j4ObwVzd2bFiOTw/rfD+ph1gBuSmGiYqesT3NlHXnOeCx221YBInthuliE6rFyIQxCDkx7Yg3fL07m7S4N3PXWVoObbQAJC+XZvs04Hx8vtVCFHaPTJmMUb2u7js6x7xzobbc9cIffJXFpunXD9YBa2YxfxpIWOuCOawa2/EF8MXLwdPu3SFfcDGodRRayLGLsFF+PmL7uiildjVirJBKT/91B2ab6YZXzr+bhzXzZSccYTPuReMH8IXlBOPX4qFusQedBvw/6TWyOBSAwug0gRlohQnh3BBULmlfsldx7Mz32NTWUMyK4T6DHpVRasLwmdSpycYh9Kqjzx2WZKOHPaaGiYPMDP6eyHT0HFr7b4mGMJm6hyS0RlQc6+JbVpwNKddWOKBmQmN1MdKlIh1iYDZmedTZnqlbR2at38GAq0vJZf7u6S4bwVCjZTtEaESKeVE x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PUZPR04MB6316.apcprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(136003)(376002)(346002)(396003)(366004)(230922051799003)(1800799012)(451199024)(186009)(64100799003)(33656002)(9686003)(6506007)(71200400001)(83380400001)(7696005)(478600001)(107886003)(26005)(38100700002)(122000001)(82960400001)(41300700001)(316002)(54906003)(110136005)(66556008)(66946007)(66446008)(30864003)(66476007)(64756008)(4326008)(8676002)(8936002)(52536014)(5660300002)(76116006)(2906002)(38070700009)(55016003)(86362001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?KskZahmkNXR8flU0Dab0NeTEHb/S?= =?utf-8?q?7xRa5Pu6+6aXHcWDwguZtSDJPmBU1/VCLsIY/RUsqWwfhg4U2L2FVTnMbAwnv/7rC?= =?utf-8?q?vDI5LuB6PfYD3Px4ZbCJV89KJ5KrpzHoW0iArmR2RlsRgBls8dVRJ4ZVJUS5SvdbZ?= =?utf-8?q?uw7hAV6lpUreRPbK9naWEajZwSX2/x4A77qKnGwDYJuwpSQGSCepWMjq7TVa1n7ez?= =?utf-8?q?tllJ+8JfPdZ/WI4RTQS2T7uojWHXzBdKaHzCVZr7+xYIxPUdNtmevsjYBSDW9WCYh?= =?utf-8?q?kD/HXDmJoeLhP9G1E5EOQ1Y1OTsWaNDDrILAXYmoLLEK5lcCJpyIcPznYSEnHsGQ6?= =?utf-8?q?d6AeRi+gaei6jaAjyn7lsjUGtILXqpwf/VBUialBV9lwTsfJykvjozQXJWpdn5Aj2?= =?utf-8?q?ALa36Q0UGnFFuGvmZuOp3tc/gnUBqllerJCYt8mbMnTQ7ywEhSw+T9Cf+i66I5DZ6?= =?utf-8?q?L8y/4aH/O3z4nZ4R9vAmHvd5FUCLjUDuvXHYrvdRJwl4gQrrZao2tdGILUCPiJNB1?= =?utf-8?q?7XxAr5jfrEIo2O9kIw1p11u1CAuWm6MyhZ4bDzJ8hc+7FVlMaO4xS9Hb7DFMHWAF4?= =?utf-8?q?daQiHoykKELXh3/Omej4Bwu8bXf56H5qj5QHZLs4ia/1hRwcyyk4LMQLo6VycZ7Ww?= =?utf-8?q?dJ2TmlPi91oGooINmTt8PXk+9k5gISSok/enpdVMvF2Hiq+GNXXHLxCDxZimB77/p?= =?utf-8?q?q4fhv5jIclOGXJQgLeDhPDF6LlC5W38lnu+Uy5BF6BXQaLpyT98t7J/43Jgm8POzf?= =?utf-8?q?2404xG8HKNqW2R/jbK2E9ybTm26aiC4Idnek8ziTguBWHWm3fzsviMmvSYW3xD88q?= =?utf-8?q?a8Wi0IGdK5CM0bX6Z+XFZaVvs75RLB5E2tUlA1FKiY6PNtkpyh66ez74TDeZmDdP7?= =?utf-8?q?oJYC/QSD559d4BexBUw9BJPE4nO6dHODsjpxPuw5zKGYHAoF1iHZRaovj8CCf2c4C?= =?utf-8?q?OnUwGSr6yuls9O1uJsjCGesM0TSlYfj+tLkYcOElH1Rwqe3bk3epr8gRLbpFdE2iU?= =?utf-8?q?UmUg/cdWrbvkBl7myag7Hxpggc6elujE97BDkJwj8TN4PNkaAIQnTekhAYQjRaPtQ?= =?utf-8?q?JM9/1LQQSfFEJljYF0Ugim3GeFCg40DmUigH7RFGo5DxmpEhGXVpxTfVWG5Z4VyOY?= =?utf-8?q?ALsvzcltYjs92LSwU3xlIwyzRaKA6w6YMM057ny2buWw88tE8qa4g28pHh3DZHcV/?= =?utf-8?q?YfStLeVVLufVUyik33/WUUR0JfDJBPj2NoJBMQ+StKjIFWOcfr9VrSGMzlK6VgLUF?= =?utf-8?q?dT9ZKOu/nrlGqQmUD97O1Oh2IcP30NoCyvqDITJRC6te3KnBLmj8gAVAjB/wQCXAg?= =?utf-8?q?WumiQ+tArHNSBWfVOoIcuusz+g1/G3D+CbP//oZvVqPItTbVVupvcX+AD815pBXvA?= =?utf-8?q?mH4bxU6xkDtDY6XV2gS9+D9wfqwRnJNYOKH9TXXw8SMAPxs31jtIJJ5HIgpFB8f8p?= =?utf-8?q?Ln+npuTbz4lmdFOpR+e+2uGqIT6yQARqdKygJDp2Xq79otJqPLoMy8IgaCzI9KpsT?= =?utf-8?q?csL0WRUPLqhL?= 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: /cfeH2d4i1CpEMXgU+N1GTTTHMJMWXxEyW4EA72wpeceAK3cDt3eD8VGFXpal0G7TF+OF8buCN151A51t7O0/Yf0oireRsXXZh0BW1z0VNy9pimNB477R+e0jAMjtL6TpBaj8Ga1XaUncmqdeFCwM+a+1kaE82pzX4RksJ+nW3odPrfPaxqcKiqSxh51enbAy7VarCnSj/w/+8F9/R2JQk6ON7sHsJVkoucx6iusZo3dqLQ0IsrJxaL8ld1F8ZUJ4sh1U9/YnXBgje8s3zJHpcatZ0sQ5drYaEeV1lsWP7XpHpgFIAwppOHzZVksNqUyGO54RI6kVQfKPzoBO6CSdo6y6OssAMNXmWjfoNsclTmWBfodf2KV1ed+bYKyZXpyr3CDr8vDtrDt7rsqB6G71dKy87GwXvDtiKL/gtmqyjrttC9DM0QV1imDh+wEZ/RYzryinFKux5DsvtqhUbBVeIbWdlMP3/EUmEGa1JJKIpmrBs+taMLjEbYRtm1Qy/TMjqlZkueHOdBym4plqg9X3F1U8BVVhcEPNX3IspoDklCxqQOMpMDlsBdCfUCgHOWQ9kKHVTW2u7qUJULG4oQjiwE2makMM64iR8z1PpPTN9HLwKWL4rBzHsheJ175aiyp X-OriginatorOrg: sony.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PUZPR04MB6316.apcprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: f634df37-24aa-4651-cc88-08dc07728e8c X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Dec 2023 06:59:37.8695 (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: G/d6OpFwARlstrwYF7kUcnQ6X+fIAJoIbq5Hj8QRi5xY/T4t9jq3DpLcTFiH374kBR+H9bZBEeikXnXpodQbpw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR04MB6878 X-Proofpoint-GUID: wMQNv7-ZR4vNQfxrXYbx4BVjb86qybyO X-Proofpoint-ORIG-GUID: wMQNv7-ZR4vNQfxrXYbx4BVjb86qybyO X-Sony-Outbound-GUID: wMQNv7-ZR4vNQfxrXYbx4BVjb86qybyO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-28_02,2023-12-27_01,2023-05-22_02 Before this conversion, in exfat_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 42f96ee6b9d3..33ba96a05543 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 b77cf654750a..fbf76a8b5d88 100644 --- a/fs/exfat/exfat_fs.h +++ b/fs/exfat/exfat_fs.h @@ -485,8 +485,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 Thu Dec 28 06:59:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuezhang.Mo@sony.com" X-Patchwork-Id: 13505642 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 8C11663AE for ; Thu, 28 Dec 2023 07:00:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sony.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b="BHUd2vkh" Received: from pps.filterd (m0209319.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3BS6KLia020276; Thu, 28 Dec 2023 06:59:46 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=8Z8lKm/tN8zOAaHNvIHOs279XEQJO/kpBKk2dmXLyE0=; b=BHUd2vkheyP1MklTgyJYJ8+uEM8NuIVoHG7qKZ+oB1TOl2WDMArfRUNDMaGesBRGZbfa lcn/hLvTisA126cG4d0+2ori9q5NFAL7DNPVVF0cEYBMb2CP0DRcZ2phLlAqGSXXvfjO k1oYRAbHbJwdA0vkig8+j647raBXfoiyq8hT8GFsg4dz3nEAWlh7o2kyjQjIVeL8G/rX F9juDl0mlV+66Fgclm6FWDYuFAV5mvq0Hm6XxAJrRAq4rr/q09CWR5//UilxTB/zd9v5 hx6g/8CxV+aSVk+e44R65YPIfdMKCG/7KJr53kLplN7Ap19sRCWfqu9okCI63AV6oLBg zw== 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 3v5qxtbsed-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Dec 2023 06:59:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ey+hP0xPn8AHWraBjnVP2VvWA3JJST9dtychj8XpbvMT4AesR8Fmtpih1U61FaAOPuqrJjUN3Pxb4HbBHRTNS0UrD05GjbJMC1lP3YdX1K8x5ESxi1UfS1I0Nl0Sal9fpzZmGUSrvBdA1CUerKylw0li19XFrDHv5ixfqU5R01gruaROCwzG50ll9x0T5oZnyEJWDrGT2n8fBmkYStVi3S9Q02NfPA9d+seTUFMERUrID85hv5DyUthj2wOBlOk5slkQPGSrcUS++daYwMqkb87Ck89Hf+Fl5G96uR9x3EWTM7ORsecA/7mtjvvaK12BRs74SuPYakBncxbviWu2kg== 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=8Z8lKm/tN8zOAaHNvIHOs279XEQJO/kpBKk2dmXLyE0=; b=HyzyUQe/KzK4313pV1fnFqITWCDR6BSv7QXdmWcMNR9D1U2+FtLeoOh0iw9GZihu48GWdNuEvrO1OfwhJNtSF7G3Oom6bshO6Bj5KWwNV5vqVbbN+PGcBy7eQ6jM8r3h3PlkoFILOl0f7ET/yfqwfT5CAXMaeKvBgBwF70HKfH5B9MyuzX6/ccIZkPjYs5oQ06egdd5ihPZDLDyrbDkWDwuT16n5Bt5kxYIeZ94z3VTwj/+hc+COBesWHysF3bwWWe1CxwDU7R1W1wS7WMZ8q1U9e+0+1+uDfhSQSy3bzTlZodbyPt9RGHB7Kb6mpp6HZLW7JWFXRDsD/3k+t0gQtA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=sony.com; dmarc=pass action=none header.from=sony.com; dkim=pass header.d=sony.com; arc=none Received: from PUZPR04MB6316.apcprd04.prod.outlook.com (2603:1096:301:fc::7) by KL1PR04MB6878.apcprd04.prod.outlook.com (2603:1096:820:d5::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.26; Thu, 28 Dec 2023 06:59:43 +0000 Received: from PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::5914:6fc7:b79d:7e34]) by PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::5914:6fc7:b79d:7e34%7]) with mapi id 15.20.7113.026; Thu, 28 Dec 2023 06:59:43 +0000 From: "Yuezhang.Mo@sony.com" To: "linkinjeon@kernel.org" , "sj1557.seo@samsung.com" CC: "linux-fsdevel@vger.kernel.org" , "Andy.Wu@sony.com" , "Wataru.Aoyama@sony.com" Subject: [PATCH v2 05/10] exfat: move free cluster out of exfat_init_ext_entry() Thread-Topic: [PATCH v2 05/10] exfat: move free cluster out of exfat_init_ext_entry() Thread-Index: Ado5WfYsa/OP+3nnTw2Q1KJfPdkIMg== Date: Thu, 28 Dec 2023 06:59:42 +0000 Message-ID: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PUZPR04MB6316:EE_|KL1PR04MB6878:EE_ x-ms-office365-filtering-correlation-id: de2ee97d-35db-48ba-4994-08dc07729191 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: BN/T/umrvU9HKPC0H8Jq8YI89CTuqikEeYUf0D2mZHAWbzg1nt/SNtm6OtM4SHpA+TjLMdZTEBeTPPmcjqYEBfYpK41WWr8/AqUNBhWXp7pMvfLUeSFE1X1eZpqtySPGu+1UWe5CPp7EK1binfYHiAaBAvEp8gSmc15jF1MlZwwHgMD+5IkYqOryFo8nkhXuQGHXS8zLo2uH57Vl7P9U48tjzewQxuiA6jNPHFa3TQuOeotjuMvLRXQhByPZbcAHk/sUmOHVWGAO5cSWChX6GGdSWdatS+0QlumhvuLJRBwsHWxT4FvZndiX9pSXLIrASBGZ4hfXbF60Y7AdSLCbgNfgJhmrOtd6tlLtOQt0rAF7zdDv9rWE9VRr9MHHEriZVQ+aJYOKkitIranZMW4jrC+Rrln8TVlc+jT6pT7/9J5UeRRa6qkmyBCoE9mDLZ+Q4ZWK3LmOz95KCDe/tyHj5HfMM1L2DHUIqdY9O+Q2T5X7XMxR4u6Qy94E8vmBfrFfLuuJL8lpBjeoAudbgVV3H8KaCd7IHz62Yio+1tIPiXqX/bNvVSj79x8zhfKJA8qGVWHh8BvnHoLtLsLjReIJju7wQWEALcTbgW+a3h3KdAm6qv60RyhmpmuG+HafEk0q x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PUZPR04MB6316.apcprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(136003)(376002)(346002)(396003)(366004)(230922051799003)(1800799012)(451199024)(186009)(64100799003)(33656002)(9686003)(6506007)(71200400001)(83380400001)(7696005)(478600001)(107886003)(26005)(38100700002)(122000001)(82960400001)(41300700001)(316002)(54906003)(110136005)(66556008)(66946007)(66446008)(66476007)(64756008)(4326008)(8676002)(8936002)(52536014)(5660300002)(76116006)(2906002)(38070700009)(55016003)(86362001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?x8ktQJeiT0SbHBS2jdbHmbL5y5aY?= =?utf-8?q?1dISiOpplHchhi+UaNFvIjtSjPMvTIb77VMfW8jrkDOLC234eZDwTXTiLV5UnHze9?= =?utf-8?q?tD//UoLegKI6+Mo0pnGEwmriMhGgtrU5pVWWAbOUYzeNms5jT9eYrQbW8EBh7OrwO?= =?utf-8?q?Vte3PU01BO3bg9F/tdtN/J7nn4Xxffw6m6maIBaN0wj+aCZDVwXXXhMp5qIpZBqzL?= =?utf-8?q?KQvk+qs5C/76czJiINJ7BWJRpxqz5GR2ixMM8Zkao7OS8YCCEEkhQk5PLLpweQnaO?= =?utf-8?q?UnaFh4QaY1iETpfPYxwBvB+3O6oUbe1cl2G59b+TQIZPftK1muDn0e3ItgtDzNACx?= =?utf-8?q?ozG9X1MnWfln1oH7LPHEzEQJnAi06s+vxR2I3IMGXG81fte5hUTXD+uV1J1WVsL1j?= =?utf-8?q?bAAbjO72c1lV/XeuQMo9OJC2pxCFEXWZF/tKvIGgGdtmA3lFR03dsNtRFqTI5o7rN?= =?utf-8?q?sGx6KdemDGD/KYYA9v6V1T1PCT5TBHO/yitrDGIKCcj9Ckxa6GIKsoExoXJfnZnLF?= =?utf-8?q?TGp439uO6Ze55Ey+rwtw6PvcLSXnNVRuFZSuB7/hWStFh7s7sP2ymmJzurzGSGTGm?= =?utf-8?q?rcfhBb6LeUgJJWffCsBvbinYuvX89xKubvRDBpXX0NxvE5pm9/L6kaf3653mRyN3B?= =?utf-8?q?BFz+gbCz+FSMOg+DsOmMrafW50DhCePmkHgXAqg+42EggzswgIIt3ol/YgF2AMLsy?= =?utf-8?q?sgjR4RfhAR1GI5cQuUtmBeWBs7A8PR0ENglDuPX6GZrI1RZP7xRacGmswtDx9p/UG?= =?utf-8?q?lL2Dv7JSnQuR7OSQM//z1mBjaz7VN5A0kyEBSR/3RdJuChGniBqtbwY7S/4S8+gnU?= =?utf-8?q?QkuT469sr1UEaUNNUG+AfTCJEYyNJ5Gfv8bNDRKQ4TgOaoSpB1xkRqtApDuG3Nhhx?= =?utf-8?q?2qWsDInqvzXAIFt3bTCyDa+rLo2oopF5bOGt1Oi65eZBZ7ohvyRNtpa10w0uYtktE?= =?utf-8?q?5E9t46f/DgRCmx+koXXO14uIjaW9hEzRO1Rg++r2/1d5+QLXrvIXPJNvbRXdkh57L?= =?utf-8?q?NjWVT56xlaDWYf32wIwBoTxS9kV8axoC5qfpOOFRM6AX2tnF6LVp9YM7+XkEYBhtW?= =?utf-8?q?CZMVj2QWAy/E2nL58Kxz6PFecUVmJwZc9m0aqQ4IlcOfZG3oJv9G9wxBPRgYTdZF7?= =?utf-8?q?1ZwGGtJtz7ZkNIpGF3J4S+D0hZtYnoJ9T0jM5aW4W1rCnlOcqNH4/9fp3cWOwkp+A?= =?utf-8?q?lFW7v7XHqVDygusr4YyD5ugsLJFQuI3ZD/YFHkCpi/ZGhUaD/Ow3MkxJTQuBjgtjC?= =?utf-8?q?AmZMcKTAYSzJJSOULhe2GNw1P3pTWVwlvLcOyRAlnytcjwYgkNzuMhQzRCWDWmnf8?= =?utf-8?q?LIyo9RZwznalGPc/gRTHRFb8Cpf7wzvyV96N9rio3221W72qOrVMBRaZfJLohLxDQ?= =?utf-8?q?bCZOQX6O+6eOIQDScS8leK4oUCD2OPBAzSmLNdCHd/IKP2RNsmpzZMEpnfiI2bg2J?= =?utf-8?q?33LwoFk6tilnvRGPbDxM2JXSV/36mcUGMz34SybrBABamZ/T32m8hVB8oSRu2UchE?= =?utf-8?q?NXW68MPWQl0o?= 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: EjdRxblOSvkj3S4DR2qutP+5QMUw7twCHapzGMOowY78DoeMl2n3oXOeb+iIc7PMeT4LfO7ru0o9PqzTySllBXfTPLrT/5af/2BN1C0L3eLHGkMYPYoACtdZN8z19IA4EIyDqfvM+OPdWFJRRX6rvc2/mWjE/RytaDVc+T7n/hOS6XLCUgsYuy2Wu1jtarNuhu2jGyhktvj/+VM1PBR+CBzRTRzdeQeuB7h+pUfTJOizJAax1us5aNVfOIcBMEmpq++yzld24QGaV3+MjhSGBCxLbi6C3FEjI6jD0MX53x4akBNM86F2V3uAk0E7LcsudWH0jdRCXXNvl4pblMcIPTCMEuXjxhR+MNE6LBtOBihTyjnzbJLV9jecHnbaQzHIIVZM5DMwnUhgSX9GWaOWTATq4MtDKfHyvjeWEltkI46K3q5Q+7kvORhOqpgLGqIKyJzdVuyTgPhfouy2z9pCgDF8ScOKUjV709BOIBouGmSo5M5GrCFaeRpi0fGwwUpalF3HVLzSgf3Qjbl21UwZe+jhs7+9R5aCsoT2FvnTQjnYoBochtCfdWfiiKggoCkZZFqzg5joFhjz9dBzY3vpPHJc3g4vyIKJT7FJgidT7r/qEcqRDILqmhmOUzyr+Zqk X-OriginatorOrg: sony.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PUZPR04MB6316.apcprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: de2ee97d-35db-48ba-4994-08dc07729191 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Dec 2023 06:59:42.9538 (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: 5ChK33ja7f0IRGn8f3pOmrDJ29LIaImf9rtHcGvrBNukyul9mWGXgjd+42rb833DbusFwpUcALq80wM8I3Cy1g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR04MB6878 X-Proofpoint-GUID: OxJbzNjlNZ0TC-zfmtCCUJTrx2A-HIqf X-Proofpoint-ORIG-GUID: OxJbzNjlNZ0TC-zfmtCCUJTrx2A-HIqf X-Sony-Outbound-GUID: OxJbzNjlNZ0TC-zfmtCCUJTrx2A-HIqf X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-28_02,2023-12-27_01,2023-05-22_02 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 33ba96a05543..d3767679745a 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 Thu Dec 28 06:59:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuezhang.Mo@sony.com" X-Patchwork-Id: 13505643 Received: from mx07-001d1705.pphosted.com (mx07-001d1705.pphosted.com [185.132.183.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A7A8063A8 for ; Thu, 28 Dec 2023 07:00:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sony.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b="UOBjIGtQ" Received: from pps.filterd (m0209327.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3BS5Zm6E006154; Thu, 28 Dec 2023 06:59:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sony.com; h=from : to : cc : subject : date : message-id : mime-version : content-type : content-transfer-encoding; s=S1; bh=e/fmn8Oc7Uk6aa9doDzB5jUc8QNrahgp1WZDl/3KkTg=; b=UOBjIGtQVSf1HCRxi2dk+qEgVkYMmTuuBbVoBWE3qOUP11QNBKUCdIbLgW7CBR6TJUSF Yfju58GvL8qRXRWk+Pvn66u4x9OVQAlOakN3tTfOGVNcj8kKlLx2pJRln2as1gB5udCu 4e0UJV4M+ka7eBl/+JvK5cuVCbmD9XTmWF6TZ36OFfh6Kj2CYtu0hezFPHE6ziSaxHH1 ZnP/4iJKNX24GCCBFmKT39WZuMbR/+5T58MHY59vUWCLbxFTM05gsASzFeHhdiZHSGZP gXXxQvQuC+pqUS2xfipk5elfQhxOtQtsvNtVRPlZj5f+H6VuJyijJoIMxYHG59Sg/Nof 4w== Received: from apc01-tyz-obe.outbound.protection.outlook.com (mail-tyzapc01lp2041.outbound.protection.outlook.com [104.47.110.41]) by mx08-001d1705.pphosted.com (PPS) with ESMTPS id 3v5pe249dg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Dec 2023 06:59:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X9gmLlD6D+QXdDgY6GB29Xghhh2zBqJlIKwwC+xbdgJQrXaD9GOadK6ja4qqZtNGRxObBBt1sb3noJkr8zXY9WnjnVy9feRTSrD3QIJtUQKUTJLespPXI+0SgTfEmYwApyrK05lFdolX9HthCZ/TJa+lEjlZtOfiFPtA++l5bW60bg37pTLrLXYREH/srC3iZEfEqrz3+NNsiP2GtXVQLnLspwPEKnntaVRy0jjcK5g6TO4zyI7AjJrdk54jmTcq/KBVQPcfJhHYMLKYUl/1lGv8Wkjdi3LxuB6lle9SFlNut9Kt211ECOW4/I+bn+WR5HCbbDGa+dY1KRAkP5RoEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=e/fmn8Oc7Uk6aa9doDzB5jUc8QNrahgp1WZDl/3KkTg=; b=YIFejYuTtZzR1mp2VBQflbZKeQ1bXuX+XPBvtJcY+VMxvT0XqE9s9372Tcwicq2Evs29aWZRa+70di/Pnd75OfsgIwN3gG7Y1PWEWs+iimQGUV/U0f5JPFdrgRTMeBND30BcTSrswa44aeoaHMSPELFb4+2WhBcoDgXf0T2Gtng5NSir7I32gWn42up1wtIG59MfgvIEOXuEpPpmoMcyvADtleb5jwrq5iDwo7zKw9hikzQNyG6puVrnVUnPK1yIeqvYQLAdBF8/m5nDJFRTQgv01ySjS/mU5EnLC+C5Pww9rWxd1XSUJWGqLhcjWDd+JzxB7Iz7OvHdpdNjRsidGA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=sony.com; dmarc=pass action=none header.from=sony.com; dkim=pass header.d=sony.com; arc=none Received: from PUZPR04MB6316.apcprd04.prod.outlook.com (2603:1096:301:fc::7) by KL1PR04MB6878.apcprd04.prod.outlook.com (2603:1096:820:d5::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.26; Thu, 28 Dec 2023 06:59:47 +0000 Received: from PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::5914:6fc7:b79d:7e34]) by PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::5914:6fc7:b79d:7e34%7]) with mapi id 15.20.7113.026; Thu, 28 Dec 2023 06:59:47 +0000 From: "Yuezhang.Mo@sony.com" To: "linkinjeon@kernel.org" , "sj1557.seo@samsung.com" CC: "linux-fsdevel@vger.kernel.org" , "Andy.Wu@sony.com" , "Wataru.Aoyama@sony.com" Subject: [PATCH v2 06/10] exfat: convert exfat_init_ext_entry() to use dentry cache Thread-Topic: [PATCH v2 06/10] exfat: convert exfat_init_ext_entry() to use dentry cache Thread-Index: Ado5WjOA+wdiwp54SsOXB7UOjr9FWg== Date: Thu, 28 Dec 2023 06:59:47 +0000 Message-ID: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PUZPR04MB6316:EE_|KL1PR04MB6878:EE_ x-ms-office365-filtering-correlation-id: e440ec61-1c8f-49db-e35e-08dc07729454 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: xFoy+I1e2mrLRx9oXSRnvyls2Sx7Om11JioDkIa6NAAYwIsIOXyUBKIsa/jWVtnSgi3G0A5ueD/T4ofCLxo7Mw9pPKRkrZAXodcKTdwQDgAaE9l5ESBpIwDXeLnKk4zIiJvX33LnmaD4a0DdhmA4xQwxt4hX26Rpoeo04/GBIv8k6Zj5dKeQAlcZa09UKN9er145OgJFyweE3NsxayYt36U/SgbkAWeWQuIlZZ8N62ozoNwpGCui9bAofAXI50tVTMQp/juSa1j3x1g9aloR81Q/DmCQCS5h4DBf1wB7cmB6tMAOGsBFTz0/H5eacaE0K1Jrht/hbq/9WSnvMSeMOXHI7Dta58uMWswqmOBzQAD3XkU6l1XJD5qrBAotSGl91pOd4v3YMhdel3nGW4DL5kIVcVmEsyclvg37D5Rg+YBUe81r6rxx9WEnga4XC9MwsNX6LnPlyWuKyftKgoBgzAC1SPbZw2KV23YGiPRFDG36+VtHukhTYDyT/RYWdtH8XVkSpundHX+maHcoJk8lQDEBUbrLl31XUiN8skIsMUgDV1BPkFZJReVfY8vJJg7xucYrCAj2Cq7VZnWGT3fdqVamgkfAy7VOuowyKflYvE+2yh6SivEfHPYb8fWHUvhH x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PUZPR04MB6316.apcprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(136003)(376002)(346002)(396003)(366004)(230922051799003)(1800799012)(451199024)(186009)(64100799003)(33656002)(9686003)(6506007)(71200400001)(83380400001)(7696005)(478600001)(107886003)(26005)(38100700002)(122000001)(82960400001)(41300700001)(316002)(54906003)(110136005)(66556008)(66946007)(66446008)(66476007)(64756008)(4326008)(8676002)(8936002)(52536014)(5660300002)(76116006)(2906002)(38070700009)(55016003)(86362001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?ZCS+K/IzA/+xpSM5WfA0QUjHHBTO?= =?utf-8?q?xvVN6G1DSIGrdLxfcZQNrHJWLFqjmBjFKp+xyy7GfDol38rm4T21IFGxwQ+emotns?= =?utf-8?q?uIf6WvfvdkftYWkt1b+D74QHklOVFw0qd3psgwzr+Uc9R8USjSlbx1HHzjy71eAIa?= =?utf-8?q?knUlBwqdVk1m8v3uMWbd5Ge3JYSudqaw8N1ObdT7AHQeTY6GZxak7BjhMgVUvPYjY?= =?utf-8?q?Cr3Yj+/IFC48p3GNSu09krWrjlDt2nNalggcqqCn/Pie5ZH+MUkp840chZPhUM9Gz?= =?utf-8?q?zJlAfYQ8ROBbwyeiZw2uSH7dOkzwlB4818tQesRaZWcZ0lsrSqHcWOfHNWEZUTnqd?= =?utf-8?q?7D5W9kTwnSHF7a1UM3FMqx4HnRpEURUQ5ZIYw9T+e/a6APmtXc6y/hBX104F6I8jL?= =?utf-8?q?YSvVQ+7z6FfuYDujUA7gMH6JMmXp3GQoSRyzOv9C2FV10JVL3lStOSufG7x3Lopp7?= =?utf-8?q?vmnVWU+60tApVxaqdXJvYqWU51w88iva5kvQG/0/VhSSoMtH01W1rLpEbgyTFBk+U?= =?utf-8?q?Zrh69KFRNLWOpfKopj5paCdHEyzSUpjo1lLUAF9EGZSOntuogU+JhmWwcgAJOlRTJ?= =?utf-8?q?xyZENvlsU16qds76GhN6aT91IJJ6pKquc2NEeLRugXhZUA0R88W6dqW2SOglFnQDd?= =?utf-8?q?/6+Y8M9df+xiQIcJDwmddSme0vQWCHhkAgw9ddJZTpiIF/ocSzDLe0BQlIQsrubFh?= =?utf-8?q?xuAK2W6ISE/bOTAt7Z0D/yo2PqLVxcth1C5z3YZ9TX82ulhk7/IZby8zlQWfmzabB?= =?utf-8?q?R7AnKHiVO1XnVjM2ZBHeEqTDdkvrEPSb8OS/OcwL5dfvJneCoC4FlshYmhxsyg9ph?= =?utf-8?q?2XJfIOSPU4LMgwrMYHSpcf4QJAJR3En/sWavRj10nGV1DvRGsfUJvkVpV7TWlcBNw?= =?utf-8?q?xK7hifJaNiVjXJ6vty6B8Sm8+ixH7qvs2+/FDmq0g74r1b8xxuYV6uDVV5S+Ya/LE?= =?utf-8?q?1wYq1Xyp3pgk0qFUELKC6IWpsAQRfBQJinkgXXOrXQHEmBsardO9F4h5TLAUixC+O?= =?utf-8?q?W/XKsJTZu7V6TjFPiKiyTHITh5wbn0Ep9xpA+gB0mW4otmhEnsL0oHJ7W/xLZpv61?= =?utf-8?q?cff4m2ceg0TKSF66pNcE8tbZqMpE7H0wvcBSIi/2eU0xCrTMvCyI5LHZyMxgGmGW8?= =?utf-8?q?LmBzGXhBV1PNDFsaiS30hG3oVKUnWZV/GchpWgkaYdHx/k4ahbuBqu6DP9zAQ8KJJ?= =?utf-8?q?hb1iYS39xC0f5CAwmRidzQEV1w78qUbU3sV8y+Qmw7Sp23mCsXe/4aDD0YDpq21xZ?= =?utf-8?q?d+7GaXqvQaVM1huOAGJa+Qo6Gg4TOHqCHoaKtrcoOY1kOOOogDBMkzT+Ij6Hdf9+A?= =?utf-8?q?Fteiimlzg3qy5JmaFQA3BKlKh+GJGOYOGHuoqu/sp2RdL4ezrYyUGtnS+fddMXAid?= =?utf-8?q?Uc8hsqP5p/oWmNj0axGr/ltJzKtKvaeyleY7ou9o4gqyGdcsNNndM0mbJeL/qVxVd?= =?utf-8?q?oFE13Pfrked0zt8oPw2X9RawQr1+qT20fAwZ+d1QS0xG0pC1MPWwAVZDOhNItiYFi?= =?utf-8?q?R1sel8YA4fmb?= Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: ZSSqCvZQ70QM+CxpuhnCL7Vv2AC9nRXZU+toxkNKxUn8e6BaV/LKNbTZvNhZiFgqizosgWDv3tSv3mHbwl3Y/HYB+Ynxjone7n2UQ6aBGuhQqMTZvkd+hBxqGwIm2xo+h/wAozVPjLV7IBZF7PTsWcTiWNF7+6WN2rKB+nGqQN1QPfJ9PRaqijyJoejREGBQKcGZssaIENOV6sSdgBSACJNdudzyPWgT5Eo40k+/klSFlgvrwd4Q7InEdtuEu00Fu3GdPIPjoLTTBPt7pN9Mg/GtH0v85xjnY/n1PcUmd1HQGoUMmV0Xrcl8vpvv3dIiKaRHqv+XnJd7HKxlSnnVFmh2uFi+PLCFIK7f7xJX4zFdTARd1CZpFZ8ENjsDh6C4uCqXMaU03V3X1CZoBsfxxap1/N8Uwk8ug2m+AAS5eTJWN3fj9HljiH/0kfUIRMY+TOq8HufgvG5vBTg2mUQFmvlwSLxP+NTZR5hfyCg36pBAAzmjDX7DSvfoPupkMFRXhg9G8twpKCTCLiCOrLvv1ce3mxUr+cfIEZliXp4hMAZX3Qu+U2EmJ1truqV9L5Mqlz5G4vC+G4B7yrWOCjOAJy76APwrWvhiwBVyE0wxHJFkOZNH8E+wK4b8wcmzm5r5 X-OriginatorOrg: sony.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PUZPR04MB6316.apcprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e440ec61-1c8f-49db-e35e-08dc07729454 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Dec 2023 06:59:47.5332 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 66c65d8a-9158-4521-a2d8-664963db48e4 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: XY8pzEyJpl21hYI9fJgIWvHkaxZL0kJ1EXvrYy2m9O5kumznjOY4cqINeNKNLuNKhn2uix06znV010N/QzEShQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR04MB6878 X-Proofpoint-GUID: CwTpJo-HaUIxp9UsxMfpqSzSHxTtfcmN X-Proofpoint-ORIG-GUID: CwTpJo-HaUIxp9UsxMfpqSzSHxTtfcmN X-Sony-Outbound-GUID: CwTpJo-HaUIxp9UsxMfpqSzSHxTtfcmN X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-28_02,2023-12-27_01,2023-05-22_02 Before this conversion, in exfat_init_ext_entry(), to init the dentries in a dentry set, the sync times is equals the dentry number if 'dirsync' or 'sync' is enabled. That affects not only performance but also device life. After this conversion, only needs to be synchronized once if 'dirsync' or 'sync' is enabled. Signed-off-by: Yuezhang Mo Reviewed-by: Andy Wu Reviewed-by: Aoyama Wataru --- fs/exfat/dir.c | 33 +++++--------------- fs/exfat/exfat_fs.h | 4 +-- fs/exfat/namei.c | 73 +++++++++++++++------------------------------ 3 files changed, 33 insertions(+), 77 deletions(-) diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c index d3767679745a..f123c1c2a4a2 100644 --- a/fs/exfat/dir.c +++ b/fs/exfat/dir.c @@ -532,46 +532,27 @@ static void exfat_free_benign_secondary_clusters(struct inode *inode, exfat_free_cluster(inode, &dir); } -int exfat_init_ext_entry(struct inode *inode, struct exfat_chain *p_dir, - int entry, int num_entries, struct exfat_uni_name *p_uniname) +void exfat_init_ext_entry(struct exfat_entry_set_cache *es, int num_entries, + struct exfat_uni_name *p_uniname) { - struct super_block *sb = inode->i_sb; int i; unsigned short *uniname = p_uniname->name; struct exfat_dentry *ep; - struct buffer_head *bh; - int sync = IS_DIRSYNC(inode); - - ep = exfat_get_dentry(sb, p_dir, entry, &bh); - if (!ep) - return -EIO; + ep = exfat_get_dentry_cached(es, ES_IDX_FILE); ep->dentry.file.num_ext = (unsigned char)(num_entries - 1); - exfat_update_bh(bh, sync); - brelse(bh); - - ep = exfat_get_dentry(sb, p_dir, entry + 1, &bh); - if (!ep) - return -EIO; + ep = exfat_get_dentry_cached(es, ES_IDX_STREAM); ep->dentry.stream.name_len = p_uniname->name_len; ep->dentry.stream.name_hash = cpu_to_le16(p_uniname->name_hash); - exfat_update_bh(bh, sync); - brelse(bh); - - for (i = EXFAT_FIRST_CLUSTER; i < num_entries; i++) { - ep = exfat_get_dentry(sb, p_dir, entry + i, &bh); - if (!ep) - return -EIO; + for (i = ES_IDX_FIRST_FILENAME; i < num_entries; i++) { + ep = exfat_get_dentry_cached(es, i); exfat_init_name_entry(ep, uniname); - exfat_update_bh(bh, sync); - brelse(bh); uniname += EXFAT_FILE_NAME_LEN; } - exfat_update_dir_chksum(inode, p_dir, entry); - return 0; + exfat_update_dir_chksum_with_entry_set(es); } void exfat_remove_entries(struct inode *inode, struct exfat_entry_set_cache *es, diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h index fbf76a8b5d88..b1c85f6ec90b 100644 --- a/fs/exfat/exfat_fs.h +++ b/fs/exfat/exfat_fs.h @@ -483,8 +483,8 @@ unsigned int exfat_get_entry_type(struct exfat_dentry *p_entry); void exfat_init_dir_entry(struct exfat_entry_set_cache *es, unsigned int type, unsigned int start_clu, unsigned long long size, struct timespec64 *ts); -int exfat_init_ext_entry(struct inode *inode, struct exfat_chain *p_dir, - int entry, int num_entries, struct exfat_uni_name *p_uniname); +void exfat_init_ext_entry(struct exfat_entry_set_cache *es, int num_entries, + struct exfat_uni_name *p_uniname); void exfat_remove_entries(struct inode *inode, struct exfat_entry_set_cache *es, int order); int exfat_update_dir_chksum(struct inode *inode, struct exfat_chain *p_dir, diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c index be6760297e8f..2c6df4f966f5 100644 --- a/fs/exfat/namei.c +++ b/fs/exfat/namei.c @@ -539,15 +539,12 @@ static int exfat_add_entry(struct inode *inode, const char *path, goto out; exfat_init_dir_entry(&es, type, start_clu, clu_size, &ts); + exfat_init_ext_entry(&es, num_entries, &uniname); ret = exfat_put_dentry_set(&es, IS_DIRSYNC(inode)); if (ret) goto out; - ret = exfat_init_ext_entry(inode, p_dir, dentry, num_entries, &uniname); - if (ret) - goto out; - info->dir = *p_dir; info->entry = dentry; info->flags = ALLOC_NO_FAT_CHAIN; @@ -1018,8 +1015,7 @@ static int exfat_rename_file(struct inode *inode, struct exfat_chain *p_dir, int ret, num_new_entries; struct exfat_dentry *epold, *epnew; struct super_block *sb = inode->i_sb; - struct buffer_head *new_bh; - struct exfat_entry_set_cache old_es; + struct exfat_entry_set_cache old_es, new_es; int sync = IS_DIRSYNC(inode); num_new_entries = exfat_calc_num_entries(p_uniname); @@ -1044,33 +1040,25 @@ static int exfat_rename_file(struct inode *inode, struct exfat_chain *p_dir, goto put_old_es; } - epnew = exfat_get_dentry(sb, p_dir, newentry, &new_bh); - if (!epnew) { - ret = -EIO; + ret = exfat_get_empty_dentry_set(&new_es, sb, p_dir, newentry, + num_new_entries); + if (ret) goto put_old_es; - } + epnew = exfat_get_dentry_cached(&new_es, ES_IDX_FILE); *epnew = *epold; if (exfat_get_entry_type(epnew) == TYPE_FILE) { epnew->dentry.file.attr |= cpu_to_le16(EXFAT_ATTR_ARCHIVE); ei->attr |= EXFAT_ATTR_ARCHIVE; } - exfat_update_bh(new_bh, sync); - brelse(new_bh); epold = exfat_get_dentry_cached(&old_es, ES_IDX_STREAM); - epnew = exfat_get_dentry(sb, p_dir, newentry + 1, &new_bh); - if (!epnew) { - ret = -EIO; - goto put_old_es; - } - + epnew = exfat_get_dentry_cached(&new_es, ES_IDX_STREAM); *epnew = *epold; - exfat_update_bh(new_bh, sync); - brelse(new_bh); - ret = exfat_init_ext_entry(inode, p_dir, newentry, - num_new_entries, p_uniname); + exfat_init_ext_entry(&new_es, num_new_entries, p_uniname); + + ret = exfat_put_dentry_set(&new_es, sync); if (ret) goto put_old_es; @@ -1084,11 +1072,7 @@ static int exfat_rename_file(struct inode *inode, struct exfat_chain *p_dir, } exfat_remove_entries(inode, &old_es, ES_IDX_FIRST_FILENAME + 1); - - ret = exfat_init_ext_entry(inode, p_dir, oldentry, - num_new_entries, p_uniname); - if (ret) - goto put_old_es; + exfat_init_ext_entry(&old_es, num_new_entries, p_uniname); } return exfat_put_dentry_set(&old_es, sync); @@ -1104,8 +1088,7 @@ static int exfat_move_file(struct inode *inode, struct exfat_chain *p_olddir, int ret, newentry, num_new_entries; struct exfat_dentry *epmov, *epnew; struct super_block *sb = inode->i_sb; - struct buffer_head *new_bh; - struct exfat_entry_set_cache mov_es; + struct exfat_entry_set_cache mov_es, new_es; num_new_entries = exfat_calc_num_entries(p_uniname); if (num_new_entries < 0) @@ -1120,43 +1103,35 @@ static int exfat_move_file(struct inode *inode, struct exfat_chain *p_olddir, if (ret) return -EIO; - epmov = exfat_get_dentry_cached(&mov_es, ES_IDX_FILE); - epnew = exfat_get_dentry(sb, p_newdir, newentry, &new_bh); - if (!epnew) { - ret = -EIO; + ret = exfat_get_empty_dentry_set(&new_es, sb, p_newdir, newentry, + num_new_entries); + if (ret) goto put_mov_es; - } + epmov = exfat_get_dentry_cached(&mov_es, ES_IDX_FILE); + epnew = exfat_get_dentry_cached(&new_es, ES_IDX_FILE); *epnew = *epmov; if (exfat_get_entry_type(epnew) == TYPE_FILE) { epnew->dentry.file.attr |= cpu_to_le16(EXFAT_ATTR_ARCHIVE); ei->attr |= EXFAT_ATTR_ARCHIVE; } - exfat_update_bh(new_bh, IS_DIRSYNC(inode)); - brelse(new_bh); epmov = exfat_get_dentry_cached(&mov_es, ES_IDX_STREAM); - epnew = exfat_get_dentry(sb, p_newdir, newentry + 1, &new_bh); - if (!epnew) { - ret = -EIO; - goto put_mov_es; - } - + epnew = exfat_get_dentry_cached(&new_es, ES_IDX_STREAM); *epnew = *epmov; - exfat_update_bh(new_bh, IS_DIRSYNC(inode)); - brelse(new_bh); - - ret = exfat_init_ext_entry(inode, p_newdir, newentry, num_new_entries, - p_uniname); - if (ret) - return ret; + exfat_init_ext_entry(&new_es, num_new_entries, p_uniname); exfat_remove_entries(inode, &mov_es, ES_IDX_FILE); exfat_chain_set(&ei->dir, p_newdir->dir, p_newdir->size, p_newdir->flags); ei->entry = newentry; + + ret = exfat_put_dentry_set(&new_es, IS_DIRSYNC(inode)); + if (ret) + goto put_mov_es; + return exfat_put_dentry_set(&mov_es, IS_DIRSYNC(inode)); put_mov_es: From patchwork Thu Dec 28 07:05:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuezhang.Mo@sony.com" X-Patchwork-Id: 13505646 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 26AB43C0B for ; Thu, 28 Dec 2023 07:06:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sony.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b="T+X7Fdvu" Received: from pps.filterd (m0209319.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3BS6oM1J017341; Thu, 28 Dec 2023 07:06:06 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=pSMmawGnLID88C1yRmTbclURsiudSf+TeSKsopiV/es=; b=T+X7FdvuxNuQl1Ys5BEZ3zp9F3qZerh4om7kAI1PK4oYtRvVc1O8pqAVr1Xq3aRLfmmW Rr3XTCWKJG6swE0imhzkv78+Oh8ZsS2uX++5c3/TA1rRakuHnELufPbQ4R+HdCR5O8H2 oEB2ZDUhS2bVxJzigtzVFf5A3V+oz4GqjC5HP0G7CLUdiCHxhlGxRPAWFLLnEO9Hs3gM GTQM8lTb5MyIDevTvegVEmu6fLxpgIfiYec11unWhr+FLNhsVueVAaRe5ABPwCiN+/Mu Vd2nx/CzRH44ECUidm5BFgdA3vwLiD1EE5in8amFlpmhkUz6vqYlWjNMmR7D8Y0VNko/ 8A== 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 3v5qxtbskt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Dec 2023 07:06:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Sy4ZljzIdWHhIEGtiWa+PHC1/ibb6O1FpqRmz/Rdxuy/lR378AV76gF/X/yX60Iy6EzzaQ465JTwimUJmyL1KxgnKHJ068P/KZAMAgKQFE4uUP/cJsWThPXWovvMzWxcdU0Ir77yj6zf8/gd2GkpFhsTdvr7Ev/VFTd8HLFOXizSB5Tc+HuurNgZto/aT6tHGootsxvfD09ooL/QcxWy0ElBfyZ91APFcCYVSt8HTI6dCOqg0lAVjLVfVaOF9Ha1K4s2bgDVq1U9AKrcLpA9/Cw09Ycz9PXME8n10DA7M+U/kpI9t81iFZLF58jClQlwOu/4lFe/+lc5MaVAEheeog== 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=pSMmawGnLID88C1yRmTbclURsiudSf+TeSKsopiV/es=; b=JAFlJ6lawPZ1Dt/N7GwmdX5n0qNyQeo/kEfZIYJYa6xoYdou59WSf/qOHKHZLuHUGZ28bNL330xG4BITEej+A/eVfkHoAx2QGxyK4Vnq+k05eARM5hZzwcAYUDAs0oKNHyoyHPKf0qhjeJBqa7j0QGgUQRJPy4SUY0TgAg4LxpRjm652rqsZePd27XT1FACdHnQ4AfdI4DtC+XagK6IGGRn2/QnreBFnpfryBLHr9hAqnDhio7uc5avRlLte1EybbPHZlwERG0sTLX5V3r5l1Kf+bXf2aEw42t0WZy+CzSAq/4H89UyJ+ZlJYsSQ05V5W9JA8QZGso/nWQsG+ptHKw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=sony.com; dmarc=pass action=none header.from=sony.com; dkim=pass header.d=sony.com; arc=none Received: from PUZPR04MB6316.apcprd04.prod.outlook.com (2603:1096:301:fc::7) by PUZPR04MB6959.apcprd04.prod.outlook.com (2603:1096:301:11f::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.27; Thu, 28 Dec 2023 07:05:55 +0000 Received: from PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::5914:6fc7:b79d:7e34]) by PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::5914:6fc7:b79d:7e34%7]) with mapi id 15.20.7113.026; Thu, 28 Dec 2023 07:05:55 +0000 From: "Yuezhang.Mo@sony.com" To: "linkinjeon@kernel.org" , "sj1557.seo@samsung.com" CC: "linux-fsdevel@vger.kernel.org" , "Andy.Wu@sony.com" , "Wataru.Aoyama@sony.com" Subject: [PATCH v2 07/10] exfat: convert exfat_find_empty_entry() to use dentry cache Thread-Topic: [PATCH v2 07/10] exfat: convert exfat_find_empty_entry() to use dentry cache Thread-Index: Ado5W/+C7wt5K7jQSEOJ+WU4u3YvbQ== Date: Thu, 28 Dec 2023 07:05:54 +0000 Message-ID: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PUZPR04MB6316:EE_|PUZPR04MB6959:EE_ x-ms-office365-filtering-correlation-id: e50e6241-d923-4910-6ab8-08dc07736f4a x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: FYRLj8jax5tjvK9KX5Si7nTrapyPYVWb5e5eSWl0Ur41iSGSS0u+43kZ2UtlX0/jmr4AEAUXUY/ssewl0L314rWSWMNQgEN1hKf5/w/0JAJvNbkHrM7WLYuIUmykMtFYYkI0Bp/TMKwUaVPXJsty+KP13T7yMAg3vCgXmSezhmcaqdYr4aI2Xz/sAnbn7IhHXjY/lbV4jVpI+wUtRVS9Lz6Gcr/ilYvEg5l+bvcRt8idtNpRqkER655nysGUlRIrss8i/1w0h4wS4rsxZDP8I2DLpupdQfCDWhxxhCWT7MDLIji0eYFe4beSILiH0oXJXXQLyF0Qc1zQjIaiWPorDQlXBl9EP0q9fhBFruN6lnjTxjXUxMj9AaCnbUtxj1z/DJvV9Y5+z2DyxgsRmUC1Moh2x4nmHQczk9gyuiEpVawtUq7Bi6UplB/uEXY+Ghrq3TKoV8Y10KkWom48tT/fYtmuETVFl8Spju4sOm6GgVWlk+tcikAO2XCZ8+X0MWeoLfnykdqP0R1nM9YzWvm6fFoiRlg3FqcgkKhp5ef3nebatpSILM6Q+MtKoYgGNTAB8i95CmaoIYd9a+BBZdwd5Zf3iOB85GyE14Bi6vi8KZlNxzwPA6HblPyaPx5Ct7uK x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PUZPR04MB6316.apcprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(366004)(136003)(376002)(396003)(39860400002)(230922051799003)(186009)(451199024)(64100799003)(1800799012)(2906002)(66556008)(66446008)(66476007)(76116006)(5660300002)(64756008)(66946007)(55016003)(4326008)(52536014)(8676002)(8936002)(316002)(54906003)(110136005)(38070700009)(9686003)(107886003)(7696005)(478600001)(71200400001)(26005)(86362001)(6506007)(33656002)(122000001)(41300700001)(83380400001)(38100700002)(82960400001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?l2geST/9sGeAqhCXieGNOgllERmn?= =?utf-8?q?SvakVVkFtD7Xrq9Xf2xdHybFCKbumKDIF3RcLuZxy8UAllxbWZETwWiE+ZLOLc78O?= =?utf-8?q?g+muV2j98ZtJauQlqOMxGAGTzdhpE2/WK3jtH3ShgkHrho3kVuv3D0Cazs2h5b27o?= =?utf-8?q?liGIG68BdSI7gE8dBUzgZMenMTnO0gRMBeBScdCoUTswdj2iWzaXqxbo8tqX1qxsS?= =?utf-8?q?cl2EpXP6fn/IwVV1ETGh8nKvjbmEdh3LW9/rGYrWcMBdqtxioipuuOdfYjD7zzNCW?= =?utf-8?q?GIpkLQuAuk8HHfImGxKdjtcj7j4BBOZooHyceEHNjtTWgQCTWyqDAQB40D6fSmrfU?= =?utf-8?q?VwyKoXaISPCeOBHcjLe4qpI2ggi6fkxTSmXGGo0UqvASQDANQGH+Scx5DJhg9nfHz?= =?utf-8?q?oI9OMVhwqucxyCFiognpH/6bfpUfW5Wv1KEIcUVufXfpEA8JiQZEUXHol93NWMBbb?= =?utf-8?q?znUIrw7gEM0QiaJuBY3DYXu5GjQ1nhVorUOKekCL/NqeY5bwc7N/4H3bIszy3iPIW?= =?utf-8?q?e5uAM8zbpKiK7xqwuHTZxR37OmVmiqFYtLu5xna/cGqWsxw55NEGB44mCQHvU5/4s?= =?utf-8?q?UY0IlJ6thcywbrI2GoeKEP+/SyMBLpufOxxjyvhUeMw2cz6K8lM5Tojo0f36xRrmn?= =?utf-8?q?EzNJRK9+TbEnsrZt5uWHXgU/lC3Amn+4ZlcwISNdc+RBGiVjXpGxjXD5CqCZTWCIi?= =?utf-8?q?ETXlWTBaXmFObaNzOl0mxq1OTgr8rHUKn4EnP8e5wWnGr4Q+4agma4sMcgC9OBVNl?= =?utf-8?q?H7Cz/1xQqQR37TBRBQotbuuuIqytChrMpcRLQgz5mwBckJG1gpMrYetxqyd2fCTqm?= =?utf-8?q?7/6XfCsgyTYnzmDd/iM9WUErmoZpguEa8/m0Ww+Ymc6tgMRF1btWjbOdciBSTgIhn?= =?utf-8?q?l33R/tW+SoIo41SNHdZCCwDPgmQbkZqP9BG+x1JmtkxtVmmY2D5u8MasmFcX9iTzg?= =?utf-8?q?EZ8ramsg52JnVw93C1JgDtJSStJdjbkHgxbni8TAOA30Zao/x7oDdbTvJQhxGhnsX?= =?utf-8?q?rYGZAz5nF5yGcK5A0DmBLHiQKfUXHcAanSht2SstnfD4kwi065lDP2EjaowmXJLzM?= =?utf-8?q?rIBmdx8tZEYJMIkz58sZJkh8Vg4jQuZYuUInNiqD0qQnb2EMBlUojirWJO9FfHjKt?= =?utf-8?q?gpuDXw7zqm3xoP4E43JvcN0fz4QnCt8xwxmlDwIhAxqJ6lwd3wfSFfD2IW5x7DToI?= =?utf-8?q?NgWxU4iDvj4T4i8PK9ByeGCnTvKXU0U93AGeG9QBFZ4gEYyHokovt89upl31ZnilV?= =?utf-8?q?kpNqpfSCkvrBrop8cKEJSz5DrTFv9+kK+nqR6ZFbZ+OZ+8hAq8snrMOpacbKPjzjJ?= =?utf-8?q?WYPBXw7DlRKRHJD8pL2huv7EAkuqB/MIU/rexMi+7/HHN5+ufjFNJWM8TSJXSd84I?= =?utf-8?q?27oZDRd29yCBAJMotflBw73cI5qcv4i72+dz8V6MsZA3M3rew1XBvbVvAigojPx+X?= =?utf-8?q?rh7pptvvKLPyQsxzLdvrZ6jlIHmTn+hsi0qyk0sXdiZD6x+9my6S3ChLRuLeQgif7?= =?utf-8?q?4pc8QKpIT9hB?= 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: Eqef2v3WyEyWrI6VXmZzT5Z7ranJdYBfxNzsF3/IjjRoFSr3LKGoAokhoKlVfuL6+XsTsS+1nxxXKc68KHWXNtYBRV3qz0d1nIkn0pj4/akcRdpDKPjBnKNgtLSmMyIufVQaZm7Swm7FLN+lki+aApgbAk9+N4fyA8ZcUUHt2UNCpkMjVsF5YsLbZhZgan+//eDUIkEXbhVYCv+cIArZf+VtY6Wfnl3Du2GnX4vu7/8izhlAgruUOAagkOEJMkxujBTP3QP+UeOLSCBAOCERRxPnhsxTeBos9MoCgb796roBgvMTIVKu06I8II2eGWiAwP5NwgUu+BlKhe0PxTylQ3aJ2UsIr+AM+pVEUxbPGIWIsqG4+TCqY9DO94HeEKT6uANpizCwxJWtZIKCaMcSd+TbL+E1rtGSJVRhdImGgmPyw+SPQoqu19HFrZ5yAxkF6kkLWI6RNoH0KkCp8W4COAphOT0SXF8J1SloeI9itL3/Pech7cWyii64a8jmkETdgXuDJVWJMZuAYWF0l2uK33WTq2wH727LgGC1XRoRspAHlqbAC41CWjEK1vP6gEvLtf8IomNtMuExJWA7VEVJLBO9mbSXQUQl0I2fEgarwmykC8+Fg4fUa3DxsY4E20Zr X-OriginatorOrg: sony.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PUZPR04MB6316.apcprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e50e6241-d923-4910-6ab8-08dc07736f4a X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Dec 2023 07:05:54.8971 (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: PaMX3GsfZM2I/5Jw4HHguxL/Q6D8ezFEpacZEEXqy7RnfvDbafCQT0zwl6PE5lTZuGJqQGhf7Bk0Ax9F3NsORg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PUZPR04MB6959 X-Proofpoint-GUID: QEYHza4BvzlwONllSvMzHDkH2Mab0iFw X-Proofpoint-ORIG-GUID: QEYHza4BvzlwONllSvMzHDkH2Mab0iFw X-Sony-Outbound-GUID: QEYHza4BvzlwONllSvMzHDkH2Mab0iFw X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-28_02,2023-12-27_01,2023-05-22_02 Before this conversion, 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 Thu Dec 28 06:59:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuezhang.Mo@sony.com" X-Patchwork-Id: 13505644 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 78FDF63AE for ; Thu, 28 Dec 2023 07:00:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sony.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b="A6fvfrHY" Received: from pps.filterd (m0209322.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3BS5tcBc026015; Thu, 28 Dec 2023 07:00: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=OsiQNWbeqXP3B+9uexlb7CKFzPFIDzG5i4Lt1yY0oNw=; b=A6fvfrHYVhNHgSSMx7p3a+syW/YWw7WAnKsCj3Na+ggoPwk5KCJkbQBaFgltAt3uMfOJ cnLN3F0/oXSSlCXHSZ9afKCNQ06WAx+nwphbHECS5MyBmsvbKSXnI/mOu9vk7rRwoMjf mKi09FWQiZ1ts+c7V++aHvswXJni75axXGQSbqzCHs6Be8JJEE8WPTzc+/KZ6mWup0IV q3GUzerXsCaJHTFQpOABEqGtVx7Bb7vA3at3PfxvONZgifZItqKCaOECUh5WEjWHNBZT gJ7PWU7Ni7IHgmdcKwlTb1Yt/nwlNvHvyVpr+9XbRI4eeNhRxcHjopXxED2yX0eNqWcp bw== 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 3v5pb73tuh-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Dec 2023 07:00:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M0cMwrr2LyLI4Uc3zkT31gOWq8UnxxS5pVf0aU64QI8JkYzpdZZ5npqDlErxcTihEZfNEjyPe5nVpZlCNtdax8eoH5tETbkB9vCPPjPrBZQj3G5Qt7tJE3GD7tTeKzByhlFRP7yCuZLvEN4DbOUoOj7Mfzm5j97H94KxFZIq9umY0wdiUDm6Wf+svCZq7UbLsAqJBmZg7iGzdz0G8ixoNAGiBUExyl3HJ0E31laCGSgGuOECgjXo3aZpkiB+PL/qit66otcii+Bc/HyG8GzPkVtjbGIUINucoND0sxdRYRyIS9ZoC9t/mB/yVyJjPbrOuz5iQSV/niv2CEfDG6Hu1A== 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=OsiQNWbeqXP3B+9uexlb7CKFzPFIDzG5i4Lt1yY0oNw=; b=FruOlw3XteMO8b+ArCMHyqfh3jfJJbRnRL98trJxZMbWU30mNJRa3bwQaRlj4/pGKEbVam03OymLULHL1FBFIP7Lk5SfDoAP9kRivJBv2vEwdzVwIp3gyttJ89HHsQE40gKDVomKHcal+SqeyV2TIpIcqETz+S3fJtnBZK0V9JUYEM87nMZ5VYNPTu+Kr0juuU2Ukfv82DNTpAvpeUafKczwu90bg+6oH53N91uIduZ+L9bWVhP0yfhuvXrn9uEs7vF1IGzTTXexnbr8nngmmq5w3HQKNJqIGRELDl3PrkLjD/q1+8o5eXFYYpcnNv/J/84XdFVH8lRzb7Ysn8RtDA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=sony.com; dmarc=pass action=none header.from=sony.com; dkim=pass header.d=sony.com; arc=none Received: from PUZPR04MB6316.apcprd04.prod.outlook.com (2603:1096:301:fc::7) by SEYPR04MB7223.apcprd04.prod.outlook.com (2603:1096:101:167::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.27; Thu, 28 Dec 2023 06:59:57 +0000 Received: from PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::5914:6fc7:b79d:7e34]) by PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::5914:6fc7:b79d:7e34%7]) with mapi id 15.20.7113.026; Thu, 28 Dec 2023 06:59:57 +0000 From: "Yuezhang.Mo@sony.com" To: "linkinjeon@kernel.org" , "sj1557.seo@samsung.com" CC: "linux-fsdevel@vger.kernel.org" , "Andy.Wu@sony.com" , "Wataru.Aoyama@sony.com" Subject: [PATCH v2 08/10] exfat: remove unused functions Thread-Topic: [PATCH v2 08/10] exfat: remove unused functions Thread-Index: Ado5WrnLuTRtybDYRCqx8qBlEMgWyg== Date: Thu, 28 Dec 2023 06:59:57 +0000 Message-ID: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PUZPR04MB6316:EE_|SEYPR04MB7223:EE_ x-ms-office365-filtering-correlation-id: 94043ca0-ea91-43f3-56fe-08dc07729a5e x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: WnOqVhq2+JOQzuc3qq/mjQhVker01WHsCRgORSpnIE8zfSAmifIwpcMmRGitrhRt+p8Zxx9un9mBZCd6gHWeFu250Lj+mmDE3mRWqcBUgjgHELjZKH6hXvqP9dxK6beGuxeFQ/TShnKXDm1hdQakSEzPf/MYnASFCJU7mpbLHxJFckw0hQBKXwgCSTsZAcvKADSrwEFT+V4nxrWmDmilQigc6Tv5PidPRQg1EDUxBm3f78XhTulzyzvQD0I361GFulOFP2hIq+fL76jw1hnNF0Yr0zsFeKq3SlsEwDDpYGTNCwNzN/JGMJZGjzy1IbwN+o8ujIISnRvUcAJQXAFiHs828tefOlhIkYmKMswMwlS/W6S+j4ICcnQT4bAZmA4k6q5D7sCmy/aeJgbSqmK4R6g+g8/Vva6hQd95bk7If7JxSp+MBx0PK0H4VldJ4tb48zJnlAD5+phq0os08EhIx8YzwACJY9fmJFbZ8TzyRB+20SYDXonXIn4lanOYY6TzwgO2yR8WF7O6OPILsqdfIxDCKHT3gks4ApQjDQuma6UjhcMe2l3BXL/GlXiBcaLWC1YI/nnI6GjPlNjcrdWkU0C+Rlwh7PQ7kxESHuq4b08LHL4fy0X5DHyaSarw8t5f x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PUZPR04MB6316.apcprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(366004)(136003)(376002)(396003)(39860400002)(230922051799003)(186009)(451199024)(64100799003)(1800799012)(2906002)(66556008)(66446008)(66476007)(76116006)(5660300002)(64756008)(66946007)(55016003)(4326008)(52536014)(8676002)(8936002)(316002)(54906003)(110136005)(38070700009)(9686003)(107886003)(7696005)(478600001)(71200400001)(26005)(86362001)(6506007)(33656002)(122000001)(41300700001)(83380400001)(38100700002)(82960400001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?WdpZeVYyS6l3QDNbyFpsBA6hhlrl?= =?utf-8?q?N8Ms5h0tVcjA2bd+E7eKtrKW0P7/mPuGbkDrqafj5kKYyYMWNZEQM9Lfi0qg/uu+w?= =?utf-8?q?6b8Urqp2Gw86Y7tM5ap25nwUGrXM25jYEnIo/uIntjK8+Wx0oy+tW0nppwKlm9NeC?= =?utf-8?q?GfbuL39PTIDdJKXgKgND7Op7NXlNa/W8vwMRZdLrIzZ+tButU73YezSvWC6nQ0yqr?= =?utf-8?q?s7WHt1MFqoRd228uw74MueiogAHKpr3w5pRa+/KlAB/TDNdpb974F46I9OG6bmkX6?= =?utf-8?q?8gWQzW4Cj9TMojCybG1murMixKlcek8rJnucdOjNeBu5Tno5W26YGB0VDlUlZZ03I?= =?utf-8?q?5XeIA84dqj4unJaPP3Y+5NyjXZr8p9OCRptgDF69lrLga6NtM6CMppBB0V3H2VuZi?= =?utf-8?q?hYn56r0oLgw0RGfqnweQkhAI8hgNOMOWMjbl3GnqcuIH6rcXDOaDnlWjm+CFFNOnx?= =?utf-8?q?3JcD/IalB7urnp6ggEZ6KZ4KRwT2r1qHsTVdM4QUKy8eNMYHolpqWgHexm+mNmSjH?= =?utf-8?q?097pfAamW/ycfaP6tPTmnNFi4WrtMktmgXzRb4Jx1LNbzHBa6/GxQnJyLZ69At5IK?= =?utf-8?q?BPPABPUoHVJnh08OAAp144vHp47nfQcOE3B6lYyLaaP82retz2WOhGxy39O6q7/m5?= =?utf-8?q?W0WMNVgLXnyl5qSMLJ6dtYPabZ4jYNmVQCAspOUicd62whWsd6qWJqj8J7EJyM2DG?= =?utf-8?q?ExyjiaxBCLo8giix8nFb+bxLNxFHgsPBXlYQVMgQtrnDkLEwupRnOrleet3cU4Aow?= =?utf-8?q?FRltssyZ628HXD62AE0UUIh0kiHbxtbJAs4U5OvDNckECnwQaVJ7IUNfv9RYKTEey?= =?utf-8?q?1FaA5I5WdEBNqG+cr+67y6kOF6AKJECLf9VdjfOfnB4UZ8b62sIhQSuCtrNPdrQ+w?= =?utf-8?q?DWICiX1/lZ/lTq+7bfkJVu3sRn97OVm61USgsOPVaFeI1yU63DgOeNqf0+Al3Fbxp?= =?utf-8?q?wZUrL8bx156LoRar7qzbCqdzWHDbwEo3svnd1LJr4hEXCJ+C+opDf0dyuIjnGYaMu?= =?utf-8?q?TqfpiPVagi303hrevYPWCJbURaGjbQ2vsQJ6JI+XCQ8V0aMAFzdE6qnUwKgDYg1YK?= =?utf-8?q?se1AiAcrzAWRpDSucIlY2EHS1ZEYL+0SmGU/pVko8QXe5cqKU6LZVDQKmy8nKTKGo?= =?utf-8?q?1qTHJS642Gs3iWfQRwu9xR0FHnv1OcBcsDNnuVt2DFKXatQxP59dcS+0vyc9BRNJB?= =?utf-8?q?uxTd/lOdo87cN+lz/4MjPcZTb4RXJdI8oySK8sU/zhPkpDguJ0Lxf1FPH9+PO+YkZ?= =?utf-8?q?Smbw0ZKs/JlawlYo6KaWKJSKkVTwyocDCr0E2+HxngFWpZeEl+nmz8rZF4fFHVzFv?= =?utf-8?q?gYeGdXXE0aIviPdxdntL2Kvyt7sBen7ABgBrWhPQe2XNDXbAhhb6K7aFMz8HQnwlA?= =?utf-8?q?QM8Vf02yAMsaug/1iifm8ANS1qNO5sU6VRQCBFYtCzh2q5eYEYEMc+WpSjWKUMGAW?= =?utf-8?q?UDKySl2c02FPp6abu/2H39rFZPiD2klgWAKaouQ2n6FBBhb9m3ZSx0nGqB5YaeY6C?= =?utf-8?q?J64E6FzViMs/?= 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: 21Y1zOcoNMIGfAR+SS/yr3FShelxXg4b/sxwfWaFYKGqKFWyAGyP3oZKuchFH970VnjcTAcHGDgs5BY07sw4V3yzf9I0ucuVOycYus1KAS8SKov/J8504N8b6qjzJPlgg/lBcOiuE3G/hUgefJ+Q8VqHPgKO3nN+vyR9No/T3IUS/ABnWIUNjS18n1BBqRCVrh5KAO5Ooeum6MOxgiNKPzp4F/UrBAB4gjnN8igbzeXBRsm9ywH+Rq7Ql+PL6HNL6pp2WeuU7PUwDE1zXdqnC4sZY8/OKhYoNTl6cxRZnUzimskWIiDi7hIuqIQJfma07wcyc3dzMvX5bnO9nhW950uUGKmauzBisIn+WiDJZhUL/C6HhZvnKaWMTmeTtp+ucMV4mwe9wkcXwGUiC3VztnZ7/i8cNLgetNb5bRFwFgr0zL7McULpOLibDDjFL/3uCvooABRwmCleqn+iQ842m1eHasDcQLMWHf1T6ssG2s70HRnH/h+d5eoDQf3rG76W1PE6pVFJcqPnSZ1s/R5Y7djzFwLkz1mf6RXLpf/8kFI2hRMDkD7dgmCc+m4qUGWMS5/HhjqcBOAeC2o7ZUEkGDWApvC7NSz92nBjK3gSBGEAbyHWhxR3bIaI7ii1H9Lv X-OriginatorOrg: sony.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PUZPR04MB6316.apcprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 94043ca0-ea91-43f3-56fe-08dc07729a5e X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Dec 2023 06:59:57.7121 (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: M88SN/opLymPftqBbm7SVVQgU0xSPOovZTljNQ6bl2qVLWRjPvd/jossCSWbC2eQ0Em6IN6w0OTZ/LGR/SieqQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR04MB7223 X-Proofpoint-GUID: eRXtKkVheJdveC2UArHaxQeKkQTT-uVJ X-Proofpoint-ORIG-GUID: eRXtKkVheJdveC2UArHaxQeKkQTT-uVJ X-Sony-Outbound-GUID: eRXtKkVheJdveC2UArHaxQeKkQTT-uVJ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-28_02,2023-12-27_01,2023-05-22_02 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 f123c1c2a4a2..88a8c2a60988 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; @@ -1237,27 +1202,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 b1c85f6ec90b..77fe410c11fb 100644 --- a/fs/exfat/exfat_fs.h +++ b/fs/exfat/exfat_fs.h @@ -431,8 +431,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); @@ -487,9 +485,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 522edcbb2ce4..0614bccfbe76 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 Thu Dec 28 07:06:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuezhang.Mo@sony.com" X-Patchwork-Id: 13505647 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 2EE5F3C0E for ; Thu, 28 Dec 2023 07:06:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sony.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b="GWsv22BC" Received: from pps.filterd (m0209319.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3BS6oM1K017341; Thu, 28 Dec 2023 07:06:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sony.com; h=from : to : cc : subject : date : message-id : mime-version : content-type : content-transfer-encoding; s=S1; bh=XQc7WilSUqGnVRhUeh5Xfm3jTDGXLHZG0DSA5X05eLE=; b=GWsv22BC5b3nJAsz5LlSL9uZGw4666xC3MXATTE9AUH2vd/lQTvuOTAHL7ffiHTZsrla ZwgyBS2bw405z/4npr66/EUncMFfhCDga97hHPWWnupbx6nKgd+hoEk8A2wylhLbyuV1 VocWZI0IaywDlNA1NZxusNcdS+DbKLpDyOxAYCPVuc0Gg2orBHf8j79uyQ5SnUxAD+sE T0qpxBx2p1Ts3bXU7fGttyywK+wwwCKFF+9z9TQ8rVql75aHz1COEruuYkoTM/hIlsKO IwbHjI7NjRumeheeQeUcljrAf4/s3HC/c11utPit3LQpfOqwqesoA+xkZIZcGBiWi9yP Nw== 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 3v5qxtbskt-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Dec 2023 07:06:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iziYquhZQgy6YbPUdkvpKajW4Nnzy1ifBAioRNps9cqp6oVsKVRmCCJKqWBgwjUN8foPU5jtH5y/32oA3esajIZuHzzA2kTvTg/cYpli5i4uvnUtEBre46BoWR3HzosW++Q6fKHO/2qS77ZCQYPjmrer3j+kiZ3c5w9iYfcSA9cJr3d6bQBIDzB89wSJPOViRUWteEpu3BiywyffFW9R8mx0G6zmARQRX8rR3W1HQBp5byqo+m/I99cml6HzcBSuNg5r9X/OfC3S0j5pIja+XunK4RfTXGGTBzBZuDD+GpyMelCMFhf5ivSCxTObCVCPmDtBEEdvVZceWwj+fyx5iA== 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=XQc7WilSUqGnVRhUeh5Xfm3jTDGXLHZG0DSA5X05eLE=; b=QLemR8LALknkXp/8WjgAaX4Zeb467EtgE545HC92xXD8j4aPPjv7Aa/oEkM2WOchucwwNiwcp1Pyvman45Ln6OFVCUBRq9bJPsoHNuNsWuEAgSW6F44SMbO9Yu9rQB7oIks6h9552f0Ggt9SbhSLgJeYlsNVARlOAOpUBVLvfoY3VZWj2/6TfiCK4dXht0TpvDXXnOCZgVZbFnlYcWumcoCp1a05mC0OWhiueBfAGhRP26jlfO3mD9laGqk+oAWRZKD28Gih3yAyMrInXOEx6ccqM2v3VhmnWlHrI0gpWGOTEoYN5EiECgLAufglWNaTLdG02hA+mbPUb5GFu1pn6w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=sony.com; dmarc=pass action=none header.from=sony.com; dkim=pass header.d=sony.com; arc=none Received: from PUZPR04MB6316.apcprd04.prod.outlook.com (2603:1096:301:fc::7) by PUZPR04MB6959.apcprd04.prod.outlook.com (2603:1096:301:11f::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.27; Thu, 28 Dec 2023 07:06:01 +0000 Received: from PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::5914:6fc7:b79d:7e34]) by PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::5914:6fc7:b79d:7e34%7]) with mapi id 15.20.7113.026; Thu, 28 Dec 2023 07:06:01 +0000 From: "Yuezhang.Mo@sony.com" To: "linkinjeon@kernel.org" , "sj1557.seo@samsung.com" CC: "linux-fsdevel@vger.kernel.org" , "Andy.Wu@sony.com" , "Wataru.Aoyama@sony.com" Subject: [PATCH v2 09/10] exfat: do not sync parent dir if just update timestamp Thread-Topic: [PATCH v2 09/10] exfat: do not sync parent dir if just update timestamp Thread-Index: Ado5XCkaXD3jsLKFSrmKxdYpGZSlCQ== Date: Thu, 28 Dec 2023 07:06:01 +0000 Message-ID: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PUZPR04MB6316:EE_|PUZPR04MB6959:EE_ x-ms-office365-filtering-correlation-id: 81d43e89-79ad-403c-d258-08dc07737333 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: BepZ1U0YtQn/YRgaphtcLTBxBBHAezSzBSGDAwTIvkAYLbf471SFR4rOKFwFB63zb6nGYauoOEEjGHb8ldKW7gaPFV2zHRwFhr+uTlslJDEyLtkE6KegY0oT6P8A8OCl2s9KMS0uYYRbygcn6ZXgb7uZ+H1mLauh2sfEKAXOQOtDTClaDkMAa0/v/Vpv5enpnIMn6/tvChxbYbYu7H3q3q4QH3eb/8ok0Be3kVXmGQY8cDMBPAyijCf7drMI0eWREzxyjbFt80xeqGI2/e8WV0WJGSTyIA/V9Dw1SdCZC3kiPefo4fg4X9dKcYBKJavToRjT/QuWEWTkHTp0lAfsgy8ELQ100+NTj4w4bBHrgwwzBj5zRyo97j+Fshkt6EiDos6mgIX69+iokciZlwjsRgEKh/gaMkiV++9Gf7cumZzNMDREYWxkNi2tSxhAxVsK7qujenyopuvuFT4S+YipBNNjplzPizfC5FuSDs3WkNNj/uxEvSJp/jdLZo/QQNH0lnfIq2zgYyCDQbSH26gcqXxgI+R7xHvuUfwlg96QCN6bZlVmFPStPQSjXbY456nZR5IPNBWUyuo6SkaHhX2T94kD5QSiSla4wD8tnDc3375rQ8BN0JoZ0FED4JBPmJAf x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PUZPR04MB6316.apcprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(366004)(136003)(376002)(396003)(39860400002)(230922051799003)(186009)(451199024)(64100799003)(1800799012)(2906002)(66556008)(66446008)(66476007)(76116006)(5660300002)(15650500001)(64756008)(66946007)(55016003)(4326008)(52536014)(8676002)(8936002)(316002)(54906003)(110136005)(38070700009)(9686003)(107886003)(7696005)(478600001)(71200400001)(26005)(86362001)(6506007)(33656002)(122000001)(41300700001)(83380400001)(38100700002)(82960400001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?l9mMNjB6ylKwo0Yw0D1ChQHt3mzp?= =?utf-8?q?+drp8zsPLFHPwJM2pdpL0BzrDkpkNahgpFmNmF1Li9LmIiSqe31cIJX+eSUn/eepE?= =?utf-8?q?IpYPN2NIOGP2OsDnra2OoR1Y+o2+iuO8nLImSCC97ugY2phOsm+fkFSKnwJ69FdpW?= =?utf-8?q?RzycixJa/fnBFm0y6Xy7QUva6vJoH/zqrZo80NJyFT5H2IR8XKzih6iYhvvaXfcnH?= =?utf-8?q?BcD8sRikZN00BNtmWr9ZGosi3+bCE6tWd5TQFdArE9xQi5sPozLVdKv4A6pqDq6K3?= =?utf-8?q?xMc6MQgtbKyEpz1qVDyIZnRDgV21uN0mWHk92SHE+9eUj9kSJAYni68Zy6hxwcQr6?= =?utf-8?q?IMZ3h5p0920y7x0/RWBGApKuaSAgej4E+uXIF+7BMDa9w2RfC+gm0jvm4w1N2Elvr?= =?utf-8?q?e1biCzPdqG/s4orjpCfUpFtMbO+60/hQcXYM0mZFuk24pAG/0GLobmrmcg135ignk?= =?utf-8?q?+GrN9nfuavjwltHAYtH85UxX+VsTk+71a72MF5g3f1h+LsXHTefjgCgimElOJsx2H?= =?utf-8?q?83tI1sx4eYNVeQO16pveKamWgvbAIlmJamLuVWdE5IObbf4iEzuN0+Aka9imyrWPf?= =?utf-8?q?yLw0oeWG5eEXnUZBMfNhxzexWjyVlLUBjAdVs6JP6YmceaEyRlCVXY63w+GXHF3dk?= =?utf-8?q?h/WdmwgylJxqLWyAkQ4LmJadYofxWuOEFRaoSqW4dvzAPlAE1WLYIHVnxl6gcOfCe?= =?utf-8?q?G6gu4Pub3hHgACb1I2RWfP69V0vCZuRCbxh9cpGyS6ijCl0bUOssuJVFNbSWA2tmq?= =?utf-8?q?KoSOSQE+aXdgZqlLRuD0uPnUg7kN39MeAKLM25g/YKvsQKEyYUJAcfmw9KqppUoO5?= =?utf-8?q?y+Bu3ow5ioXGzBk41yX1jDNaEr9SPV7CenND2sCQHiPoCPfYaSEQi3TjSXLY7rEl/?= =?utf-8?q?fXZbx3QHZbMr79143DcKDO6CzfCzTZJaCF+9p6Jr4rMrO9Z/3IeLGUiyxbd4jyOQk?= =?utf-8?q?9HCc9+XAg70pauJ9xHJ4hSjVQzlARS3qpJTTzmpD4y4yDwqMcddWFHxW2XY3JY49S?= =?utf-8?q?x3QTjW7pmkZm8f1ZV/8sBtEnQRymfVmEUlnnpELB/LEV4XUQFeg2CttquvIPTmGZm?= =?utf-8?q?fStitFSk9P+pDSCRoO7PJkaR9e2Ladeign9KNSGTJpvqPgxdZjdLj8BYqzuURFqii?= =?utf-8?q?5lGgqlxzKR1PDHdgWa9vvDVU2kwFsJDTvTfuF6aGSwLmo4JaqPTFnTEz+Z6Vp8bZl?= =?utf-8?q?Mppn92xDyYJw2lFt9Yc4Qjl2tI92+CYjxb9nXMONJ87CmS/p4kJXOHXU0UJ0Kg7Tc?= =?utf-8?q?1HUiz67kqaRnxqZ+ke/BaMXeWQyABZvACYM50ydY5eAPunFhjZ4oXmlX5uvJE1MJ6?= =?utf-8?q?l+aZQnmsAB+O6JCxCVLeX6C1ViH3Pca5E6F0tMTD+xw7Lrh7FjsLAi1KiNB8ZO9/4?= =?utf-8?q?RL7FdI34O3kk+dOboOT5vLquz5qV3BlR6jSYCqEDTzGx/oeaum1g08khTIVLOD4x6?= =?utf-8?q?3o3ksV/o8MiU9gdaFo+HXtM8DykIUP2sEVIyo0F38Pql14OYKhUkXyLjVb6sX4JSj?= =?utf-8?q?h6lW2z8+hjY6?= 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: ev/Spd2Y7Q971iF9kFDHJ1qDlVsfxjftw3bgFpYkA391DJF7olqTgC4Tcoay7918G2EXrDJ8CGX9Xn46QGw03BmOxV2oZnokuBKkcil3KN1mHzB4RlOOHPr4AMe+6vaDsh/ITU8gs+L0NzIBiZ3Cs/+utZrjCE9iq+ubcIqeUffnt9ByHtTxM6g464f+wzfnbouPWrvu+BSLz+jk5XQD1P1bJlx4y8vicpDooyW1ZIdUCOWERcpoHqa2Xizuryo3RmshikHjMMHofP1MSKCdqIgU21sUumYo6n5q3DUqmdW4nW/zc8khyiR/1eh6TErGJMCeu+lwQ3r/kY7jenAzu2oWMO1P1HZxWs9Nc5GvyApLhscbWz6K1no9Fs1FrShRx5sA0MRaj2dMsV73o0wUziLdetSb4Xy3nuIXIMga1+h+918EwdTnGplcl2cjx8pHCAleZpTDAr7rt/RBvdNm6JZaBcxEAjet/xcUhcfcJhX3YyVfejHlao3z+6IrNFJ0pjkCv09u+9pfxKpZv3o3UKvBDT6xiN/lSbjNDz0csNu3CTR2Y42UlHmBSShgguzW4LOZ5nsBNRa6MzgP7+8x6t46QE7Z7FdxUBAXirKILSNg5ipI23d1SXPgENqEaJ4j X-OriginatorOrg: sony.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PUZPR04MB6316.apcprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 81d43e89-79ad-403c-d258-08dc07737333 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Dec 2023 07:06:01.4777 (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: DhWhx8LspX1JLKPVyr5/x9yyR0ErB5wtbJ3i/DsESCLuJCqBGYz90eRaBBCq5XLUgjrqnRTSualtxwpaxX3g6g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PUZPR04MB6959 X-Proofpoint-GUID: JY5QemxAGC9vJom_98rTG_bljFcXiw9_ X-Proofpoint-ORIG-GUID: JY5QemxAGC9vJom_98rTG_bljFcXiw9_ X-Sony-Outbound-GUID: JY5QemxAGC9vJom_98rTG_bljFcXiw9_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-28_02,2023-12-27_01,2023-05-22_02 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 Thu Dec 28 07:00:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuezhang.Mo@sony.com" X-Patchwork-Id: 13505645 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 197A43C07 for ; Thu, 28 Dec 2023 07:00:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sony.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b="fbJGrIaO" 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 3BS5sBVl013923; Thu, 28 Dec 2023 07:00:11 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=ORbU2cqMsTvRJr1w1HFDe0xceFIO87Wgaalnna9+M14=; b=fbJGrIaOF3EK8rvbGd4FrhaEvXOeI33LkvM6ZLzIk5N80y7pVOOk/O7M/v4F8QTEt/LL uCI4Hala/Ponw8s7yXCVwRJMejuf6iRldAXQuXWs7Lwg09JBS5Ofk2hnxzR/ld/gE0Tv 8x3mAJUxHOpiEfSM7y7CA5hzbQPaDzSCssXeH85NUnESFKHV7RyYr3yB9jiUuGO6ZGAj D4XHptLtlygLlhmTEmUtT1kBekqSaC6NtW8QnethAj4u9u01SKCJv/7z+i02+BmxR3gl rd69U30OavxCn+brz3rc87PSq4BmQsNQ0WxtzicbcQBHpeMOaheB0rmSwNoZb69D6+cc 3A== Received: from apc01-sg2-obe.outbound.protection.outlook.com (mail-sgaapc01lp2105.outbound.protection.outlook.com [104.47.26.105]) by mx08-001d1705.pphosted.com (PPS) with ESMTPS id 3v5p7149pf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Dec 2023 07:00:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bMw9iToKNqyRQavhSRZxbn/04KqLhFKN7i+zB8IKjELawE3eV8m1OCmBW9cDEwnsuaPKwwbiIo+FyS00VW6Z7eVZ8iWUGAG2InpAjiaN47n5vJ8GE9ojA3sbH/9EoGY5aT7Xm0+uq1uApOjE0sEWIwcnIOzZH4Ycs5M9iapoANadylOchQofbm7kVsWoXyrJ9gxxbUcrkZUCLnByAJJN6KLE9z0Diby9yhG+Pi0bKTJfRhquzI6p/q+1jgl6G5oo+hvAayA3sNikO2+ursXZX2cXr1BVKCcvsI3NY/zL1qLGkPQ0fZNjw8rQMoQtywoRvdb4M86f/wsvgAWgnsb+NQ== 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=ORbU2cqMsTvRJr1w1HFDe0xceFIO87Wgaalnna9+M14=; b=V22o8c9PQ4l6yE37oezkNcOIGFUesNc+pJVgwfOeK7hqW2zLmTufH6cy976Y2mbIsvsC64nbaT0Uw1rlVpCruBEHxe+1t4e2x9k/h3nJvwRndma4x9kS7S9qFDE7sNzb7gEtDFACxUNMAYsF0q9RKkQ4wUYu5wlAX+oxphqqMUX9HABGJdbosiZAqWPFurCZAU87UBSE19LaPW1zXg+qM7s5FxOwEnUallosHtlHTf2bQF66po+ca/kze/8FWOApnxA3rxUPHeX+abonj6f1qFLuGaSq0imvpSoNTXzNvY38HVbPWoyU+sIksqV28obwhj2DYhAqCBYNMeHgJM/dmw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=sony.com; dmarc=pass action=none header.from=sony.com; dkim=pass header.d=sony.com; arc=none Received: from PUZPR04MB6316.apcprd04.prod.outlook.com (2603:1096:301:fc::7) by SEYPR04MB7223.apcprd04.prod.outlook.com (2603:1096:101:167::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.27; Thu, 28 Dec 2023 07:00:05 +0000 Received: from PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::5914:6fc7:b79d:7e34]) by PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::5914:6fc7:b79d:7e34%7]) with mapi id 15.20.7113.026; Thu, 28 Dec 2023 07:00:05 +0000 From: "Yuezhang.Mo@sony.com" To: "linkinjeon@kernel.org" , "sj1557.seo@samsung.com" CC: "linux-fsdevel@vger.kernel.org" , "Andy.Wu@sony.com" , "Wataru.Aoyama@sony.com" Subject: [PATCH v2 10/10] exfat: remove duplicate update parent dir Thread-Topic: [PATCH v2 10/10] exfat: remove duplicate update parent dir Thread-Index: Ado5WyQamlonHuZbT6mkMfRhSzKbCg== Date: Thu, 28 Dec 2023 07:00:05 +0000 Message-ID: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PUZPR04MB6316:EE_|SEYPR04MB7223:EE_ x-ms-office365-filtering-correlation-id: 3f09add0-c741-4b9e-d360-08dc07729f08 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: NXMxG98LNvO1zBlk6cvdVpctnEFCCACcoLNkS/szy87sNSDbzS5p9+lVvZap3GGVUrhKwQuz3Ei69MxuNEZJzyUzpum1J6hGbAhPVrTpst2P2vH6bG6sxJ78PO/0ttqNSe2ZVueRWXLkBzv03KzDXuo7FDj2uY/9bYeRxj91ErkGtMkkV9vz0WI/I/hSvVBZRdohe3GIscjKpMWVD7XuhmBCX5kJFei7jOjd4qdlrRU2XLpN53Rl3lclrUG2gXUEJStYxFLmUXwBDx+VLTRM6kqsUt8OtlNmkNgXv9ywQB2BWYX1J9jV9hlkZFqZouHooK+O/e9tDK4xErX4VqD+gTQk97j90hT0PJkCMda2em1SbnVnIV/U6Tl4EGq2PLjHfanzC0ixc6hcfSbZ+5jp/9Da3qYqt+d/kzKEJ9pGGBwgKFtRfBud+lbrxmbbuLaNhqRs8aANuLtJAqS5lD0dZxmbsBV0l3FBT7DdKX5vN6dmhOApLqXU0y47GkJATECzca9ZAHtEyfinHuK78IfSGnZw4otVRrgUOV0/Cy4wFtzirlS6LCx50CLiyE0lsB4XhXr3o7Jdu4Hq1l7jLudNqWP2j99xrBPwVRyPMcOq+1GY2XqsMdyGxVgERX0yzO5k x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PUZPR04MB6316.apcprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(366004)(136003)(376002)(396003)(39860400002)(230922051799003)(186009)(451199024)(64100799003)(1800799012)(2906002)(66556008)(66446008)(66476007)(76116006)(5660300002)(15650500001)(64756008)(66946007)(55016003)(4326008)(52536014)(4744005)(8676002)(8936002)(316002)(54906003)(110136005)(38070700009)(9686003)(107886003)(7696005)(478600001)(71200400001)(26005)(86362001)(6506007)(33656002)(122000001)(41300700001)(83380400001)(38100700002)(82960400001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?RTxBCtJwrkLx8j27Mzq4UArgcHq0?= =?utf-8?q?BYSkZc+owJkAe2MKXd5TxpPcQXo1fHL4ZSuDhROdL3ASauGtAJk9xb5EuZmZWR9Hs?= =?utf-8?q?8jbLVh5+d892xjxtTrBq3CE5LZD4y3DvlxZKOvFR2hcevFun0N9FNS95bCRp6gHsj?= =?utf-8?q?83cSpZJUqQdayNmtrIQ7kZo7QjuGt/PGVquiuoqfB+QZotDR8jIBOuVMT5fjMJuZa?= =?utf-8?q?i5RTAXStfWQZqoMunxflL1pXZUMLGIzhat8ECla5POTcVpNiQUXlwOrDoTyQbX5Ia?= =?utf-8?q?7QYZx8Cy9kLZQdbKUqwLGZMNJp1MtOmCdYYMG7aV0DvFSkfo9P4ltgO2oQa+ETSVO?= =?utf-8?q?oBHnRNHhgmZPTgdrlTnJpzNGcKFY4IvBn+i230jzSoLUaUM72bHt5N24cvNLszAcz?= =?utf-8?q?j6uSvVWyYtX4Z8n5CARgqY/5767EDi7a6Fg+fqw0fOMF1Xut5SVPhVy2SDk1Pd/aQ?= =?utf-8?q?F3ly22hiGDJLGWHnfkr15DW+4vlwGbS4Ng09ys0A1MV4ywVBKbs/tBxmTFPLHjP35?= =?utf-8?q?qREW+TLvQxaOxeNkAN5bHZgrHjEjukTJH93d7T+he9gG5IG6L1odtvtESZNjqzk/Y?= =?utf-8?q?TXVjqRylVmw0Xec2UGgvdArB+9CSaySZb1a8clTD8kuv2SqnsG+P4jco886x74eCz?= =?utf-8?q?XHgqgCM9FiNXSbhVxT69JtEq+11oPh1PIHsV8AFPL6NJKv4Oxk5ZOv9AJS2yxKPzd?= =?utf-8?q?7AW91vUs2pN0ixVK+OSl4YNIqYgOjd05bsCuLsmcnziig/3uuAHJspIdvXX2uTV2k?= =?utf-8?q?PgyGJZEHGpCiFxO97JkPfBg7mqkX1aneRcDqRaKqu3BXOILj/KlduA8AXcSo8gv8D?= =?utf-8?q?/tKNOXlQi4INV2SIfplES8EykPngkJfU0QR/dGjuIZm+Nx/rpYSfUthGhG2eF+fbV?= =?utf-8?q?YH3AmvvcX8yqvCyKXOpZ18uMycw3Fina1Eg7GffXQQROU5WLxplNy6awDYko26nuc?= =?utf-8?q?KB/fKr9L+znZAYzAxcUGKMOClKOrdBMfZ4PNakMYJI2PkK4rRGodx8frDH8pzKJoU?= =?utf-8?q?9/hnR7hpWLMwXqpupsmzDjm93FJx0i1j8/fIKen7f10hs4Ixzuep9mDiRQx53pLQ/?= =?utf-8?q?CfQMmPmOVZAmnz3XHtzcUs/U5HicBwXW/sh/4BRYxJ3/JOSrwgoruVN1raH5coZlz?= =?utf-8?q?sq794vs4aARrKaVjGp2NyqgQc3uU2fo2El5Hhv0yGu1FXgWZgH94iEs6kL2OE1e8A?= =?utf-8?q?N0JrTaSmjUvwWHAJLoU3FgAVneH2xPlFWmFvQPX8dFvny87zV5xQprmtr5hj7+jX0?= =?utf-8?q?EneScpJrBfdDO5/xraOhixRwf29yW2P+cg9b1j5bcmgEq+97dkDEsxlIAJ6Iw+UGB?= =?utf-8?q?lpZpXY/6++4ObTOLH901Uh9bAhMLAJ9ONoY4vz04XIOguLEeFWkhlIRQpW/mSmTEY?= =?utf-8?q?+tsvwXqq7lKfpcmTUOFu+fszOHXS+BkqO0DNtstuoAUhzaWLv/yxDvAuf6NkNRoWK?= =?utf-8?q?xsbZO62TJe4rc1WaURuTauFOW6bMnCpDZkYyGvv75T6dnkOead7eKxm+BYM43QydD?= =?utf-8?q?oo+NcklA3K11?= 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: Ut26Og/TQ+Wqtc/jRnO8hN5OqWE7H48EY/MhbhjvioJCbjz4XcYlNmmPHFFZpscFmzLTmbwgbx367+Kw82LpL30d6w9KmkUSex/W9Ol90sb5Hf/FEX4VCn5wVzRvK2aW3xy07O0bGTV1RVwufq/wZLMqwEdLQrpTi+eOBnK+BzQso+Fqlp+/MAz1xU23+rZGp2+0tRB3lBlU+VQdTply6JGyxG7VI9woguPr0cmjCsFJnTwO9IBJ+/JAXVqcI+LIqZeeA+wKrbf2MUcR5Gla1Zyo3jniqYXqdj1rdSNw7hf5GxF+SOfTDWmfDElop7EMqQwuXJr8mLRpChoX8cL5GYsygGQFOTCOsa0+4Ax1u+znzlpuwoHZs0TKWzXfgsUCU8mM/F+8/hIBwZPXvYUw+uPI9Y32ifhMFEmczAxFPZlYo4ZOZ7KzRZdMVOekPAn/unJXLX+ShQ4QZpJKQyqLu05E+GnoRUEihyzHWcPip8k/b/1tSCA8xpsAQ9HSVjKIGLovX9g5KCGUj8emIcqaEZ82nijZOhnYw9wB1LysBiQlgFeuxaMeuiEDcAtUqwNLQMYo0BC2ru7miedJhBNJtO7s67VZcJrGYW48Vg06vvVqtTeW2ml87iNYeXnw5nNX X-OriginatorOrg: sony.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PUZPR04MB6316.apcprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3f09add0-c741-4b9e-d360-08dc07729f08 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Dec 2023 07:00:05.5090 (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: RYWbPdN75Efu3drfaSFxGMh3o0Yn+4UFOSqzTqUpWPD9yN0no5lh9KPOR/j0CZ+LXmr4gCkjQcTTecO3TZCUMg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR04MB7223 X-Proofpoint-GUID: 5N2gLS6TfoPrrkHhw5xeF2sRQusGnGP_ X-Proofpoint-ORIG-GUID: 5N2gLS6TfoPrrkHhw5xeF2sRQusGnGP_ X-Sony-Outbound-GUID: 5N2gLS6TfoPrrkHhw5xeF2sRQusGnGP_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-28_02,2023-12-27_01,2023-05-22_02 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);