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+nn2XnnWXu6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ZqGZtjXbS5IImbgZDpVry8leeSB4hFAVAmmXGNh8IbEJDfntlXMs?= =?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);