From patchwork Thu Dec 28 07:06:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuezhang.Mo@sony.com" X-Patchwork-Id: 13505647 Received: from mx08-001d1705.pphosted.com (mx08-001d1705.pphosted.com [185.183.30.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2EE5F3C0E for ; Thu, 28 Dec 2023 07:06:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sony.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b="GWsv22BC" Received: from pps.filterd (m0209319.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3BS6oM1K017341; Thu, 28 Dec 2023 07:06:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sony.com; h=from : to : cc : subject : date : message-id : mime-version : content-type : content-transfer-encoding; s=S1; bh=XQc7WilSUqGnVRhUeh5Xfm3jTDGXLHZG0DSA5X05eLE=; b=GWsv22BC5b3nJAsz5LlSL9uZGw4666xC3MXATTE9AUH2vd/lQTvuOTAHL7ffiHTZsrla ZwgyBS2bw405z/4npr66/EUncMFfhCDga97hHPWWnupbx6nKgd+hoEk8A2wylhLbyuV1 VocWZI0IaywDlNA1NZxusNcdS+DbKLpDyOxAYCPVuc0Gg2orBHf8j79uyQ5SnUxAD+sE T0qpxBx2p1Ts3bXU7fGttyywK+wwwCKFF+9z9TQ8rVql75aHz1COEruuYkoTM/hIlsKO IwbHjI7NjRumeheeQeUcljrAf4/s3HC/c11utPit3LQpfOqwqesoA+xkZIZcGBiWi9yP Nw== Received: from apc01-tyz-obe.outbound.protection.outlook.com (mail-tyzapc01lp2041.outbound.protection.outlook.com [104.47.110.41]) by mx08-001d1705.pphosted.com (PPS) with ESMTPS id 3v5qxtbskt-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Dec 2023 07:06:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iziYquhZQgy6YbPUdkvpKajW4Nnzy1ifBAioRNps9cqp6oVsKVRmCCJKqWBgwjUN8foPU5jtH5y/32oA3esajIZuHzzA2kTvTg/cYpli5i4uvnUtEBre46BoWR3HzosW++Q6fKHO/2qS77ZCQYPjmrer3j+kiZ3c5w9iYfcSA9cJr3d6bQBIDzB89wSJPOViRUWteEpu3BiywyffFW9R8mx0G6zmARQRX8rR3W1HQBp5byqo+m/I99cml6HzcBSuNg5r9X/OfC3S0j5pIja+XunK4RfTXGGTBzBZuDD+GpyMelCMFhf5ivSCxTObCVCPmDtBEEdvVZceWwj+fyx5iA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XQc7WilSUqGnVRhUeh5Xfm3jTDGXLHZG0DSA5X05eLE=; b=QLemR8LALknkXp/8WjgAaX4Zeb467EtgE545HC92xXD8j4aPPjv7Aa/oEkM2WOchucwwNiwcp1Pyvman45Ln6OFVCUBRq9bJPsoHNuNsWuEAgSW6F44SMbO9Yu9rQB7oIks6h9552f0Ggt9SbhSLgJeYlsNVARlOAOpUBVLvfoY3VZWj2/6TfiCK4dXht0TpvDXXnOCZgVZbFnlYcWumcoCp1a05mC0OWhiueBfAGhRP26jlfO3mD9laGqk+oAWRZKD28Gih3yAyMrInXOEx6ccqM2v3VhmnWlHrI0gpWGOTEoYN5EiECgLAufglWNaTLdG02hA+mbPUb5GFu1pn6w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=sony.com; dmarc=pass action=none header.from=sony.com; dkim=pass header.d=sony.com; arc=none Received: from PUZPR04MB6316.apcprd04.prod.outlook.com (2603:1096:301:fc::7) by PUZPR04MB6959.apcprd04.prod.outlook.com (2603:1096:301:11f::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.27; Thu, 28 Dec 2023 07:06:01 +0000 Received: from PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::5914:6fc7:b79d:7e34]) by PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::5914:6fc7:b79d:7e34%7]) with mapi id 15.20.7113.026; Thu, 28 Dec 2023 07:06:01 +0000 From: "Yuezhang.Mo@sony.com" To: "linkinjeon@kernel.org" , "sj1557.seo@samsung.com" CC: "linux-fsdevel@vger.kernel.org" , "Andy.Wu@sony.com" , "Wataru.Aoyama@sony.com" Subject: [PATCH v2 09/10] exfat: do not sync parent dir if just update timestamp Thread-Topic: [PATCH v2 09/10] exfat: do not sync parent dir if just update timestamp Thread-Index: Ado5XCkaXD3jsLKFSrmKxdYpGZSlCQ== Date: Thu, 28 Dec 2023 07:06:01 +0000 Message-ID: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PUZPR04MB6316:EE_|PUZPR04MB6959:EE_ x-ms-office365-filtering-correlation-id: 81d43e89-79ad-403c-d258-08dc07737333 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: BepZ1U0YtQn/YRgaphtcLTBxBBHAezSzBSGDAwTIvkAYLbf471SFR4rOKFwFB63zb6nGYauoOEEjGHb8ldKW7gaPFV2zHRwFhr+uTlslJDEyLtkE6KegY0oT6P8A8OCl2s9KMS0uYYRbygcn6ZXgb7uZ+H1mLauh2sfEKAXOQOtDTClaDkMAa0/v/Vpv5enpnIMn6/tvChxbYbYu7H3q3q4QH3eb/8ok0Be3kVXmGQY8cDMBPAyijCf7drMI0eWREzxyjbFt80xeqGI2/e8WV0WJGSTyIA/V9Dw1SdCZC3kiPefo4fg4X9dKcYBKJavToRjT/QuWEWTkHTp0lAfsgy8ELQ100+NTj4w4bBHrgwwzBj5zRyo97j+Fshkt6EiDos6mgIX69+iokciZlwjsRgEKh/gaMkiV++9Gf7cumZzNMDREYWxkNi2tSxhAxVsK7qujenyopuvuFT4S+YipBNNjplzPizfC5FuSDs3WkNNj/uxEvSJp/jdLZo/QQNH0lnfIq2zgYyCDQbSH26gcqXxgI+R7xHvuUfwlg96QCN6bZlVmFPStPQSjXbY456nZR5IPNBWUyuo6SkaHhX2T94kD5QSiSla4wD8tnDc3375rQ8BN0JoZ0FED4JBPmJAf x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PUZPR04MB6316.apcprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(366004)(136003)(376002)(396003)(39860400002)(230922051799003)(186009)(451199024)(64100799003)(1800799012)(2906002)(66556008)(66446008)(66476007)(76116006)(5660300002)(15650500001)(64756008)(66946007)(55016003)(4326008)(52536014)(8676002)(8936002)(316002)(54906003)(110136005)(38070700009)(9686003)(107886003)(7696005)(478600001)(71200400001)(26005)(86362001)(6506007)(33656002)(122000001)(41300700001)(83380400001)(38100700002)(82960400001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?l9mMNjB6ylKwo0Yw0D1ChQHt3mzp?= =?utf-8?q?+drp8zsPLFHPwJM2pdpL0BzrDkpkNahgpFmNmF1Li9LmIiSqe31cIJX+eSUn/eepE?= =?utf-8?q?IpYPN2NIOGP2OsDnra2OoR1Y+o2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4yDwqMcddWFHxW2XY3JY49S?= =?utf-8?q?x3QTjW7pmkZm8f1ZV/8sBtEnQRymfVmEUlnnpELB/LEV4XUQFeg2CttquvIPTmGZm?= =?utf-8?q?fStitFSk9P+pDSCRoO7PJkaR9e2Ladeign9KNSGTJpvqPgxdZjdLj8BYqzuURFqii?= =?utf-8?q?5lGgqlxzKR1PDHdgWa9vvDVU2kwFsJDTvTfuF6aGSwLmo4JaqPTFnTEz+Z6Vp8bZl?= =?utf-8?q?Mppn92xDyYJw2lFt9Yc4Qjl2tI92+CYjxb9nXMONJ87CmS/p4kJXOHXU0UJ0Kg7Tc?= =?utf-8?q?1HUiz67kqaRnxqZ+ke/BaMXeWQyABZvACYM50ydY5eAPunFhjZ4oXmlX5uvJE1MJ6?= =?utf-8?q?l+aZQnmsAB+O6JCxCVLeX6C1ViH3Pca5E6F0tMTD+xw7Lrh7FjsLAi1KiNB8ZO9/4?= =?utf-8?q?RL7FdI34O3kk+dOboOT5vLquz5qV3BlR6jSYCqEDTzGx/oeaum1g08khTIVLOD4x6?= =?utf-8?q?3o3ksV/o8MiU9gdaFo+HXtM8DykIUP2sEVIyo0F38Pql14OYKhUkXyLjVb6sX4JSj?= =?utf-8?q?h6lW2z8+hjY6?= Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: ev/Spd2Y7Q971iF9kFDHJ1qDlVsfxjftw3bgFpYkA391DJF7olqTgC4Tcoay7918G2EXrDJ8CGX9Xn46QGw03BmOxV2oZnokuBKkcil3KN1mHzB4RlOOHPr4AMe+6vaDsh/ITU8gs+L0NzIBiZ3Cs/+utZrjCE9iq+ubcIqeUffnt9ByHtTxM6g464f+wzfnbouPWrvu+BSLz+jk5XQD1P1bJlx4y8vicpDooyW1ZIdUCOWERcpoHqa2Xizuryo3RmshikHjMMHofP1MSKCdqIgU21sUumYo6n5q3DUqmdW4nW/zc8khyiR/1eh6TErGJMCeu+lwQ3r/kY7jenAzu2oWMO1P1HZxWs9Nc5GvyApLhscbWz6K1no9Fs1FrShRx5sA0MRaj2dMsV73o0wUziLdetSb4Xy3nuIXIMga1+h+918EwdTnGplcl2cjx8pHCAleZpTDAr7rt/RBvdNm6JZaBcxEAjet/xcUhcfcJhX3YyVfejHlao3z+6IrNFJ0pjkCv09u+9pfxKpZv3o3UKvBDT6xiN/lSbjNDz0csNu3CTR2Y42UlHmBSShgguzW4LOZ5nsBNRa6MzgP7+8x6t46QE7Z7FdxUBAXirKILSNg5ipI23d1SXPgENqEaJ4j X-OriginatorOrg: sony.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PUZPR04MB6316.apcprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 81d43e89-79ad-403c-d258-08dc07737333 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Dec 2023 07:06:01.4777 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 66c65d8a-9158-4521-a2d8-664963db48e4 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: DhWhx8LspX1JLKPVyr5/x9yyR0ErB5wtbJ3i/DsESCLuJCqBGYz90eRaBBCq5XLUgjrqnRTSualtxwpaxX3g6g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PUZPR04MB6959 X-Proofpoint-GUID: JY5QemxAGC9vJom_98rTG_bljFcXiw9_ X-Proofpoint-ORIG-GUID: JY5QemxAGC9vJom_98rTG_bljFcXiw9_ X-Sony-Outbound-GUID: JY5QemxAGC9vJom_98rTG_bljFcXiw9_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-28_02,2023-12-27_01,2023-05-22_02 When sync or dir_sync is enabled, there is no need to sync the parent directory's inode if only for updating its timestamp. 1. If an unexpected power failure occurs, the timestamp of the parent directory is not updated to the storage, which has no impact on the user. 2. The number of writes will be greatly reduced, which can not only improve performance, but also prolong device life. Signed-off-by: Yuezhang Mo Reviewed-by: Andy Wu Reviewed-by: Aoyama Wataru --- fs/exfat/namei.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c index 79e3fc9d6e19..b33497845a06 100644 --- a/fs/exfat/namei.c +++ b/fs/exfat/namei.c @@ -547,6 +547,7 @@ static int exfat_create(struct mnt_idmap *idmap, struct inode *dir, struct exfat_dir_entry info; loff_t i_pos; int err; + loff_t size = i_size_read(dir); mutex_lock(&EXFAT_SB(sb)->s_lock); exfat_set_volume_dirty(sb); @@ -557,7 +558,7 @@ static int exfat_create(struct mnt_idmap *idmap, struct inode *dir, inode_inc_iversion(dir); inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); - if (IS_DIRSYNC(dir)) + if (IS_DIRSYNC(dir) && size != i_size_read(dir)) exfat_sync_inode(dir); else mark_inode_dirty(dir); @@ -801,10 +802,7 @@ static int exfat_unlink(struct inode *dir, struct dentry *dentry) inode_inc_iversion(dir); simple_inode_init_ts(dir); exfat_truncate_inode_atime(dir); - if (IS_DIRSYNC(dir)) - exfat_sync_inode(dir); - else - mark_inode_dirty(dir); + mark_inode_dirty(dir); clear_nlink(inode); simple_inode_init_ts(inode); @@ -825,6 +823,7 @@ static int exfat_mkdir(struct mnt_idmap *idmap, struct inode *dir, struct exfat_chain cdir; loff_t i_pos; int err; + loff_t size = i_size_read(dir); mutex_lock(&EXFAT_SB(sb)->s_lock); exfat_set_volume_dirty(sb); @@ -835,7 +834,7 @@ static int exfat_mkdir(struct mnt_idmap *idmap, struct inode *dir, inode_inc_iversion(dir); inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); - if (IS_DIRSYNC(dir)) + if (IS_DIRSYNC(dir) && size != i_size_read(dir)) exfat_sync_inode(dir); else mark_inode_dirty(dir); @@ -1239,6 +1238,7 @@ static int exfat_rename(struct mnt_idmap *idmap, struct super_block *sb = old_dir->i_sb; loff_t i_pos; int err; + loff_t size = i_size_read(new_dir); /* * The VFS already checks for existence, so for local filesystems @@ -1260,7 +1260,7 @@ static int exfat_rename(struct mnt_idmap *idmap, simple_rename_timestamp(old_dir, old_dentry, new_dir, new_dentry); EXFAT_I(new_dir)->i_crtime = current_time(new_dir); exfat_truncate_inode_atime(new_dir); - if (IS_DIRSYNC(new_dir)) + if (IS_DIRSYNC(new_dir) && size != i_size_read(new_dir)) exfat_sync_inode(new_dir); else mark_inode_dirty(new_dir); @@ -1281,10 +1281,7 @@ static int exfat_rename(struct mnt_idmap *idmap, } inode_inc_iversion(old_dir); - if (IS_DIRSYNC(old_dir)) - exfat_sync_inode(old_dir); - else - mark_inode_dirty(old_dir); + mark_inode_dirty(old_dir); if (new_inode) { exfat_unhash_inode(new_inode);