From patchwork Mon Dec 5 05:10:18 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: 13064131 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 E18A8C4321E for ; Mon, 5 Dec 2022 05:10:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231520AbiLEFKj (ORCPT ); Mon, 5 Dec 2022 00:10:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231488AbiLEFKf (ORCPT ); Mon, 5 Dec 2022 00:10:35 -0500 Received: from mx08-001d1705.pphosted.com (mx08-001d1705.pphosted.com [185.183.30.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D7091007C; Sun, 4 Dec 2022 21:10:33 -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 2B54ssoh014669; Mon, 5 Dec 2022 05:10:24 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=i8mzUZ0Gj0RgefCIdReg3EXpq95aeA/fn0H+fJWolttIRyo/bsj94twD6esIUTGSDC1u JgpC3+jM2Oen6G8i3oj5vl1K2GAIy5F40HTMg3loa0dmSxH9/3jzgXe7ZldqOzvnnYjl MnHTJP+Ir3OMiKg9RDC130NPv0OQes0piuiNnymu/nlaQ5Nn6rJyljWLRg1GuGRz50tY HEc7b6dR5uaNBE/Vil2wD8yKKX0MPVDI99NzCEsrA9wgrqEf42OXX3AtKbbzD7av4Pdx kV/yZSYUMjXxSujvzKytfOtg0Vo0JrmVtvmxgE5tlepa0btRvGIMxbLA+i9u43CPd+bm MQ== Received: from apc01-tyz-obe.outbound.protection.outlook.com (mail-tyzapc01lp2044.outbound.protection.outlook.com [104.47.110.44]) by mx08-001d1705.pphosted.com (PPS) with ESMTPS id 3m7ycb1ahf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 05 Dec 2022 05:10:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Xh1xx+LKo2RbGTNUjiDXam5WVx1rkMY1+OfI1h4hv3drFqL2P8DD0RxCNqzFpt8BFpvmYyeYo2kqgCpFao36l9qZO018e3wGRjOKXH7RDtHYQgC1i/nMBuFIZfZc1b5KurRkDvGZcPF2bD+4xSjzJrNU8KvOngSWmrEm8E5CnSLKklcugft328l6bVllsLrYGuvOjFE6pEY9g712CxVMz6Zt7u+jzlWtj0aP1i0LktmYEwz8wmrGvDEZJ4dprP+bPPyyR7CWVsZMFQnvtmqk073R10jHs45VBr4LmMU8qDk9QgYLkdEGRYS9yoMbGicjzkcSFppjByExrPIKJtCwDg== 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=XIZCze8a7jpvgE+FX2pa8p1AwEVi8qxhIOb5D/mgqQkGMumt1hLblNZiZXUYVHIwoI1IbcozzqJmZij7ExniikGb19Idr4dD8djJOdUd6HSuu8SUWSqJPMzIRgmXuAIsyglosdDTgS31qn6OXmrmmWLeKwyhXkvIB+EpEiiryuZQOLJ23mIVhsr0R5zc4bcoU/Z0nTMrXxx1q1/kz6bNGmORFE5xd4qQqYi+2SwLUOMelwxt79sGBhfCsOb1PZ3fHHWuplNiC+b2UvcaMaYSo09mtNFYrVDnRMzAGbWJRHzzjY0xKYb4aQHUSPdhpGj2c1BBqZRt6wfVTiRWF9qLiw== 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 PSBPR04MB3909.apcprd04.prod.outlook.com (2603:1096:301:2::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Mon, 5 Dec 2022 05:10:19 +0000 Received: from PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::c689:d665:b3a2:d4de]) by PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::c689:d665:b3a2:d4de%6]) with mapi id 15.20.5880.008; Mon, 5 Dec 2022 05:10:19 +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" , "Andy.Wu@sony.com" , "Wataru.Aoyama@sony.com" Subject: [PATCH v1 5/6] exfat: remove i_size_write() from __exfat_truncate() Thread-Topic: [PATCH v1 5/6] exfat: remove i_size_write() from __exfat_truncate() Thread-Index: AdkIZqkGDJStBxJVRvqAguPRIr3LCA== Date: Mon, 5 Dec 2022 05:10:18 +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_|PSBPR04MB3909:EE_ x-ms-office365-filtering-correlation-id: b9af9feb-a35a-40ee-d321-08dad67f00ea x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 91yTOwbdmIdNS/UM75Z8MHPziZexYOYD+xbNQI84R7EhFbkXO43QR+8pVZHWWLQTvxLqn67HHNdxE2d+u9OloLFN0I+zev6mlVyg9g9kUhvJWUUX6x3aCN/6IerQoqyZCxJa5uYtsaWYU0MDo4utVdzlBInJlacJYwmKzahipAuqtjSRJ4SlQIkAsK2GjyJaI1CgBqeZY2d9q0WjobvoeGLO9v46WnFv4Nt4BB7cXW+9q8IetfTt1CVoGHQNQuDT+LA2oHXpWV5/gUJJdEkK6KSx2MfNRN8h/bEAxwE9DhHGLJB5oBEAx7TgLiGHfpLYupC+Pm2i+Zxi760hhbjYJjQrmicE3WQ7rI7TN6ncP0Pelwx+bsgWoeJwAdXkkVYG1kWM0E/xQs+6mQ9yS2LP89ZrE5G3KF2KpjdR+dIBjmdfoP1YO9wwq1Jo2EIVmfxNxQ25Kq8PYBDvkbJ9df3PMkQV8y0fchvi7aCFdV6Sq9UiZdbT5e3ycVYs52rDy9c3CuN8zOR0QfclYpR8tidKxqJyn41tXN0OEFnUqDJJcIpa6VzQkyBOsnJtsDP7CCSIHJB8Kn2Oldek9TFARYZ++as/5lBVBQumEmLkiF5/51GZk8eIcpjcWxNHiCmrRSGz4WWHlG2/YG1tGRiu6JTuepRsYfS9w1a7Q2YJz3YW2cDGZGj+6E7aqSsgGhyPuEB9tiBuU/08ZDifFe2Jw7xfxA== 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)(366004)(396003)(136003)(346002)(376002)(451199015)(26005)(316002)(107886003)(478600001)(6506007)(7696005)(54906003)(110136005)(9686003)(71200400001)(76116006)(66556008)(66476007)(8676002)(66946007)(4326008)(64756008)(66446008)(8936002)(52536014)(5660300002)(186003)(83380400001)(41300700001)(2906002)(122000001)(38100700002)(82960400001)(38070700005)(55016003)(86362001)(33656002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?JRTuwVPmO+OB3l680JW39aveno++?= =?utf-8?q?lj+Bb/+/qD5mQFn7LJPSmcimtAzBGg6CLvQBdXCj52TdpeFEtxca1aEw+UepijSLx?= =?utf-8?q?ZjMu42ic5R8yw7wCc2zbfVPQgVTwfampWfIAdVastiphe060wc6b7/0FJW7Ereu3l?= =?utf-8?q?oC5aHxyR54mViTqijCiFCx03fILhOc2+SazqTDmoLFbWQOSK1zvLBcWxfKXNTT+34?= =?utf-8?q?Ph8qiOfxbZ8vLHKNq9eSh0JuzBGL688isvkEkmZd08R+ivw+ZpiFvn8q0tKkxVayE?= =?utf-8?q?9GBt6krPTy8SRqBfdpEZXCgr99p8z9nCRtobX+Yo26CZQIzgCYThZvGxrBeEpnCuy?= =?utf-8?q?r3mDfTkBVvX7bxEj4A4Fj1SQa4fSmSZRg6r/TCPewHqhiR7ODbN7B6f/mY1SKX4bk?= =?utf-8?q?xm1WBdNiyy3y3gFYESMKMTQVkToZEP49BL07DU9YOkppLfWo+FiGLH7P4nMoipmwT?= =?utf-8?q?AuiuXXHtBhXvAnBb29Lj4ZJ6XsQbZ7FKIKnADnIV/gOQqmpVeksktaY3BXDERRDes?= =?utf-8?q?xtSX8eMNGFM63Q2BwRULP4zsFnEiFifyYGV3lcz2nsv/bSODcl9SjlM2t+sQByuzt?= =?utf-8?q?1YbLFZZcEsO5pjur2fR/GR6zJIbJYWqAnutZ41Fz9nJulajTv0ejk/sTCw7T2sX/5?= =?utf-8?q?pwHtEFEb4rJ9jxg6Ochoa0Zb0yD2yOlkhNNz4i8mn8LOJVVQnncy5Sj2M5M1pF6Pv?= =?utf-8?q?D+gBgKDPuIF2yPJXOZbemkOqxVQSRdR3d3qvP4ZP2LmQFB2lTbjLT0hDnOZYFKhvZ?= =?utf-8?q?UML3vOGS280Cgoh9aRqVa2t9GYtZKp0GJR6s1hoVcFD/D+955eHhjZFgcq9QavGWP?= =?utf-8?q?aOkbJealezip5tss85Bz44arbzurb9EwEeZ9S1BsUB/3pmQmsVs0OXExHXoI0uZ1h?= =?utf-8?q?ZmGaudWkYuLUJxRrxp6QlXQ0uQZ8S6e5Y2SbWp4Qgx4rLxUplKD5raqFCLR7Hlpja?= =?utf-8?q?LF7ecstgItR9YlFm7ccbOzKWDLUxHSvsHR6AQg4zmXWY8PcmNMSxHZn0bdx+6NqEl?= =?utf-8?q?HQ43+uFrvCBiGXqlHyqXXWN5JXmkYgj/3CLRkXgp0K20edoC+r4MtQxvm0wOe/phO?= =?utf-8?q?FtHArQTI6ZyTT3P5mBQGzgWtviO1mRIeB93rjtNpVK3m54NUi0CiU+CCn1RPpzHNW?= =?utf-8?q?ChqugPZOeEo9YEIhFAXsaDZy2B++qUeYQjzUIZt64b3BO4m433BWo5yo3adKHZNha?= =?utf-8?q?x/OKIuk2QSfIH9VoIQPY6c11U+DCWpRxorOO7ObX/3NWS4DQu89rTw4pYngYaxD8z?= =?utf-8?q?BigVf4Hag+yMhi//snRpt+x7fM6+IB4Yy6xGWvE/r4D0VSyMDayJtexSPRlW/B97N?= =?utf-8?q?QjGA/V+TSjftcYS3TnMK/GMskk5IWu5EtP7zPCkv2GcY35BF01dV5MO7na28KSIJZ?= =?utf-8?q?V20wcT8i0PMDidSyzKB1OulPVW08KDD84bBXgHWzHTKT/dlaUuAxt6J/JKU3Hga7B?= =?utf-8?q?HLflqYISUOYyZQEfCprE6JbiBfl0qvNT+xw9qBogGhmQXuCIhy0OdGXlauAOX/W5E?= =?utf-8?q?ohOvLXj7DSPL?= MIME-Version: 1.0 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: WaR/8hleepkupXMpaA8a8ZV81DDscynRR3HTbHPRN3fEGqeD8ta4Yx6iIPHVCMHhCFLl8ZaBhyCxROvtwlXfaB1SIj9+c5TC7He9IzHUQa6H4lfKVC7x9PYoolL+c1m0XanG9JkMuBj/nVI60dkHtkVeuuSIQXziszyZDykCcRkgyT8MEi8rsTmitjWhf/8nP3HhGmRyOk+xQUClmI9hBV1VjoKreVRnOLcccqkWDZVSfp1h8zqR7xWBGBylOCSTFzzMhQ/5mewclCq4qq/YY0jVZqFlnSG8343y9KVYVx9gb16L4ByXdFYzGliRiEHABi7JpCf4ZrLt+p6j+Loj6Xj93sc/aXLJc5eRncCVJKDZ2HnVesZYXeBJTHBeAfQ3RmVniEqThgN/ZJiYzcvTW44kxX/fv1SkEMoSuPG/UBpCK1RRHs+HNIWwPSAIW9V4f+ltDH7OA07IJtoREoc9Z4XYi/UNG3cqaQ/qT9ofJqS9Kk2EgFrmWajaGYtf33/4PU438Nvu6u39a6xZSxq/Kg0M6rMzy/5iqtvsAWw3c7itH5CPf4Ymo/nnf6T93K6NNE8ilxni7KoI3tmKjnCPj4T9fSrXtZ2eSIeP5Sfu0QF29f5KtX6QbqYy2Q/o3X1ckkz3XSQS+vM0ZUq1qTdda4tUPdEhEZKbyWpLVN7u8vzf/mS7/VD5AX5R9NtgiwpaGWQ+RQZhrhjXwUe0MzyUQv9LCHA77/3tmJLd2I2yxbi+GBpsl4F1QWbi1Xu++5orfg+6oDpwUJK5CmqozLo2iV3SGaADYYtCv8eYWE9xZ56zPDY/NW7Htjs+hoZTZdOE5m2sya1CGD0OeiKngoVF6qkaL6odWN42abE+6y3YKIboTNwmF3wUeJAyy+RcW8/s 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: b9af9feb-a35a-40ee-d321-08dad67f00ea X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Dec 2022 05:10:19.0301 (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: qILIC8eybYI7nqtph9szwgqZ2wcAWjQOAg5+EPZG4J2+bQzJJwnPSx/7HWNaZz0kZi0vld+J6EpinKuctOQ0Hw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PSBPR04MB3909 X-Proofpoint-ORIG-GUID: cOA1nKQpeU4WFVRvITZCwCuweMQOfAIN X-Proofpoint-GUID: cOA1nKQpeU4WFVRvITZCwCuweMQOfAIN X-Sony-Outbound-GUID: cOA1nKQpeU4WFVRvITZCwCuweMQOfAIN 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-05_01,2022-12-01_01,2022-06-22_01 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org 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(-) 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); }