From patchwork Mon Mar 11 04:25:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuezhang.Mo@sony.com" X-Patchwork-Id: 13588287 Received: from mx07-001d1705.pphosted.com (mx07-001d1705.pphosted.com [185.132.183.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 04CA217C77 for ; Mon, 11 Mar 2024 04:25:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=185.132.183.11 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710131144; cv=fail; b=JLso+cdeSIJmBHLIfGj+Dpq7Kt5YAf7RM0nc+DfNYB6sNDdGxf4Dnu3S7AT6AKa2wxQ4IabPBEE2qczzWWM9SjRI/QUVJGl/DL/2bFhe+te7qPa6HittF8QCinKNoLShKxNWvh/B/iqv/JdqSCgJxDygxO0XkUPklKnwUCaRLT4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710131144; c=relaxed/simple; bh=/4u/TY6uNxij5w/Kj9dXl++kd71MU1xXNXwr9AXACS0=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=oX+eJ2x+uWDLlIM9HO++3/tBnvpkXK6Y+2ZgTlkYl84Qyl/A9LOeYiN7L6uHNQK7UPikKGwtdYAIrCIxAyAo+EAlk2sxvSp+aUPIFynwQyau3RhlFSoqOOURpKAaQt7R8MChH3NkH3mTvXPtE/iGwEGQXg9tuwlRlPxZukJqKXM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com; spf=pass smtp.mailfrom=sony.com; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b=J0kohaBg; arc=fail smtp.client-ip=185.132.183.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sony.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b="J0kohaBg" Received: from pps.filterd (m0209326.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 42B0MdoW032336; Mon, 11 Mar 2024 04:25:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sony.com; h=from : to : cc : subject : date : message-id : mime-version : content-type : content-transfer-encoding; s=S1; bh=/4u/TY6uNxij5w/Kj9dXl++kd71MU1xXNXwr9AXACS0=; b=J0kohaBgR3iN+vQzKjcfSYLKewC/zv8s6DM0F8HYj3H1ng7IFbB8FFjndC7RtGf1wZne kL+jF7pDgrpT+0N12mU+aYpiJkTT2CpPSD5obaCFofALMS/5eycLBvqUoVQCPGKzB5os PBevQAAWkEyzWicH7ipmt5ZJkZsQKj5Q3t20sWWguak5QpR3qVjTLgWgg0xLkP1WHBML 2szQNWKmpuPw32Ozb/NoM7On9l1TV1sbpf6VGYcBdsTTeXQBEjWnhhlxtqm715B/Ion/ 1AiO+G6pEHGsYFl3diQHu6rhDYVwU4e6vupRAUgQ/+dgKoJptpgagLjNBADl4ctVOshT yw== Received: from apc01-tyz-obe.outbound.protection.outlook.com (mail-tyzapc01lp2040.outbound.protection.outlook.com [104.47.110.40]) by mx08-001d1705.pphosted.com (PPS) with ESMTPS id 3wrdyk1knh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 11 Mar 2024 04:25:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jRJAmt+rmhlh3NTkBjrkxNqp1DbbY54dq5f1G6E+YSMF9CdZtA3ElglVwXcVdYyyhgHUttJbKL2OhUrBeQkgJ1Wz26KQ/+Wy3ZPp7oYSZFXnfTbp29LDvLYS/XYFWYUtVCbY7OrsZwFK311eJKKJnhGtcJtwBGP+dEA9xmINtFl/4UwgEDFQojtRFUt2qrTtuVMJvVIBcgBZSGBC758D4AQ1cLJ4x/38G0udKFwlxdeEQ+5T01dP58k/4KfppkDtDTADA8bYA6yWq2xq29c21JvCNUF5J+f8sLKxI3ftFOjag+YiZ8KBICL2ZutYwVChyH7XaoPaiyi1ZPbRJb9sag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/4u/TY6uNxij5w/Kj9dXl++kd71MU1xXNXwr9AXACS0=; b=hEnJkOCBZq+yB9+1cg0bs7k1NC50Q/Y1TJXvopZg4Fmlmdee6VgkwRN6fbkE4JY2RPdPYZgJ8qHLeK9O800aLcyBKuaqjLl6UcNG8giKU3h7MYONQCKop01LH/aZ49FiTsKMGkLI29saADwqdTvIJy2kgmViuBrIgAiirSzR0dpgHcLfQ/+Lz+dUEktKBSX2MYaqH1FcXdG+G8Sw6yprkxiSV4DupvF3r142EdZ5SnW0CIgDW64Dh2FQYbrjKkM6lV77ctlkU0EzQVC/YpYvp5NQgeM6PAoCSnQ2nSFVXAkLVa9S/Wz12UHFllO51ToIHj78WaoS2exsUb4h/1Hg0w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=sony.com; dmarc=pass action=none header.from=sony.com; dkim=pass header.d=sony.com; arc=none Received: from TY0PR04MB6328.apcprd04.prod.outlook.com (2603:1096:400:279::9) by TYZPR04MB6635.apcprd04.prod.outlook.com (2603:1096:400:33f::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.28; Mon, 11 Mar 2024 04:25:27 +0000 Received: from TY0PR04MB6328.apcprd04.prod.outlook.com ([fe80::c5b0:d335:658e:20bd]) by TY0PR04MB6328.apcprd04.prod.outlook.com ([fe80::c5b0:d335:658e:20bd%7]) with mapi id 15.20.7362.031; Mon, 11 Mar 2024 04:25:27 +0000 From: "Yuezhang.Mo@sony.com" To: "linkinjeon@kernel.org" , "sj1557.seo@samsung.com" CC: "linux-fsdevel@vger.kernel.org" , "Andy.Wu@sony.com" , "Wataru.Aoyama@sony.com" Subject: [PATCH v3 09/10] exfat: do not sync parent dir if just update timestamp Thread-Topic: [PATCH v3 09/10] exfat: do not sync parent dir if just update timestamp Thread-Index: Adj0JkwXPMQ8nbBQR7SEkH+NN01tmF/RPSvA Date: Mon, 11 Mar 2024 04:25:27 +0000 Message-ID: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: TY0PR04MB6328:EE_|TYZPR04MB6635:EE_ x-ms-office365-filtering-correlation-id: 1e20544b-576e-44ea-177e-08dc41834744 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: G66UK8I6qd5iA83X6TVwnr7/o8z/DKmvsDfUpuo2q7fIBh3vl+fsJcU8jEFFCg7mkXoeF/UKebukPMbuxbEiaQ4FRcTaKbKhVot1KAMr27alKhdlPN8B14VqphcFZWPGKHEyVvZ7PVZD/UKqb6c7bpMZG/5Y0Q1H017MvVclDV6pWhFnVjdg7nT6YqgJ2aoy6KZnw0vKKcB+1uygrtiMd6ZQD0FWnqzbxh/A2WlCr8vnWORys6hmU/GJRKeSUkyJgnrL1nw4WexmBQS4BmjmgOR34ADtRmxlHODLCe7csd8K+zjuqbY0CGANr+9v7QcOp3Io60XM6P2sMa1rpSgYm//YeP55G/39Zed6nfowzW5yYAXjEqQF++lVE2AsBXjkzT7kicAxYKpiPETFmJIq8iaOXjXKLw/2oJdXSDWtEDSHMr0pWUSDuZg4fcbMa3Y0uMmE7agj9+O8YiSbZ9Id4s9LIlRrdz9gjdbehInMbduY35AKTi0ZAZuSJ35t0Gs4cC46xcwVqByLC7Lk5CSZqOoWx30LIECyv5fT6mngayMKOOm6/gm2ZQzmU0/D8nrZIuhBG54YyW2ObNUmcdfTILzTZjFLnhf2Qcde+60hcM5GZymSxK7GuavMCWARqYlQZI29iGjInScIR3JkTq9S4TDkDUlyoDUNqAS0mqU6kfM5HP9morOGggEhO7wvD2sIRYWOw0ghAbLKBk21vSb9og== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:zh-cn;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:TY0PR04MB6328.apcprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(1800799015)(38070700009);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?YKAUicZXCj1pz1Y8pna+PlE0zc4u?= =?utf-8?q?Rza6X5iTUV4IyBRpqrWT8EswbbzOvp8/8f5Y3qA21z2/uUAYzKPBWzy/g/Xh6pwXu?= =?utf-8?q?Ig96jPH/o3Po/OFTs7vyowv045AAIF9elbk/4ft0taw+4aDVWEQUO4ywJw4VkMS9L?= =?utf-8?q?w9QTdam7+aqdQDey44DPw22rFPyghyQE32OLQUxB29kNiiAKDHBuTi5xklIPIt0IZ?= =?utf-8?q?BTNF6k1VCs7KFYyfTb+76q9uGmP/fHWUl9w698gV5HfRrf5pDFC5vrtnQ+6wF19G0?= =?utf-8?q?KlpXTz679MUkIPsEFGWm2CQ+bzpURCJwCC84ShW/Nl3beE7spURrmK3igqINTG/+t?= =?utf-8?q?mDptqrRyXsre3hSIzsS9cJtU7tGqK/OGgmZaTLtVORue5ojQkINiCgGoAyObqu7HB?= =?utf-8?q?+Tt4hUb7YJiaztAPWwEKSYHX468svL2VQzM9e2DPAqKPZ5/nueczGoc/vQOYkLBQC?= =?utf-8?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?q?I0/PgfAs5hhVKZePYHAvtkuLAlkbAaL79jU65HFJl/p4ZXSGgqmQkh2NQoLyw2JKb?= =?utf-8?q?28nGV4IPfrSi0Ge9BO1Snhms4gpR7/hTFg/mcYHNBfwU49+8tJ/IackQf0V2asnvg?= =?utf-8?q?AHXDAxZ1Sd6adWJuu9OAJXVFIuGrsb9M+QFa3uj8tvXb2kGRQlV7E51stD2AZ0T0i?= =?utf-8?q?zkgR0nWiEBP6?= Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: yy4TVqdmtswfRbmXii4PYglhlmC7PeQxbNur3XDXtlBOBPjvvoyMs67jhd0TFqEzBLl3jwcsdv3KFUo8E4yN7jsvy7VYaaA49bpQERYPM0aS52Vnro5AV7hpgqgJHlsinyPplRJ/JyTXOxcviFmDMuKUu7SNkaZs7b36cft0TXlAL8rc1L54lykPscOXUxEh/Qp1VUEzJytHLoSQSv1of9O2c2p3KdKKhfKphkVSjGYe7E3xeB4xlxA0gdL1m6WncD0XFLe67x3WdoosVac+iTEYW8+1fMl4AN9VbaGnvafeOOwLR/r7q9tbtAWLn3onAGGGM+SbJCj1m5Lqy0elRN558hivHVWQNe8WZ0GBkyQv07PMhwZ70zLxcTtIm7ZliO5ryFKTJTYaQcJfe/0UdhpDsGisiabiEOqAKr1bXAaN2BOnzX27NG7+edspxLEnJ4vJ9XMKqAjvXVVLoUCiLEbhsdXN4O7IE7c6saAER34cH03P3fJ1T8kLx1SqgS1ORFrIR4VVwUA9uW5n7qKhex0o9jKMP4RvFw2VPiWfLXDUvsg1vF7zaEZ43qqr79W7B1u7lvHK99VrG7LyPUIOmUka8XXhmNklJGyzkurKKh+Mz6+O0AIYYVaim+//qDGt X-OriginatorOrg: sony.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: TY0PR04MB6328.apcprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1e20544b-576e-44ea-177e-08dc41834744 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Mar 2024 04:25:27.1882 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 66c65d8a-9158-4521-a2d8-664963db48e4 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: hyEfyLTI0mhu5YJsMfJ8axkBhR3o1Pxodi+8sSLmLuWTDwTYq6U+J0o1CZj2ykAaE316883KFxIoo1nXVEXALw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR04MB6635 X-Proofpoint-GUID: pO9LMEOPQV3kl2RJ-m8l_Rn1H6__I4XY X-Proofpoint-ORIG-GUID: pO9LMEOPQV3kl2RJ-m8l_Rn1H6__I4XY X-Sony-Outbound-GUID: pO9LMEOPQV3kl2RJ-m8l_Rn1H6__I4XY X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-11_01,2024-03-06_01,2023-05-22_02 When sync or dir_sync is enabled, there is no need to sync the parent directory's inode if only for updating its timestamp. 1. If an unexpected power failure occurs, the timestamp of the parent directory is not updated to the storage, which has no impact on the user. 2. The number of writes will be greatly reduced, which can not only improve performance, but also prolong device life. Signed-off-by: Yuezhang Mo Reviewed-by: Andy Wu Reviewed-by: Aoyama Wataru --- fs/exfat/namei.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c index 79e3fc9d6e19..b33497845a06 100644 --- a/fs/exfat/namei.c +++ b/fs/exfat/namei.c @@ -547,6 +547,7 @@ static int exfat_create(struct mnt_idmap *idmap, struct inode *dir, struct exfat_dir_entry info; loff_t i_pos; int err; + loff_t size = i_size_read(dir); mutex_lock(&EXFAT_SB(sb)->s_lock); exfat_set_volume_dirty(sb); @@ -557,7 +558,7 @@ static int exfat_create(struct mnt_idmap *idmap, struct inode *dir, inode_inc_iversion(dir); inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); - if (IS_DIRSYNC(dir)) + if (IS_DIRSYNC(dir) && size != i_size_read(dir)) exfat_sync_inode(dir); else mark_inode_dirty(dir); @@ -801,10 +802,7 @@ static int exfat_unlink(struct inode *dir, struct dentry *dentry) inode_inc_iversion(dir); simple_inode_init_ts(dir); exfat_truncate_inode_atime(dir); - if (IS_DIRSYNC(dir)) - exfat_sync_inode(dir); - else - mark_inode_dirty(dir); + mark_inode_dirty(dir); clear_nlink(inode); simple_inode_init_ts(inode); @@ -825,6 +823,7 @@ static int exfat_mkdir(struct mnt_idmap *idmap, struct inode *dir, struct exfat_chain cdir; loff_t i_pos; int err; + loff_t size = i_size_read(dir); mutex_lock(&EXFAT_SB(sb)->s_lock); exfat_set_volume_dirty(sb); @@ -835,7 +834,7 @@ static int exfat_mkdir(struct mnt_idmap *idmap, struct inode *dir, inode_inc_iversion(dir); inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); - if (IS_DIRSYNC(dir)) + if (IS_DIRSYNC(dir) && size != i_size_read(dir)) exfat_sync_inode(dir); else mark_inode_dirty(dir); @@ -1239,6 +1238,7 @@ static int exfat_rename(struct mnt_idmap *idmap, struct super_block *sb = old_dir->i_sb; loff_t i_pos; int err; + loff_t size = i_size_read(new_dir); /* * The VFS already checks for existence, so for local filesystems @@ -1260,7 +1260,7 @@ static int exfat_rename(struct mnt_idmap *idmap, simple_rename_timestamp(old_dir, old_dentry, new_dir, new_dentry); EXFAT_I(new_dir)->i_crtime = current_time(new_dir); exfat_truncate_inode_atime(new_dir); - if (IS_DIRSYNC(new_dir)) + if (IS_DIRSYNC(new_dir) && size != i_size_read(new_dir)) exfat_sync_inode(new_dir); else mark_inode_dirty(new_dir); @@ -1281,10 +1281,7 @@ static int exfat_rename(struct mnt_idmap *idmap, } inode_inc_iversion(old_dir); - if (IS_DIRSYNC(old_dir)) - exfat_sync_inode(old_dir); - else - mark_inode_dirty(old_dir); + mark_inode_dirty(old_dir); if (new_inode) { exfat_unhash_inode(new_inode);