From patchwork Fri Mar 18 07:15:25 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: 12784939 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 0979CC433F5 for ; Fri, 18 Mar 2022 07:15:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232971AbiCRHRM (ORCPT ); Fri, 18 Mar 2022 03:17:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229650AbiCRHRM (ORCPT ); Fri, 18 Mar 2022 03:17:12 -0400 Received: from mx07-001d1705.pphosted.com (mx07-001d1705.pphosted.com [185.132.183.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9CD01C0242; Fri, 18 Mar 2022 00:15:53 -0700 (PDT) Received: from pps.filterd (m0209328.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 22I54K9g011253; Fri, 18 Mar 2022 07:15:35 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=QbwulrNTUmrVcOTrYTaz8ovNE0l9wDpZHSzXCvxOKwI=; b=iaAYuQxRqG5Kolw1hl0oVRR6Ato72X1HfDKYtVPm4Mt3vLUJq8v+GfDgCWVvpw0wUz2n oqOF6EQ5oiT7MfFJNp7qSPCeTJ7MZW7nTUpL96+JUn5KfBrfTbBcVxnqmBqv1WFd/UlR Nkj4Wm8Ht+OdekMvYQm18zrnSGk2Ixoz6TGHm/zIgNnClsGZLu3RDnFtXit/qd4ZSW7G hX44nUE8Z8tShW+456JbQSFJUI07FtKBOswPrbnbNg42h2s+KXkiHZd2L8GeOeYAAxA5 f1G73fxcwpvDZsJK+t2m5w9ozlAUWvsb206gM8aeSIyPcqhOVB5dTeiQ14sUVBYB99Jy jQ== Received: from apc01-sg2-obe.outbound.protection.outlook.com (mail-sgaapc01lp2108.outbound.protection.outlook.com [104.47.26.108]) by mx08-001d1705.pphosted.com (PPS) with ESMTPS id 3evgjyg7x9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 18 Mar 2022 07:15:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L/W/iAWeGTWmzDQ68YqMjt4IgWq3Y87gGbtI8IU2rGBEJexicRX3xC5Nm2guAx9fw7vCIUKNvqOVSZo+PXFvprMgOZ348w8uWPSyejCkGEmc4ptA8aFjkayMQTWOFxG+x4z7aszT8Ax0vxODZfTFViCEiz2eaK/Rm8ifiUWimHEazIDagQdeZCPLgy4CHDqJBWMscOpDIr14UqE+z+b2AgFa2/K8uYVMYsdKodGp7ixTcSB9Pf6Zvv+LNHBeKYkOanPqI+FbEZNLySNInwZVQszodahZl5WsyV+oKjU1WqrxQtS3pFWjLqa+7Xk5cRItZjHofACIRbd9UAE7eHYtlQ== 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=QbwulrNTUmrVcOTrYTaz8ovNE0l9wDpZHSzXCvxOKwI=; b=OMbze9yusX3a4WTtO8JARfYKvei7m6HTr4pMuMM7lm5Itfh1Txqdk3shaDCufaumhldf16M/gMTVpYe1FhAoKlgbVfXimQc3q5TovNZpJQUtFFaiaAjKfuWbz9pz3brU7C2TZkZtLw6d2YhMNS4UhLpu7bL+3NjacJSj3Bc42kn6XALzx4df4C1dUKwK3dIXaBOHTK7LaDb/pTOUgf3FylYaOLTK39wvvbmuP0jxu1G7vgy3Xxhn8G/U2Y/+KX03Kg6dhpc86yMgCBX7EQ7/3HzULkHPyli4jojed2FUSYAjwZaKfXS9HKcSoDVtz3od675qdh+zjpEH+mPIduqHcQ== 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 PSAPR04MB4407.apcprd04.prod.outlook.com (2603:1096:301:36::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5081.16; Fri, 18 Mar 2022 07:15:26 +0000 Received: from HK2PR04MB3891.apcprd04.prod.outlook.com ([fe80::7440:bc88:211:6094]) by HK2PR04MB3891.apcprd04.prod.outlook.com ([fe80::7440:bc88:211:6094%4]) with mapi id 15.20.5081.017; Fri, 18 Mar 2022 07:15:26 +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" , "Kohada.Tetsuhiro@dc.MitsubishiElectric.co.jp" Subject: [PATCH v3] exfat: do not clear VolumeDirty in writeback Thread-Topic: [PATCH v3] exfat: do not clear VolumeDirty in writeback Thread-Index: Adg6lzDjhk7fjGoDQ3egmYNh+h6C3Q== Date: Fri, 18 Mar 2022 07:15:25 +0000 Message-ID: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: yes X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 6491c9dc-39ed-47d2-b477-08da08af132d x-ms-traffictypediagnostic: PSAPR04MB4407: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: Y7fzBPBK7Gje8SlLQokt6acly4mHxPpyawtUZrHOOngqfnvDDOZaUHayuNqcJQe9MmCkA0JkhO7xcFVWmning0l556fXT+uVBmw9B/YHz4E3V3Gp8hJB3xX+3L7GH2SwlHNY2RDtDguH40+5gF5JB2yQ+dizqzY2dVtGZ79EfdCFgV1+PmAFKCrqZOuIOLa4W+w9KE2eJ1c2ZKMG3GpNcdF2cxOJK1L5ihmX4kBHuCWWiF5PqTfwU9Hp7tnkzFBkiAv4e2nfdVhxYDkTI6FrOZWdjQkbOsMaRuu9WWICbYIFEA0XvyJBvyAeiAhh3qK/CoCFKn4pJMcS/j03U7u/VEGibJEDUBz40MbJXwUfT6sQfF0AIe4sGqnSyQJ5KcQkrZcQI5VLAwPiwUPeDOPsMIiFbhmKzz4tfUt7fqvXBQRR14m4BVTfIRdoEdm9DSG8H1s3RXMsCqZqizIQIsTLnQ+wHKL0bPnW96SgGEcgIXFrIhUXPaEbMnAH0etSpIPSYDyVy5307/uxUpa4fUD05f4PWB7Fx5WrOrEowa5UwKbYpYehXN9jiRTDySihsG/FjMPk3Tnht+TAjxqzbEtA0m31T/6hbtFqioHXRqIvAGnmn1VoSvoK7ImaF0r4CvOxMPbCAVbZAW7cpJgImesC6EVj1oVboMNIW8h4ay+imrIyVV7zmfwFsVuym9VtHIacrE5k+0y4j/5s/+fvUmRGPQ== 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)(9686003)(122000001)(82960400001)(99936003)(508600001)(6506007)(7696005)(38070700005)(38100700002)(83380400001)(186003)(26005)(2906002)(86362001)(8936002)(5660300002)(52536014)(55016003)(33656002)(316002)(54906003)(110136005)(66446008)(66476007)(66556008)(66946007)(8676002)(64756008)(76116006)(71200400001)(4326008);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?XVCpkRpBZjDon5vX90vDTt9JTeA1?= =?utf-8?q?57Z1f4amoAFQB10MU0J41HN+h3PhfX+nkRVfrYYR9A4xqgmJtrs3BW6Tv1T03btrO?= =?utf-8?q?UsAs6SXLTF9uTIVyy7EI92gNn2hnOxu+8MMCGrNc+8N69gagg7NCitpU/52+cQkqx?= =?utf-8?q?iWdgBnY6O72GzXAUmJ1kKFQw+bea6sZojYc4IvSjQ6voOP27004d3z3GZ0bYoBynK?= =?utf-8?q?mMCAHGwmb9CHLfttfP3FyiM7QCOJw5bVGkpT55pidHF9OUGZ2WZ9L6UX/ERbP0VE5?= =?utf-8?q?lI0sHk5UIQGm8jTk4InE01WQGXQFex4a2PmDGLZBbSrLSnX1BiOuHtA6m+DrcaZs7?= =?utf-8?q?noN62aeBzW94C5zKlAal7zun53pZCz7+hGQ3nHQtkxWgnZVREtRUh+k+yRajjd1dt?= =?utf-8?q?Yv3kF5HAUVmCu29i2HVCIKHpXfJJM1rGRAGeZmfAN2lN358TvSbt9ocZuLLJG1Wqz?= =?utf-8?q?6ETNFDf/G73kzzhU3Vdn9CDUL+rJkDRgDjqjA0uZ/FlttBRUOrrnPtfbPB7/uCh/2?= =?utf-8?q?gt1zNqNprudZUKQXNQfyaiPEZ8fjPhI6S3O/plnb1f+lVGISIhI+MdbsGx6qCO/ZC?= =?utf-8?q?Ri1KIvJ3j9a44f1jby1G2Z6FyFNQIuzm/qm5R3adN+AHD2R00euEvgQTZI1c4HFi7?= =?utf-8?q?LKSGKQdCTqmhPUqW9xm0vJY6928T3z5r9SHgqFEdO2RJGl8JxWFfhq1zs9RX09lQk?= =?utf-8?q?CQXOFmUkl5m137BDgh5NWogQ0g6OUV6bMeO0YJiwRsRqSBAWiu0lRE5uCkAxvj4+M?= =?utf-8?q?9eeiWl654XwT+CjnGeCnJqLFmKKua9HNHd4kTHaXnh3rO9NZYGbfLJq7FT1Ij1hDI?= =?utf-8?q?nYEVzzVh/VlxP1MA0mO2kujVHtKbcgBv2Lt0toKPQrdXAIo2qbS96BhG7aNLS+d56?= =?utf-8?q?Xgde8+xe/HSrRFqgldMtVGgrCPh6wRfHcDqgkV0IOWJFgRTe272G2tmtXcbdI4DZS?= =?utf-8?q?jqbufABLblPSPDofZeI34ywibnHgWZdqWbRviTFi1onFwD8LtNAM3/QvR61zudNx9?= =?utf-8?q?oqc56ulH8d0ic7b1tPUy2rE5E2tytyNnKzLIJqEHHmt9tCYmN+sM1wuXkBwXQo/Qp?= =?utf-8?q?W3lu+vptGR2ZhxHpL7G/huVqHb1+bWr38LjepvbDfU3n8BEIAxl9hYOGu7IbthSw6?= =?utf-8?q?qiwIjwSc4GJxuil2RTaLF3letBdGOCbHHDA00CMJ98XUtG8uebJX0cssBGnGdfrdd?= =?utf-8?q?kVZf9+BZGfIor4uWbW09cjh0EjV+yKscGsYUlOBsdVAVGfSc4ZVVws1FKDYXs6G49?= =?utf-8?q?KzPHTwyY8/38FhjEOF9vVF4YXpkRTAN9Dy/SS1LMTC/vAk1S0yOJhwvFrzlOygeuR?= =?utf-8?q?Ft4W/b0WKHZsld8PsZ+ILA2SLfUIbv2ZLI4A0LBAEkmEQ80dZq4FA4HP9pHUCmhHe?= =?utf-8?q?LaN5TPS2qlvGmX?= 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: 6491c9dc-39ed-47d2-b477-08da08af132d X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Mar 2022 07:15:25.6814 (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: aLih8PkP+95dil4yC/2FNBY6zBEbRsPckhE8qHhUMyp2m8VrJCLrdS6Yp4TwVMh0yX53EVOkka4U9fcL4kz/vA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PSAPR04MB4407 X-Proofpoint-GUID: fT0vY_vIuNa6CHEf-lK6xz1ocQRdzEWn X-Proofpoint-ORIG-GUID: fT0vY_vIuNa6CHEf-lK6xz1ocQRdzEWn X-Sony-Outbound-GUID: fT0vY_vIuNa6CHEf-lK6xz1ocQRdzEWn X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-03-18_06,2022-03-15_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 malwarescore=0 clxscore=1015 priorityscore=1501 impostorscore=0 mlxscore=0 spamscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 lowpriorityscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203180038 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 --- Changes for v2: - Clear VolumeDirty until sync or umount is run Changes for v3: - Add REQ_FUA and REQ_PREFLUSH to guarantee strict write ordering 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..c1f7f7b7c4ab 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, REQ_SYNC | REQ_FUA | REQ_PREFLUSH); + return 0; }