From patchwork Tue Feb 8 05:18:57 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: 12738207 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 5CCD4C433EF for ; Tue, 8 Feb 2022 06:00:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245289AbiBHGAv (ORCPT ); Tue, 8 Feb 2022 01:00:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232896AbiBHGAe (ORCPT ); Tue, 8 Feb 2022 01:00:34 -0500 X-Greylist: delayed 2473 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 07 Feb 2022 22:00:33 PST Received: from mx08-001d1705.pphosted.com (mx08-001d1705.pphosted.com [185.183.30.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DB30C0401DC; Mon, 7 Feb 2022 22:00:32 -0800 (PST) Received: from pps.filterd (m0209322.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 2184iM1R015321; Tue, 8 Feb 2022 05:19:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sony.com; h=from : to : cc : subject : date : message-id : content-type : content-transfer-encoding : mime-version; s=S1; bh=AYEx30/22S6Pe7WoL4POKsxfuEHRXVrpBC/A8TRJhm0=; b=ptrsLPx0oRnAxyqXAKZUSn+zqt87i3RDUN3xxQ944tw6LaBsTxztSUv9rZSTAaMK7qCB kscYh/CTJBosDJsq0cddHW1HtrAetaXAlR+S/ucFOgZUlvcRQ7s5Z5HsXYa3YkkknDA9 feLntWHRgo/+19fCkes1FXe3vG0I/dcU52aBO0LGeTKjOywl8hYmZIrhvPral+n2NslX qIKsHd3LB8GIfxJarKhHrTcO6PFYUGOZAQAerPOMmtv/bdxJ5zJxFeXFZizNHDRB0mtI 2FftsSiW95PFUBPqoyTSmulS63oKOMMrBY0pDYaYsh3Xx56Wn3mFgSgqeD0bGWpZfwOJ bA== Received: from apc01-sg2-obe.outbound.protection.outlook.com (mail-sgaapc01lp2109.outbound.protection.outlook.com [104.47.26.109]) by mx08-001d1705.pphosted.com with ESMTP id 3e1g16aesn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 08 Feb 2022 05:19:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZwLqb4vsmL4plCIlKU1dXBBtRzGPkojlxorU/k8ohI9NK6s8yTdTIft+LMV0/gUWLg7Ppy9drmIIqKcG5vA+pW9AbMmVwSnXhHohmaITDcqtsMgRDV80cfqGrpHeDkJbxcLAvOXI7VUYd0xIy0OjU930HHQHrCpPgkcaaq4hC6tMroSaYbH4/lflUD2/Qh9CA8aLPFP6AbVKYafnh3WARbcNSNuj4QfwbEbgIAwG8sYIlGuKpTtDO3fYpOTLsYwnOFpiupPqXLutQMdTGkuI7j5U3nU7Ibvod7gzhHlhf29gU+h1PYrqIY36XqPugSsMyoQX+yc5DGIDOkGxp7/GjA== 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=AYEx30/22S6Pe7WoL4POKsxfuEHRXVrpBC/A8TRJhm0=; b=JpwNaW1APy5q1K051pySPkjz/Rj6LnnHJ/ZzNdQKVMqlCCMc4Clcw1zhBwp+95K3Fnl+a1+70WUDCpOp3BM/E2B0pdpUf+dkDJrNCN8IofSOqoXwiy7Sryz9EwpZc7ZUK/Id60UkW6eulvJoqTxrbhtxliYWcT/7OvHEwf+YVccyozUPlxoYFBDuppdcX3EJM2CAHyfL+cqexGWjKvIHR0vMfI5Kwb6AMR0xxA0ozIDkDeIyV4v/5eHkbnfBcbFW1nY2+ufDBHujyeh9kSmAUpaUG4SF0JexDDTX7+CFBfpjtd2rdle8A3ktWoCXFtv1ENH7Yq6RlsNcfTdeX0Vp6w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from HK2PR04MB3891.apcprd04.prod.outlook.com (2603:1096:202:35::13) by HK0PR04MB3169.apcprd04.prod.outlook.com (2603:1096:203:3f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Tue, 8 Feb 2022 05:18:57 +0000 Received: from HK2PR04MB3891.apcprd04.prod.outlook.com ([fe80::24c5:f243:ecdd:80b7]) by HK2PR04MB3891.apcprd04.prod.outlook.com ([fe80::24c5:f243:ecdd:80b7%5]) with mapi id 15.20.4951.019; Tue, 8 Feb 2022 05:18:57 +0000 From: "Yuezhang.Mo@sony.com" To: "linkinjeon@kernel.org" , "sj1557.seo@samsung.com" CC: "linux-fsdevel@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: [PATCH] exfat: do not clear VolumeDirty in writeback Thread-Topic: [PATCH] exfat: do not clear VolumeDirty in writeback Thread-Index: AQHYHKozeVmted1T5UKvjQCq+AaGCQ== Date: Tue, 8 Feb 2022 05:18:57 +0000 Message-ID: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: suggested_attachment_session_id: e9111107-af93-7ba9-9a04-b4d950db9f08 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: a2b85178-3207-45aa-4cf6-08d9eac281c9 x-ms-traffictypediagnostic: HK0PR04MB3169:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:43; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: cMB14keXnm3EqxEJFBh3dmo/h81dA/wBvE5EgzeY5/TsZa1Z1GAnFr4F1Lw89/3FOJIAjOT4SpymtG7Js96AU6dPUMvpzka+wtcRYKOGVLVrcS796dX3zGad8T7JraYMr9/uqH1ed46LGH82QjxBnFgQt6tA3FNaDzTD/EJ6lnwseGlAr7QMGWwTnSIUy7T2y3eOdlE4jpFDjmq7gt65TyL9o6KJYkWTV5j/Hr1Y9UT2ZUAEeF9siBV254KkeR+wgXfoFzttjRpJv/hLTuDRGrV62+nr0NzwhQynEnv5hvh2A1sefHsRrWGeLCd7/FjCJTjawFETNz/R2HekNhyXoGQgpPNgvtgWu8p8y+lH1jl5HnvxPoBh4Dj7z824cGIkMXCgYaH11w99fnpBF2wWSppGKRi35z8MoWDuEQ8Jm3uOY32km1s2FJyagk9oXmA/KCePEg4iy3lOxzUBJL0lGRAHBKN4Q/fx/3c/sgml0u6EvJTJ/lB5trfBUM0Z1XXN1/iiDMWS642E/XZPYKuQzmHk74K7N3xo12/szRE6Qpx2OSxynBltMT1gB/91ab9FZnE2jDz7NKKOelUR8kVw2HTgKwnOJYdpDQ3Ie4nK4SMSIWlzQenUMRkuqTbi1pY2sgZJ/3tA2MLFq98rsfJ2LPZTohOtyq7U6J9q8iT9kGDFnQ8XHE0KA5OXFya5fFpV 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)(508600001)(38100700002)(38070700005)(76116006)(82960400001)(186003)(66446008)(54906003)(8936002)(66946007)(64756008)(66476007)(66556008)(110136005)(316002)(91956017)(8676002)(4326008)(55016003)(52536014)(5660300002)(122000001)(83380400001)(86362001)(33656002)(7696005)(6506007)(71200400001)(9686003)(2906002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?eucgb2312_cn?b?REZjWS9XMXpjNGtJRitpK3Ey?= =?eucgb2312_cn?b?UlQ4dTlaUWo0dXBpY0JYd3YxOGw0b2U4TUNOWmVOVmhZbkxleW9iVGtobFNZb3p3?= =?eucgb2312_cn?b?YjdvZmI4QkxoL2Zzc0d5NVNTYUorRlQ0b1laQlJtcEdZd255bCtWOVVrb1J0SkJu?= =?eucgb2312_cn?b?akpyRWdkSXEwNXNKV281VkxoOURVS3Jxc3p5cTVtNXorQU1helVwTDBnM1kxeDJQ?= =?eucgb2312_cn?b?R0hnRTJydENPZFc3cHhJM3hVN21VbUh3dnhEZzA1cy84ZDZGL0N2S20wR3NTdGdK?= =?eucgb2312_cn?b?QXk2c2EyOCtMZm0yalFUaWJOaWlPQmlPZUlxcnBaTm1zcktXMkdXUm8xTWJJUTc2?= =?eucgb2312_cn?b?M2szQ29NNlhSMTZDTms4N0FFeGI1R3hVM2pURmJ1V2dIVnpWdlQwS3l3WUVmczM2?= =?eucgb2312_cn?b?eXE5MktlcEFVQk9pMFBzS1ovdTFqUG9VSmgyMmYwc2JHbjY5N0M3T2s4VUpQaHdP?= =?eucgb2312_cn?b?dG9GRW11V1UyaHI0U3ZGOXZEZVRxZVo0WHEwQjNjOEhvQk5kcXNOd3RMYkNtbTc3?= =?eucgb2312_cn?b?dDJMbDdaYXBxejl0dS9rdGQzRG1uZ2VsYUluemt5dU9Fc2NTUHNIc2k3a3VjdENP?= =?eucgb2312_cn?b?b0ZNeWxxeEpyRzZHRyttUGYwSE9UZlQxTFQvQk9JK0xkVVV5ZkR5UEVSL21lVzFR?= =?eucgb2312_cn?b?bkZJWUo0SThKMlZOTEtDWlNVRVd3bmRwWTBIWUdXcWZLeG9aTVZNZ1pXVHk1eEti?= =?eucgb2312_c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312_cn?b?dGJVdjhjaWxIempQbGNrK0s3WksxLzJqOXZKNkpOeWY4N1ZycTFUa1lCTXNxRm1G?= =?eucgb2312_cn?b?bXQwUlUrMjhWbXBsNlpEWnFmcFllTHRvOUg2V1dxcHZrdVJQNW5BTWNjUmkwOXNE?= =?eucgb2312_cn?b?U25YektkRnRMR2w5WHJUTjlLNkRGTjdNTHB5dkl4V1JrNDlpLzlGc1JjeFlpeWlC?= =?eucgb2312_cn?b?QVdSVjN0VTlwK0JWOWtlZEY4RVE0V0ovRWlOTEI2YjNEVU5YVHdmRXJMZjVtSHQv?= =?eucgb2312_cn?b?MFBwcVNCN3hGbVV2cmk4MGwyR091N2VjU3pPeU9aai9FUURIaDlaUHlmbjZSb01M?= =?eucgb2312_cn?b?czNOVTJkMnZaL2djdElFeHkzN00yK000UHk0Tm5ZMUtNMmdMZDdtcWVSVkxnZGdG?= =?eucgb2312_cn?b?TjR2d0hyQjlXdHBhbm1yekVMTGpjYitNZU40bFc3c2VlTnFxWnl6bmFGNkVKcFl4?= =?eucgb2312_cn?b?Qy9HMlZLUGxKNXIrbWFvbUdxNWdoYWg1M3l5ZjgwWXhhbXBQa0FTdWRNcjlFTjE1?= =?eucgb2312_cn?b?UWxXQm9rV0gySnd6ZldzY3ZLdElDa1kwRGxYdkFSVXVvMG5lN2hIbUdodUgyUHZz?= =?eucgb2312_cn?b?THpIZC95YWt1cHYzQ29sT0E5ZFg3ZjExQUlUck83ck51U25SUFN6aGM9?= 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: a2b85178-3207-45aa-4cf6-08d9eac281c9 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Feb 2022 05:18:57.0706 (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: kb56fNVVpb//8A41FPEHMvhi68ZnXXi9fWBDs6FWxef6SG3x3234vGhlzqyiF6px4h6uAvod32WIyYDwYMCmXA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: HK0PR04MB3169 X-Proofpoint-GUID: kGt5BMN2kMnxSjvndz8NXTrtjAm0rlQB X-Proofpoint-ORIG-GUID: kGt5BMN2kMnxSjvndz8NXTrtjAm0rlQB X-Sony-Outbound-GUID: kGt5BMN2kMnxSjvndz8NXTrtjAm0rlQB X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-08_01,2022-02-07_02,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 clxscore=1011 bulkscore=0 mlxlogscore=999 spamscore=0 phishscore=0 malwarescore=0 mlxscore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202080026 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 when updating the parent directory. It means that BootSector will be written twice in each writeback, that will shorten the life of the device. Reviewed-by: Andy.Wu Reviewed-by: Aoyama, Wataru Signed-off-by: Yuezhang.Mo Reviewed-by: Andy.Wu Reviewed-by: Aoyama, Wataru Signed-off-by: Yuezhang.Mo --- fs/exfat/super.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/fs/exfat/super.c b/fs/exfat/super.c index 8c9fb7dcec16..f4906c17475e 100644 --- a/fs/exfat/super.c +++ b/fs/exfat/super.c @@ -25,6 +25,8 @@ static char exfat_default_iocharset[] = CONFIG_EXFAT_DEFAULT_IOCHARSET; static struct kmem_cache *exfat_inode_cachep; +static int __exfat_clear_volume_dirty(struct super_block *sb); + static void exfat_free_iocharset(struct exfat_sb_info *sbi) { if (sbi->options.iocharset != exfat_default_iocharset) @@ -64,7 +66,7 @@ static int exfat_sync_fs(struct super_block *sb, int wait) /* If there are some dirty buffers in the bdev inode */ mutex_lock(&sbi->s_lock); sync_blockdev(sb->s_bdev); - if (exfat_clear_volume_dirty(sb)) + if (__exfat_clear_volume_dirty(sb)) err = -EIO; mutex_unlock(&sbi->s_lock); return err; @@ -139,13 +141,21 @@ int exfat_set_volume_dirty(struct super_block *sb) return exfat_set_vol_flags(sb, sbi->vol_flags | VOLUME_DIRTY); } -int exfat_clear_volume_dirty(struct super_block *sb) +static int __exfat_clear_volume_dirty(struct super_block *sb) { struct exfat_sb_info *sbi = EXFAT_SB(sb); return exfat_set_vol_flags(sb, sbi->vol_flags & ~VOLUME_DIRTY); } +int exfat_clear_volume_dirty(struct super_block *sb) +{ + if (sb->s_flags & (SB_SYNCHRONOUS | SB_DIRSYNC)) + return __exfat_clear_volume_dirty(sb); + + return 0; +} + static int exfat_show_options(struct seq_file *m, struct dentry *root) { struct super_block *sb = root->d_sb;