From patchwork Tue Dec 13 02:37:05 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: 32602 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2594481wrr; Mon, 12 Dec 2022 18:42:47 -0800 (PST) X-Google-Smtp-Source: AA0mqf5DPTTKYrk1ZHcMbQuvPHdjO/nF/abbt7v1Gck2skCxS2EfbNhpFybpyNLud2xhKpnOxI0B X-Received: by 2002:a17:906:5f97:b0:7c0:e0d7:b73a with SMTP id a23-20020a1709065f9700b007c0e0d7b73amr16915632eju.68.1670899367322; Mon, 12 Dec 2022 18:42:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1670899367; cv=pass; d=google.com; s=arc-20160816; b=B+DbkDR08ZEsdlG/an5RUlszpZZjqPFmMZ6C79JdPADBhk+27RJzwdajXztV0sfoTd zN8vzhjDzIrmAZkdWY+MzpMd+e8ckYLeLlaWw2S9perp+GhvN+NcnGL0g4NQdTtXki/7 7mMYi+VswMF4KwG6asR4Vj1NLmwxYrCyEKieqpt3J3PsbpEJdHPgpWL9y+nk2EIhoxlM crvvbgtkr/Kk6aJSFOnPNT+xlwE8XBHYxWpQuTMXou1vo+NFiwNukN5D/0Uw29ODotbW uZECObChexwXep7mJAGpXv9BFJ3z075922K46+BAvdpNCaUcqQiBOH7r8s2CrXiOWByo BC/Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:accept-language:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature; bh=PSMaimujD+GcIpTakMpqfamqwhGTGdsLu8ggA+LdFq0=; b=MMU3RIC/YOoFz1KfJ4sc9ANErrK5j7PYPVZKG5juvOVDKAJlv/RgxFrdTPQqT6VUFD yLEuERf8gNeuLWviczgBdkbhvbVFlAwDWA+XgBftZNsO5Sz+FecpLcuRuS12CeuI0rTO Oxtu/J9NAhnM3JG+LMA23D+V5umUJD6XemxDS9QAi0R2W7Yvom88NuZLzcDIlNNJu111 JvZulLLx1KNwijRW1Ak8YpqIzHX+2fK4o0e+ezXbWF4CFisWaUetTzqIYg9ZgahdXPFm ltxmfAf3IAqrK+GVVTHrReXJqceIZ86Cyeqf6HTrwjhHiW5uyJPalixZBCpTnd/PFQre /ttw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sony.com header.s=S1 header.b=Y1ebObPk; arc=pass (i=1 spf=pass spfdomain=sony.com dkim=pass dkdomain=sony.com dmarc=pass fromdomain=sony.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sony.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id js9-20020a17090797c900b007c189b2939fsi834056ejc.482.2022.12.12.18.42.23; Mon, 12 Dec 2022 18:42:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@sony.com header.s=S1 header.b=Y1ebObPk; arc=pass (i=1 spf=pass spfdomain=sony.com dkim=pass dkdomain=sony.com dmarc=pass fromdomain=sony.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sony.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234282AbiLMCjP (ORCPT + 99 others); Mon, 12 Dec 2022 21:39:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234278AbiLMCiE (ORCPT ); Mon, 12 Dec 2022 21:38:04 -0500 Received: from mx08-001d1705.pphosted.com (mx08-001d1705.pphosted.com [185.183.30.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 680371E735; Mon, 12 Dec 2022 18:37:20 -0800 (PST) Received: from pps.filterd (m0209321.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BCMKDkr027794; Tue, 13 Dec 2022 02:37:11 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=PSMaimujD+GcIpTakMpqfamqwhGTGdsLu8ggA+LdFq0=; b=Y1ebObPk+gwBPJ+nM78q4/8Oo4Q1s6THlTA1FIcB7qyc7MppMmrDC0E+pXS8Udsc+h5q WhvHVr9am5HB6MsLHMXMYd6yba6s4iAD2FeGgwEIfiAw34l74q7BZbSP2hu8sImXT8aq LuZ4lwGpHP7ZYGDuvuZXA5exOpR+SmzLRE3yuUE9pb14CMfXfFidz56xRD4pJa8KRTvJ +B3OVt5+mZKesE2ckg/Hs9/oAkvySdS3gLdqsWMBLwmKDF5qSpwhYjR5Qkl0SrbHIJoH ndzAcR/pF2wkfPn6T1dRGIEwE1eACsY71UnlsnxQZMgPWcJQt1yXOBExvj4NyNN1/lXU MA== 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 3mcfh5jkrm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Dec 2022 02:37:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JXWmK3hqarR7EZ9JTGLTWYQorv4lCTi07xttNomS0JMAsfGA/IHFqwbnPz3eLg+Cw0lXxPcuOBjijNu/59++5RloBfZbLtEI7Fet6Qnh3eG60oEikdxb3Rp4+irDpckLhGnKkwXd4Y4nSe+iiizxjA67JBbslkbW/Bcs0iWphPuNUBnVG/asq6J1I47/WtKnZAUthOgQszVoK9xduCUIwEgv7KnxozKTFJfcwU4fawGGq6+3JXzaXLPo0rHSYLHtUQMNEw2W+GT4KVkvnXtf3Y69h36jpagV28RVQ84ddMHR9OAkjpBb6ilHq8pzXaxAX+ZM95B4cS2G5PSbvdg08Q== 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=PSMaimujD+GcIpTakMpqfamqwhGTGdsLu8ggA+LdFq0=; b=EgG2hTxiEHmF34OxshaKUFa7GXxZWdwNIoRO1zs/abwf4zaesFwsDJa+MfAvumsrNqSXY/d/Om2MYFpOIhVt8EhhLRaYEWRP7LbcrcPBtqFxJp88+nR8DUu6YO2/wzCGiwzlW+7ICUebbXhi76vGh0SOiSSXVcteh9BUlzM0kGwB8IgI6mIn0yaV9jrZhr3eAHUU49iri/eki3LpG05XSYLnCKa+Dt3dN8q0wC2EzNC5C8vypDhrakdDCycqxM/0W5mdha+U+Tisz3o0nMpcDfNLRRDbxSRGdkVE/z5nF5CGGuM4pfnsKyX6hmn0C7HWSWDKxXQ4a9XOGfohewUA9A== 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 SEZPR04MB6948.apcprd04.prod.outlook.com (2603:1096:101:e1::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.10; Tue, 13 Dec 2022 02:37:05 +0000 Received: from PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::c689:d665:b3a2:d4de]) by PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::c689:d665:b3a2:d4de%7]) with mapi id 15.20.5924.009; Tue, 13 Dec 2022 02:37:05 +0000 From: "Yuezhang.Mo@sony.com" To: "sj1557.seo@samsung.com" , "linkinjeon@kernel.org" CC: "linux-fsdevel@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "Andy.Wu@sony.com" , "Wataru.Aoyama@sony.com" Subject: [PATCH v2 5/7] exfat: remove i_size_write() from __exfat_truncate() Thread-Topic: [PATCH v2 5/7] exfat: remove i_size_write() from __exfat_truncate() Thread-Index: AdkOmkJ0uiTVDE8BQKmjN/VSAzn0eg== Date: Tue, 13 Dec 2022 02:37:05 +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_|SEZPR04MB6948:EE_ x-ms-office365-filtering-correlation-id: feb30d9e-2b7d-4d92-4d7b-08dadcb2eca7 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 8hjfPxKoevsSQodnVEDgt0HXLl7Oo0rKXK47kYgoBGuGnImFOxs0v390aKHZGGz27kHNlmcBF2gZNetGhK41Z6HN/XcJ6EW4ZcwmqZyoy82bh/HZZQbgzBKU9Cw0+57aYV43zO+KYQPlR+MnfKAyxVigoAIfLeLh24/0tE0aqI0lwIl83p/JSbFtbIAO64E4E4000VueczBVotZ8QtvtX+2c6LEwi8l5t7CEsAzIlx+HPyv2T5XhvgHxbS+yVzshN531HnSDLpbJyE80Qrx14mvE/yxNjPW4+gXQa8P/zRA64kteuN84o+IPPj9bS4RDFoJ/YNSwMVwgq8CQSUfiadJMk15iLwiZ0kuBTqQECQ9u4sqvk6KU4nzLzwA5pysjp5WuxPj22x0SZ+vj/bGRJdn8n+IuHgCu1xIOGuGo4tLq0efrv6rwoEkuslGRmZ0G18jpfMe9SxOdNR0jrmL28IZWOluXR0+Fbsy02Y77SA+j0srKrmiLWyYcVDDuwvx4VwyFZfpnpkPXml3Iz7Y2DZYdCska0vDOTdXm9KvGmDJE7xlksvgnrI63wl3qyjLNz4rv2kQCIfRtzn5x2zsJSgWkWaCcj0NTyb2N3Wjho+qZvDrtJXQNK7EGHICgkl3uXujfElUU+9oLXw5vCNL9V3huYJziHxQ6AFGWsKKL2m3AY77HLcOrYl81yQ2e1AySbYSEYVCwwvXM4XFRwqpcNQ== 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:(13230022)(4636009)(39860400002)(376002)(136003)(366004)(346002)(396003)(451199015)(86362001)(82960400001)(38070700005)(2906002)(8936002)(4326008)(8676002)(66946007)(66476007)(66446008)(64756008)(66556008)(5660300002)(122000001)(38100700002)(33656002)(83380400001)(478600001)(110136005)(316002)(54906003)(71200400001)(76116006)(55016003)(52536014)(41300700001)(6506007)(7696005)(26005)(186003)(9686003)(107886003);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?N5sWusW3M//GhKDVPWxN2bSpUAQf?= =?utf-8?q?UsWzoqSLsVBu03Rs9dMWbhevAkeP2O2qw+yY5jAbU02w1NY91+QTN7knvSfZ/EZ4s?= =?utf-8?q?QVD4Qesc3/zVgDNqvPOq1s43nZwGt/M3ZgaMTw1TX3/GKwko1vP2oDSNo2Ljd83CW?= =?utf-8?q?K5BcAIdpd2Kr8w8kdhmMKpt6HtyDgWdyCr9x0/VmPtMuRf0JOzpkouaSLi2Ml2Z6B?= =?utf-8?q?r/RQ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9ELRuYFKYiWEzUm33gzJ53rEJXViL5nPq44fviUuM6vP+PgrruSem8qRFv7tR4z?= =?utf-8?q?FwvVTj9CMvSH42OxCsn3t+mgh/EYKYPK5+QZfTtLDozpaRYxf7cQNmGMESckL5FQf?= =?utf-8?q?CaOoG6F2xUfufZ7Iz1qt7jW4zrgl+MGcdPzyOnZ5hKDIVbcmfwebvXQVZlrkjlK9b?= =?utf-8?q?p0vgI1sAIN/aCF2JwC0OpOqF+j7T3QZcpnS/NC24YPUw4gKOVBuumL6ZDrPLKvEG7?= =?utf-8?q?desHLNEMrZFFonSWPdmKiQNNTwMGB7bBeiUWKDe5epmwKb0zKX9TqnOvETpcR/6u7?= =?utf-8?q?jIWmFRGU8NawDrRpxweNVp2AXo6nbg7/0IjXBgjHOTJfs6VSGAZbDKqQDYDcdGctZ?= =?utf-8?q?JIq4S/lUmzxHyzi4ZTi+rdj/eEcVFQ7VlIbVYKwNNNfDaI6d72nSKaqC+NHm3ukTT?= =?utf-8?q?sUv2AsLwQriX?= MIME-Version: 1.0 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: feb30d9e-2b7d-4d92-4d7b-08dadcb2eca7 X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Dec 2022 02:37:05.8867 (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: CP5Ok2Qe22XZugFx3bz3PuPVjMM0/wPaJ10hBkMJEwn2nUkWRXZNDxMCZxduF2JdmHUJbsbkxEjonjFbrtaY5A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEZPR04MB6948 X-Proofpoint-GUID: SvMlE44TsVIeAfjjT2GCEAm92TCn90ap X-Proofpoint-ORIG-GUID: SvMlE44TsVIeAfjjT2GCEAm92TCn90ap X-Sony-Outbound-GUID: SvMlE44TsVIeAfjjT2GCEAm92TCn90ap X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-12_02,2022-12-12_02,2022-06-22_01 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752064974585357787?= X-GMAIL-MSGID: =?utf-8?q?1752064974585357787?= The file/directory size is updated into inode by i_size_write() before __exfat_truncate() is called, so it is redundant to re-update by i_size_write() in __exfat_truncate(). Code refinement, no functional changes. Signed-off-by: Yuezhang Mo Reviewed-by: Andy Wu Reviewed-by: Aoyama Wataru --- fs/exfat/exfat_fs.h | 2 +- fs/exfat/file.c | 8 +++----- fs/exfat/inode.c | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) -- 2.25.1 diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h index ae048802f9db..a1e7feb22079 100644 --- a/fs/exfat/exfat_fs.h +++ b/fs/exfat/exfat_fs.h @@ -448,7 +448,7 @@ int exfat_trim_fs(struct inode *inode, struct fstrim_range *range); /* file.c */ extern const struct file_operations exfat_file_operations; -int __exfat_truncate(struct inode *inode, loff_t new_size); +int __exfat_truncate(struct inode *inode); void exfat_truncate(struct inode *inode); int exfat_setattr(struct user_namespace *mnt_userns, struct dentry *dentry, struct iattr *attr); diff --git a/fs/exfat/file.c b/fs/exfat/file.c index 7c97c1df1305..f5b29072775d 100644 --- a/fs/exfat/file.c +++ b/fs/exfat/file.c @@ -93,7 +93,7 @@ static int exfat_sanitize_mode(const struct exfat_sb_info *sbi, } /* resize the file length */ -int __exfat_truncate(struct inode *inode, loff_t new_size) +int __exfat_truncate(struct inode *inode) { unsigned int num_clusters_new, num_clusters_phys; unsigned int last_clu = EXFAT_FREE_CLUSTER; @@ -113,7 +113,7 @@ int __exfat_truncate(struct inode *inode, loff_t new_size) exfat_chain_set(&clu, ei->start_clu, num_clusters_phys, ei->flags); - if (new_size > 0) { + if (i_size_read(inode) > 0) { /* * Truncate FAT chain num_clusters after the first cluster * num_clusters = min(new, phys); @@ -143,8 +143,6 @@ int __exfat_truncate(struct inode *inode, loff_t new_size) ei->start_clu = EXFAT_EOF_CLUSTER; } - i_size_write(inode, new_size); - if (ei->type == TYPE_FILE) ei->attr |= ATTR_ARCHIVE; @@ -207,7 +205,7 @@ void exfat_truncate(struct inode *inode) goto write_size; } - err = __exfat_truncate(inode, i_size_read(inode)); + err = __exfat_truncate(inode); if (err) goto write_size; diff --git a/fs/exfat/inode.c b/fs/exfat/inode.c index 0d147f8a1f7c..95adc4b2e436 100644 --- a/fs/exfat/inode.c +++ b/fs/exfat/inode.c @@ -626,7 +626,7 @@ void exfat_evict_inode(struct inode *inode) if (!inode->i_nlink) { i_size_write(inode, 0); mutex_lock(&EXFAT_SB(inode->i_sb)->s_lock); - __exfat_truncate(inode, 0); + __exfat_truncate(inode); mutex_unlock(&EXFAT_SB(inode->i_sb)->s_lock); }