From patchwork Mon Mar 18 05:21:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuezhang.Mo@sony.com" X-Patchwork-Id: 13594974 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 8324420B0E for ; Mon, 18 Mar 2024 05:21:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=185.132.183.11 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710739321; cv=fail; b=ftlNe0jwYebiTEleK2axhTcjqbCixO11YA+DyHR12geT0/9N+RPtYQEZG20RjYoavqgNAUB9JJ1Rs0r4BVv3LbnWGyhIfMpvM3E2bbVAwW+XAIngSUbmd4Gh42+DapfZZvU9McbZ2pZBttfwiZ1nQ6YBQE/6oYbYFGJpJ0h8iJQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710739321; c=relaxed/simple; bh=PnhzH8fGr0WSfz7Yzn2ZxGPtd6zTHnHVS/hK3zIJFio=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=sIRVgRgIbAXdcj3908OEb6yZJuuaUM1oChEK1r1XFqCHxBla9g3CPIeQF3VQJ7KooZyQUe2de+CE4zruLL/h08Ad3b1CVy8I0zHoLXmMjAZ2ZSs8TlvT5U+bmQ7uRPsERktHNUKA26HHgbvvundWPQ8WWAST9RiZHZ/bf2fptsk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com; spf=pass smtp.mailfrom=sony.com; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b=gxebkXCS; arc=fail smtp.client-ip=185.132.183.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sony.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b="gxebkXCS" 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 42I5EV3U022214; Mon, 18 Mar 2024 05:21:36 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=PnhzH8fGr0WSfz7Yzn2ZxGPtd6zTHnHVS/hK3zIJFio=; b=gxebkXCS48IBoOa45MheQKxXeSODFd2UYqqh11RQTa1Ic2wDxUIrffiVKs7BCdGPu67Y UfJQmx+3eNmkM9Yybk1ATHxao0wju5de+kYNSDrIxsicRRElUN4qtkFaxqnS0PiEXwQ9 sPzCN2Hfjm/ZKW4ktbD6Ecz0Yckbw82n+ExU7+YI1M/sGxrbrvLkpD4Z05ANXzJsD92/ aGJwdOOZs5bHcO3w4D8Hb23FZ38oGgW2cmTb683umMYxOvkKtfJw52phDe7gj+KD/Mel xZ53XmxNct6FrCHp69LRDY7tfaAmPk2KqmxgvM4GfNHoszBVTiFC8Fcaboq0rsIuIlqg wA== 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 3ww1mg9qcj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Mar 2024 05:21:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OKKODVDRw7NDNl5C6N9ZLL0aoUEUeVALB1jBbTh+JEaZaH3vsyVDwf9oIlWvXvtW341lDrDlLq5aPkvaYa8HRep0Z/rxGiGFfzYD+yXnMbtqSl6wYxgJVVXhZ2Lq9IzupLEVzwK2dttu3Z+aJf9C0fYQrIcSKvQkl1MjdM4EByo14+Jbj9fYyr1GHZXVQhgL3FQtA0R7sgjCCXIWCBI33bm4H50jNp65xXqQH1aayTxEV3SKIJsD9qi7ILcUVY/OlpXaZM5/E62OkbzdtePGZvaUDxBFZu6NtlVKXtIIsSlgnYYwCaDp+0YJrAVm6TFdQ5KSUBEkEDC0nNadT2ggRg== 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=PnhzH8fGr0WSfz7Yzn2ZxGPtd6zTHnHVS/hK3zIJFio=; b=IwNL/lqDgT1t8wzKDHaeGDdjkZS1a/kzRgaR4SJwBBlMRc7doLy+YwsfwtdMri3LzRTJUEz1v6YXA5/rXqBErIPANffkvCmGZbwumZPWf/CswOTnCFs8iencXMXbcum1FnOQOzpFuKm3nsU4+m/tYX4/rcrOQ9vE7LPwV4uT7J3vC+4k1qYHahC3YweweKOgHYfWBY9H8EVCXLewIPg7Rflae1hO0QUXRFDtWBgslUSjleSoxoEO0VdY9jnb54i22WiQeLn2Q/yZ/qWQYkcjOiHFyQHHGxh+sXrTo/HeNN2NWA+Lm0o+kQ68F/QfGW10cv2JV+opdCjLY/SZDSasgA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=sony.com; dmarc=pass action=none header.from=sony.com; dkim=pass header.d=sony.com; arc=none Received: from PUZPR04MB6316.apcprd04.prod.outlook.com (2603:1096:301:fc::7) by SI2PR04MB5895.apcprd04.prod.outlook.com (2603:1096:4:1eb::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.26; Mon, 18 Mar 2024 05:21:29 +0000 Received: from PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::7414:91e1:bb61:1c8d]) by PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::7414:91e1:bb61:1c8d%7]) with mapi id 15.20.7386.022; Mon, 18 Mar 2024 05:21: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" , Dan Carpenter Subject: [PATCH v4 01/10] exfat: add __exfat_get_dentry_set() helper Thread-Topic: [PATCH v4 01/10] exfat: add __exfat_get_dentry_set() helper Thread-Index: AdopyBE5IlGSbIfjRuOO+PgQhKYhxBPKZcsg Date: Mon, 18 Mar 2024 05:21: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_|SI2PR04MB5895:EE_ x-ms-office365-filtering-correlation-id: 5fb0f5e8-25c5-43d4-210b-08dc470b4473 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 1Gwhp6nbjdXkuVI+Emtx7gqZrLpmc/uAHp0j9cdAuE2JmiUWqnYJQMzIHr4mCBVmDKYvhGvDDupwshs3a0KY7rXjByEh9YIBtSzIBkJ2jVtSKUzvLoYAkJvIlMiJSzztqHKuHRHm9bW5npM0ajQwAqtMEAWbdJPAJAy67EM3be7oQe8/Q8SvqWnGZEE7okIKicFBZa5aBPf70NQ42Dp7TXCiVEgCOnIqV0NMJdCB8aAajnK4+zS7WCKFwOJ8bAnoFQsF4JTfptMRl0UT+H95TcJFkfyo2GYEbzuaZeSsMo85ppDjEJwUzacHrW/xpQMyhkBu7kTp1zba8YQSz+KjIl7Qw+qb5BpVN/tlZfEb9TcSryHC7aI6Z+oC00DCzycznBlN33dq3oks9tpYS9Wi6cg7+BGxoN8+GD4UO8g5d/hnZUy5Umm0f/mjV7FBVDn7LwdaNqcx790XAWKq6GiCNxnidR7WOm0DxSzUSJhBZyf9RYHJnW5G7xBOJhjrPUP8qxNzo4enkfq0ixeNRzdxFfEyzMTWE5d3vKlJHmJxErtJuffRt5TEKbx640UjLWTvW0fX0y/ElDkm8PGaW8LaozaIi+Oaq0LrmLOMzM4hZfzlc4koBeUWqyXPJ/YGn9flEe/fAoz3UomOiturWcbBPI2WA+nEbFRXIdZj3kz5r215/8LlsTB7JB9o7zGv2kcKbPuI6Kqs7+gaM3uQSPQMku9oS2f5R/uC9+qQk8e/P60= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:zh-cn;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PUZPR04MB6316.apcprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(366007)(1800799015)(38070700009);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?at0W3k0yrd1RSnx9+MelAV6Uuh9z?= =?utf-8?q?Sm3kUbB0haJbPpHycC1p23zA8MNnCSrDmJ4dib8vcL0sR8RG5zfNYPDUN2y25vmqv?= =?utf-8?q?eyNxry1ypRh94Dvp+6fZoaMt9beHkdCkduwI1u7Szcybnzz72gZSoHWt2A1f4/8zJ?= =?utf-8?q?P17vo4dCZqIkbJE0X8uNZFTbKfcxYGozthjGYqXwtawV5DFmTjG3W3nv3YhtACtT3?= =?utf-8?q?Tv9A8H0tryMPU4ueorDs+TngetR48QQMR2fBt6xNAVgI8eOITBeWZK3qQ3jM18nwe?= =?utf-8?q?qlkLp3thU0E9Ahel6YSJ1RSHEsYvWqfM499tqTrKDKSQAg1Jkc3slW2p6cTr1Yqr5?= =?utf-8?q?G1yWfsOnNaJ8d6+ozeGTTB/7o4EGVtpGiNyPr+wyR6YQPKwpQiSjPV+s0RJg7nuJV?= =?utf-8?q?MFx033ANsCTMBsUv3OiZbTi0c+cGWh5eosftojPhJ4K7C4Dl8s9ryq6JMJSj61fjU?= =?utf-8?q?C7CCgC1i3AX0mt8q5HKTdEdmaCvrKe8VvSjmWMWmQNA3f2Eg3U5NvwylMrK0osiLY?= =?utf-8?q?w1isJCpkiifsEqkOvQ9a5wTLCi4p8PQzKZdoV0lscED82pVxK5UlSuy3+2FQixLXx?= =?utf-8?q?jhnK5ocI9JNrDiMuxWkieDgOgxFDtHlVjHsADSgMm8q7jrKsYJf1wX/njIsKmfc7u?= =?utf-8?q?GqOK3GcQMlM6+9Q7kVlx5XhuJA3OzsncHjYqyWzW6ioU/YQAluudilYGLxlWbhomO?= =?utf-8?q?KLpaF8xnCVUNKRHmIFM+QMtHIuYX6wiQegNyJtIpk9HRh6Dc4bxlWsAdDsEC62fqu?= =?utf-8?q?FYkIuaXiZtDcOl0ooW5JSik9Gre7ASRfn2VJb/9jjdW65ubkT8UEfm95EGfEkzUme?= =?utf-8?q?O26CsUXTKpjEib07MOtMUuJaEPy/nfS8FSh6Bo6I/PfwWLLgB+e0J9m/v6zlv8ZIM?= =?utf-8?q?y+BScPZt6uE2EddP5mLTUhXkTE47TNtkrAWcRP0fqnlQ8IbRHAjrQc0HkYIubOUJh?= =?utf-8?q?vaJ+js0Z2zgO17IDbUIRsZ3MChc2I4AA/DaqMYZ8LliKfwQlc1aygt7HlfwKC1dad?= =?utf-8?q?QnB1QSrM1eXinnTWpQYFfX6ujc15fEIhQGhuPeYaYkT/Bz8CYccwGI7aglvwm/6A0?= =?utf-8?q?/harzN+gAPn9q0ge6RMEEOFinSA0RKPq0z/nLcVzsp0wQwMWz9RNe8SkmZpBYxOAo?= =?utf-8?q?nNrw7m9vXoXn5zVPJg1vfsC8YLnTipLIqcJQPY+EzhKVkXkn2LP6CxW8l5Myrbaiq?= =?utf-8?q?XVFp7K7ITnO3UxCQSBCt02WkvABdVWAvlnvlT7GIyfuO/WpM6fLO4Rpz+h3H2rbc5?= =?utf-8?q?zIpy2J1utVAsspKd7Wvh5eUZgcFN2WDHLyIUI2Zd25cEYP3NwMpf126JD9hSJn3a4?= =?utf-8?q?ZXoK7o2l3kZE11sScYmRfPnarq/AhgCsbIgZX8oGyQTg0uIuZuFZjih9G2Ap1rke9?= =?utf-8?q?CQOlpUTEqZqhfRHb6YIt/m7+T6jkFLC0yfwCBKOp5EruzRL8ScrDIopXVRicIAq2u?= =?utf-8?q?5lZnHYYNdtTvpIYwEpyOLlO5RCfEwoTMCS32DlXCxuJC5H3kexAgvcy9kDv01UGzx?= =?utf-8?q?xRiiRQ0wseBQ?= 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: wyNtDLQrkXxkNIX3CGtIa5oUjWcJBB0VK1H6jj1NQCYXiQzu7DvCtEI9lBy9ia20cL3oOVbYR61pUBPwmDtGfk02xGZFhhFt9VrqEutS4N3Qy6Se1xgEWXhGQuTMzYUQrphkqHXUbXZnmDtVhy+R/JeFVo/bcelx4zak/VU9UgL27d3G9daxWk/xhSbl62t720K6+uA2NPEM+AWemN6BsxT3PuSqKxG+3xRjRBTICiOnragA21H0w683ImpLOvr43ecmtI8M+v0gY83fwltcUi6y5SAgQrQl9eiTRXL0+Fyvq+ecEDXl37mX+gPzBPCfFfQw6+K67W4EU/osPl9r3smEXMJ51GNG9HmRUOZ7MjoeRBTyDkgBT6Ipl3zORUE3L+hYNghZX0nxspx9qOJBzqJ3Z2Ra6XEi28FldnGhBqkmuZUkiJcer0txigEtBhqDi+lCYaGQqkGg00s/8YoUDFpeFMZnXIKhVJ/RUo4ZTWGTuoCtvBSRMG78f87vT4I+evVx2G0InGS8GOCGGkrxIYIKqXc4GRw99I2+K7Klvyt6CUCXgfv1JW8Gn7YTLoLvy2llVqo5mz7CZPkSf+MAx9KyM8Mpsq+vIk/Wc3l6PRc475RLsncYCdOGeDZk3rj/ 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: 5fb0f5e8-25c5-43d4-210b-08dc470b4473 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Mar 2024 05:21:29.8350 (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: pnNIjrI7G2zQuCzD5OBtQDolQR73lJ5ASSyWwkyCgnXFWgjQ0ilxWtkplvK/F+h+862gVOB9umuSvzBef0FCXA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SI2PR04MB5895 X-Proofpoint-ORIG-GUID: hznLZX5XCRJuzbMkCOfo3UzyrdpIuDSr X-Proofpoint-GUID: hznLZX5XCRJuzbMkCOfo3UzyrdpIuDSr X-Sony-Outbound-GUID: hznLZX5XCRJuzbMkCOfo3UzyrdpIuDSr X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-17_12,2024-03-15_01,2023-05-22_02 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 Reviewed-by: Sungjong Seo Signed-off-by: Namjae Jeon --- fs/exfat/dir.c | 63 ++++++++++++++++++++++++++++++--------------- fs/exfat/exfat_fs.h | 2 +- 2 files changed, 43 insertions(+), 22 deletions(-) diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c index 9f9295847a4e..543b01a5479e 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,18 @@ 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) { + brelse(bh); + return -EIO; + } + + 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 +920,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 361595433480..037e8827a56f 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 Mon Mar 18 05:21:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuezhang.Mo@sony.com" X-Patchwork-Id: 13594973 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 8327F20B0F for ; Mon, 18 Mar 2024 05:21:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=185.132.183.11 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710739320; cv=fail; b=f2NBJMCeQG4NBFtMJHnWNt4gPGH/lvE8mhWLJKZY5y6LIlk5nq8wGeVLhYoavu2cXhcdJx9XFvJCj9uOjLnwYynp8i1M7RUzBjl27Y0B47qjfhSIBUROddSN1NGVrgHxPLR7NbUJz8dyefDxZK13AJZbA/KRFSmHXh2Xw2RHLX8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710739320; c=relaxed/simple; bh=PnMJitd6KqA1dBq18vmCdBFleL6RXGlCR5nD6Zl5XfM=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=HpdLQdT3lknqKzk4J0zI0GsdJTuNTkFoJHAlPufxxG4ImOZkFwrsJzW8LdxjXOgvF/9nxNZXNXDnWss0HHkj6X4Yv682S8QCQj1TXbw5FzERs7iSPP3YGIAWPNMpgdbMB0zCqq3f6vgQwztOqLuyEjl1TF61aLJ1AGwTKnuT0dE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com; spf=pass smtp.mailfrom=sony.com; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b=XqsnwV9h; arc=fail smtp.client-ip=185.132.183.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sony.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b="XqsnwV9h" Received: from pps.filterd (m0209328.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 42I1sKIr014434; Mon, 18 Mar 2024 05:21:47 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=PnMJitd6KqA1dBq18vmCdBFleL6RXGlCR5nD6Zl5XfM=; b=XqsnwV9h1LjrMagcubu7BisjE/iJYk1mAKraGjJcwo1XIRBD7kulvx53gLLXHzz/blbL OHpLYtY9HeZbNdAbn20e8wLTg6yUgt3YPFwMF8qTv07j3xxGgMI6KXB7NR54BtTaVQDZ Fb538Zq2x9ZOxtQpPnr+Ze8ORCc7FyzUay2PBdoXG/dXJTWnfyps6tMFkegwWZuK6H8Q DN4FLmj+FfZsFY1lH4635IzNMeftSK5BTq82jaJOWYU0cn5JxvdTHSMgRZQwPNKsRUSq wnuGy9qd47XEtAXnHbzH0+S+0ruQxZuj/hQ0BcpzTKRf33ozqKDWWt5V84njjCHiWld5 zg== 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 3ww4km9n0d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Mar 2024 05:21:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lJHOjadUYZPhCEtrmPtL96B7wOhBiJhrzUX0APRz2RRfjkKJiAArC8lmkSsaSwhKuYj8Ti/Lk4hpg+oedi3psn72EsCCFw5JFKErzjKdvzZALknd+tON5sD+Ys7Wbe/PqQHbXoUeyeCx1RVfQMULLDMOHB4kjaCHcWx3dRIG3U+D3EArLpnX5rqQB4pPU/qZIH7YCGsinkBdpUJQ6uWYja8ds4crEl5Upye7hB2Er+lXXhTtnlUdbgh0BlUEKvoU0BSvHxbsMldpF0XiXJ0zL8VQKgdl0EJfm1gFmwZPXomiViX2Vyr0iWQzoJcUO0eFi+NijmcLt6ez9egOagHAOw== 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=PnMJitd6KqA1dBq18vmCdBFleL6RXGlCR5nD6Zl5XfM=; b=n2BQkx2jOhE3R8FAojCoDU5ZO8wfETLgd8capOyUp+3OAYnFrsMXNhfLVndadYXmgUwIpb3xPp9ceaa6zsrm+SYJQa0g0jzFykEQIx3auYMJ8e/0j8EFjBV+mVwuiCG6+T4xPgvgE8pVXIm9LMZSS8x3gM6DbnwUsFtAh85/jNk9UK0v177mGunMEgOcmr42uU77NWYHADIT0vkyWjkOCMqgKMWl+Q0eEsj/M4m1WK7amAaX5KfZNy3wHW2H5kVAhFSCzUvnRRHji0opwNN3HFC44Ng6Z0iaj11W2t/4Hnb5YAwRmshRdXWeDMZQxZ4inWW/V7be5ujvWld8Jk2jaw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=sony.com; dmarc=pass action=none header.from=sony.com; dkim=pass header.d=sony.com; arc=none Received: from PUZPR04MB6316.apcprd04.prod.outlook.com (2603:1096:301:fc::7) by SI2PR04MB5895.apcprd04.prod.outlook.com (2603:1096:4:1eb::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.26; Mon, 18 Mar 2024 05:21:40 +0000 Received: from PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::7414:91e1:bb61:1c8d]) by PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::7414:91e1:bb61:1c8d%7]) with mapi id 15.20.7386.022; Mon, 18 Mar 2024 05:21:40 +0000 From: "Yuezhang.Mo@sony.com" To: "linkinjeon@kernel.org" , "sj1557.seo@samsung.com" CC: "linux-fsdevel@vger.kernel.org" , "Andy.Wu@sony.com" , "Wataru.Aoyama@sony.com" Subject: [PATCH v4 02/10] exfat: add exfat_get_empty_dentry_set() helper Thread-Topic: [PATCH v4 02/10] exfat: add exfat_get_empty_dentry_set() helper Thread-Index: AdoLEwb381t7blsHTr6+hyR/PEn/jRt3t2MQ Date: Mon, 18 Mar 2024 05:21:40 +0000 Message-ID: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PUZPR04MB6316:EE_|SI2PR04MB5895:EE_ x-ms-office365-filtering-correlation-id: 3216dccd-49c8-49a6-8143-08dc470b4aee x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 6pRgIrsGfstv4CXml3iBtaT78PbxnfD8mISdhirY13UyrSC/y0dh8TZ42RTUaSsymgNH3M7sjrF3iOc+IIMN12AevPWgA5oDroOqEdtzG2HPdV/6hDmDtRj4Hf5hS1G3T7vsnlneSEfZOPOiX02xwcIdh3jfSCBsU9pZ2+8Qlxvp/ZeVVizLoRKn1KaRXiims6Or/7Mf89B9pQiF5/TorMPGY+hq1oIrwGJPhRNbGrSraLVNXXJ7Zis15eeD7JBgGHnus1Ey4QUYocSi4UojgmmJ7P2TcEwfigaSrItkksdlYzvOKCN5SrvwLaSyyRZj2eNuin9LYfju8n5CDVqMHbJYxLPwiPuSxUNNrGRd06QvGIBjxyp9ab397bv+lHSVcpInVlgCTFQUYeU7U8iquEOBlHIJaOet/kwu4bds8qZd3UpE9UotbLG4FnqYwnhv3LDx4iGMMF6wJskvpXUGhmn8zdU5RYkafgP4+AqQMCb3sbjr+SAKmixrOGaobSvxt1+gpkeTH5irtLvxX2KsEpFSiF6YTTbG2myp7ZfLmB6d30RdX6Pf2jYNGvarVNv1ymC/e/3qGavVj7qXjLUn6OCzZxNwGMxclVkoKF6MkDTbToXaiOs45JeEcX9OvCVTml2+bAELf2H3dwWbZCNKse2XkCFDoijJg3ftSd6D0KLOq920cxsj0AesERg9AsB8JEsi3TLb1l/okS3dCv8tnLVNTUOR9qeMhSiG9NZSxBA= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:zh-cn;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PUZPR04MB6316.apcprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(366007)(1800799015)(38070700009);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?QAVYcE3r6YrZutp/4avtk4ufAhBB?= =?utf-8?q?zhizTcSurkdVR4c6gH+g/mTBqm2huU3e7owEYGdZ0RAHuy8fMZ9nPLl8fARAVB9V9?= =?utf-8?q?PqIu9mqYs16rHHR0rZZ8F9b6pHDjThHNIvuYItUKFgE1XUvFgl/DfI8KpBeS4TuTw?= =?utf-8?q?aL1xNIOmnX54XHIzRK/ubcqSy/tVh7q3oOzEQFqlHenCXV0i8/9w0kAlc8zQIZBv0?= =?utf-8?q?aUrOXyeYDt2zM/vCdH6rynSuNGQbnipjWzYCOaX93gjH7LnSWDSp7E4sfmddGP2vI?= =?utf-8?q?HBF/FgmWvDr+coJCKzr140fmV6mvNJmdKblw3Rq4MEFlAN2Gi2Z6PxWy33u6o5usG?= =?utf-8?q?MQ5y5LolKBa8jyxcNZn3O6pgVJIwoCUcI8NDXpRL/O5jMhP3bdupW4hdUPjCznB1Z?= =?utf-8?q?FrlwmQtZTnmT697v/7rC910dbgS7bYp+RfYmvzL+6t8G2MCAh5jfzk/ZY/ybo3W7L?= =?utf-8?q?Bsbkq85z4HVoZ8p6OS6AJOw72tREjB49zDeenOiGesP/EAkhLBjW2Gscu8KWYWkUU?= =?utf-8?q?4lsl4iIz0XJiSXVndWeUocYnxX6fWnMx66hG9c81hCCJQoMU3Vw+M9Z3p84lNpWCL?= =?utf-8?q?am/yUT1vyx89VsWITp8M7BSKUCJ9Xg0QDSAc33E3PMr56H0zqzsA9igzo036il0HQ?= =?utf-8?q?bq06rFGO6l4qVlhAsewkW9AIUen/BnqFJt5+nA+JdaR7gOff6qS3B30s+BY2ZXiP7?= =?utf-8?q?Ox7rFMClK9dM1WVlVXkwdF4HOYttVvMfWANZWivU8vphTICCaUrTZ/yfO/JfqQFuF?= =?utf-8?q?q/QadwrxJS8V2cPWi0ucx0vbQKfbMr4bgK4C5A8vf1eQ9OeoVBimt8HbjVKGfCbuJ?= =?utf-8?q?m8NdOBHDO++PhsgFyBfAds8gOVWCWtEHZCnrXDlyDBIntkOS2gnpt+rzekKRakqrX?= =?utf-8?q?r/oT2r0TGu+KA0XreQ5TW7LaZ57IaPP0rUevEF6s9FlxpXyznUAMpExT6av9pm8s8?= =?utf-8?q?xXiiPqd5tEt1u//slLBFCtFyeejH8xAnvOwD+oER6PdNxwaq5P+Hods7wlkpYz2Gj?= =?utf-8?q?xj7aNKk3UKr/y/F6vkb49qMxm7mf2wO8goai4Ag+0NuVqMlUTaFBMpczdPrSZFrY9?= =?utf-8?q?n1zTdWd/FQmmu9YX2ojBrXv8nr8Em6uf8M8uV3IkFgPLvXA9vHp6NuCPfgPL8DLVd?= =?utf-8?q?zA40qeBmZlN7/uKmWXNWHJA/byF54eji8Hy18JWazBaSFcbsyE1m+h2hUcCc29qf/?= =?utf-8?q?LZyn5RQ3ltsyWvn7iwaWqmbGuSgY2Ffu529Txwub39lgG/8o4S5TlyVqzUw6OrY13?= =?utf-8?q?pFpeamPLB4h2fLvsQVe9zVQzH1VA8PYYXyHCt/nK5AQWu5W26nQ+Z0MqKC5eNyPIh?= =?utf-8?q?/mIsk6ZDex1Jr+LYDzFlSATdkwPvCEkjjIWmM+Sto81sBq/GkE+muYfeP1ZZhj1Ha?= =?utf-8?q?Gh2gpqSuQ2F81F2K1AfBCBo/mB/oyiny5MhxRU2kBglSa8BluxBunP51DmUL6nT/a?= =?utf-8?q?Tebw5RgJFf1JWEnTjoaFxFGowkt7yRlM13NHpunQQ3lsk2FdzCwVohw8EFIzbI+5H?= =?utf-8?q?RKc33qS4QQzu?= 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: usca9gYycQNTA7YFWFYaY+1B+2C/jzgHuvUCiMFXwYfiGLZqOk/JGqT0A2jQ1fFtqPtRiZyDo4VdF1JDOmyrJ968sIeafHTzXJhJGdKguG8FgjzaeJaWFb2AQZPchDELofS9ufmLzENlxK4ogAwCju8e0W5C0OHJSdU2nX95d8RGp7838dMc0WvCJmKRCqNqxbakP63LBUfrB2zd8qycx37FKab+1lWv2LPPe2A/ELGeh5qvt3sSqhq5QzP6hCzm0cw2KkkSNoRkPN8cW76wppII3SBFNzHlCNQB8G80u5SqmdROZjIlOkjxTsvXEBChj8UOMLMJLoX61CdWN0eDOOMOnKiTAir4mInFy/L4YDRNabiVc/8551MfAcuz1oQiv9y/lDbtD/dNREt5A3Ft/JPGnbNGdNoS3/QGXzHRX9y69zZUK2VzeX594rYg2ee3ExP3mePm5NSBdYakRgP0ARlEO7AbGIcF2sqxWIJmIZzOPLe9IYeaJ2BExIfLJAxYce9aOni6J2hbV1v9Uycl+NILpkZ9010ptjQuSg6icvC3QCW22HqxX6N5iey65Pp0SxEp6mXhpnEK76Zpxalys6suaXDz4lgpRoxhlTC8GFWVK+kwRsi1zrU8NHWPcBly 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: 3216dccd-49c8-49a6-8143-08dc470b4aee X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Mar 2024 05:21:40.6981 (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: ZEzaErxHnN2gBqRZT1A3h/XBJce1NbiZxjrmDLkCbRUxCmgDSYsXb8YmrrJgp37hzcR03Jqw/dnzqpCTZh2ZcA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SI2PR04MB5895 X-Proofpoint-GUID: aN6G09HUgux5632t1PD3E3vWwIeZd7UD X-Proofpoint-ORIG-GUID: aN6G09HUgux5632t1PD3E3vWwIeZd7UD X-Sony-Outbound-GUID: aN6G09HUgux5632t1PD3E3vWwIeZd7UD X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-17_12,2024-03-15_01,2023-05-22_02 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 Reviewed-by: Sungjong Seo Signed-off-by: Namjae Jeon --- fs/exfat/dir.c | 79 +++++++++++++++++++++++++++++++++++++++++++++ fs/exfat/exfat_fs.h | 3 ++ 2 files changed, 82 insertions(+) diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c index 543b01a5479e..e228cdfcc9c9 100644 --- a/fs/exfat/dir.c +++ b/fs/exfat/dir.c @@ -952,6 +952,85 @@ int exfat_get_dentry_set(struct exfat_entry_set_cache *es, return -EIO; } +static int exfat_validate_empty_dentry_set(struct exfat_entry_set_cache *es) +{ + struct exfat_dentry *ep; + struct buffer_head *bh; + int i, off; + bool unused_hit = false; + + /* + * ONLY UNUSED OR DELETED DENTRIES ARE ALLOWED: + * Although it violates the specification for a deleted entry to + * follow an unused entry, some exFAT implementations could work + * like this. Therefore, to improve compatibility, let's allow it. + */ + for (i = 0; i < es->num_entries; i++) { + ep = exfat_get_dentry_cached(es, i); + if (ep->type == EXFAT_UNUSED) { + unused_hit = true; + } else if (!IS_EXFAT_DELETED(ep->type)) { + if (unused_hit) + goto err_used_follow_unused; + i++; + goto count_skip_entries; + } + } + + return 0; + +err_used_follow_unused: + off = es->start_off + (i << DENTRY_SIZE_BITS); + bh = es->bh[EXFAT_B_TO_BLK(off, es->sb)]; + + exfat_fs_error(es->sb, + "in sector %lld, dentry %d should be unused, but 0x%x", + bh->b_blocknr, off >> DENTRY_SIZE_BITS, ep->type); + + return -EIO; + +count_skip_entries: + es->num_entries = EXFAT_B_TO_DEN(EXFAT_BLK_TO_B(es->num_bh, es->sb) - es->start_off); + for (; i < es->num_entries; i++) { + ep = exfat_get_dentry_cached(es, i); + if (IS_EXFAT_DELETED(ep->type)) + break; + } + + return i; +} + +/* + * Get an empty dentry set. + * + * in: + * sb+p_dir+entry: indicates the empty dentry location + * num_entries: specifies how many empty dentries should be included. + * out: + * es: pointer of empty dentry set on success. + * return: + * 0 : on success + * >0 : the dentries are not empty, the return value is the number of + * dentries to be skipped for the next lookup. + * <0 : on failure + */ +int exfat_get_empty_dentry_set(struct exfat_entry_set_cache *es, + struct super_block *sb, struct exfat_chain *p_dir, + int entry, unsigned int num_entries) +{ + int ret; + + ret = __exfat_get_dentry_set(es, sb, p_dir, entry, num_entries); + if (ret < 0) + return ret; + + ret = exfat_validate_empty_dentry_set(es); + if (ret) + exfat_put_dentry_set(es, false); + + return ret; +} + static inline void exfat_reset_empty_hint(struct exfat_hint_femp *hint_femp) { hint_femp->eidx = EXFAT_HINT_NONE; diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h index 037e8827a56f..c6f684bf7b92 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 Mon Mar 18 05:21:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuezhang.Mo@sony.com" X-Patchwork-Id: 13594975 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 4A04C21360 for ; Mon, 18 Mar 2024 05:22:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=185.132.183.11 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710739326; cv=fail; b=ana/fyxE0mVgl4DRSVZfR8GcGXCB/uOV+i58L9EcEPb4PvYiSyyiIOX7BqOqoq+ferEkwIOHQd9zAy2b3a0yu154DlbbqSjEmRnEtxyZ/sKZ1IkrEOSCxsdTP+Qypwmh5ConBZ0gOZV0k2rjCTQ9PGJeIOZQaBOgDNvYsTJJLjI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710739326; c=relaxed/simple; bh=tGGczJ9m9PcWARzDZadMOKJG0URnpH6jy1dU3BbjM3g=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=oAF0GkRbqx5E9xQLxJQ8X2OU3V1mzJU+O7800nK5tNcEBoy9GYgwVqNnV+mDcpej0itktu4NbKh1VXF2/x1Q7xJbAby3BW3ZOtrwTcBbX7owS7YXGD+rP60rPsrBsqCVVQNhxRvq4XYpEFYn+sCtYFKWkfVw3ELhxCLqoKY3y9s= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com; spf=pass smtp.mailfrom=sony.com; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b=CbODJunq; arc=fail smtp.client-ip=185.132.183.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sony.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b="CbODJunq" Received: from pps.filterd (m0209324.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 42I4lDBB008885; Mon, 18 Mar 2024 05:21: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=tGGczJ9m9PcWARzDZadMOKJG0URnpH6jy1dU3BbjM3g=; b=CbODJunqvgMHGEhxFSS6OvnEmMriBAi6grplJKS1JPdYyNvcqyTfG+e2cvwCp9jpXojY IX7CvBREQp0kmvc1fqxFl45TEuFIlaGqEX0evaP1nwPowaqY+30j+AftlUhrxgsJy1JA gWRSbN3fDM6kCQ4pYRtoEY10hoBMOaDFanPaF+9952ZAN9baaK2iT8VNhXPTPa8Zakwd xACFvrUL4BW6WGMmUCUQO1+yS9vVWqC7RtG6fod95B1RKeVsfe0yKSaURJ+SXd8MsDdB EqMaJbFIWip/NxXSd8SbZXqkCyMFZ4BMDcnPpZaM9jLFSNl64SOMSVflbnqvCZm3UOh6 Tg== 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 3ww0k4hrhj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Mar 2024 05:21:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f7jJYTOxX0RZJUwRMo7D6HdVSJa7Cxr4A9FOriCuzACpcKdovh7/ppbslWJnQyDWeWa/udTN4W+0vTEEBwq5SlqEJGZdlne832sbANp0rvrchvGTfjrqgPAE+NTLWBI35BswF1C+QNVbIbYF2Ql5JXxpfgGfJ90qy2ks0ZsVNxgF9vs6Vj/luT+k9p2fibpF8V7p+r4IKR9YjdXIwamdh2cn3UMeWWoBSP+MfCzX0lFPsJov3RYolDQq3vqSeaEp/GIiRs2qDjs2AYZewik4Y+k+vSuXGEpI1/B3nnuqwLcohvCNaOLZZT+LGhsh8ZWN9PDnZsIuDugTUpoyZnl21Q== 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=tGGczJ9m9PcWARzDZadMOKJG0URnpH6jy1dU3BbjM3g=; b=g0ko7p7G0gAqHrQE9sRUsOvkU4QLuqoVbRgPRRRpTPJRIyyuXuM7puqB8DzulkUGANT4/YOmpzTZ02fkwihbaeJlrjneEmERxsB5injIn11oq9IxpQvbiIJFc1UQ5gxHSY6YwSIb0ZtM6uxqJRyj3BkxSO/YCs15kI1EbqwkrTADcl2ssS8hhTAQ16vWCeWS0Dmt4reR0dfR3/wws2MX3UJvSBbuiwnkc5hDVdhq74wlrdDe6rl8HJH1+iqBaugOgf0sMS+nhbNDBCZl6kHuAqwxbLoCs2Wdljo5IK6jdP3fu4etA2lZIJZpWbPMelbT4TcUsXC62sQbPqgsii6GgQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=sony.com; dmarc=pass action=none header.from=sony.com; dkim=pass header.d=sony.com; arc=none Received: from PUZPR04MB6316.apcprd04.prod.outlook.com (2603:1096:301:fc::7) by SI2PR04MB5895.apcprd04.prod.outlook.com (2603:1096:4:1eb::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.26; Mon, 18 Mar 2024 05:21:48 +0000 Received: from PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::7414:91e1:bb61:1c8d]) by PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::7414:91e1:bb61:1c8d%7]) with mapi id 15.20.7386.022; Mon, 18 Mar 2024 05:21:48 +0000 From: "Yuezhang.Mo@sony.com" To: "linkinjeon@kernel.org" , "sj1557.seo@samsung.com" CC: "linux-fsdevel@vger.kernel.org" , "Andy.Wu@sony.com" , "Wataru.Aoyama@sony.com" Subject: [PATCH v4 03/10] exfat: convert exfat_add_entry() to use dentry cache Thread-Topic: [PATCH v4 03/10] exfat: convert exfat_add_entry() to use dentry cache Thread-Index: Adin2HOA2tU4zpe2RByNSy9FrS5gf3RGYqUA Date: Mon, 18 Mar 2024 05:21:48 +0000 Message-ID: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PUZPR04MB6316:EE_|SI2PR04MB5895:EE_ x-ms-office365-filtering-correlation-id: 132814f5-2de2-440e-6d98-08dc470b4f94 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: ELGLP7T8dqqxNXfFmejjkFmBbywP5MwrcKd4uDBqzIBikeRYyeMu8H9qZQE1okek8OQmxAwazD1TsAHqilYEbyM3DxhalLu3AGhh7HvvTooV4J0oWYZr+8hRulskWAROuddTrhUj8KtL5neQ9IDyFp6y6W2alF4buSLIiISZQGEQdOrsujc232DN3AJAOG6GwyPfVTK/iFjw7dpHOJ7axUsjp5XLduEzR2nk716U+BQuPhl6IOSLuGjRzQVso4dLygj4kk3cGsi1jHqeL48l5Unl5HbJVAQI0+gH/YnsIuLNjirsun5aElEjKXO+UzuTQR/UT0n6A8Ib9xbQr3+ddD2LyDTqmlPKBBdy0ZT+Hjkk73elKtVPKGg+iS9kcvslOzhWLwOTMFbjdf1vJ3Cd4rlWfmssUmhnMYhNopUe21O9FWHrA57Umd/61pI3TeKp7vABvN/X8NIXvzkyS/y4TK1lIRs6FPcutmBOzJ9tq8O+xAA9BaYELVHk+2LZLZIOF+FIxWopIcPxxR4EA3dDvBpANIw7cLB6a7vjcjmLFaode73TbwD/4RfH2tUnG4jrlBUgd73/4VlV9hSt/S/3g5UXSp8oO4/5RP/uEhTxX+sY4ZP+nW6oBo3iu++JwThb8kBXrBzZPu47K3uWNP3xjl0+9zjoudNLlZFnW5CbUeIkaEd93ugY1ezm3fff/ci0dCSMkgH4IsgNcjLv+2QZ2A== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:zh-cn;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PUZPR04MB6316.apcprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(366007)(1800799015)(38070700009);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?7YaGCpuT6S6UKynJObikQd+3NcRY?= =?utf-8?q?D7P05DVeRQqjChe/eoFG4rJyRZxgbPRN9grjPn2T0FknCnkcuwOM1jg7B3sEvXuW6?= =?utf-8?q?wkxINwqwRB1r1Kj2KtAQPMpaB9r01yPZKszRnWe+7OS1Ybsyv6rkt8AyElz8iI3Jv?= =?utf-8?q?TLQ78u5nrdOHb7oggXl5h4jonWfxiwERRyfPKQGVHmUk+8e7tkLNB0h2E1uD1AW74?= =?utf-8?q?qmM56F42thH22FRkyYRGG0S3r5A3PoYD/Q+7uQlFcnjn7eUSMHZlwgpqNcgnplLQI?= =?utf-8?q?qC4RmdF2uUX52HMSIjLjyBfmi+oz4rec33wxXJSpGkzZslYiJmpzxrffZkI/MXQQ5?= =?utf-8?q?yjQIkCBAfVdyZOmaU1MfnF6LOwcnObfsF7VdL/ORy5ZHA0QzRwBM2VPuopFeXyi6O?= =?utf-8?q?RSE1GpTi9deYMXrbPSBH68uJOdQ+t5l1gbiZphz55SyTqHkMe28MpIJ7GNR1JOkst?= =?utf-8?q?4we2XPUyLh+Mt0J+BOAJpcQ25YYDluW3Bd5DoRcACpbrmgq6W8sSFnNVjFUVlQOrC?= =?utf-8?q?4uXUw7tLkzAAy2JOcXAQTYUb0DtYH59JMWaeqyPcQ1qvu3cbZWU8AGTffgDLPftpm?= =?utf-8?q?DM4bRcbAG6mbMhYzSX+PEw6P6KQIREbOqlO+iuRHNty9NX6GLzjOP3JTbI/WcW0wR?= =?utf-8?q?X0wB3DIeiOJ93HchcqdbrFNZtLUj6QE4q6qTKiKIYVQFzCWwntLUwrCGq3ZDZmmcJ?= =?utf-8?q?WfTQAVYgyeVzNLkfn66nl7/vJI0mCht2/6JcZPSM+mhZpxPDCPJTT/dFmOHpFSeYM?= =?utf-8?q?3tP2HvvygD5Gt3uEhDYZI/CCOBKfhXykF1InQ0YSPMbPpf3UmEam8uv9t181VfdpP?= =?utf-8?q?+cQsKeI/QNR8kGhQjGMS21wJXxBe9pD+u9uPGTX8uBHUk/2RBAeGwsdnR92nD89rg?= =?utf-8?q?wbVakgicgLWJs7kg10T1L7vy3iTvGFs5NPTavXM4ueNP/mvKfTOJbaoNEbXDmrsOs?= =?utf-8?q?HZkcQBMi5LP5rzfRQqR/NK/o9I0FopzSs/RzgVWhn7M96klXUtr7LnukoudX71xZN?= =?utf-8?q?9+GFQXw2rSAB+ipBhN/94T6sx0V5jGLH+1oxZTvR7iV9mrRmtk2LobHDy5v/zR2kc?= =?utf-8?q?YhaEiXJcoLh1c0hKm0qoyZ39PxSvGjahmjNuhSh86XSZZLnlJJ3yZnmKyVqEqCS8n?= =?utf-8?q?vdKs670KGgRrWPo0KJ0GhdmZ+LrIIeBwHw2zIUCwweOssxZnDfKC1sR6diCBz03K/?= =?utf-8?q?dw2h78KjkUpQTbto9eMthLNbsvo/rZgSXvbCTp4je0tADPWj7opgHIjUUfCF01UPr?= =?utf-8?q?wgyEcdrhsEVDaNGRjCxfzxQRaW0eeOsrshRCcN7kkdU0FlXkSlP3TjytIQDmjYahl?= =?utf-8?q?3Ia4w9tlgGULWcbwXUrqv3zMIwElUyisT2dR/xI9AYr/QpQIAYrVxIEm/Tt9/PvxP?= =?utf-8?q?F+OPQha3wnblIneXAu0qtNAFbhUBsXMN+H2TJ+vW16xZKoQsYD9gHMLpDyMqljXdg?= =?utf-8?q?j2B2rIGpSk9P3tHTjxfbhgl2BIpsqaPxs/lVne7zYoX8CLm2T9Nj53/KfxEqREmiH?= =?utf-8?q?o0JOzeG7QP4h?= 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: aF3mza3dVLo5ETriLAjOBSn+G+ZAUqh/tFAhbWR8LZ/1B0ZCLQ6cgRxMabTtX7PAxY9njK9iPhAXAAA9p67y1NmYU2uyhI+5M/6s15zl2r5aguurEVQWDu2Otx5epq4IGAf0iWBKp9OoPgvAKyvmP1dEHyLyoCxduDLoOgaYGXOYoCJPYJ4Eo7fc79cJ1ycSy7DZLY57bAEtvH/BgSA+1dWNJIZjJ772oUKjom1sUY4tnf3OgnaEQU7otsiz1FAGq/sfS1EJlVz6u+K9RwHkCwAu78MUxWhoLnru3h2h3NT5VdtAsi7ZUFnzbx/FDToy4Kd7tACBnak7HMzaGX9RStKrGJ8iSdDftx2Dtgi46WFyAtSRehf3G0hUPAamAEzusShrDNu/zLQPYNp2WVmm4VXNKWPPe8X3qDOTMQ9d6aKNs30I75gDMfbh4RSUF2dClFAqO57lQGNl6Hyvh5mdChwIaxA0IVwFurDL5U9qkjHG1vNceF5QkRRGNPG8cPBnMAB185WFEL8kS6DmxIvFIkH34tZLcJZ+NHH/0b1Q+1uApmbeHloYxZ71AhDUTdj6awR+HV5XdZ0YY/pkjADdm0+L0c8PYNdkKjiiWs6jyKkhAUWqzvPRs+Pfm0tZMnOB 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: 132814f5-2de2-440e-6d98-08dc470b4f94 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Mar 2024 05:21:48.4549 (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: CP0xi+wmOAd/oaaesjAaJovQ7xHJuDEXJvTHgTXPPkYDM1QIuqBfVoJeXuYyV/KGIkzbJJTSPvsFXCddxug2KQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SI2PR04MB5895 X-Proofpoint-GUID: 9ArBJt-qUJF2-HrEm71HoiPBcWbkiry9 X-Proofpoint-ORIG-GUID: 9ArBJt-qUJF2-HrEm71HoiPBcWbkiry9 X-Sony-Outbound-GUID: 9ArBJt-qUJF2-HrEm71HoiPBcWbkiry9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-17_12,2024-03-15_01,2023-05-22_02 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 Reviewed-by: Sungjong Seo Signed-off-by: Namjae Jeon --- 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 e228cdfcc9c9..0065d2abc983 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 c6f684bf7b92..ecc5f6a3ad87 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 Mon Mar 18 05:21:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuezhang.Mo@sony.com" X-Patchwork-Id: 13594976 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 90C3620DC4 for ; Mon, 18 Mar 2024 05:22:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=185.183.30.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710739333; cv=fail; b=tW9SulFLSIu/dHyNcbJhxjiyO6jmhI8PxB69RD0iJxmvzpWRzy3XCAACzmX7ivhp4XyAI+XFSRNbcIb3W/dDZB0EFUmJUgL/TCMdFxNfrGnpzetsDQ39QAggIR2g2++Lr9n/JqW0K0/f52W5RlRr/WnYC3F5rJRj9UoCodi0ZfA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710739333; c=relaxed/simple; bh=+IIQhLmUS1tpocMZbumCvHZ/dfdPQ1/vOPA5l7CLrWg=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=qfK/mYer3a1hr2Lk8bmVq8jrQq5grXHhnA0ouP/89fauevZlrtNKbBdsC8smmAW/hckLKug5PEqhKfmnupaPoeg/tJnZRZ/cOnX2OpgFi47d2OVY+hcDPljZ3acHjprq64E36Chk29YpK6qRSRPZ5CY1S8eUVHjAV9njIP9HoYA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com; spf=pass smtp.mailfrom=sony.com; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b=UTz7UbjQ; arc=fail smtp.client-ip=185.183.30.70 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sony.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b="UTz7UbjQ" Received: from pps.filterd (m0209320.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 42I0YVtd006187; Mon, 18 Mar 2024 05:22:01 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=+IIQhLmUS1tpocMZbumCvHZ/dfdPQ1/vOPA5l7CLrWg=; b=UTz7UbjQ7hqDmcBruuweKtUCRv85AAbD2F22H6Tkiwuk5ujgrGeOPBnYC6lnHWLlTx0n acf7oT+hJgb9F34tpVWTXV2dj0b2OwOKOVp/Zn8wVrmJlGQOpN1wzYc78AMXfR4L5b5V vYeeil8G/IrYzngYVir3PZ5xhIrPucDzExkn3gHho9YgsFPQeEOS9tT45wD78wx140L7 pH4mM24csDlMOuS2nzvwLPq2vbkeBRoPZ9Pe6xLDbxQ1su+AXW3g90RzkOnvD/rM0lLu hmwRe55zstaHnmzO/4bB8sw2GGoJjaVQ6NmbE3zSH8Gr42TBjxoNYWS6zIsA3F/Iboz+ BA== 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 3ww1am1hk6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Mar 2024 05:22:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c6N4wxAq81fq025tlcofXR4ATzvnHpIZAotyo4nXSOB0BJDVgdWGYIW5Vk52t8UrbaisgZ+ve35fjWDBZTiM/7AyQ+FqwzJGXx8qZIbcoIlnlKSm6RZChrXajz7femoQuFgT37rLcmK6UIDRkdFIH4tHvo4W/Ps7HOjtbPMQ/esTIAN1ZkomdJmFGaCIsy7h7D2Oi7rlTMhOBiFFDxeO8Inf6Fjys9TZQy4PKYn4UaMntw/gPDpUTO0hAAxmOUIN42qPLcwgsIOay6Ni/CuaAaCEEDpSl5Y0Y2H4C52+LaLfNudFG1JFyixtlwZWGog6l/95kBYYZpZM1eQ+43GHqQ== 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=+IIQhLmUS1tpocMZbumCvHZ/dfdPQ1/vOPA5l7CLrWg=; b=Rf1uEq4N6Lp0HmsNypBIY4bbS6goCo8XjiivCKPeu5KAnSSZd0PIa79Kvy6g1EevEEETxu8/rPELT0GiUCVRf+NCejdpRmAR5Vycvrl+M9S/zwYjJuros+e+rN5BKFxWIV3pdDsu3t9IqFEux/iVVxLFN7QizSQR9baxXbZeO0THSFIyRt+09Si2wS4rQdH+iwr2Hc+C/WrLWIyGC9PVMiZl3Cl/Ra3Gshx2ftmcK7YvD4Eg119oa9ClkFV3fb7htd2wsMdVNd4Hj7YTvr+CwV2qwUNKys/ZvEzFY2v0gFnbO0OnYAHnC2dAGjMqpM4ad+uWrACYZ/TsqH0pDjl2hA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=sony.com; dmarc=pass action=none header.from=sony.com; dkim=pass header.d=sony.com; arc=none Received: from PUZPR04MB6316.apcprd04.prod.outlook.com (2603:1096:301:fc::7) by SI2PR04MB5895.apcprd04.prod.outlook.com (2603:1096:4:1eb::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.26; Mon, 18 Mar 2024 05:21:54 +0000 Received: from PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::7414:91e1:bb61:1c8d]) by PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::7414:91e1:bb61:1c8d%7]) with mapi id 15.20.7386.022; Mon, 18 Mar 2024 05:21:54 +0000 From: "Yuezhang.Mo@sony.com" To: "linkinjeon@kernel.org" , "sj1557.seo@samsung.com" CC: "linux-fsdevel@vger.kernel.org" , "Andy.Wu@sony.com" , "Wataru.Aoyama@sony.com" Subject: [PATCH v4 04/10] exfat: convert exfat_remove_entries() to use dentry cache Thread-Topic: [PATCH v4 04/10] exfat: convert exfat_remove_entries() to use dentry cache Thread-Index: AdiooMwbxmVRnjZgQTisyZfS8SST6HQUX8mg Date: Mon, 18 Mar 2024 05:21: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_|SI2PR04MB5895:EE_ x-ms-office365-filtering-correlation-id: be4c4766-bda3-4627-302c-08dc470b530b x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: tdD7cec7CqqibmHxdiLxVP9DxSHaAN47Fda6Dbx7KHze/nJWsBFiP0knj6fTJhkawnL6MMwWSCbxAvCGSVxHPcN0DwuD2RTvUObI7W9TEJa/kW4UfhM6+0dVxjjiXeOCIPsLPIZ8VUUyw35blsE39re1QouDg13/Oecr+md2pwt5i4b8sVKd1ykXHDfFDlOAaz0IZHXJY7+i/CruVqv2jChY6kLrdgSh7gv/2VQmi4AvGgj2YMKOojBsxOMoYgWgv90QSvhPx58tsI7VLoBswYJuYOBWL3JR92a+0eijWe7oWSUnMw57PYKSlxC2w4bqJXu6/OsvcDVjnLlWopp3aUnx+UtsMZL32kIfYOMJZugyDyuVNpLHfbxkLYSmIFsFlf2e9Wc/gylRM9ZBExpRqCyr7GTr+Pi7OFRrvsOkGs4ULQ+o9tHtTXmHRaCSu17/S3NTzI6FDWf1T1a5MqiIb4CxFmCr/+lF3qAYNCIpeyMp1ltie2j3EOYTY4qMhntyVEzey8Dyv2aZen4lSYVCvgOFt0xX09cF6ncOTEIElnIAclCivDxoPVwyr/kFlePF1yEtPoUQqmGM+XsXbgT0G4ICGrJUj1bLJZ771YJ/iNDU7DguMsFUK14z5e9cjZrvgWyGqTrxy/xp5MbA2YOvXPzR8Vj4VVlsnYzNuL5QSmt6KPq8azqwqvq41wLDSSRdCHD51uYFQFJF9TwlFiYAeHAvwlmD1l5NgqU1/pXVBOE= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:zh-cn;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PUZPR04MB6316.apcprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(366007)(1800799015)(38070700009);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?q3xByfovkc5XiPMFDAGXQUBjTYYX?= =?utf-8?q?lQwW29MqmyD35VkycpjN7PYi5zFOFuZTRmXe3izEz473JS2Dwbv+Dedjh/wCVMl27?= =?utf-8?q?in9FZDMQVG6IUMIEtuUf1aOEC//bGOsZbZHaGcbUVELtD7IsYmYVnCGN8UY4vsvvM?= =?utf-8?q?WbC3U28v00Q+/5ooozi8LgND12IfFqMeFAN/UStdLMTAX+gDpxcPEupKxlvisKEmi?= =?utf-8?q?O05kMggHTOA8zlnycrnZh4PqpAkO0NJcmsLL0wRZ6ZnCp/eLiW6bSxjvg4JumpLbk?= =?utf-8?q?hWiOxyduPX2EzU3/bYNMRdCrOt3o7RNxP/rkfthidH+S9pIQp1Jcfo807OJs5REF0?= =?utf-8?q?pDwbyychdPI3XicHzM70ta5Y2dBJfND/0Y6QZMNl5CBJgpIwvIilcyxO0AAid+/yg?= =?utf-8?q?nUwo87RUI0gXqyylyatyhk8/jtemtZFRlKwRl9bMmmM59aJuCM5VVJTvjTCKiKJ90?= =?utf-8?q?rA+J1OFMllFv+kvS5iFGC5NLtKZudmMgJXZQ6qXxECATrDX9jPTcoy0JChaFwFWwd?= =?utf-8?q?VjoIDmcAWNNSR1iFZRZlRFIX5JMnFQUphVFiRIdzAneyPRYpIIs299PyGDVqi+p/x?= =?utf-8?q?kYoELukcm3rW4kEtmI7hGuqNmNozbH9vevJDPVaaPP/SvMjGT+od9m2pAQYj9a1y7?= =?utf-8?q?cL61pAbENt8BWA142V4JtoBGtDw5n3XIMUjvxDnci4Tj98Jk42cZqZtIZsvSA5krv?= =?utf-8?q?E4EU5Cw2CiKji41c+jDkIwfHixejHBbJHQczJkfz4gFPn5844z7BiZNbpjKnVh2k0?= =?utf-8?q?O0DXSiZaaxhhbvo15wimDX8/bqGipIPyEjcKXrFpJKYmn7XCIhiR89fcogkYCTNtA?= =?utf-8?q?yWLO5zbHiP78Zd3439NQunfmMl2l/nW8n4nx14Y/2uZjomz6X7I97Q7OuksuBokWS?= =?utf-8?q?wGkzyUEFdW9D8DwOwcwVuzIX15JUSAYWRTbu+nYArHC95Liq8H62bXxebTSrKccn1?= =?utf-8?q?cfT9Eno6tdaeB+F3ZWYGULCD4lA/PIhTe8ckkhtkhig3unUwL9NEfozhP/sqSiRxU?= =?utf-8?q?j3iLvGR9mqUX2uW56PEoUMqdh6bZd6WzQrqPolE0f26VikMDxOz/oc4awmatQRQz1?= =?utf-8?q?GUJqbVS89u/OUwKh4ZEZsOhn9HjMk9KmsZNbduOJyHea+7B0tfSmW8TaNgebErtfR?= =?utf-8?q?6X4doQ6wFnHed8GD7un2DoTy1yEu4DfeFvFJ4IkkcVsfanuBBtHR+m4RU2jrLeMjp?= =?utf-8?q?HNhQRXqtsobke05rUJICgAkFVXUL2EkxiQHYvKZ/gcZxNRgAfyyuudTxFSHGSmWt9?= =?utf-8?q?NK5cAeYAAGyyoGyxDHtr6tcgOZ2x2HOvhmL4DbIYbHogZTb3qcdrXRgSWUlMlJXE+?= =?utf-8?q?sBw0ks97dK16qeZorZwytXyBOlu4F/vP/aBoEP6bzq4M0x89Gf/G/ukVBtJ25xbxh?= =?utf-8?q?MzQrjijCP1QAEPP+8wp+0cHSAf2AqnM1BP3O6iZ0n72qSANlPv/8Jfy+dLkBAWaCb?= =?utf-8?q?p8d+IV8xOVAEHqi5A8Kj1+/PjkDjhKIXXO7OJRN14R80lpNIS9OpuuYNBSbxu/X+N?= =?utf-8?q?bCYUj64d/Fhh?= 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: 2XJkn1Vuy8cAaqFZogUt6QL/fANJMhCO0M2rcB/rcjKRtF8astVMK8SYO0/kQCpugxPrArVi1v1ZZu8ISLNq3mB7maPULY4Z9Xc5jsBCfNjI6J+3QhW1dW6OEam/mEsGLQlcE0hOoVLNXSq4TasTwbmitGZ+T0bPYuuPdxMRKakDt5kKWSwqxq7pAyd6GoGCYjpaWV/OYP5WXIbCkWE8qbKgen+16biMiGVPBJFUePqzLkFsZ09b+QbI5Snn+CNCYLvQsD3FfGFy2q5bhkNdVvHVgyaJyveo0JcjHJbvOBDf0SfDozI2cMYRcY3DYd80qWEQvfYcrSBZTVUif5LVhktvfLjQsUtT/Kls0ckD1R3BcmiN5hXe2kZDN2cFWmw3ljh49i7PB8fcFLKtlMhY14K5miA+P+VLM/Cem5SROma7Cgkm++JFJHNmcJnkAbva6vCvHwfUybt7CFm4Shl64Tec9Z5unMLf73ByukQDjJfqfC72LpepBhmSyU0wpHK2u9UJ7+xgA0PTpNHgPuTT49mv50JMijcD55QN+khYuer5KYu98rb3Lljnqcsu416Mw2uDk2XJ0Tkoc1jHZlR0ZxqVnMCQGAd0C9XVpKG43ojkElv6iXVRHcsbidwnnWnG 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: be4c4766-bda3-4627-302c-08dc470b530b X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Mar 2024 05:21:54.3040 (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: Hd/1TxLE5uzrAdW2l17LoZBJ7hmn0O0NrSrpnns65SgEnN4q8d+h7Z/1DSCmVYLdpkIpArWurLTk8novzdFLsg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SI2PR04MB5895 X-Proofpoint-ORIG-GUID: QjoO1Ib4w5vAImY4t3ClwD8dxAEsbnYa X-Proofpoint-GUID: QjoO1Ib4w5vAImY4t3ClwD8dxAEsbnYa X-Sony-Outbound-GUID: QjoO1Ib4w5vAImY4t3ClwD8dxAEsbnYa X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-17_12,2024-03-15_01,2023-05-22_02 Before this conversion, in exfat_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 Reviewed-by: Sungjong Seo Signed-off-by: Namjae Jeon --- 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 0065d2abc983..599dc81c9a08 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 ecc5f6a3ad87..83ae84a657cd 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 Mon Mar 18 05:21:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuezhang.Mo@sony.com" X-Patchwork-Id: 13594977 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 734F321342 for ; Mon, 18 Mar 2024 05:22:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=185.183.30.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710739337; cv=fail; b=Ptk079yERGoVnGN5l8Fce8pGCa/iJWpCwgljuk29VfHRlHbolOw0eezDaZJtddaXMcscKZA16vCXucoSc1QMFTAEc9XtsqKZqMKZXPo34joN9vHFImzKq0tnCB4k4NDvOHYjPWNeS61fIlr0HRCQNw2z1Saf3HV+GD3vEYM0/PQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710739337; c=relaxed/simple; bh=nBeDhgFFZs3r4BPA/Amce/1ugnuxpfBM4oUoncKMbPM=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=rC+txWvmXGoMpbck1dUkYgwW/6hA/VAtnz+azI/9ioC9euKy8eeIbXm00M2w82qrk5o6fetDuxZQ61jstmcAuEoS9hfyxgu5rOupYPCCj7+mWWQO7gechHqryH69LeHlD44XmVXkwxY8znrTFMHyLcLyBXneLAG2OBV+oSsU+qI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com; spf=pass smtp.mailfrom=sony.com; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b=VzxYMJM6; arc=fail smtp.client-ip=185.183.30.70 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sony.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b="VzxYMJM6" 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 42I4i96p027621; Mon, 18 Mar 2024 05:22: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=nBeDhgFFZs3r4BPA/Amce/1ugnuxpfBM4oUoncKMbPM=; b=VzxYMJM6QHZL0kLsScZ0e5iECelKh6pYUnWr7ZNVrJ9UnjSMk+jXH5Ln5+IjyBaAqooE N76pc6AlrJmeqngKvCbDY9e1gnU72dDbMIYGC5oJzNHi9N02LERkyuJgKSrxSo0Nj0Ej zf9ynq0DK3ToqjqIekRVANezBDlV25SPw3TmZ+GoK64s+S2C7UYFdiA4gB5m/YDJZJ1t nmpS1aRXDAglLsOsQNMYlugGfdVmUTzAP41zLE6uIuxDkpk1cbubYG3jNqBnIufAKVPF hG2iAb87jz1WKzga6+qLiv9ZjerXzkb27KEujkfE3u8EbP9GUOcj/DKeJh4H2ibGd0w5 Rw== Received: from apc01-psa-obe.outbound.protection.outlook.com (mail-psaapc01lp2041.outbound.protection.outlook.com [104.47.26.41]) by mx08-001d1705.pphosted.com (PPS) with ESMTPS id 3ww2769h1q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Mar 2024 05:22:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L21p7taaqmI9wlQOhFb026MbkytHzCtwzW14Q2ihqBft23QTKJvp9DuAYJP9DspGut5aLx3/LbS7i0Vx3kywA+cgQH9JM6xyj5AuFHSWFdjeDUaPdjMHTkPw9uhXTx9+djmKOLCjCftr7BlDbim9EoxirYM3bjNBe6oGNtcoVsiZCyE+Sn4TaQm86CLlY6MK9o5j0mBGKsWn2xWjH4owUgxN8VgpKWl+zgzZ+aMGmfRSqCvqqRbTmIOpZwdifcuPKQrFYiUvUZDQin0drg5e5tbbj2y4SEF+BVafcLJBFh1i9eP/mw6djsUoQNwPvcidhTdI2O8ehBV2LsY5pJXHkw== 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=nBeDhgFFZs3r4BPA/Amce/1ugnuxpfBM4oUoncKMbPM=; b=m5JFScLYDzpP82ISMQCkd58n7Gu/wYVd2eqI4UQ0dzRtrE3Z5eUMLVHyaAHLFasls6GrX631udb8KsHSaWgzlSOmHybwWOD1L7Ny8Yd0f5rufaaYcB6qlIZsWrTebzHSKBM6nd5vxXMARJAeAB8jKcy/NrSbW7x99BZP63E73Zf+IVz9hGpUC+PMTEE0lTSuS6GXXlzHiYbDspZ1NFVmFVwt+hAmhtoi//0DSfUMyYy6Zzp817oBEvfgqqgY+9bb8bCJ1eDw/WKM5G2gU867K5jHU0UyxnUioOwDQ00sYWGhZEbSFgGdf9RSvPOgsjQaXCWo0WhUEekC+wBMoZsYyg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=sony.com; dmarc=pass action=none header.from=sony.com; dkim=pass header.d=sony.com; arc=none Received: from PUZPR04MB6316.apcprd04.prod.outlook.com (2603:1096:301:fc::7) by SI2PR04MB5895.apcprd04.prod.outlook.com (2603:1096:4:1eb::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.26; Mon, 18 Mar 2024 05:21:59 +0000 Received: from PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::7414:91e1:bb61:1c8d]) by PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::7414:91e1:bb61:1c8d%7]) with mapi id 15.20.7386.022; Mon, 18 Mar 2024 05:21:59 +0000 From: "Yuezhang.Mo@sony.com" To: "linkinjeon@kernel.org" , "sj1557.seo@samsung.com" CC: "linux-fsdevel@vger.kernel.org" , "Andy.Wu@sony.com" , "Wataru.Aoyama@sony.com" Subject: [PATCH v4 05/10] exfat: move free cluster out of exfat_init_ext_entry() Thread-Topic: [PATCH v4 05/10] exfat: move free cluster out of exfat_init_ext_entry() Thread-Index: Adk2K2RlKDzYiUB2RIeEGX1cod9h91CxyGog Date: Mon, 18 Mar 2024 05:21:59 +0000 Message-ID: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PUZPR04MB6316:EE_|SI2PR04MB5895:EE_ x-ms-office365-filtering-correlation-id: 027461b9-6e2a-498f-4263-08dc470b563f x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: w6A6j+DXkTvkw/ZaGGyL7rXo9N6x/IF6ujHGRV9lNZyCi8+CKBln/Vgskaod+LlOl7UeKGDmvC5iv5OATp4ANBx2YKOQfgiRC6Q+9EAozMd3txvGf4ZyFErMqNcadlB8Q7PfrCNFc0midyruU3FQBTX0VBBM/T7e36xl/iEosrqKJLBhLvjkWMBC1loVVifUJqeyde6iKySLd3Qg1CSCRoIUnbzjKXwWBsZ2+bIv5WdmtqXOJFqFSadRht8B4lQr4RiPzyhM443CXq71eDCgu2ntGukhaMOLCHvJBT6YuZetmiSc8U9rPC1tiPpwoBhKoA+/qgg0tPfLJV4+XNrfcLGLCVK6OLjvJn5/IbNwNYDvzZxqIBpRt81XVcKB04C0D+Vib82alzM5PcuvIyoP3uIzMG1tgw7zUNEQFUJcegSjD1Djd5PhJCEXw8Qa/2wu2bD1YXDe6dpnu6U0mlDSb6bMnFB7ZRBy8bwGOfVqicO98HAei27TLUo0aPsiEOxm7coPNiLqBPBuO0IbO0MdrDi8eu9FFq1JWyoSKUZQHa2Q1wxr3kYb9oROxm2o6K7Z2+V+i7yn34vvs7Dpjf1UUeBVCflFDkHkoZe64kt/AxwvTbdSk4j0bDORn6KXQErUr4YZXTSfGJVE5XdjAw/cr2g1NjaGfVJM0idPMFnHFzg/IremSNbfMZKggFCcQ8hBC5ux0FzqDJqpzdoasP9MJsK3G96ZBSmo7JPgfbjfHbw= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:zh-cn;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PUZPR04MB6316.apcprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(366007)(1800799015)(38070700009);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?fGe2mnSFxfOzUyZ3oRb4zk4XOXbD?= =?utf-8?q?pNEHbqhNFPTGZzSh83N9bTBoUMezfwBPk8fMGy9xTI6k44jZJFBVJnbevIdUz+0FR?= =?utf-8?q?rd823GKyia5nrgNBwjUM9Csel5b6WW6fPkAWnJNAn8WNA7sIMYT3oRcHGwWOMFph7?= =?utf-8?q?7UQL9dbe0DGBx9HbsKXRC80teAiLPzfD62jxtFfuh1uOlcru0W+NmgEuQm4uG3Kka?= =?utf-8?q?DiPgWgfq9sEOmenbUHn8MtY9ZLO5XKN6oSgEcurennoPsI5CJF6SG9KcCGTaW2ZBl?= =?utf-8?q?mK7oSNpEUGK9axqPxQVB9I+5nQZhxOzK/aqNlz9zMtV7ypIt45eFhMS4Fm6KTX9uG?= =?utf-8?q?c9/e+KA/yACuVaUHhLz0eHxuGDgG/KBR03NSN76GqsRub8h9kSFxvH7vrGSumCeDz?= =?utf-8?q?EMa6oEVKLz5/ffw5z8GaxG64HI5L2AEaiwpkOw3X5M8xQiOgRQFP7Sh42p/L2tHFs?= =?utf-8?q?WU0lm5BMlyX1/t5ogw5R1oJ505n0KDdW5WZXy1FlVi2RjIY+vCPm0Dq6CSvixPApp?= =?utf-8?q?p09CpqhrwJLxx1dGrzaKylbpu4tZblZBJnTmt3VSv+hT2L6x7rKEWZR1a072j+Pl4?= =?utf-8?q?N+682yTwljsHOE3ZHYBx8tipwjZ3g/TkYPC2XVWV2Ay1MxHHzGagq7eC/Y85VNa5h?= =?utf-8?q?oWo0BYTlX7eiSCh7uiRzBQeTUPke/jGw9kBc/3IZtgBeIgKt+8wctiyC0yagNckuP?= =?utf-8?q?uSEbkRkldW6nq4yXCsDJECVizLl3SgLdzuBI7CYDs0yPmRZbBnpDFCOgqBk85bKk7?= =?utf-8?q?sNt4ko2XvQpYmlxzVsWLnchY2MJoomAPlwMn3sMuXu9LhAGtAubpBQiCjgajTnioy?= =?utf-8?q?TsMDibSObYcBQi/aSVGFw7GYcotMMnkq0CbCP04XczyHcslZuhJVCd/MdHjaske5q?= =?utf-8?q?HoYL4BI1PwsT29eMIBKMmam5LLyY5USmXMQhfDZwDLh+D5v0EvIZ76PVUZkYMOeOm?= =?utf-8?q?OAnmzVWwPty5yzvGHzmHbzs9mz8nlEbcD2jqa6wyeubC6QsmKg1XIPjRbwihRYHX1?= =?utf-8?q?maQlN7sqEDNxAMt4uia/GTHVLPpmIjE9CvesWuo3hc+/Gw+Hg4Yk2n5IOkyOKqSZw?= =?utf-8?q?mBgzI/istIfpT5jZVG3O/CszIGpeApPid/PBU430jiywLTNg1aDzV+IAdiDYtFWSa?= =?utf-8?q?52xefxtyuLWKMEtUgtJ+tvN1LjJg0JJ1wvmSDErsK1aXVVedtw5TklDVf2xvRO4Ke?= =?utf-8?q?ZovSOpuDqUQBZGp+KyRIlU0U5DtfSfhO5UADsxowJGzUwBytO/xqkIgEWLTAWh9nj?= =?utf-8?q?Ui5KXj6lhzz7MvFnnPVM03FYMdpiCVBGAUCEnPb2kUggys8zIR8UY+UwnCRqi1qCC?= =?utf-8?q?h2TzeMFKX4+DGCOpJ22NMSuhQLBBRzaV1F3YppTZFWWpMgYPP7q/Zpe/gj537xDo/?= =?utf-8?q?7fb6UyoWu9Adg7mQ5AZmm7wmsLpqvX2QnC/xHZ2jZrzN1WhSfZKxk1Icuuf4IYLbs?= =?utf-8?q?X5GUKBZwkaHJT4yd8wJFp69LPqc0x5SYDVwfI4o57w7omvAaSxJokJwa2amw+/Gk7?= =?utf-8?q?yW1wmrzu1mec?= 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: IyR6MwO47sY+wlLXolcIYdBx20o+sYTdnlwFylwBjhv53OEPOi6CjemFXLwjIpAwZTI4IvV+QWYWQoD+3JBrmuP0Yb4cyLCpNdLch85//F8dNpKo5VaIpjZ2Y13Yxz7yL2VFYcglL68SejK5cPIVsRJxmtgyJVE7nyCo/mCfJisNCR/Haov8RL+izQsXRqZJW/EXh6EWbEKrAIVr+cep0QvTrFU/PNi9U3qKAzrytUhjTTGqdXnaI2VvkM4yAP9iZFQ+eAnu1HKgILc9/i9qKLzvjPvVhzejFar6uNFifca7rjolFCpppDEy3Wx+wIJRPcm80LkY1eSGHGCTAuY54TQDA2348Bd9s2dSxTLHEpxQ7YfO84IQRqQUKbsq6TL+KD87xwlNAWAdKRj6LuBtTqXtp/0CMdgj3LUq6u5BKm5yB9eaL2CGbILCs658zccdI82pJmhLsa1D9msvnNJ2U60yLz3S1GiWIXFe/AHt0gWv5L7PsTTgcsqFIsfdUFtvsG1Wb4qBrkhuFT0eEbeWvvaT0WFYY0jMifPZkFzO64HwjRotssrT222q885UBlIlkgSas+zGE7LfGjDsDeR3QlpI+rsxZtKAd0Q/bUdQ+vx1GaXqu0ijaYdqfWddy5kg 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: 027461b9-6e2a-498f-4263-08dc470b563f X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Mar 2024 05:21:59.6764 (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: K7QG/vsUiwoZdZDxX5T8XrjIqNj86ObJBqZEGO/ZQVLDMIecVhtSMLFRiraD5JAylKn6/45KVL5bWuWFzlSFHQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SI2PR04MB5895 X-Proofpoint-GUID: xzeC6bYr1SIbkw9au3SkVoIS0vVP0G3r X-Proofpoint-ORIG-GUID: xzeC6bYr1SIbkw9au3SkVoIS0vVP0G3r X-Sony-Outbound-GUID: xzeC6bYr1SIbkw9au3SkVoIS0vVP0G3r X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-17_12,2024-03-15_01,2023-05-22_02 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 Reviewed-by: Sungjong Seo Signed-off-by: Namjae Jeon --- 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 599dc81c9a08..0008d4681d29 100644 --- a/fs/exfat/dir.c +++ b/fs/exfat/dir.c @@ -564,9 +564,6 @@ int exfat_init_ext_entry(struct inode *inode, struct exfat_chain *p_dir, if (!ep) return -EIO; - if (exfat_get_entry_type(ep) & TYPE_BENIGN_SEC) - exfat_free_benign_secondary_clusters(inode, ep); - exfat_init_name_entry(ep, uniname); exfat_update_bh(bh, sync); brelse(bh); diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c index f56e223b9b8f..be6760297e8f 100644 --- a/fs/exfat/namei.c +++ b/fs/exfat/namei.c @@ -1082,12 +1082,13 @@ static int exfat_rename_file(struct inode *inode, struct exfat_chain *p_dir, epold->dentry.file.attr |= cpu_to_le16(EXFAT_ATTR_ARCHIVE); ei->attr |= EXFAT_ATTR_ARCHIVE; } + + exfat_remove_entries(inode, &old_es, ES_IDX_FIRST_FILENAME + 1); + ret = exfat_init_ext_entry(inode, p_dir, oldentry, num_new_entries, p_uniname); if (ret) goto put_old_es; - - exfat_remove_entries(inode, &old_es, num_new_entries); } return exfat_put_dentry_set(&old_es, sync); From patchwork Mon Mar 18 05:22:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuezhang.Mo@sony.com" X-Patchwork-Id: 13594978 Received: from mx08-001d1705.pphosted.com (mx08-001d1705.pphosted.com [185.183.30.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D7AD21345 for ; Mon, 18 Mar 2024 05:22:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=185.183.30.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710739339; cv=fail; b=WVmlajT8TfZ2hHOn6E3hPpOXKj6Q5DmdvRFOyaQ+S3UKmzicF8YHeSlMVLGowpnzpKYdCMQBmuuiGtonId7jz8lk3Y1kQQfUw/Esane+YjDZAGlYVNIgxhSYUgW7/GsAqu7q847seE4ynRV8SltH1txBq2tRRrAvXegKx5FWFYQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710739339; c=relaxed/simple; bh=UJuS2nJ7FyYC+Nja/UCSoqDNYqSpbvt7NR6UfoR8eLI=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=mfSBnTz1jJMHhgKKws9W51rzpuuywpjQW1IK+f5/i59KsjNKDfJOiMbP7veIc6ody7OB5FoQQLt1E3+zoM7dCkXEi9ANd7u/v2KQWOn/p+vr/k6F8w0m8pEwpggIYkj58n4vy98ftoYcVnN++XgWTWfb4PSdgHIRWLbRFuPT0/k= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com; spf=pass smtp.mailfrom=sony.com; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b=QnjxGIiY; arc=fail smtp.client-ip=185.183.30.70 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sony.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b="QnjxGIiY" Received: from pps.filterd (m0209322.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 42I4i96q027621; Mon, 18 Mar 2024 05:22:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sony.com; h=from : to : cc : subject : date : message-id : mime-version : content-type : content-transfer-encoding; s=S1; bh=UJuS2nJ7FyYC+Nja/UCSoqDNYqSpbvt7NR6UfoR8eLI=; b=QnjxGIiYqEGvVl2RAau/BNhaRVokjigvN2cPeCwZm9Y/EOidBadQ1rNyZuzO7zPiUuje c+Kb++isXjXZV9vjE9zQnzpujZsd4s3X8fVmUOF1y58PMHSlN599BUmKqTEpiU4WbzOc kPSp4hSg/82aLOg3a3y7AMETvcNYILkvn5teCrHkj6VoOf4TT+pW2Cb7PAW+8HUh5rWQ YP7XkEu6zeu6i3WJ4l+ONk5MYHMobl7H1tnIze+rCQuwcBskuJ7a3pyc4faUNe7Pt0g2 L7A4IE0kmtFkpLZ6+N22XAZSYoQKXoDCaZlKCAc1IeoFbIXxReC+rBhk6clLcxXhnom8 NA== Received: from apc01-psa-obe.outbound.protection.outlook.com (mail-psaapc01lp2041.outbound.protection.outlook.com [104.47.26.41]) by mx08-001d1705.pphosted.com (PPS) with ESMTPS id 3ww2769h1q-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Mar 2024 05:22:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fWxt3jbQlvoLRDMYMO0zbCDe7Vt6h+mb4KFUqgn0K+VRox8tClInKSum/zpMdqSeUsUnfML7xUfpMkwiaAcaeDAv23Xr+yFD/fgtnY5LEMteuvSLQ6H1g128G7t+ub39srFjXdRvmxAq4CPF8S2nJrY7HVwQyVLP0wcFFccAVG+VaapvSLZaeaG8AhJIwV3dk/iZIrKQVQQbF5GuZQ74kjFsZqp/jbdgLFeqdZ/Ukzs2HpXPpvhvjd7f80PsKHV5TOaiTz7YzBQlhptu+kkQfU2XinaRvca2wEce7gCT2dC1S9JSZ6jQLRvXarzSstVC91RtoCYKMcfmz6zzCW+BQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=UJuS2nJ7FyYC+Nja/UCSoqDNYqSpbvt7NR6UfoR8eLI=; b=ZoP/+uK8iUuoljw7XWd24V45+S79h0dXgvL6+dv0qx5UislDHP+pvqnbYgot75CT9yNk/1dU0kJ81aPnU5yn6S3i7qSKOIeaOFjh4RT+dTQuR8xn3vCDRcrGdCqZG59+I+OXL41iLI1aFLpxf4RIqIcXTXEhkakPMZ58AOgyqrF2wGdXd3S42v1nTzL2Eae8MgDKB4U3BstWH7y2BKPq3VCkISGe02WwsALhWBZhw/0aivUtecRfhuOX65dbJhntC3c5jQ4kT5jBT0R0tSulB/yo1FrslhKQlXo0xvfKbDp0Eye3unoCga0NnWqCbRn5OLSIxO+LXax2VQZJwBO4PA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=sony.com; dmarc=pass action=none header.from=sony.com; dkim=pass header.d=sony.com; arc=none Received: from PUZPR04MB6316.apcprd04.prod.outlook.com (2603:1096:301:fc::7) by SI2PR04MB5895.apcprd04.prod.outlook.com (2603:1096:4:1eb::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.26; Mon, 18 Mar 2024 05:22:04 +0000 Received: from PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::7414:91e1:bb61:1c8d]) by PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::7414:91e1:bb61:1c8d%7]) with mapi id 15.20.7386.022; Mon, 18 Mar 2024 05:22:03 +0000 From: "Yuezhang.Mo@sony.com" To: "linkinjeon@kernel.org" , "sj1557.seo@samsung.com" CC: "linux-fsdevel@vger.kernel.org" , "Andy.Wu@sony.com" , "Wataru.Aoyama@sony.com" Subject: [PATCH v4 06/10] exfat: convert exfat_init_ext_entry() to use dentry cache Thread-Topic: [PATCH v4 06/10] exfat: convert exfat_init_ext_entry() to use dentry cache Thread-Index: AdiopzuU0qp5uINBQASO58AHYsMdXnQS3oyA Date: Mon, 18 Mar 2024 05:22:03 +0000 Message-ID: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PUZPR04MB6316:EE_|SI2PR04MB5895:EE_ x-ms-office365-filtering-correlation-id: be62b945-aff1-43f0-9cd4-08dc470b58c0 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: AHfj0ddo0m5Ovy4yEjBBgs9XdbvWvFurDQbjwI0SW1GyjonyOhUcBEmIQsaEsXuooFlAAhLOWaMLmkMCSUFOZ6pFgVjRkrOIiUKMNUb3ceIAF4AzeaAdYEHmv09G7IVxYcyOhdi944rNCexh3uDUZSteFtEkTT/12+y9stYB49QBxDj0gSb5C+GtJAC4vYxzQ9CV+30PXBpYQ4sL93ZCz2uDMz3qihdzgPqsAqXFQYkeIJVcoXXFhr7ywVUcu+jUn0au3ymF8SH7xShRkkZPgopQCE5sVnRjKgDwWYUQLCwPAsUBiSEDeaLTHrFtZvvZzK4uNuUDh7mewaCJhdij8jU2Q/DY+RuyFDwkPm3MUePfnpWBTVDRIhPZyYnQmnM4lj2ge7chsbM8cvvlKeUh99wu7C5UjoCdDCJTr1gq3JnkNx4O2iodYWwby5LDV4dpoSnLM5sXCsr00uAejRZQ8NzcLYAkLfgHFSrQlPUAP4YaMjCS7sRKEalxnQT0osd6t9ogb7RtlGKcRBw8Ofb+1GolVRk16tt6strRKDTOksZAknv6sTaVCidwp4JSSUS0XRhm8ej2TPwQtEdm9/Wa3lu0g4GHa3OS/ZmoiDI7o1eSk+IEyuU39Wa7kxahR/eHigdoZToSnmbknVfd/mbK74w+B86g3JwPovOlvlwYBi4SNrzgL2Y0ZB7Hr0cT9bQsNvXkUEzwzlgt5rwIomYeVg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:zh-cn;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PUZPR04MB6316.apcprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(366007)(1800799015)(38070700009);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?6wejKt5nlwUD1ovj4f6A9NNLOrRD?= =?utf-8?q?EcTey+q+GwwqevFwqPzJQByvn3cbQZ+ALqpeu8YVZYKoRWaVTFsZ8Byjr276q7vN8?= =?utf-8?q?zBN6Fxzv+NkLVN2UgIADKZqkcfWFO3TCy9Z3VxjF5ImYbh94/ZWzTJU1dOX/VfDEI?= =?utf-8?q?nhpE2XSdfIMlt3tDgLXJE6aLgy0t9ig2CqZIsBq2fyN4BXzJ1fo5TpKK6WCDDrNnD?= =?utf-8?q?tMBjBNUNmWp7rssOa0EK1nZGdP9oqwmvhqIsd86sIk8xA895hpEIgz9sF80Asj/Z5?= =?utf-8?q?DxcnRFqcPIRgO8u6zRx5RPCyojwqqgIdXSwxXoauWAPJy74yfiFIGiArwkfw/j955?= =?utf-8?q?NqsnBKaO2zXKoQtoJAXPTK83BYURpa5epm0iMdVz/bKPURuAQZ4i0AqhMmlIeWUry?= =?utf-8?q?c8Yuymj+STDofeFw/2wHLRkp2ui0vharYnRWL9WcwECJ7RsTwDV4gGbEGj80Ksf9f?= =?utf-8?q?6TL9gcqcqDqJYU2Ps1KB5laHp+lK59PtbowwybwJmUc5IxWowsiVkYVNmXKgZCR4r?= =?utf-8?q?qZRdHf+tPjbaJpvxfNotnW961RRr60BUi7DpmceCM2Jx3MlSFnRo4FKnMH4cMQoZB?= =?utf-8?q?iIwmPhDOIICxNOxxmTdSHfD1CvrOX2QZFpIlvSJSzv1sRV7FqFdUG29c3ztzjGVxm?= =?utf-8?q?ZMNDPWb8MBj+5VZ6bVHjNoGP/tIFliZcYcmaHipRNKvY1WrXNAaBI+k6v8N1wB4Le?= =?utf-8?q?KMCJcyhokbf3IwU3i3Jd7nVx3xUczNbtOCj4fqD0r8T9Jk2REFbp96c6i4h45bt8D?= =?utf-8?q?Tdvd9blIUEsPvRFiNmmQaZvjphRwFOi3B4XlkOdBs3J0mH8E0k28Ag+FFyC67pzdD?= =?utf-8?q?LtuwkP8NoU9TP0sP46lFGRY2EPGO5oZCN9kCVvgSFPpoatOoR2Dr9WzvkLZMJ0Nk8?= =?utf-8?q?e4N0ioYR116xdCbQtYRme3Obgg0JIBU+g/J5o/B9T0foNbekOxY/ajVQnGrZ1ouOC?= =?utf-8?q?uM3A7oXhnWyhniSaZ8EVlTU7al3WUvuBVCNBroFUrAQySv6n2kptnS2933nbgoZsr?= =?utf-8?q?q533J3GiATK9umcDbsUkRcf4Wj6CA6Ri0YhkRNYKRkAxKgTY5/QmGJN/JoD6REeSn?= =?utf-8?q?+/flR5AEokXXJDJJuKltKteo0MmplWKzCnkT9Xwn3rTCqOnt79ZgVCPOZS55mkqR7?= =?utf-8?q?UsJn/grGs5CVXJoOnvqCLPRhZ1Zzd1b5bzqZpNLtx9AqNp4lQki8mu09C1P2/vqMB?= =?utf-8?q?2LvqFvkPNjiIKUeLjs4+rfc0GMvmMuCBXUGWlQ2Esf1wLcxGO7KlMawc7XqszKm5E?= =?utf-8?q?P2MEl61HZIftv2XxTkQcSGGwAtujPJkcJu5fzwyE2+r+pUmUcnEHW2IKq+QPzYZYw?= =?utf-8?q?Hn+4a1TfRiIibo5WHK5YsjdXRkL07bvMt9mkah+kR/veYy7Y0HOsobfHyHEPaaqxg?= =?utf-8?q?KSw6p/bCTCxdmHgICI2ybRB7QyjA4HcM00ldDnXids/ZEdJsboRM8GG+CGMNABNLq?= =?utf-8?q?rhdTPpwcWazbeR0zq8KQeq4IrRwNRXG1mUW/xz5qJ8CFgiqAnxkRCwhNNDpAtLFYe?= =?utf-8?q?4n2qz+ctrAjx?= Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: wSjjEqtyZIDmTpBIrG8H15VPr+vnGZga6ioYJ2ox+/Jq7RZyOaprfnQZ31zT3f6noEhqkR8tGZF3DMDmMnwaALAP0/fz0kGYp0FHplIsOTeNnzZ0UZPmy1J3X+TnZkABzOILfBRqZsT4UgDG84GtoPwVSsI4Zclrp9jaB1fX5T/NQoCKXtX7y4N/4GacJvTATSpzqjOZzCKx/L33eKZ57DMl968t6b62Ta4uUMhskGoSNcq0uO69/55IxiJU29vh4yZk9uPjOZEqUezS0n5PxAz2bfKTLj/dB1e7jahM2fghgq1B963/r3MeldDieJL1Opmvn68A0+7aHxJ0idtyNYn1KjM/3+RJwphwoaHroN1iRxe6+wNe3FkZMxNiFc1rY+p2wYbQhHdH5kKipIdPhobLOeZEQbjU72ojJEbZLRQ0yqeYAN5BT8bn9FDdZKJi01PXJ4RIpT4dv0EalE6neKLit1ro/+ERpRcu8p96yDv2xx5BW5a+XzJRSdiuQMKVNZGKp3vvm2Na2EB3+eMKE1AJ8f6kleQ1/T4axhRMyh127507cxMmYWwcdbkfSWmckrw/QEM8RnBnaklmsSe5xUXWZbq5Y5znkhfeBxGSP/vTZVoUDmqdHd6LgsUN8kUo X-OriginatorOrg: sony.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PUZPR04MB6316.apcprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: be62b945-aff1-43f0-9cd4-08dc470b58c0 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Mar 2024 05:22:03.8405 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 66c65d8a-9158-4521-a2d8-664963db48e4 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: YqKLDOztSKoSJTZkhI1Z8Oa8uPvNkuz4GK+oipsJB8jv0+cQabfcUXZFz1WRiOTgRG4hXMVwYCrRgvlt98eu1w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SI2PR04MB5895 X-Proofpoint-GUID: sn3S5G9E-MEaNbu19V2Y4TBCQaZL2K5n X-Proofpoint-ORIG-GUID: sn3S5G9E-MEaNbu19V2Y4TBCQaZL2K5n X-Sony-Outbound-GUID: sn3S5G9E-MEaNbu19V2Y4TBCQaZL2K5n X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-17_12,2024-03-15_01,2023-05-22_02 Before this conversion, in exfat_init_ext_entry(), to init the dentries in a dentry set, the sync times is equals the dentry number if 'dirsync' or 'sync' is enabled. That affects not only performance but also device life. After this conversion, only needs to be synchronized once if 'dirsync' or 'sync' is enabled. Signed-off-by: Yuezhang Mo Reviewed-by: Andy Wu Reviewed-by: Aoyama Wataru Reviewed-by: Sungjong Seo Signed-off-by: Namjae Jeon --- fs/exfat/dir.c | 33 +++++--------------- fs/exfat/exfat_fs.h | 4 +-- fs/exfat/namei.c | 73 +++++++++++++++------------------------------ 3 files changed, 33 insertions(+), 77 deletions(-) diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c index 0008d4681d29..df39e245671d 100644 --- a/fs/exfat/dir.c +++ b/fs/exfat/dir.c @@ -532,46 +532,27 @@ static void exfat_free_benign_secondary_clusters(struct inode *inode, exfat_free_cluster(inode, &dir); } -int exfat_init_ext_entry(struct inode *inode, struct exfat_chain *p_dir, - int entry, int num_entries, struct exfat_uni_name *p_uniname) +void exfat_init_ext_entry(struct exfat_entry_set_cache *es, int num_entries, + struct exfat_uni_name *p_uniname) { - struct super_block *sb = inode->i_sb; int i; unsigned short *uniname = p_uniname->name; struct exfat_dentry *ep; - struct buffer_head *bh; - int sync = IS_DIRSYNC(inode); - - ep = exfat_get_dentry(sb, p_dir, entry, &bh); - if (!ep) - return -EIO; + ep = exfat_get_dentry_cached(es, ES_IDX_FILE); ep->dentry.file.num_ext = (unsigned char)(num_entries - 1); - exfat_update_bh(bh, sync); - brelse(bh); - - ep = exfat_get_dentry(sb, p_dir, entry + 1, &bh); - if (!ep) - return -EIO; + ep = exfat_get_dentry_cached(es, ES_IDX_STREAM); ep->dentry.stream.name_len = p_uniname->name_len; ep->dentry.stream.name_hash = cpu_to_le16(p_uniname->name_hash); - exfat_update_bh(bh, sync); - brelse(bh); - - for (i = EXFAT_FIRST_CLUSTER; i < num_entries; i++) { - ep = exfat_get_dentry(sb, p_dir, entry + i, &bh); - if (!ep) - return -EIO; + for (i = ES_IDX_FIRST_FILENAME; i < num_entries; i++) { + ep = exfat_get_dentry_cached(es, i); exfat_init_name_entry(ep, uniname); - exfat_update_bh(bh, sync); - brelse(bh); uniname += EXFAT_FILE_NAME_LEN; } - exfat_update_dir_chksum(inode, p_dir, entry); - return 0; + exfat_update_dir_chksum_with_entry_set(es); } void exfat_remove_entries(struct inode *inode, struct exfat_entry_set_cache *es, diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h index 83ae84a657cd..1cc91476b9c5 100644 --- a/fs/exfat/exfat_fs.h +++ b/fs/exfat/exfat_fs.h @@ -483,8 +483,8 @@ unsigned int exfat_get_entry_type(struct exfat_dentry *p_entry); void exfat_init_dir_entry(struct exfat_entry_set_cache *es, unsigned int type, unsigned int start_clu, unsigned long long size, struct timespec64 *ts); -int exfat_init_ext_entry(struct inode *inode, struct exfat_chain *p_dir, - int entry, int num_entries, struct exfat_uni_name *p_uniname); +void exfat_init_ext_entry(struct exfat_entry_set_cache *es, int num_entries, + struct exfat_uni_name *p_uniname); void exfat_remove_entries(struct inode *inode, struct exfat_entry_set_cache *es, int order); int exfat_update_dir_chksum(struct inode *inode, struct exfat_chain *p_dir, diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c index be6760297e8f..2c6df4f966f5 100644 --- a/fs/exfat/namei.c +++ b/fs/exfat/namei.c @@ -539,15 +539,12 @@ static int exfat_add_entry(struct inode *inode, const char *path, goto out; exfat_init_dir_entry(&es, type, start_clu, clu_size, &ts); + exfat_init_ext_entry(&es, num_entries, &uniname); ret = exfat_put_dentry_set(&es, IS_DIRSYNC(inode)); if (ret) goto out; - ret = exfat_init_ext_entry(inode, p_dir, dentry, num_entries, &uniname); - if (ret) - goto out; - info->dir = *p_dir; info->entry = dentry; info->flags = ALLOC_NO_FAT_CHAIN; @@ -1018,8 +1015,7 @@ static int exfat_rename_file(struct inode *inode, struct exfat_chain *p_dir, int ret, num_new_entries; struct exfat_dentry *epold, *epnew; struct super_block *sb = inode->i_sb; - struct buffer_head *new_bh; - struct exfat_entry_set_cache old_es; + struct exfat_entry_set_cache old_es, new_es; int sync = IS_DIRSYNC(inode); num_new_entries = exfat_calc_num_entries(p_uniname); @@ -1044,33 +1040,25 @@ static int exfat_rename_file(struct inode *inode, struct exfat_chain *p_dir, goto put_old_es; } - epnew = exfat_get_dentry(sb, p_dir, newentry, &new_bh); - if (!epnew) { - ret = -EIO; + ret = exfat_get_empty_dentry_set(&new_es, sb, p_dir, newentry, + num_new_entries); + if (ret) goto put_old_es; - } + epnew = exfat_get_dentry_cached(&new_es, ES_IDX_FILE); *epnew = *epold; if (exfat_get_entry_type(epnew) == TYPE_FILE) { epnew->dentry.file.attr |= cpu_to_le16(EXFAT_ATTR_ARCHIVE); ei->attr |= EXFAT_ATTR_ARCHIVE; } - exfat_update_bh(new_bh, sync); - brelse(new_bh); epold = exfat_get_dentry_cached(&old_es, ES_IDX_STREAM); - epnew = exfat_get_dentry(sb, p_dir, newentry + 1, &new_bh); - if (!epnew) { - ret = -EIO; - goto put_old_es; - } - + epnew = exfat_get_dentry_cached(&new_es, ES_IDX_STREAM); *epnew = *epold; - exfat_update_bh(new_bh, sync); - brelse(new_bh); - ret = exfat_init_ext_entry(inode, p_dir, newentry, - num_new_entries, p_uniname); + exfat_init_ext_entry(&new_es, num_new_entries, p_uniname); + + ret = exfat_put_dentry_set(&new_es, sync); if (ret) goto put_old_es; @@ -1084,11 +1072,7 @@ static int exfat_rename_file(struct inode *inode, struct exfat_chain *p_dir, } exfat_remove_entries(inode, &old_es, ES_IDX_FIRST_FILENAME + 1); - - ret = exfat_init_ext_entry(inode, p_dir, oldentry, - num_new_entries, p_uniname); - if (ret) - goto put_old_es; + exfat_init_ext_entry(&old_es, num_new_entries, p_uniname); } return exfat_put_dentry_set(&old_es, sync); @@ -1104,8 +1088,7 @@ static int exfat_move_file(struct inode *inode, struct exfat_chain *p_olddir, int ret, newentry, num_new_entries; struct exfat_dentry *epmov, *epnew; struct super_block *sb = inode->i_sb; - struct buffer_head *new_bh; - struct exfat_entry_set_cache mov_es; + struct exfat_entry_set_cache mov_es, new_es; num_new_entries = exfat_calc_num_entries(p_uniname); if (num_new_entries < 0) @@ -1120,43 +1103,35 @@ static int exfat_move_file(struct inode *inode, struct exfat_chain *p_olddir, if (ret) return -EIO; - epmov = exfat_get_dentry_cached(&mov_es, ES_IDX_FILE); - epnew = exfat_get_dentry(sb, p_newdir, newentry, &new_bh); - if (!epnew) { - ret = -EIO; + ret = exfat_get_empty_dentry_set(&new_es, sb, p_newdir, newentry, + num_new_entries); + if (ret) goto put_mov_es; - } + epmov = exfat_get_dentry_cached(&mov_es, ES_IDX_FILE); + epnew = exfat_get_dentry_cached(&new_es, ES_IDX_FILE); *epnew = *epmov; if (exfat_get_entry_type(epnew) == TYPE_FILE) { epnew->dentry.file.attr |= cpu_to_le16(EXFAT_ATTR_ARCHIVE); ei->attr |= EXFAT_ATTR_ARCHIVE; } - exfat_update_bh(new_bh, IS_DIRSYNC(inode)); - brelse(new_bh); epmov = exfat_get_dentry_cached(&mov_es, ES_IDX_STREAM); - epnew = exfat_get_dentry(sb, p_newdir, newentry + 1, &new_bh); - if (!epnew) { - ret = -EIO; - goto put_mov_es; - } - + epnew = exfat_get_dentry_cached(&new_es, ES_IDX_STREAM); *epnew = *epmov; - exfat_update_bh(new_bh, IS_DIRSYNC(inode)); - brelse(new_bh); - - ret = exfat_init_ext_entry(inode, p_newdir, newentry, num_new_entries, - p_uniname); - if (ret) - return ret; + exfat_init_ext_entry(&new_es, num_new_entries, p_uniname); exfat_remove_entries(inode, &mov_es, ES_IDX_FILE); exfat_chain_set(&ei->dir, p_newdir->dir, p_newdir->size, p_newdir->flags); ei->entry = newentry; + + ret = exfat_put_dentry_set(&new_es, IS_DIRSYNC(inode)); + if (ret) + goto put_mov_es; + return exfat_put_dentry_set(&mov_es, IS_DIRSYNC(inode)); put_mov_es: From patchwork Mon Mar 18 05:22:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuezhang.Mo@sony.com" X-Patchwork-Id: 13594979 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 E225C22087 for ; Mon, 18 Mar 2024 05:22:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=185.183.30.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710739346; cv=fail; b=Ac/x6VMgv/NHegjGIuoiu780Z4nQNjVwuMxCqYxYnjqVgloXoI5hJ7rV80BvIaIfR82oEDJsdEo4Y25jfihuJgu/nkROLjq9cmduPjlihlfJRgNB9vGOZZbjiPnyzd4L7beGHMs7TDEjXTjQ33tyNGOxlHqm/me2fPIE5XPI8bo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710739346; c=relaxed/simple; bh=iny/RLi5AJITGGyXIiTsZmhESbLXSqTlE9iCuz04RJk=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=U6KzcoN0jV6ekBvB65cka6r2HKchZBJrvQZQcIgmQuOiSCar8WtEMLOnHRIGwtt8rIbEK32pC8Yh6xYQPIiCgygohTQZcVHz98LeQcTHgEOEs13uY8iZKMleTpQ++s4jT7QSfZ/uO4ZtGNE+sYYX6EjFch0KdqX3OxqNw8tIwVs= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com; spf=pass smtp.mailfrom=sony.com; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b=YA/CmI8r; arc=fail smtp.client-ip=185.183.30.70 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sony.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b="YA/CmI8r" Received: from pps.filterd (m0209320.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 42HNd5eR030951; Mon, 18 Mar 2024 05:22:15 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=iny/RLi5AJITGGyXIiTsZmhESbLXSqTlE9iCuz04RJk=; b=YA/CmI8rtbfMbI1s8ePzE4PtF3/JJFkyykpOji5EV68axXvCX7Ty/M8TxXL494MtZVVf x1nLBNGggXDwivQIKdFkDCJ4oZxvvlBSIowDuJUdHs4iWxdsna2a3HVKFIKAgAbIK4cG NpNIHKXc5pAKF7E1XRh7xeTnNN9xQHzqfuoBLegcifLi/lYVqN0+fdw8E/akQnZMpLPR 4xZTi004lAex7Ik9YEM0HhyIPrgusLyirvQqCWyunjZ0sZoCRzbKhANl4zO11SNiETJK OW4EZPnEoIxGzaSZT5FBZKO0zhoze1ht8+vIiD4Vbx3ZOSR8pr2VGTQBAGpGscP3PwyN Rg== 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 3ww1am1hkc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Mar 2024 05:22:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l0J+Q4UV4Cu9QZ4AAivVXSdUvzRISWA7tI7jBahcsMwZyVpleEnqLJKeASfj3ocf6JYluLJmoi/ZoJop7LeDlzHbB0CU60UYsidEG1Wsq0ePJR6vExslILefRMvpauREPnrq4/M2yZe5jSAi/AnC9OniGr/R9bQKyDTb0BxFZBXs4oEmSRS/tFCcmecAhZojAOnGreKiHoPJw0LIjul06WMsBo6+QcwKPs3uMwgotfiXMqCRBW7mb6lKKobJGqNdHa+O0rwocHpJKKVJaWciJMu3Gue+0qdU2MXn/10mzEDe3vVx8EFha+ftRvno/JPqd6iOAAIPJZagTX35Zm2P2A== 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=iny/RLi5AJITGGyXIiTsZmhESbLXSqTlE9iCuz04RJk=; b=K1v/EaCtmWip2E+LTn2YMlSB9IWiivbupuA5ZE6ommS52TrDJVw0qTCCJ5EtLSGIhzFFWbdN7pxSTOziAeq59AQCc/twr867YPtxnZKKwKr/tepeA0ZovGHYKccW+1N72qtYBwcsqu0OKSsQKMai453wWlgDiWonRyZTjvC3NT9LnHBEXnMiiNly6FOClP/geyd5udIeYZZ/2SiZE5M8qf2oFN/QPrKZ5uAvKnmE78uamxSwgtstTMT+Y5K5xgiJCd+cjo8ZxQYg3IJm8scT1kHTU9AO1POQVsZcO9a7X8Sq/3FqAxvXjd11vGWHpBC9R0TwBCpo2fpemvNFOzF5Qg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=sony.com; dmarc=pass action=none header.from=sony.com; dkim=pass header.d=sony.com; arc=none Received: from PUZPR04MB6316.apcprd04.prod.outlook.com (2603:1096:301:fc::7) by SI2PR04MB5895.apcprd04.prod.outlook.com (2603:1096:4:1eb::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.26; Mon, 18 Mar 2024 05:22:08 +0000 Received: from PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::7414:91e1:bb61:1c8d]) by PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::7414:91e1:bb61:1c8d%7]) with mapi id 15.20.7386.022; Mon, 18 Mar 2024 05:22:08 +0000 From: "Yuezhang.Mo@sony.com" To: "linkinjeon@kernel.org" , "sj1557.seo@samsung.com" CC: "linux-fsdevel@vger.kernel.org" , "Andy.Wu@sony.com" , "Wataru.Aoyama@sony.com" Subject: [PATCH v4 07/10] exfat: convert exfat_find_empty_entry() to use dentry cache Thread-Topic: [PATCH v4 07/10] exfat: convert exfat_find_empty_entry() to use dentry cache Thread-Index: AdoLF/aVSH28hG9dTA+AfxdrhgQHWRt2tcuQ Date: Mon, 18 Mar 2024 05:22:08 +0000 Message-ID: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PUZPR04MB6316:EE_|SI2PR04MB5895:EE_ x-ms-office365-filtering-correlation-id: b0d78aa1-0b2e-4aab-b265-08dc470b5b3f x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 9cVBQZHa/uYIVTnb/7W9HZIdemYav34CvbH2xGmCU7+1rEYhXuvfPtF3jp6FgKqoJDUv7k4v2Dc5bGXyRDcOoS4qHBMDb9Htv5aW2ngfdMwxMk5/U54YwmnCH63uM2HtY5eDml5nm0L/FoG1AkgvPpf8WBQ3fkfiXVWOFcd0c/Lh1c5HVSnX1ErJT86Odrfpkcj675dIfbGH9Ms43SeRWvpV2kISSuLycbDPidjBCNfoB9Z1ZaFZ3aMPPPnc/mJzOWZPk6OhmkHlyB++439G2iUAJgzA9l06+1mNRC5Pv1W4LWSCb7JELE3qzGyXZtJEETywCrgN8eZTLj22t9/te8bKQnk+05FV3wY4qLWR1Ai3mVQbrXPb0/8kCT/7+No2EKpC9MhMkaD62W4ONLNNG1KsBtNyBt5OmG7fzH8sLowtBoBBzRNBIkUZWeTOnvJQI5sKO6LPwdvMI4raGwVBL6B8esWI8vIQz4YpuG/fix42bp7jN0R9eQnQhCwMsvYt9WRvN7rrnME95le/y1Cf+1HIvqPOuxdzxAOye1ug37R9ijLWgovx42sfxbc6uTTDRZ7hLjqb+aTbcmp9PdmhtNwCqo0ekeCbjymv4Bqe8FQe1r4W1x5alK5K8VcgKhY/0dvB0V7t8JZrVpVt+pHWa+W2Nl4yKYzf4PdZCsYGykDG7PfsSYG2DuuhU0yXvRXwQ1cHnDqwp4/QB8TZrH+c1Q== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:zh-cn;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PUZPR04MB6316.apcprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(366007)(1800799015)(38070700009);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?rwmzaJnXDQG8ju+DqcAEgrwax6Ic?= =?utf-8?q?RZPo4hL+65k88qNEVYlrA4OBuHZRk7FSdw/wa60RyKJRhKTCqU9o95b6zb+9ltHaj?= =?utf-8?q?q9Af76vhugJmIu91PhBWA6jBdutIo1CvuaX8N1C890EBIkQW55do/GNhe1cjmtjqP?= =?utf-8?q?mv0tXHrXKCg6xj4guMIEwebWNEYvmCbl3pkXlCFw9ABJDR0mEROwvvhIMjUmyHCjI?= =?utf-8?q?scbjf5Kf7QY0o5OszjuXutBOZhNgbRFgqp4RDErLxJEqj25Ynbo/vSfObk9oPgovF?= =?utf-8?q?I3zmNW/V4T5/wW+gC6bjSYDMWnC64MFNuRt9zb17dgasgCjaxGR2cOHp3AbAokF1e?= =?utf-8?q?AD9Hcf1zYjvjUtJ5LPlZuRfp0m5S/8NU8myKYvqe88hdD346LLdgNxlQIvqYw6ruj?= =?utf-8?q?K4U4tIKat8rvyXpc7sU8ucENGLunggUaFrU0G+Ig+NzrUOpurP6/Q5dGzMySON5dV?= =?utf-8?q?gTdc+MR9ott0Xzy09TsXnPtqQTKY5jwWYK/Mt6HTCc5gh+5FmuXvvKfkf4e5WzZWF?= =?utf-8?q?VDjLwaBGGV1XT55BMYhcbY5LX/ENWGpGg3W70iYBUqiuXlxbml9LhEzdNlsGrsoLz?= =?utf-8?q?IV3H4HyVwMcDquLPq5J7jkzT1I4tZTQdTsAcuW0XV9ksBle8UEYNLHoG7CfPII7zK?= =?utf-8?q?AzAXAmOZxQbloeI8RTIB2UkjLG7xZytFITmKmmT5Q+9QUtW8RKypmIgzo9p725+q1?= =?utf-8?q?zBS67NEQFls1INM5833QokHPiYS6UHJV7WmlleFDEZSPjWXx7I+t83iPMMebXs14O?= =?utf-8?q?NQpQQtNQ44nAFlwzCCgzV1a3gF4F3FA/ev42x7C/RAPOqguSbcwBVGOi6ZRArm5Qg?= =?utf-8?q?YkLi2S1Nxs+TSsA8Bqqpnz1KWWrjjh5S9V0QgP1gpgplENCwUnkcoBh8gyjOszOG2?= =?utf-8?q?ofg6pMCvKAK1lNA9lprKnh5uRJa8te7qkX5S2ris80Vv4K9/bsAcCncO6KlhQYIj8?= =?utf-8?q?sYrngs15eLG4dFoja6f/azJur/QfvMcSMsI+gOuqfO6pzvVd5xD+qYHYMkrUSFL6N?= =?utf-8?q?qkvvjyoR0xLeq40m1tMbGOYiunjbauSZTJCixPoXIlkoP9nRJO8ftyfJUlTy5tsH2?= =?utf-8?q?HAhEKU4p97JIjhMlt5y2DZsalQuOO0AsFIhMtES2tKwdzo43WVY5avTXNtl085Zm2?= =?utf-8?q?nE3osn7iBfWORoFc7d4v8NA9adMBcsy5wO4ZfAoEWzjQrPaxM4OZKA3nimedzYowZ?= =?utf-8?q?JMNeN50yDNDUiRx5eVhKBjZ6y/M3nPQjcZH/gEyAD1ULRoE1GsBc/PyOBbCt+q/5G?= =?utf-8?q?B5Xv97Y37rGlOm3cypxhD3LmqUgcF5LmxB1Q8lSw2W7xX6R81wMJO8dENzFw9ektP?= =?utf-8?q?PNU3e7ZxTEjUFs9hk8Q1Wgn4E5w8xtSg/BhGzzgM2PBIbgBDW7RlC28LSl7HisDQK?= =?utf-8?q?qSQD/rR23cjsaTr9aAZaPkSbTQzWudGQlhOF5LolHsm1LVaZjPyIWeqCg++jRRI24?= =?utf-8?q?AcptotKnO+tZEdsXm9lbN8qb/0q22nb32Mwzw/hEazOd4Bi926Wy8ogOJ0KxFAlQL?= =?utf-8?q?o2OOsKZHmRwj?= 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: CPJ+D68iuxQlWvl3tKPdyVbn8v5izW16sRRvWsNA1MXFQCmH+gcFAKr0Su989G5Lx+XMwbTatC/vVg6qCfK03Uevn7OT2cLyjSMMmCCbyJ2XDZ+aJfWVE3y5bxExADTyC4HHLKq6evLr8gbqg0ID+ei1n+i9uDh0DNmREMy0WHbN+F+3ck3692YP1JI/AfItd0sel7YYT20UVVcewRY5hMNY3SHTC2COu6tE/JH4iWDnpf0EeDGpZmDxb8pwy6HlBbVzKkQEdnMW8F7DgX+fk44Luhw5R8zWFM4PtEzJJshLCmMdULKMPNKTUcih1HOY62pJIq3QkVYKlWt2cd92XDc2UeYQj5AH7gxIdSAmjskgjBPIjzFhvFi4HfeK3D+mUpqO6DoMjU9GK5OnT1bJ91F5e8Fe5DC6nwXxTqDTSZX+fG2D9feYGF/G6XRShUyS3t6k54PBUuOpbC1qSMtknuozgbcjPY0ZkW1egLJBySYBcw7e3RCqhWSQjik9YqyN6GaTrEYvPbspNDBHo894vKL26AioR1AGP8xCFYxSwxFUJL+eM/gmJVYEX0SXxoKOGFAcUK1Z3dVoBcGYXQfHohP99pnKNbpvD/xd6/fe6AgBtjYU/HrSh3FTFZtGmiQl 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: b0d78aa1-0b2e-4aab-b265-08dc470b5b3f X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Mar 2024 05:22:08.0443 (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: Og0QGon1zN938oXZSo0mp21whEXhKIyEOoxv4M9QvT7a2lqmucYfDAUDdrbi/5rCoxi0ygIpGaqFlvY8Iv6YDg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SI2PR04MB5895 X-Proofpoint-ORIG-GUID: cAy1RI7Bjt_O_QpXBJedaQ5IQujzegKv X-Proofpoint-GUID: cAy1RI7Bjt_O_QpXBJedaQ5IQujzegKv X-Sony-Outbound-GUID: cAy1RI7Bjt_O_QpXBJedaQ5IQujzegKv X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-17_12,2024-03-15_01,2023-05-22_02 Before this conversion, 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 Reviewed-by: Sungjong Seo Signed-off-by: Namjae Jeon --- fs/exfat/namei.c | 126 ++++++++++++++++------------------------------- 1 file changed, 42 insertions(+), 84 deletions(-) diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c index 2c6df4f966f5..79e3fc9d6e19 100644 --- a/fs/exfat/namei.c +++ b/fs/exfat/namei.c @@ -204,21 +204,16 @@ const struct dentry_operations exfat_utf8_dentry_ops = { .d_compare = exfat_utf8_d_cmp, }; -/* used only in search empty_slot() */ -#define CNT_UNUSED_NOHIT (-1) -#define CNT_UNUSED_HIT (-2) /* search EMPTY CONTINUOUS "num_entries" entries */ static int exfat_search_empty_slot(struct super_block *sb, struct exfat_hint_femp *hint_femp, struct exfat_chain *p_dir, - int num_entries) + int num_entries, struct exfat_entry_set_cache *es) { - int i, dentry, num_empty = 0; + int i, dentry, ret; int dentries_per_clu; - unsigned int type; struct exfat_chain clu; - struct exfat_dentry *ep; struct exfat_sb_info *sbi = EXFAT_SB(sb); - struct buffer_head *bh; + int total_entries = EXFAT_CLU_TO_DEN(p_dir->size, sbi); dentries_per_clu = sbi->dentries_per_clu; @@ -231,7 +226,7 @@ static int exfat_search_empty_slot(struct super_block *sb, * Otherwise, and if "dentry + hint_famp->count" is also equal * to "p_dir->size * dentries_per_clu", it means ENOSPC. */ - if (dentry + hint_femp->count == p_dir->size * dentries_per_clu && + if (dentry + hint_femp->count == total_entries && num_entries > hint_femp->count) return -ENOSPC; @@ -242,69 +237,41 @@ static int exfat_search_empty_slot(struct super_block *sb, dentry = 0; } - while (clu.dir != EXFAT_EOF_CLUSTER) { + while (dentry + num_entries < total_entries && + clu.dir != EXFAT_EOF_CLUSTER) { i = dentry & (dentries_per_clu - 1); - for (; i < dentries_per_clu; i++, dentry++) { - ep = exfat_get_dentry(sb, &clu, i, &bh); - if (!ep) - return -EIO; - type = exfat_get_entry_type(ep); - brelse(bh); - - if (type == TYPE_UNUSED || type == TYPE_DELETED) { - num_empty++; - if (hint_femp->eidx == EXFAT_HINT_NONE) { - hint_femp->eidx = dentry; - hint_femp->count = CNT_UNUSED_NOHIT; - exfat_chain_set(&hint_femp->cur, - clu.dir, clu.size, clu.flags); - } - - if (type == TYPE_UNUSED && - hint_femp->count != CNT_UNUSED_HIT) - hint_femp->count = CNT_UNUSED_HIT; + ret = exfat_get_empty_dentry_set(es, sb, &clu, i, num_entries); + if (ret < 0) + return ret; + else if (ret == 0) + return dentry; + + dentry += ret; + i += ret; + + while (i >= dentries_per_clu) { + if (clu.flags == ALLOC_NO_FAT_CHAIN) { + if (--clu.size > 0) + clu.dir++; + else + clu.dir = EXFAT_EOF_CLUSTER; } else { - if (hint_femp->eidx != EXFAT_HINT_NONE && - hint_femp->count == CNT_UNUSED_HIT) { - /* unused empty group means - * an empty group which includes - * unused dentry - */ - exfat_fs_error(sb, - "found bogus dentry(%d) beyond unused empty group(%d) (start_clu : %u, cur_clu : %u)", - dentry, hint_femp->eidx, - p_dir->dir, clu.dir); + if (exfat_get_next_cluster(sb, &clu.dir)) return -EIO; - } - - num_empty = 0; - hint_femp->eidx = EXFAT_HINT_NONE; } - if (num_empty >= num_entries) { - /* found and invalidate hint_femp */ - hint_femp->eidx = EXFAT_HINT_NONE; - return (dentry - (num_entries - 1)); - } - } - - if (clu.flags == ALLOC_NO_FAT_CHAIN) { - if (--clu.size > 0) - clu.dir++; - else - clu.dir = EXFAT_EOF_CLUSTER; - } else { - if (exfat_get_next_cluster(sb, &clu.dir)) - return -EIO; + i -= dentries_per_clu; } } - hint_femp->eidx = p_dir->size * dentries_per_clu - num_empty; - hint_femp->count = num_empty; - if (num_empty == 0) + hint_femp->eidx = dentry; + hint_femp->count = 0; + if (dentry == total_entries || clu.dir == EXFAT_EOF_CLUSTER) exfat_chain_set(&hint_femp->cur, EXFAT_EOF_CLUSTER, 0, clu.flags); + else + hint_femp->cur = clu; return -ENOSPC; } @@ -325,7 +292,8 @@ static int exfat_check_max_dentries(struct inode *inode) * if there isn't any empty slot, expand cluster chain. */ static int exfat_find_empty_entry(struct inode *inode, - struct exfat_chain *p_dir, int num_entries) + struct exfat_chain *p_dir, int num_entries, + struct exfat_entry_set_cache *es) { int dentry; unsigned int ret, last_clu; @@ -344,7 +312,7 @@ static int exfat_find_empty_entry(struct inode *inode, } while ((dentry = exfat_search_empty_slot(sb, &hint_femp, p_dir, - num_entries)) < 0) { + num_entries, es)) < 0) { if (dentry == -EIO) break; @@ -515,7 +483,7 @@ static int exfat_add_entry(struct inode *inode, const char *path, } /* exfat_find_empty_entry must be called before alloc_cluster() */ - dentry = exfat_find_empty_entry(inode, p_dir, num_entries); + dentry = exfat_find_empty_entry(inode, p_dir, num_entries, &es); if (dentry < 0) { ret = dentry; /* -EIO or -ENOSPC */ goto out; @@ -523,8 +491,10 @@ static int exfat_add_entry(struct inode *inode, const char *path, if (type == TYPE_DIR && !sbi->options.zero_size_dir) { ret = exfat_alloc_new_dir(inode, &clu); - if (ret) + if (ret) { + exfat_put_dentry_set(&es, false); goto out; + } start_clu = clu.dir; clu_size = sbi->cluster_size; } @@ -533,11 +503,6 @@ static int exfat_add_entry(struct inode *inode, const char *path, /* fill the dos name directory entry information of the created file. * the first cluster is not determined yet. (0) */ - - ret = exfat_get_empty_dentry_set(&es, sb, p_dir, dentry, num_entries); - if (ret) - goto out; - exfat_init_dir_entry(&es, type, start_clu, clu_size, &ts); exfat_init_ext_entry(&es, num_entries, &uniname); @@ -1033,18 +998,13 @@ static int exfat_rename_file(struct inode *inode, struct exfat_chain *p_dir, if (old_es.num_entries < num_new_entries) { int newentry; - newentry = - exfat_find_empty_entry(inode, p_dir, num_new_entries); + newentry = exfat_find_empty_entry(inode, p_dir, num_new_entries, + &new_es); if (newentry < 0) { ret = newentry; /* -EIO or -ENOSPC */ goto put_old_es; } - ret = exfat_get_empty_dentry_set(&new_es, sb, p_dir, newentry, - num_new_entries); - if (ret) - goto put_old_es; - epnew = exfat_get_dentry_cached(&new_es, ES_IDX_FILE); *epnew = *epold; if (exfat_get_entry_type(epnew) == TYPE_FILE) { @@ -1094,19 +1054,17 @@ static int exfat_move_file(struct inode *inode, struct exfat_chain *p_olddir, if (num_new_entries < 0) return num_new_entries; - newentry = exfat_find_empty_entry(inode, p_newdir, num_new_entries); - if (newentry < 0) - return newentry; /* -EIO or -ENOSPC */ - ret = exfat_get_dentry_set(&mov_es, sb, p_olddir, oldentry, ES_ALL_ENTRIES); if (ret) return -EIO; - ret = exfat_get_empty_dentry_set(&new_es, sb, p_newdir, newentry, - num_new_entries); - if (ret) + newentry = exfat_find_empty_entry(inode, p_newdir, num_new_entries, + &new_es); + if (newentry < 0) { + ret = newentry; /* -EIO or -ENOSPC */ goto put_mov_es; + } epmov = exfat_get_dentry_cached(&mov_es, ES_IDX_FILE); epnew = exfat_get_dentry_cached(&new_es, ES_IDX_FILE); From patchwork Mon Mar 18 05:22:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuezhang.Mo@sony.com" X-Patchwork-Id: 13594980 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 42BCE22339 for ; Mon, 18 Mar 2024 05:22:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=185.183.30.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710739350; cv=fail; b=O/mY1VEDmcxqss+ykb8z6rJ9ZcQg053taz9KojjVddlEzQaBwbu1E4Gx/Y+MiVf414kZzsEGu4+Hqu+NQR6KjbTRQKFrfc1t1lrgJcAsNcSJcbowUagBdCfr8YzQsTEni7mHYqkq+P8U8EkT9iEwoppUYHnft04Q9S+jPsmH8BA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710739350; c=relaxed/simple; bh=2cxotguNhqg5IjeDU8nUGkFrzttsCG2jjRUoPC1cEIs=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=BM7Exw7IHce0mBgb0lZJ0GE2uYm/ORkO+clmMLfGA2vti3Qu1sQ0cMD4VHhCGI4hGzxxvXf8NEs3fCwtfJEj/wmO2Xw94sBH87kVnlDxx8JwJeAmtp4pEhZr4mauXWYlmDXB+nr8pjTL6767xVjX1R1v9TPWOmRQh/jdFN59B4I= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com; spf=pass smtp.mailfrom=sony.com; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b=j9MGtWFY; arc=fail smtp.client-ip=185.183.30.70 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sony.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b="j9MGtWFY" 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 42I5EI9u018209; Mon, 18 Mar 2024 05:22:19 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=2cxotguNhqg5IjeDU8nUGkFrzttsCG2jjRUoPC1cEIs=; b=j9MGtWFY+FbPiZWziN+OM3Tnx1MK+FdOOXqw15ot8l7I8GwvebsyqWUp0ZLVTdK9h3AQ RGvipaT8CplOCoFpjaYVSytnQioU3CAhAyMwFk6Y1JhLL7PXc6srWGhphlPvCmhi+ERY fyfiI8OyiPcSg7vJZttK3a8dABllI29unmUhwXkt0hYHoRwITs/dgkKm29hYjodRT0zq 2PpEkN8/wGMClv+1DtDYELXRWx1D9T39YtgBbTlw1oTHdFOUMpqnXhNu5JoH7KI2pHOG Z4DK+3KQ1hNTMvljwVGdJcnUpi+pFaq3QkPWIN4UkQalj8ld5XFb/We0370TS64ImDQj 2g== 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 3ww3ts1fph-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Mar 2024 05:22:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Jzdo67qDXAazLoG7lKyuntyr7dLGW4LVpP8wPDbYzO8OqHVZTP0fGuDwKk5pLICoytmf5enaXkwtTvraL6LcOQUkIcYiVIJ//nvNlJUE5M8+2BBaYiA1qcgfo+TejnNHsbbCII+BFvT/ym46QFUgkQLdEimvV6jg1HTIbTV4MPskux+DGyULliaXDbYayQucQ7zG+R9kvxtuXBMMQwKnq+SdktMe4GsIpKC1tH0D0wy4uxdSKdxg1sGC+BN5QoRuKD/7qlpj5RGhWYVq83iVKceXIkJIXeBz1fjARFSZf+jg6S76hmZr3Z9lQeIbMWhjOZadgEK9pn2x3aS0YiTgtw== 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=2cxotguNhqg5IjeDU8nUGkFrzttsCG2jjRUoPC1cEIs=; b=Jv3NMwkTHLkcuMSa6o4y9OXgw2M60tifa/EmGALleMHEq4bzrTWYZfz7HOk1kWs9n7fUoLYSfNEBpE3d58jOLKe7Bf2WQPZ4jjyyCxu20GGReFOLeqJ+/7a8+Hr/APP2t7DWiH7c+VxlnSoVAbp5JBNLJtVhiojlECbUM92ZqbiiieRnWd7T+aon2BpGD6lVXtla5mJ8UIoXnTiJTJAHkYRdD7BU5TN6d9f/NvH2OA0uETxs9dhQbZLc2K2qKe4ZbKv4MZq2kIquWDseHVVVclDAosEMoau1IfzXDr5bKteXb3gO+BNsFJ0fsfvKPYpOwKUn5KgUgg+e8aVe3ROX7g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=sony.com; dmarc=pass action=none header.from=sony.com; dkim=pass header.d=sony.com; arc=none Received: from PUZPR04MB6316.apcprd04.prod.outlook.com (2603:1096:301:fc::7) by SI2PR04MB5895.apcprd04.prod.outlook.com (2603:1096:4:1eb::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.26; Mon, 18 Mar 2024 05:22:12 +0000 Received: from PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::7414:91e1:bb61:1c8d]) by PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::7414:91e1:bb61:1c8d%7]) with mapi id 15.20.7386.022; Mon, 18 Mar 2024 05:22: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 v4 08/10] exfat: remove unused functions Thread-Topic: [PATCH v4 08/10] exfat: remove unused functions Thread-Index: AdioqVU2JWS0suJNSvGQTvtgpxEVZnQSY7fw Date: Mon, 18 Mar 2024 05:22: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_|SI2PR04MB5895:EE_ x-ms-office365-filtering-correlation-id: f1bb8146-0220-4e8e-5d84-08dc470b5e01 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: nfCVTTFTo2yt0s7VtRiikPgee5JiSHiC5kxK/HeVYSoHgW9LZAGyDfdEBT+EQvDwr+gc4WswvxtiRkRqrWz/+yeTloZ9unWOqwBEY2Vo4y+7UmGky3ZY6RHozi/zaE2JYtt52wdGVboCXNnBvn/NsJcMi4rbSFpZg99N2iKfJnZT5UefAiPPTolWwHgB4WL0BNhwibFjP9dsKTWlN+qrMA5KD5MakFRCLLEctJRo6oQI4oHO9BMkytHVn1QRl6m9eLoPBGXbGJ3Cq7mRzhOFXFNmx6v+Hi5iXXKw5wcIAd2OcZWhRQQHvBj9m2jJ0oKAAnYmrLBGmVA0rFFkeP0Oplz2TxVD/dNnEb+GsrPaPLAsZNmzit0VfMQvwMtBQr99wlBGk5ZLvTzk5omKVCGbBKbA+BotvCqBahp7gtftEhCG0NbilXRAXYwm+CabE0H2mh0a1VaTcJlkXfCBTNFSN/JkwLeXpcbGlu3D1pU3mttMXw5hS7mVmfvL9zBZ69UQxIg2WbpI+SZciRkdce44ynl3kQWn3rHQFxZ1K3MoZdkW2eBU70OA4k8Pgy9Xynplo0qcujR8BkUk6Pp0h/SX+qzUUVcMmXm7PggG4sGHNCevEOxgTD7dWYkY+aOEGLC999RvocTI59UZIC5iuEo/td0QptbeUg1XViTFnnBV+Zp6JwhTDKH/1FkB+hBCnxiuQOOH90LVmic5r5isUmvpvZhR/+QAhNSeL2kSKRadWKE= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:zh-cn;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PUZPR04MB6316.apcprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(366007)(1800799015)(38070700009);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?iJQvLgK8PHjCkNx1U3iQMkQ8Z7zJ?= =?utf-8?q?myI8R4m2ZDZzfxStdjXmqfScyhs5v5NFZytthQ8xYIKQL7wHDfL8IhwuC2l+HI2z/?= =?utf-8?q?iGL0uYMxQbLZckpN2HU0COCP5VLQxcTE7f5rX/HWM05P041vfBggzULY4dd4zmV9D?= =?utf-8?q?c/bzEyczgsyoLab7GIlIa1xxFRDTWzL/IvdLSDbCRqLS0ds2FoEIbMmBlGmcHKt5k?= =?utf-8?q?+HZHl2NulGQ0sDa27QDqUOpdA7Dri8k2Yxzq/jeIQ6bbgYC3xkc5Rqb7kotDu5+K0?= =?utf-8?q?Wd1BbbtH2BDgX0/w3HZkl2Vy/VrQKM0I2Opwu1aMMjs8XJT5tkzO2EZ7FgtxwEN+K?= =?utf-8?q?lSqxmCjJ08zLRbHY/gBPo7VbMG12zLdeKxAyqxO98ELBMW7Yt4BY1uN8l4b+YXTEf?= =?utf-8?q?Fam/YylfIJWzGq4nbdDTyCbQimDZsj7cHxNIcTvyS0Jwz5TCe17ef2fHZOywWEP1S?= =?utf-8?q?FprTCVgpl9KJddV/oibdgSuZy6smo2UOTh+q8xoKXWj9/0H2TAlx03HpytnK/BgeX?= =?utf-8?q?m5BBse0yX9L0O1AA+zfkAkcAmG6yoVuhZYfVZIqfmNh5gJQQ+A6/UJ5gfsLb6iNkt?= =?utf-8?q?n6RjR2cW3PAzzN7kow+FY6Gn650Vi3fWNbEYfSP/1vP/Jk9IDW9ZHU5e/tANkrcbz?= =?utf-8?q?ehgG+umEEfnernqLltiEBo6p81dmtUZGix0pVzgcf4YsRW3Rp2liGA/wz0ka380Ns?= =?utf-8?q?44vWqKEekcpYwfoSPpG9p1axDc9/N0CEhqiP/z+PDsIwqt32g0LI/4U8xf7WmOD/f?= =?utf-8?q?N3cBzTA+tVORitIt3nhUB1oI2EPbD0cfQx6x7/51Nq8ChGaj/kcQhe9TLuzTRgERk?= =?utf-8?q?9X/prO+rq8NY+CiAsPRqYYBuONwQxp3GL0XE4NZJHTvtZVuKTyQacm7JinrN8Vdko?= =?utf-8?q?0XuXYReTPNH/91iKpUSQl5unK5hq8V/WRUGAtTn6DizoT9O1mS5N36uiKl4Qc4CX8?= =?utf-8?q?RvsBDM5kNMN/W26eASrBlIxRCAemsXLddTHeFXLjmf/M3oqhCEA3uvKwGtz4vvKnT?= =?utf-8?q?kHb1+7Fq8r/Gm5x13DPoNpTFZlybYHXbeN8vq+WG6vltKDWCWOJixGg+3ne8tSidK?= =?utf-8?q?TEz9FetkcMORFMqhQDoRUkCDqBxRtHDm+7lXuWXviRNlIliSYuOCp5R9zProcDHm0?= =?utf-8?q?0kfJUfBemAJpwxiK8b/zQYQ+Et6pUgk6cYWmnFskZHn+T7F6SWQf7cBUOqGik7iB6?= =?utf-8?q?JiMl4VXQ4JtIUoSy0N8uQmizPvGRXPzVYFdh7JZFEx84uAxs3n34VQW3+LTbEXL+b?= =?utf-8?q?hewG76CG6LQd6KDQiz0Dnn0sGvCYEd6xoJFuVNY3swbaRekdpnTixHJAvTPKASxNO?= =?utf-8?q?y/i3D00/IEKFE0JxM48twV9H+UjfugdScxgEcBsm0lqdZPdgliiJulolb5JVosQzQ?= =?utf-8?q?GK6d+/N1UtHg9sab4HTuFXu6hL3qgLKdVexA8RHoXpCpLvtzaj7NOkT54VVBCZBBE?= =?utf-8?q?aLl/r/YzLwRupkHSiZ6GYof7ZX/eDDX+Srb3q/5I1nrr5lXTwYmTHn6vbtJN64k1/?= =?utf-8?q?MB5wvFveOr9R?= 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: JxRp29nI+1MxRzjhXipEUTRi3Ui98L9QvtP3vyphJNscvodieGhvsK78fO76lALBcaKmwORm4MN1XQrFc74SUCXSg4bsMNDNc2GYT50Nym44LuPwr20B6SWxyxAAds72LjvYaAGJiSOWpZQFDmsQqf7w7yJGkaFTlu3B7IySxsUVLGj2mZwAEYCsEm2BYT4/wxn2gX2aWFZ7LvBoChfyTkODr+RxqUHKU8fGHuwVBP/FJG/ccB4SRd1H7LHbGCwPYJhYAuLApwKov0tY3fbRKyQ8Cc3Ri3Luai4GVHmAGfi0s+ng7zlzpSfwkco3kX0uGASVkkV4rsEN0TtJAAoJfe5xd2ARE9uskSPCiKYsQLVNeCJ4g1XJpGyU7tRhA3ouSl5ZXAE5hoQGtO2+4GPf8fcNcWMspCjD7ClsRw6jCaaj/oAkIWwIauEV/bZYVl5o6Ff5Ur8NDS2eRbSlquW4Ik/WpAxwNtfFEgF8dnGttJQ2UicmQpiAXB7T6jlAGJIDFuXRCQdDCYUGm7tapcb5/mxhsabZ5yW+EmlbqPAy06yK60KOP3XPu1h/A9/Qufi4U5kRCfQ9yy4BEmjMWPOACrb2J/UJOq470OB0LaoHRPMkH8yHPwpCsuI+9F8AJ/SP 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: f1bb8146-0220-4e8e-5d84-08dc470b5e01 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Mar 2024 05:22:12.6659 (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: BKNw6i8XNHqSKohnTRkEFOTH2I9Nb+DyI4N3dniyHacX0BkpPxm8fXoBQi9vyPnMb7m0uEgRW7E/C4SsQC/oIw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SI2PR04MB5895 X-Proofpoint-ORIG-GUID: of5lH21tgx7VgD6L6_pvoCeRdNPepPYR X-Proofpoint-GUID: of5lH21tgx7VgD6L6_pvoCeRdNPepPYR X-Sony-Outbound-GUID: of5lH21tgx7VgD6L6_pvoCeRdNPepPYR X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-17_12,2024-03-15_01,2023-05-22_02 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 Reviewed-by: Sungjong Seo Signed-off-by: Namjae Jeon --- 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 df39e245671d..077944d3c2c0 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; @@ -1241,27 +1206,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 1cc91476b9c5..ecc5db952deb 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 0687f952956c..dd894e558c91 100644 --- a/fs/exfat/inode.c +++ b/fs/exfat/inode.c @@ -94,7 +94,7 @@ int __exfat_write_inode(struct inode *inode, int sync) ep2->dentry.stream.start_clu = EXFAT_FREE_CLUSTER; } - exfat_update_dir_chksum_with_entry_set(&es); + exfat_update_dir_chksum(&es); return exfat_put_dentry_set(&es, sync); } From patchwork Mon Mar 18 05:22:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuezhang.Mo@sony.com" X-Patchwork-Id: 13594981 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 9DC0220B0F for ; Mon, 18 Mar 2024 05:22:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=185.132.183.11 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710739355; cv=fail; b=aUf4RaYNRzRujxZYvu1ORv/dCJVCYAIr/b/uiOC4NCPFBy8lax3fbFasta7WtOrYdJue9vDfhi0OO6gd7eIuS2u2lYyimDL9HAgNUx4ICVxm1PkSoYmwZp2xPP3chjDSw4lE9l2gaerR7TdHgjJ1JQTFyTBfSANsILGMA3DIcJw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710739355; c=relaxed/simple; bh=5fgkVcTPkfbFwdcYfXnsJvoPyn1t0G8cbBuN2+OfwI4=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=aF7PPRGIxwUZjnBvAl3i2nPJAV2SDFHWkZB+5k3bWRG9HTptyyc164lyFnNO2lB7/axLIyLPpSGuiuG+mFn6notXPyKWilWmEYwH8RKxxCoA1KdOAWZGoZN1FDjVYdhFwlOMWwSVAZJcnYaGfQYdFNRKDpc8MqgpA2PMoWLZ0M0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com; spf=pass smtp.mailfrom=sony.com; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b=WnKS0Dkq; arc=fail smtp.client-ip=185.132.183.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sony.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b="WnKS0Dkq" Received: from pps.filterd (m0209324.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 42I46nuZ011235; Mon, 18 Mar 2024 05:22:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sony.com; h=from : to : cc : subject : date : message-id : mime-version : content-type : content-transfer-encoding; s=S1; bh=5fgkVcTPkfbFwdcYfXnsJvoPyn1t0G8cbBuN2+OfwI4=; b=WnKS0DkqO1vXv++7GWxmRp7ITbBB6oEeq0Vu++8v4ITY5FjCcYCp2E9qWFza8djFzpCw KTOwfvqQosrCzQ9kmisU/kjG5ecWVNOG9s1c4bHX9eJDSsZEgwiaid+z6wD7YW0nQAHt Tf3vBlBshtNWk02oPiUywzZY81KlUlUb84H1gXKWn5828hx3QA8Tc4dZbQ5cmGAsQsX7 I9o6G6YS4ROdNmN4KFzsLnRdXu2iBKBz/U5dtrWRav5GlZm2FAj9JtwevfGXGFf6jJZ8 qyhXMt3gtil1AAFm86yszlCizAV32gZXLzkUnRS9ZJhyRKPiWOxtchhtQFwDJhmscbQI 9A== 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 3ww0k4hrhy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Mar 2024 05:22:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mZxDXHE5OmJVuTzN3PbM/JNJ5mkRABP2UeJG9wbybd3fIZh8l5arSL4YmBrpN3ohgiiNINv4yJ/OKNRqRDBS/CDtkiK6rqJglcy8KvOUc9t4JI6OJWSbW1eMrmrrLHUEOzUDQyJgjOa7UruW1v1TMnZj2P3019ZzEi7jxTpm6qWXVRg7BwHd8bfJKcLzG5dOWhqMLzJXiHO+ii55BElLuzqA9oNm3ysfGOJf+vp6/updb1xDuXcZv0bPG7CRcmKU/ulVMrcuCm8uYxGuVLGzE9g1t8jcyur/Q4IJKrBTBkfdejQUlb7mrZw8eZU2EhOi+c8OoLb39kmxi9qwF/gc2g== 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=5fgkVcTPkfbFwdcYfXnsJvoPyn1t0G8cbBuN2+OfwI4=; b=YG0MhI3FGECgCTVcDhmYo2biIIoZC0GL3jCYBTJ9LjUEwnVI0vTJsJ76AtMSBTefR1V6YKh17Qspm2Bqk/nKMbn4Z5NvX3yN+rHKM7n008NQUbfsZDaSYqq5sz4hF674ZqizpKfzgOK1rVstjy77k399ozeY44DmLpl83oQ7o4UlLrjGK1/2Hy1Y4ND8oiwmn3mw/xFCnezMEl6x/RuqF/t4M3ZT0Q1377xHFIE9otXkVq4oRLbbRphrTDP0Pf3eh/EQja5qWtlc8fJ32N+p8cD5xAWJ2Op4+jjrfEpkPMXJOHSCuytQXomSxZJWBNuRYQpl06CEEtwWRJbSAdX1FQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=sony.com; dmarc=pass action=none header.from=sony.com; dkim=pass header.d=sony.com; arc=none Received: from PUZPR04MB6316.apcprd04.prod.outlook.com (2603:1096:301:fc::7) by SI2PR04MB5895.apcprd04.prod.outlook.com (2603:1096:4:1eb::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.26; Mon, 18 Mar 2024 05:22:16 +0000 Received: from PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::7414:91e1:bb61:1c8d]) by PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::7414:91e1:bb61:1c8d%7]) with mapi id 15.20.7386.022; Mon, 18 Mar 2024 05:22:16 +0000 From: "Yuezhang.Mo@sony.com" To: "linkinjeon@kernel.org" , "sj1557.seo@samsung.com" CC: "linux-fsdevel@vger.kernel.org" , "Andy.Wu@sony.com" , "Wataru.Aoyama@sony.com" Subject: [PATCH v4 09/10] exfat: do not sync parent dir if just update timestamp Thread-Topic: [PATCH v4 09/10] exfat: do not sync parent dir if just update timestamp Thread-Index: Adj0JkwXCy4LGeDfTAq9PLjEVpoj9WEzKnWw Date: Mon, 18 Mar 2024 05:22:16 +0000 Message-ID: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PUZPR04MB6316:EE_|SI2PR04MB5895:EE_ x-ms-office365-filtering-correlation-id: 7ce39508-99e4-4e6c-9a00-08dc470b607b x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: cVMExQaKl3ncunMAu72W/R/8nBwgQnceET4yrU3AXqbHF9k+CV9QkIVhzFwXPfRnexL+kiePJkyxAv7ylMhRJv4JCl0+HlDVXlUUorswLQ7qSLJJR/DH3UREUS6fQnShEoBM8DVFApJ4tk/l3l7cxR+yFXLPFYqtW0fZwDKq2UtPJUOZmxr18/gFMR2i9D246GZgkKLqQYzLwutB9PJ5Q7kLh3yynY138KB4Lifb7aMdVhPI/NgaH6uGi0BXxrLbeN5/IhE7NvGDofCMdFzxFBa3TCn32l+qUBeDwPL1PpEuWFe2Mrz7GCwoAQmrDt5MiJ6JM5XyEqx+0yNWK/cnBDyDMTnFvwcHhPPpCEZKpXH7oHkGq36Np/H6/31IdOTDO8C8kPzft+/c1KTENZI7qHiMEZcmaAa2ihjlyP8TKRG1sU0SfL8SCZpV/Ciclu9du5EJChIJZZr0vh2sB8BUnpX8Vuwx+uCjKwXubkVZ7PrJtzcBBrrgV3VRt1CpPmBP56siKGoqDlNdjNWrZ951YKdRz4XZwJbD9q7TcssjWkaKPD5/1HbdoEZw8yZpT3oCqVqUqtdwsDnc9Tx8/LTWDQrIfterBy4D6lKq/5WCVFvP8LvUZbPOixWDrGVOz5/n/xD/gM50XNTrPvwDZlb7IdPnWzjoiXrawN49+t0pjTqj1CLpsTJ53OTBF2Dj0NLX1cg1xYoCSalhRROiN1Iyeg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:zh-cn;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PUZPR04MB6316.apcprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(366007)(1800799015)(38070700009);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?g4Xea9gihddQtaBpbpDfQCrtgeQ/?= =?utf-8?q?HTG5fN+gI9wmGLMSAMT7G5uWxKSoZfWWO5K+PFhB6mIa+1HpezSn9CjstCJtDFXEF?= =?utf-8?q?lKRc1jb87CyZvwHWij8fmGINHxtxnBLrA2vo4vnbFgVxQnZiCIvNbjYgYNFr1Vdof?= =?utf-8?q?BkTtFrXW5b9h9bRBwk/cqXBngRRkfOkPCmnH2O7wXh17lEveGRltwTYuEH0O1bUTU?= =?utf-8?q?bZqRbCQLpd6z9HXMwkAbwkKwmZ5OkExvuZwh2IifZdlhDtt1FRKpE6+xhPH8sW8Wb?= =?utf-8?q?/cd/4yx4dRk/eboVB34+sDlBX5TiCVvRGyQ1LcJETtq0ZAcUTGBlotUQdTrH5jAdg?= =?utf-8?q?eLeNET2uF4my2EVnQCMRfMH3pE6Zf69PRzr6/kKnS45GAIC5GTuK34wFmu2HyCwdt?= =?utf-8?q?KkILET+nn2XnnWXu6zXI2B/Am7ekUTnhxi+H7x2REN7WcAjWTYXmzLBeGtdVodSv+?= =?utf-8?q?QBu8QRGtmUwkVaFYvzBX9NFraLIasiRpKocgpWWaB0pgESJvByBk6iypo6fbLibz8?= =?utf-8?q?MTRAG6rs8G6n83EHpK2bZNWFNZXyObZMRiMMwH8zWrYaYynZYmjjPaOquFLARciIr?= =?utf-8?q?MmtdQISammXnNrYk5fLAGcWRFvyiQfxWJcdNmh/NxvVdUo+0kvMEp9I4/+RUnzvF3?= =?utf-8?q?S5AbBM+HLj52tuAfVWMRqWjlBNUgN5ZopcWZ9ZXJwUwVuAFieRNzG8UejjHss+Qqi?= =?utf-8?q?QpCFNm0nKAMzMIzj7G7qXzS4Srj6MMm7PjWjkC9KQ5MtwJy7pTXDK4dmsJaAFxBf+?= =?utf-8?q?ib5QcIyglP0+N39Ycqa9KIjMGWFL8SOveiV5tCPSKaSzuPwvyrHiBC0sPQUFtaObw?= =?utf-8?q?FXgPKoXymo7VkUyv/4JdTN43+7gSQEQwAhDK2Ol2QTAMv32qB+h8mzsepVvivsVgp?= =?utf-8?q?kBarg+HUQeZv7nXHa+Qe1IZlZbVdSZKQv24YN+slJAmx3/TMJpumKu3QBOA7N1P5V?= =?utf-8?q?/U/yBsTAz0w1UZk+7EAaPZyecsFhCbEWyiPaoCR33quJwVR4M8TTOWFuYlEzD0ANC?= =?utf-8?q?2ldsKKJoBJA8TOGhKkW1AvGbIpyCPNcJpxs3ZlSQ5QXrQobgUmj0I3CF2QOKBSIJj?= =?utf-8?q?KCLBBFpGGzACE0ZbpHTx5xvFsgj1JB0Wl9uh7r2ovH20gK4IIu1vkbjuRcNwuJp1u?= =?utf-8?q?84YPES1Mh0lBbkDRSyzUsffvdDaYykFUtalsiAC5RnOvWxfaOk6/YPtEuY5KBTSlb?= =?utf-8?q?b2BAhTJ/7ErQnAIUKJP1MXbkdC1e1YQ630XRkvxQpuezXC6cBQru3LGrD5O9KcE1Q?= =?utf-8?q?am8gKDe51sWs2ZqGZtjXbS5IImbgZDpVry8leeSB4hFAVAmmXGNh8IbEJDfntlXMs?= =?utf-8?q?D1nfPZdY/N9XnHkZC46JOZZs1eB9C2EfeQh5wy4g4sQ3yDhyz8NRGDSCnbrZY3kVL?= =?utf-8?q?No8bgD+dig5ROihU3fMDk/WPkWNazf0AmHiW24AgjdK6Fll6+GOGtYSbnCbqD7zEM?= =?utf-8?q?4YNFWa5uAJrn9VxGME6dcQIrOpeHjv3JQppQCAX22DAZm5/yWVy9PocH4/CJmmHF8?= =?utf-8?q?edVhyqCWswUF?= 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: xnmZpxXShHIXLWTYmNcKC969i/2c3TTMZirb/Qihf10XnezNkHQ8z6lYhXKaFKWVWQT4wKLweZ/tWM0zcQ3EfBbxDpopyApByiZEzLhuVX0A6iBv9RkU6t7bnFVqcf7z1PT4aEC1JklyTpxC323kP+6jacPr4zuT98KBLmhH6mtIZLM5uNDcCpiH8wOzHX7V6EYIo7SNhkqKNLP3x5vf+II0LT4xcIoI6W034zUirIHXJ5yq5ioye2LvLQve3VLl5ddN2IvXK8Hd343aa2EUfprcYtAGwEIcdAyJa4hVsmO6NivXAPPTM54yMmBO8r1/2F6epBffPHk6qB+br5cVvmMGm8YYpJbPZxqYVmJAiAMRDW+6H/uLdkwTNvPLp1cVZhK2OAWHTKl96y6jZRLJM/T0KGjYKCYiqHAiJaDILLkVG0s3mU3VS0m2WbalGDTcZ7UFy4YG+jFncwu7EXTz4/IKbKm9c7wuLJp4ir1a3Yt8R2zv8xtkTaiv17W/lnZxoPaNTAKW4552eAfbXPgtwfbEVSxXXVgWJotDNo3e+mUXC+23jaRtRRONfwv6sHR/5/Uhdly4fgJvUB3BlOWVcF6wUmimcBjdAom6YJ44eGMne3osJQ+zG72B0yFBzuKk 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: 7ce39508-99e4-4e6c-9a00-08dc470b607b X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Mar 2024 05:22:16.8373 (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: oww6V3xxIOFzHzkJHGFsB35R7ZLOT8tKQ3tqvaiEB1EMs0GVyj9Mpjw10pnMvOyaieQgVrUZdb3KxoRCxhyzdw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SI2PR04MB5895 X-Proofpoint-GUID: 0OpP4SFI7DfIgjuHTHdySmBHbvliUCtc X-Proofpoint-ORIG-GUID: 0OpP4SFI7DfIgjuHTHdySmBHbvliUCtc X-Sony-Outbound-GUID: 0OpP4SFI7DfIgjuHTHdySmBHbvliUCtc X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-17_12,2024-03-15_01,2023-05-22_02 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 Reviewed-by: Sungjong Seo Signed-off-by: Namjae Jeon --- fs/exfat/namei.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c index 79e3fc9d6e19..b33497845a06 100644 --- a/fs/exfat/namei.c +++ b/fs/exfat/namei.c @@ -547,6 +547,7 @@ static int exfat_create(struct mnt_idmap *idmap, struct inode *dir, struct exfat_dir_entry info; loff_t i_pos; int err; + loff_t size = i_size_read(dir); mutex_lock(&EXFAT_SB(sb)->s_lock); exfat_set_volume_dirty(sb); @@ -557,7 +558,7 @@ static int exfat_create(struct mnt_idmap *idmap, struct inode *dir, inode_inc_iversion(dir); inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); - if (IS_DIRSYNC(dir)) + if (IS_DIRSYNC(dir) && size != i_size_read(dir)) exfat_sync_inode(dir); else mark_inode_dirty(dir); @@ -801,10 +802,7 @@ static int exfat_unlink(struct inode *dir, struct dentry *dentry) inode_inc_iversion(dir); simple_inode_init_ts(dir); exfat_truncate_inode_atime(dir); - if (IS_DIRSYNC(dir)) - exfat_sync_inode(dir); - else - mark_inode_dirty(dir); + mark_inode_dirty(dir); clear_nlink(inode); simple_inode_init_ts(inode); @@ -825,6 +823,7 @@ static int exfat_mkdir(struct mnt_idmap *idmap, struct inode *dir, struct exfat_chain cdir; loff_t i_pos; int err; + loff_t size = i_size_read(dir); mutex_lock(&EXFAT_SB(sb)->s_lock); exfat_set_volume_dirty(sb); @@ -835,7 +834,7 @@ static int exfat_mkdir(struct mnt_idmap *idmap, struct inode *dir, inode_inc_iversion(dir); inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); - if (IS_DIRSYNC(dir)) + if (IS_DIRSYNC(dir) && size != i_size_read(dir)) exfat_sync_inode(dir); else mark_inode_dirty(dir); @@ -1239,6 +1238,7 @@ static int exfat_rename(struct mnt_idmap *idmap, struct super_block *sb = old_dir->i_sb; loff_t i_pos; int err; + loff_t size = i_size_read(new_dir); /* * The VFS already checks for existence, so for local filesystems @@ -1260,7 +1260,7 @@ static int exfat_rename(struct mnt_idmap *idmap, simple_rename_timestamp(old_dir, old_dentry, new_dir, new_dentry); EXFAT_I(new_dir)->i_crtime = current_time(new_dir); exfat_truncate_inode_atime(new_dir); - if (IS_DIRSYNC(new_dir)) + if (IS_DIRSYNC(new_dir) && size != i_size_read(new_dir)) exfat_sync_inode(new_dir); else mark_inode_dirty(new_dir); @@ -1281,10 +1281,7 @@ static int exfat_rename(struct mnt_idmap *idmap, } inode_inc_iversion(old_dir); - if (IS_DIRSYNC(old_dir)) - exfat_sync_inode(old_dir); - else - mark_inode_dirty(old_dir); + mark_inode_dirty(old_dir); if (new_inode) { exfat_unhash_inode(new_inode); From patchwork Mon Mar 18 05:22:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuezhang.Mo@sony.com" X-Patchwork-Id: 13594982 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 B597A20B12 for ; Mon, 18 Mar 2024 05:22:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=185.132.183.11 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710739356; cv=fail; b=mjmyEliMxRvzfObbcHQINgQUsR3w78+AeeUa1rygDhdC1lqX9uUnZQ5ArvsfMuehVkVtose3HXmRNckATyJUXc2wg/vlVZUzizxRlFavJhD9ST/vXZSed+Lk5XQY/ojMchDHZHdCf6viYgudSEyNCSlZH5SjzkPzqM/+KTn58fE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710739356; c=relaxed/simple; bh=pB5Db+NPIE+eGQ4NcuvpOEt3DjdZrMQJZgnF35Usd8I=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=X9gClIfNuxW3vj2LJHBKzNWkG1l/bMopt75NrwapK7rXjd/nswgDFYae9T86PRWhYwrteNw3oYqqZeV2ouGyptsVBna67p4msFNN6PS/RK+WSJsVh7HmazxARsnqWSk/6vek8ECOq+hGhaeKgtHCk0FGUXOJ2xgHLfNT+32nu50= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com; spf=pass smtp.mailfrom=sony.com; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b=mpwA+Zb7; arc=fail smtp.client-ip=185.132.183.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sony.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b="mpwA+Zb7" Received: from pps.filterd (m0209324.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 42I46nua011235; Mon, 18 Mar 2024 05:22:25 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=pB5Db+NPIE+eGQ4NcuvpOEt3DjdZrMQJZgnF35Usd8I=; b=mpwA+Zb72K4Bw8Z4Pc7KPN8Pc4W7NltEkjx2NQANuRFaqDNDVjwMoKrQ5mykGCkulGUT Mp6NMJFjgxlu7euwTJwTRgpYH8/LQ5jAr72XJ2R3SGAdU3j452B1tKyTfbc3nL8HrbI3 JdXTCPuYshPtTKWTIgGfW98I93yX9ftiHwyv5kwDXRnat0pzWjNdc9cAK8PwdX7YgFKQ p/DX5jvtXShDr4ZySZG2VWdJzYWDcw99o5CuFpbxbG2NoYxchfF8tt5C9yhO/S/vPcQl 92NzNPOjG7B+XkjM1ecpopQxUE9scUFYznC4ejjVVDabTGRlh4QG5cKA8b1MA68ijqdD kA== 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 3ww0k4hrhy-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Mar 2024 05:22:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YH4oyPViAcAq/4pAmiR74EQC0hdqIr5tH2GlhdmyKtiIbKyOqC2HoXvQrxn1iRCrfs4DjfNxVdXePvwjDiC6VMIEKXKQpKWt4sX4P20CjspxwXUz75fc9FpBg9oRyuGlB8ydIuprCJXJBMxYVGojlgLvgewVtFJhQ6uhPlysxgimz9m4V/Zu6s0digJKVWHzkja+pW/ZpxQn1D4Nx6fVErYIRt3HnW/1rkGrgLefbW5/HBG7PdRvbLJUXCOPsF3iWr7w4uyK9ie6QXBpatX97ROXRsd+vfZuXNMp6sG9ypmSzwGtykymP7vDjBqiyDOlWLNrTp70UF1nZocSVbAxHQ== 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=pB5Db+NPIE+eGQ4NcuvpOEt3DjdZrMQJZgnF35Usd8I=; b=jH/c3Hzqxw/T1TQebCNVVmyTm2ZBVdKaC2O3baNGNiE/4zOHSEc0j+h0uDcy3+ktARo2t3KKuxrN8CQ+JXCRtCiq6/ICmnEWKeAhnJ5cDbiTnh2QcvyXSr4mq/maWzl7d5bIhyzY/nvqrVdhe1w1b8DhUFh6Fr2lgSQF/hJ+iTTCK4oSATkg7EZsgCPpj8ZvJ5rYwdKMbA8mhofdbkl1yXEyzCCkCWyP8iXNIHC7VyDnRD0Dt/AsEY0FC+O4A/9qHOQC5lls+VAgZnpbp7HqXVl+2rjMCLDIZv5P5SgBJgYcLyInsL2hz6t1doGAtj37rtw1/7jKJP7Ei1L9MNCxUQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=sony.com; dmarc=pass action=none header.from=sony.com; dkim=pass header.d=sony.com; arc=none Received: from PUZPR04MB6316.apcprd04.prod.outlook.com (2603:1096:301:fc::7) by SI2PR04MB5895.apcprd04.prod.outlook.com (2603:1096:4:1eb::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.26; Mon, 18 Mar 2024 05:22:21 +0000 Received: from PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::7414:91e1:bb61:1c8d]) by PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::7414:91e1:bb61:1c8d%7]) with mapi id 15.20.7386.022; Mon, 18 Mar 2024 05:22:21 +0000 From: "Yuezhang.Mo@sony.com" To: "linkinjeon@kernel.org" , "sj1557.seo@samsung.com" CC: "linux-fsdevel@vger.kernel.org" , "Andy.Wu@sony.com" , "Wataru.Aoyama@sony.com" Subject: [PATCH v4 10/10] exfat: remove duplicate update parent dir Thread-Topic: [PATCH v4 10/10] exfat: remove duplicate update parent dir Thread-Index: Adj06Ci13KwnqdD7TBKYMvBVkuBBi2ECueOQ Date: Mon, 18 Mar 2024 05:22:21 +0000 Message-ID: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PUZPR04MB6316:EE_|SI2PR04MB5895:EE_ x-ms-office365-filtering-correlation-id: 3fb9812a-b416-4e52-e79a-08dc470b62fc x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: t06Jl9hT43oNMPLyRPlgPkOBT9YuAh5Agc7QlMAi6dOs4Hg41EK2kaMo5dZ7Hdf6YA76hajKYQLeQpqEYjj4gMbGYsVsOCI9CM5K0PwJTFIqvUFoK+1n1r9CdabKhHf9tJahkIitD9g6AijmK+tamXz/PP+zjWlkKlnNxhTLY33AozDYMZXZ+PFIymABCAwIa/4uhQDaZg/CwFGIjPZXPgyxSSp1of1l3wGnlg2lHzMZvT2xjG/GWlacSg2l6ehO/3Tj7TbmjjEg1EA9Eof9uCV2ck4hzdX8RLYhhNatvyMGtths9JPekpz9uWpnVXHIi9ib2qEyEzWiDknCaD1/7FGlKB4Gfb7WqyxGy0hn8qo6tAkRSuMDHjdcrpDtGPOS6FQFSYwebVL+fDOpTqsZ9WQBzacxFI/71C+Ba8wGvfXSxBsQk/SnFXrxH42YNv5/ViXGCjguBBzcvqwgZFYwwljv5b27TglzBDM4l7RHqN4DdeN/KdjFAaRF5sJRScsI+Q+6vpRcv1SN4BXETix2sWfgSaSLNxhMOd2Dt6nJ7Kws8RyQBjQjkAA/B+SzlYQnD7QoEmbUu3PYpZ9uc118R1vMlNqQzI7+NCJWZFca3iab5uvN6ep86bH9zmToRk0GrgySsVms7KOu3WA/UNBYRZ4ccxnWsdPDaP9TP7sVnvJ4Qd+L3atoH4y/xrojOQOAenMgL3PfhB58tLsTRJNGbw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:zh-cn;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PUZPR04MB6316.apcprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(366007)(1800799015)(38070700009);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?PDMKA6boxPIrGJdQvf4aglGsUfPo?= =?utf-8?q?NfYF0Tqf6JNMIj5XW6X4gW6KjPdL+mRtJaZK1dEfk29dY5PIhbiu3w1jyN7S2NEWx?= =?utf-8?q?YsD0q5sBXL2JYvAa0xEn7WUoQun/cH5Z7AA9pS7qgL9xnQsKVzzOKc2/H7HaNv+a/?= =?utf-8?q?6YOKeRhM/I4t3ECnvBhQt4yMziFaZwegv0OzLDGM002P6AqdPBanOdUT8TJSVWh+3?= =?utf-8?q?Va6tmdyzri2y6lHC4BHuZrDSJ04+svPx9Ke9pyzGLilEm90yLK6NArPhP2tgY8dft?= =?utf-8?q?eAd/dbvQiMXXbgQ7jt2JlSr4oTKDRXwufqB/qckItG4gcdc6UrC6jxAlatrLR+din?= =?utf-8?q?qJd6etGPtqimbGFL8KfNAkJgi0ldDa9llIgCe5tyGfDpY6VjOAFXqHWLnKfDWGZ8C?= =?utf-8?q?8FUno2y4W5wNjewBPazy7BSEoxDGd/9nqGsZCy3rT00PT4ydWmoAXyEg/bxoP/0iY?= =?utf-8?q?W1hju1D54CnJ97T4iqUQBzWplR6CX6aS74YjWu+6VD0XtV16qD+9tfvvTVEM+YRtR?= =?utf-8?q?ao5LRsuXXBFYRM1jqM/w/1oYMmWxI3FINl4r77gyy0qP+/8Nlyr99Y0200et5PywC?= =?utf-8?q?gs1BrjDYSg+dlrWKpO8s2G5/a4Zq6SuGv6eAhXin+7+dyLZrQUfao1r43NwyzKgHL?= =?utf-8?q?Lph812GPiTFEYsLEYPJBGtZvMzxqjHRij/9oe/ZnRVo7qrnY8i2xBDh3oVzTgXcld?= =?utf-8?q?vQaFLhLDrlK3ft/i4rGvOmR+JsuHfgEhim/idePN5lOP16lvbvWiUWWFPswdT5sgI?= =?utf-8?q?W4LEJQPKP6XAYmbmDt3MAiVv7KdnQrs+HB8SQH3aATW4k8TsFykavYA/PbhjiLC4T?= =?utf-8?q?7RKZeyQsT/VCMcruIpOJ7wpmx0VwyWM9pMrGliCI7DlnlQFi/85KO+dpW1fh4YwO2?= =?utf-8?q?ATaWSrrewXflWHe8lYhH9z3qhcKXpdDNNTonT9xx6h1H8QNyP4Ux05qKgJAF1Fycm?= =?utf-8?q?MTTGYez0tdZcHu5gAPFuUwdwwLqTLYqudRW5WYH2gXw8pGX36sWLJl1Y1hlZTz5vs?= =?utf-8?q?qH8LQHJZpyM9iAOJleUZwFnwxv53LhgvmuZA7B1x56kg4JWEXqV5gO6Cd/4/mlbIM?= =?utf-8?q?yguF45Die8kY26MTRnX2x0euxn2R4yoZpHDZn7ZtRfG9GUR1jhetI4BW7zwpOj4P5?= =?utf-8?q?RZza+ZsytVbTgjcuU8BpCI0S0v5cC1d9FW9C0dWp1sl3O8RJMFKYo0TcYnF7s+sLi?= =?utf-8?q?2LG3rN88DARxCEd0Be3F7JOvl8vxr4kt+QGI3ODzQP6WnKzXLB34umSktVqWGoe4F?= =?utf-8?q?PYhxZoJWTLX0UrQyWkvDu8l4o4xjV9Vr+54RYHw9MfM0jTQMuFAwJp2Y0CiMlk9AA?= =?utf-8?q?oTNQndb6mubyyPDov0GufdujBAuw/zL0HbWfuTThneDxZ0P4eN/XhEaZW2e10kDIh?= =?utf-8?q?IZ9JWz2S3EMHrCqsoN8iiKSymxj8iomJcUM01UvECadITcrTtZcHUv8Vd3m/AvGn2?= =?utf-8?q?tIwiVBMKdgSpE2fqR2zBJR2FpPwln4IhaVSjck2NgHj30BLAyGms4DD4yipZgD7wh?= =?utf-8?q?ChW7046TLU5F?= 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: VUbWeFLLsQjhQt/6uPwyaunYvr3qZT/eV1VCD6xT7K85k7F9302GrER/VjPvnhlx9/qFp/3alxd0iN2mh3CoQEilbLSghvj5XYxJcUol7PcMvMNhY1aFYwNBSPaKkC5LDXYITnE0O9mJv/9ib8rhmq1KJi4lEG2qUaQBrVlh2jfngANmRop+DeMtgR9SrOEcnp8cynQPKE0/i+a7iCgEBinubLcUAaPckrs1YpMGXjOhxs89q9eUfgdaZmHBmlIRtedem+wMBmdEFBJx5PbfNv9RQWE4kky0+4JDp2EJzkCd0ztFHpYgGfvCTfqFoB9f/n0FgI48draBytP6QJvVZPImMeVJd7K7F1qZ9denvYOpRGSVFgCJEHsp2zOcMrvuhZMxwZY/cV79LLYrQWnJcP05hn6eH/gedhLyIv7S7HnGsIuF5ExnBH9Q7tp5r/RPR3IPILZSCBmNQ9HgwM5F1FIBdiwFPKTEX56ypQ5KkU0pMMtpVjzF+PT1Q24L6DAulx1+q5dUUqlZWFuPfyvyEQc6J44ImAc9Yk4VINUQI9+FienbPP/Wn3B+txEGvih94LjCZLyZ5rYxls3l/BYIuDhdd4Tqs8F/N/eoyfU6JVcqguVtDMaBZBuh8e+beXHN 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: 3fb9812a-b416-4e52-e79a-08dc470b62fc X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Mar 2024 05:22:21.0418 (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: adMVN/Ns+3vO/jcAYHyTvC1Jg6TcLzDzCuWKNpFy2TUk9ZQxQMQpUKY/Q3RiN75VGE2yU3aGRnE0yfW9iMgnYw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SI2PR04MB5895 X-Proofpoint-GUID: K18Ggh7m5LMVmPCpOCdPgcbZuF7Km9mc X-Proofpoint-ORIG-GUID: K18Ggh7m5LMVmPCpOCdPgcbZuF7Km9mc X-Sony-Outbound-GUID: K18Ggh7m5LMVmPCpOCdPgcbZuF7Km9mc X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-17_12,2024-03-15_01,2023-05-22_02 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 Reviewed-by: Sungjong Seo Signed-off-by: Namjae Jeon --- 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);