From patchwork Thu Mar 10 08:18:34 2022 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: 12776024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2FAAC433F5 for ; Thu, 10 Mar 2022 08:19:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240262AbiCJIUH (ORCPT ); Thu, 10 Mar 2022 03:20:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240259AbiCJIUG (ORCPT ); Thu, 10 Mar 2022 03:20:06 -0500 Received: from mx07-001d1705.pphosted.com (mx07-001d1705.pphosted.com [185.132.183.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 009C1443DD; Thu, 10 Mar 2022 00:19:04 -0800 (PST) Received: from pps.filterd (m0209329.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 22A6oZE6021751; Thu, 10 Mar 2022 08:18:47 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sony.com; h=from : to : cc : subject : date : message-id : content-type : mime-version; s=S1; bh=o88d0l1C/GST9ZkdRfhXDgEHwt6YCT8f4bS1TFJU+Q4=; b=NmmItyU8aRH1PVYOLVRqbCvH6PZcnZoUr4YhWL5xH+4f1ah0TrxWcOieRTKbASLM8FNV RSketHk2/wB4Ywb1xGLqNErUwSCtl1bJPdQqCjl1phXBdftTaZBfmWuUJJI0kpbRnlD/ 4janvHo2HZVmdaJPVLrL3W8axqQHDKxlS5PXs3dWD3iYhv9KIA7OJywdJEvbzIKIHlaI AJRYTzIARXh70SpvZ/J8cuRWmTiugPoiEkYWCMkwQ1jSOnJZUJTfCwkIxC2LYaWRiYbY bEddYjKNhtz1dAv7UmC8XFhGWGVi0/bmFkRmYjQatfXz3TXAFiVwei/AqxlPj2nOZ4/S zw== Received: from apc01-hk2-obe.outbound.protection.outlook.com (mail-hk2apc01lp2054.outbound.protection.outlook.com [104.47.124.54]) by mx08-001d1705.pphosted.com (PPS) with ESMTPS id 3ekxgxcnst-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Mar 2022 08:18:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TkoIOkx76BwfegI9vTS3Tev03u3GmDCNDFlVylHRZjjBh+XALuuWqh15mAgU26MaO5IK2NpuKzmR0XjcUYVuJfnTHDxhMqdw1GHNwEuY5y3dJamiMp+Z2V+3U/oyY3DkEAD22GD9gisSn0J90kta8H46nQjhyVfL9lnOFxaYueveFD9OYjDHEVQlUr6kac9xMxS+4DBi+c5K01VR6bcFLsdjytT3KB+HF/+iBAp1c2Q33nIKW6PV7OHsRzPDv+/+U/bfcpXq6fWQVDKXAykgUzzgFZWNms2NBSaTOYz6ZTU4MFF2af8dY4tf5AXpvNiOP3TR3mqmFN7/UAASFWhsMw== 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=o88d0l1C/GST9ZkdRfhXDgEHwt6YCT8f4bS1TFJU+Q4=; b=dGBbQ0qTcJi2x9gHcNlRTCtGNnGXrTtc60zEeLNr1yQrtjQzCMnl5G4caBfDGI3LexWnJDBCKWKOGl+5j5FA7e7mLrxWI6jZHWJZvaZHrSvASbBFnZZ3IIqfu/ajSbbzLmCAKWXHEx2u7lpU84KpgzfgZ+HMuGTpQuf9SVHLzT44Rofr18nclwsw3523BmaGstfDaWg/zVWsBj+nt2O+ZVGvAoWuXL9W391TRYlfmGWIBQ6sIo88xbY82b+JFRN7OP2/0ylm7ikwNGvdtO4ldhLCTbvZOHGTBjYMenlihc4gtl6CHspR11uF4AVgUfgcjE78VoTZi6JM4JZQ/9rlaQ== 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 HK2PR04MB3891.apcprd04.prod.outlook.com (2603:1096:202:35::13) by SG2PR04MB2267.apcprd04.prod.outlook.com (2603:1096:4:c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.17; Thu, 10 Mar 2022 08:18:34 +0000 Received: from HK2PR04MB3891.apcprd04.prod.outlook.com ([fe80::7420:b05b:beb9:38a8]) by HK2PR04MB3891.apcprd04.prod.outlook.com ([fe80::7420:b05b:beb9:38a8%6]) with mapi id 15.20.5038.027; Thu, 10 Mar 2022 08:18:34 +0000 From: "Yuezhang.Mo@sony.com" To: Namjae Jeon , "sj1557.seo@samsung.com" CC: "linux-fsdevel@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "Andy.Wu@sony.com" , "Wataru.Aoyama@sony.com" Subject: [PATCH v2] exfat: do not clear VolumeDirty in writeback Thread-Topic: [PATCH v2] exfat: do not clear VolumeDirty in writeback Thread-Index: Adg0Vskc+T+8E+65Sm+jIEZBsmb4mg== Date: Thu, 10 Mar 2022 08:18:34 +0000 Message-ID: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: yes X-MS-TNEF-Correlator: suggested_attachment_session_id: 87d863c1-a82b-e0d6-e7c2-f43e385a686b x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 36873832-a971-4909-300e-08da026e9232 x-ms-traffictypediagnostic: SG2PR04MB2267:EE_ x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: xfjz3thTHc91wUeDTOsKcE1t1e8phXvuHqJRjD73iPx8OUzNB8R7Po29CT2Q2JxFh0qWsPail600DJKVcRmc+fFJrqwOoFWa/5+ETjYTnmvncNycjdhqgbxs8SFKMytlf2a8z1PM4eVQCG0nZe4EcWWglkiXcx3tTQnZ+shYtsPS9B4Gge0syHNHfz5t8OkAV+PNg0K7fW5OsfloBB8c76wWNZAdtr3E7wS0MRFXJ2VU1n1uC0GFQTk4Ie23S9Rq60Ukah/2jhqaRYi8DXUlh9r2FztV6KBkwIzS4t+hRwhv+LqAB+HeoYrZtPChPQSPdLOUoO4zQLGzk2uq3CWnvq+2kLhQhFW10gW4BK0Pj6y6AGMMSv4AbQwFh3OlSsG0t1l61et6+ruv3E5NvCs061fIzh0FuIJ7hbbhxl0oZPDcSJWQgzChmvk7Qs8SddlFT+xWueF9qRSUbBU9SFYgX/Yo7kFEYQ/tSIZWy3huDgi6x6/wdoJS1blUFtEFmDX1k251R5NxXB4K7IglpnGddeHDE2y5F6A/nYG2qV5PWGVeyyvxxBYzerZBBfqCv9ZuOlscvZmnfcA9X+ZrobS2aUe1ewbBEIjEGuxIe9i+nW49VPX7+mOS3WySoRtC/SlIq49sPHobv1mOqrhECQpOVfdKbAJzqJkSHQ3ypnxjSeiuN/3yQftgFl8uaFTTXeLCh/nBT63wdvx/EadLjbw0Vg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HK2PR04MB3891.apcprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(8936002)(107886003)(66476007)(64756008)(66446008)(8676002)(9686003)(66556008)(110136005)(82960400001)(38100700002)(4326008)(5660300002)(76116006)(66946007)(52536014)(6506007)(2906002)(7696005)(33656002)(186003)(26005)(86362001)(508600001)(99936003)(54906003)(316002)(55016003)(122000001)(38070700005)(71200400001)(83380400001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?9n12js1Cpfq/DFj5XtfY1rXFXagT?= =?utf-8?q?jTD3DRIY74mdjLrjhlvwULTQGAm1OPbtVeI1I0txKhej0UOU0xNlA3UoL7+U9IkQa?= =?utf-8?q?4la/IzSa+7Q4A0DiWeZslDqUzsxnrymcaOw8wxWgkA5Yz+ZUMm0ZY0fr53SXk/JJt?= =?utf-8?q?ZiFZrJ0F70BxvDaQgxRnbxKe1r2Dgdq7gFlBbpJkrBE4QTH7dzhTOXm9x4aOMqthG?= =?utf-8?q?+6Kek0Yezl4vSqM8tczkGPt62t7j+EULyhsF3bNxOVS4y1oRMBDwBylFo0dYB91yT?= =?utf-8?q?P8OYwEYmqT+r5v2dh1kOtwWQdbOxyEkG/wA80od75ZucPaOb+O+Mt0oCWH9HFTNiN?= =?utf-8?q?4OUj+fghgMc9SVLbFEwldzwIaf50mvXUL9JzjO0QvP+GlTiGmuRhpSmqr9bxUkxo6?= =?utf-8?q?V7MyLXER8YMnTpfCWJrXCtemgd54X1RG3OummDhmb8VlpjZrWHNgEV01F7pq7oj+V?= =?utf-8?q?fCw6yUwIb3/gWDc32CePaQOpFL0AoKaQRJuG6d4T+aarJxcLH6vxIHBqSJtRbRmcJ?= =?utf-8?q?Pevxx/bK+Tk3Hh1rmzJwtzkPLk0Zj6OherS6ns6+NYyUXaHwxNuwaKqdvJP3szcHx?= =?utf-8?q?NA3GkS0jMpu2jIovwuwPiZawTh9XGmuO41UuNsj9u/3/vaHT8jDcYDpLfz/7mzD1L?= =?utf-8?q?zij3B529sfriae4xdOYB+VnkEGrp4QlxMtI6IarKkhoG6jETNHBQ9IOkBQCATUrPL?= =?utf-8?q?4F80jEhHQvriCVQMxDA94YK3gYUjVVe++ctiKc9ZJ8bXfOo6T7hQO1ZskkeX66fai?= =?utf-8?q?PXvE/gpb69N5LoVJ5CcnZAfMN2nrFxGNevszAgubVPnzHGpmamYR/oXwseKAfZS46?= =?utf-8?q?vlbDrzVOzT3FB+egVT35GOocCunwQcZKkgr4/e6pWqIMD8WhskZUcBtcTBvDLVqVy?= =?utf-8?q?mHAzry4xbt+ELu4OFsn5DKJaYF2YcpzQGTEWBFTHVQRijnw/mMhoHWJNzLXlatb3S?= =?utf-8?q?ZiR4Qu/kMcdNnMXKaUt7MdHKOrj81YaAN/EcBAT5qgrceYhUL0FgiIAXZUiTETpGP?= =?utf-8?q?oST4du703XCalMH08OjejQZGi+cxDy5ZORvZhsWfCjnrA2hildtwSg0aHDxmnYHYJ?= =?utf-8?q?/GhPyyeELgswMAmz0RfH2e8QtibvnKbB0jF2d/wHhyI0Lfm0JXLSFk/7kob8I8yyU?= =?utf-8?q?1oAE935QFjdvHnePzDz4Fc1obFU4qUXz5th24LZ6rv4R7cqHgAWXtcAt92CHRGOq+?= =?utf-8?q?JQYMo4Mi/KdsRd+KoyY3QxJnnszpTqVfrKzkg0we3Yzz+GiFwjxXDbFIUrO/7pPIj?= =?utf-8?q?V6zrkvr/juxc3f2GO5CV6rY5jPVAkcPI06vLqJsLUy5mUAW9Yeh8SvwHhxpH7kEAa?= =?utf-8?q?gHssSm8V1iubSLKIkjhNWOZXucyO+L2x70S6P6jjCa2CFVMVAMlOc37Y6SmCktpq+?= =?utf-8?q?jFNJa8mXFIe3BW3jdD7FOhQvR99Sm5HxSs6x5DI7eVFn6zUearGRi+CgN2VaV+3tA?= =?utf-8?q?qGlIKxVH30Ey0DMou3zWpCi/WbFo1i0zacZCtHGzuhE/HihlXJuXlTT7qCY6OugrM?= =?utf-8?q?3S8me5jhi9+yXj5dgpxBMYDF110Fc+Fc5Akaa/BPJeMjMMAnzf3k9UU=3D?= MIME-Version: 1.0 X-OriginatorOrg: sony.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: HK2PR04MB3891.apcprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 36873832-a971-4909-300e-08da026e9232 X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Mar 2022 08:18:34.8298 (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: SeWI+cFu2Xi2gVoBHdRoYjY6OMvnhG1ZwweJ+iB5tlGhkJCag5nTDnX0aNQvE77NBc1TtHRJ1abBxcwRyB++KQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR04MB2267 X-Proofpoint-ORIG-GUID: 714v8txXGxVOLMxEYW_tVmo5tOo-sEcw X-Proofpoint-GUID: 714v8txXGxVOLMxEYW_tVmo5tOo-sEcw X-Sony-Outbound-GUID: 714v8txXGxVOLMxEYW_tVmo5tOo-sEcw X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-03-10_03,2022-03-09_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 priorityscore=1501 mlxscore=0 suspectscore=0 clxscore=1015 adultscore=0 bulkscore=0 impostorscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203100043 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Before this commit, VolumeDirty will be cleared first in writeback if 'dirsync' or 'sync' is not enabled. If the power is suddenly cut off after cleaning VolumeDirty but other updates are not written, the exFAT filesystem will not be able to detect the power failure in the next mount. And VolumeDirty will be set again but not cleared when updating the parent directory. It means that BootSector will be written at least once in each write-back, which will shorten the life of the device. Reviewed-by: Andy.Wu Reviewed-by: Aoyama, Wataru Signed-off-by: Yuezhang.Mo --- fs/exfat/file.c | 2 -- fs/exfat/namei.c | 5 ----- fs/exfat/super.c | 10 ++-------- 3 files changed, 2 insertions(+), 15 deletions(-) diff --git a/fs/exfat/file.c b/fs/exfat/file.c index d890fd34bb2d..2f5130059236 100644 --- a/fs/exfat/file.c +++ b/fs/exfat/file.c @@ -218,8 +218,6 @@ int __exfat_truncate(struct inode *inode, loff_t new_size) if (exfat_free_cluster(inode, &clu)) return -EIO; - exfat_clear_volume_dirty(sb); - return 0; } diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c index af4eb39cc0c3..39c9bdd6b6aa 100644 --- a/fs/exfat/namei.c +++ b/fs/exfat/namei.c @@ -554,7 +554,6 @@ static int exfat_create(struct user_namespace *mnt_userns, struct inode *dir, exfat_set_volume_dirty(sb); err = exfat_add_entry(dir, dentry->d_name.name, &cdir, TYPE_FILE, &info); - exfat_clear_volume_dirty(sb); if (err) goto unlock; @@ -812,7 +811,6 @@ static int exfat_unlink(struct inode *dir, struct dentry *dentry) /* This doesn't modify ei */ ei->dir.dir = DIR_DELETED; - exfat_clear_volume_dirty(sb); inode_inc_iversion(dir); dir->i_mtime = dir->i_atime = current_time(dir); @@ -846,7 +844,6 @@ static int exfat_mkdir(struct user_namespace *mnt_userns, struct inode *dir, exfat_set_volume_dirty(sb); err = exfat_add_entry(dir, dentry->d_name.name, &cdir, TYPE_DIR, &info); - exfat_clear_volume_dirty(sb); if (err) goto unlock; @@ -976,7 +973,6 @@ static int exfat_rmdir(struct inode *dir, struct dentry *dentry) goto unlock; } ei->dir.dir = DIR_DELETED; - exfat_clear_volume_dirty(sb); inode_inc_iversion(dir); dir->i_mtime = dir->i_atime = current_time(dir); @@ -1311,7 +1307,6 @@ static int __exfat_rename(struct inode *old_parent_inode, */ new_ei->dir.dir = DIR_DELETED; } - exfat_clear_volume_dirty(sb); out: return ret; } diff --git a/fs/exfat/super.c b/fs/exfat/super.c index 8c9fb7dcec16..cb6b87c1d6b9 100644 --- a/fs/exfat/super.c +++ b/fs/exfat/super.c @@ -100,7 +100,6 @@ static int exfat_set_vol_flags(struct super_block *sb, unsigned short new_flags) { struct exfat_sb_info *sbi = EXFAT_SB(sb); struct boot_sector *p_boot = (struct boot_sector *)sbi->boot_bh->b_data; - bool sync; /* retain persistent-flags */ new_flags |= sbi->vol_flags_persistent; @@ -119,16 +118,11 @@ static int exfat_set_vol_flags(struct super_block *sb, unsigned short new_flags) p_boot->vol_flags = cpu_to_le16(new_flags); - if ((new_flags & VOLUME_DIRTY) && !buffer_dirty(sbi->boot_bh)) - sync = true; - else - sync = false; - set_buffer_uptodate(sbi->boot_bh); mark_buffer_dirty(sbi->boot_bh); - if (sync) - sync_dirty_buffer(sbi->boot_bh); + sync_dirty_buffer(sbi->boot_bh); + return 0; }