From patchwork Wed Aug 7 05:45:33 2024 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: 13755657 Received: from mx08-001d1705.pphosted.com (mx08-001d1705.pphosted.com [185.183.30.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F04914F215 for ; Wed, 7 Aug 2024 05:45:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=185.183.30.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723009560; cv=fail; b=ntq3xaGAxWUMvtxmB9sR6tVYy8CDiQOhuVh/tCLj7i7YLg7l4qk0Sftl87922E0rBP45UGdzFfOG1ZHeWyn3P2akSSfqZQGXMHuDkrwN9+7GBtj91BsurruorkX0+fAel5RixWK1NnXBXn/P3Rt91zMmGi0VnzOBdQMzktavfDY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723009560; c=relaxed/simple; bh=ZcAEUTeOX3VJykrZM8ImDOH/pc8jCIcAOUlTnASB9mY=; h=From:To:CC:Subject:Date:Message-ID:Content-Type:MIME-Version; b=WOJE7LBduf+4cJ1zEo9tnXbmNOYrt+faEgqlxxRmxMhWQiJb3zay/UTjqglhSVWWLx1R+XR84f8GWMKCaJyLY1M7q43BTZNs2GWf3wHh75tHNvrobjHzBftUYjrerCyA+1Qs34/qpK6p+XC1PaRtqKCZKnMPMXkrOmAhH9/GmOM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com; spf=pass smtp.mailfrom=sony.com; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b=WEXpk3J4; arc=fail smtp.client-ip=185.183.30.70 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sony.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b="WEXpk3J4" Received: from pps.filterd (m0209322.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4774OmuV025093; Wed, 7 Aug 2024 05:45:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sony.com; h=cc :content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=S1; bh=X2I+si+Df8AJgtDYH5CQjn250B+Zs 5sx/ON1CsboFtc=; b=WEXpk3J4tka47mO6jrWASeRvDmZevbUf/UdIyc3yu7tSW 7FOjF71o6Z4OrR0XN2zUXQkv2w4FAGff++wt++EmpSUBCRiOp0SyOTia4Weh8Jh/ vr/oLcma8cYvVxQnjc80BdjSqhaV0gWVDtx/dOh+lNJ90/Aqd6/9kW48m2h2e1fa g0yie7ERBHxbQPxHjZqjuffLRCq7EuuXHX88fCRAmtEmNlxspjmnsplgFs1VU+2V yIyz1KOmcp92z+isFDFRgyVu8lMae9Oprk8lcnLqcp+Pu8/t8c60BL8vObLCwj1r X9AEwCs2XROJJWVC5vwOUMD57P5pVrCThNEqq9D3w== Received: from apc01-sg2-obe.outbound.protection.outlook.com (mail-sgaapc01lp2105.outbound.protection.outlook.com [104.47.26.105]) by mx08-001d1705.pphosted.com (PPS) with ESMTPS id 40sbb3u77g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Aug 2024 05:45:40 +0000 (GMT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MpYu+WxZWqfRBgcDghDMCAEsEpBgfz4RZ/SK+VTZXbm1XMPWNO/Nsq/ldleeeSyb9bSjRzgEofWhrk+HgrR+jrzKgmpvtYFGejnfl/ZFuqW550Kcd83rumeVkn1poUmhTErg5PYRjzgOr6V0gHYSNlq3EXcvL2lG5yS3igVC362CQM91eRQs9JbS0Ms9FZBVKOo9/kmfrujqxskXBLUsrgEIxZzhGeA45D8N7tlBql4u+jhx1/c8ljhkR0AUpa1ifEWI+mfuYXMRCrscV5pmTTUdTV9417wSkRKWfU3ie5GDVxXTMW3luMwBELSYOqhZX4nm0r/rR581Z3d6qJQrYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=X2I+si+Df8AJgtDYH5CQjn250B+Zs5sx/ON1CsboFtc=; b=hkFuhfVs/uTk5RrZgu/6Fa3Mb5eE11p7eYUa+HzL9QLrpQik8aq3y/rBfiAsNkW1d+acelTXHuv6IbC0W3THYXfDIIhtpR9SViHATVcvUuqTqmKHiHKFd1XAOgTfhQei8krIyt9Vq5b+IzF/RkIUvzj67sfVQ4U2lqu1vBgn9lBTlEkudGnksYWYghsj4W5qufSGSMoE4nSphT9MZUaGG7MReDAvo0SlpjzYqDa3W5Ke1zmOJKGztMKwhj6kTe1unQnMut68NtqYo+9yTbNdp9Az+dr4vXkUoYCy2Nrz9fTOLGhExIwHnK6lZSKJ8pA1PBVl7nfdY616SE1DyIW9DQ== 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 TYZPR04MB7207.apcprd04.prod.outlook.com (2603:1096:400:45b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.9; Wed, 7 Aug 2024 05:45:33 +0000 Received: from PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::409e:64d3:cee0:7b06]) by PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::409e:64d3:cee0:7b06%5]) with mapi id 15.20.7849.008; Wed, 7 Aug 2024 05:45:33 +0000 From: "Yuezhang.Mo@sony.com" To: "linkinjeon@kernel.org" , "sj1557.seo@samsung.com" CC: "linux-fsdevel@vger.kernel.org" , "Wataru.Aoyama@sony.com" Subject: [PATCH v1 2/2] exfat: do not fallback to buffered write Thread-Topic: [PATCH v1 2/2] exfat: do not fallback to buffered write Thread-Index: AQHa6Ix7gtH00S5OykqLk7pXoBgdWA== Date: Wed, 7 Aug 2024 05:45:33 +0000 Message-ID: Accept-Language: en-US, zh-CN Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PUZPR04MB6316:EE_|TYZPR04MB7207:EE_ x-ms-office365-filtering-correlation-id: 8ae70fc4-0970-4d5f-43f9-08dcb6a4279f x-proofpoint-id: d8690225-876f-412f-87c6-a7cb45557a4c x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|366016|376014|1800799024|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?q?4bDIUSL6bXmfiFCj7kffeyjLJF?= =?iso-8859-1?q?wyediB6kUhg9oMI9COG6tBvh72+qjh2jkJT926GiEF9+GUS08JCKnJagOtJc?= =?iso-8859-1?q?Vdt3SvHvGEDO/5H+FjwraE3FwBkGpQk2vzwcdqY4/uVLu34VvNWkwcVbvLfa?= =?iso-8859-1?q?NlJCunISzu/MKfYPPp+Bv+Cu2bpArlOBzvzhXlKkLKzJOhuaOZIt3GL5EXJ6?= =?iso-8859-1?q?3d17QlGhcK3m+8BY05RG+avRfWKUC9h9sYBnYJlsEKuvyA5kt14aTe9sWAZz?= =?iso-8859-1?q?Og45nqeL2qrVPc1KKlU2a7od9+0pEHHfAJb2fnaDBL4t6F4tPRGOy2Mfkm0p?= =?iso-8859-1?q?K8w0SysjQeYMknOj65lOOStxKvPNXUlwRl8F7ZNAxuxptJjzIKvFhMkSnce4?= =?iso-8859-1?q?fpDcznPJOCM9ox0tiLD4mJ61GcNDbsV85bLdIpMfznJuvHSFEN7/oddeHCSl?= =?iso-8859-1?q?e864nIHUX+8TAJQqEQz+rEmhemhsz0s3ln7aaIDhBpJ5XZROownaHBWZe7JX?= =?iso-8859-1?q?Q5oc7g4WyfmTgyHc4sdB7UVpNZ0/hUQrksmjNGAdDLxUK6KtE+pMb44h6U/a?= =?iso-8859-1?q?HFtX9zIy7OiYVKygqzWrsrvmjl1Z4lGt0XAm7r5wm5hM3QC/3afF5v7UDjJ3?= =?iso-8859-1?q?VC13Yt/Ziq/rLrJAB0sGlZkW4dygw7KdJ29aS66MghRuLAVhJPD5GFxbtm2v?= =?iso-8859-1?q?QLvfscKrc0nrHx0+kZboOe620DQUoHQp64KUGFtkeg/eH39cbOaFu/agmeZM?= =?iso-8859-1?q?wg3LcwoB7Vsy11pkDp1K7Zdr4aLUyl+Z1qMuF0ovdfv5ZsuSvU5a+nt5JKM5?= =?iso-8859-1?q?FzWxn27uDV0NA+8GxSVNvNceRH6prt04q+FchbjJecyeY4GFHkg+d9/WCj+J?= =?iso-8859-1?q?QbdijrfbTKQXaoSXTqC2HVDi5mzqt1uFi8333813WwmahzsliyPSyKH9AjLh?= =?iso-8859-1?q?eFfAuEXanOWy/LveaR0q4dK5SYUxSGxHHTZ0DDUyDYh4/bXJsfZ6yZ3DLs7Q?= =?iso-8859-1?q?r3SU0uFYLjn9y1OSSqmwSIeMfk7KLSJ6XHuvUkEKDFIpNqyMbAqWSzAq1Awb?= =?iso-8859-1?q?L3xHNAOvv3qHReMwG5lt0bLaCxUnzKgTAmTvs3RptXejuJDX72LUegdnAdqg?= =?iso-8859-1?q?zGWMvtAJ/Fwf9vMoT7M36IDEJG6w2NZHj9WLMXUSIGHeQDRmg1eKiy/fiihn?= =?iso-8859-1?q?hAtVugSzTB3hMgWeOJeGR9187qnk4k9dUi06iSZ0C6xcKYxFSxyZ6LmeCMBv?= =?iso-8859-1?q?5LwOeGHFAlJyHBNpRYw0obULq5aJCoMTQCs4iQz1CNJwHBaWpqAV7tQFvGg3?= =?iso-8859-1?q?0fxgMkZ9mAkcjTRMVfi3TspMs5X6ATaFJJ7cCHFzkJwDE4NlPNtX+tMGENtu?= =?iso-8859-1?q?s6VXz+qZZbIM0sWmSVv8XR2s7VUArQUhIovrWRBTTOW9evfJvnc+ManhFpMK?= =?iso-8859-1?q?LcPvjUM/7+fb2A9NJp6y2KYw=3D=3D?= 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:(13230040)(366016)(376014)(1800799024)(38070700018);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?ivTEarJeB5EexbV+31zcNQF?= =?iso-8859-1?q?zM4GppB0rBOmmrXUbESg6BanQV+ucvCPIshl8wZDO/QzCQsfZtruWX6a80eN?= =?iso-8859-1?q?RdVaynWTnH7GLep5JCs8mrrajWq4sJgoYagztUFZ/bSbBzY3o3sGKtIoUTDT?= =?iso-8859-1?q?LnsDQj8LR9r1q4rUbvQ/XrhkHr74aTx6ovi0VRKeDk2RU/xyQIK0qd9agRQ0?= =?iso-8859-1?q?k30cx81NXRqmHHITj6CT9uRHiBRSBQQrw38mLuAQ2aBkzUGjWpZWFnwlYWFY?= =?iso-8859-1?q?ScUNdVXNl4rqLNZAaa3Jhp/tmlYkwh+z14ZY+T8o5NO8ppgnLC4+j5/jCypO?= =?iso-8859-1?q?BQujvSXGOKr0lfxPouq7FYmoM7uAvR4F7i7e0lMK5hco82JCESfBF+V2XG+0?= =?iso-8859-1?q?w/EXkCRu8HrOCEfcI9goMMcJCyAZAaUDQaOfknsrsq539LAuKT8zHHV2QRis?= =?iso-8859-1?q?JoN/HpN40SlzyyFkgPtpW+3DzQuIA1XW1amHjAfA6to8P4RdCViSG6ucv1m0?= =?iso-8859-1?q?NgRUhWq/784SENnW0vhxpIa7bZQO+gZf8/58x+QdXB/iVF9MXd6UJ1IIOlD7?= =?iso-8859-1?q?nczIevx8Y/SfnfkxAZnzyT8+T6w6X69LfVSfgZDJyHMDlluxo98nv3Q9i13l?= =?iso-8859-1?q?ZhpjpNjbkl29/6vt+y2aHsLXmhasl6M8xex4bOr5CrXlVZQcFUa8iNMDjwP7?= =?iso-8859-1?q?2wjL6NtlL5JjZ6Q63yHx/c5qNUpegyPaKyxs1AytLnVAQJK362aAfi2qnkSV?= =?iso-8859-1?q?K7qyblTUX5GyQBgwbDE2cxrla1dYY9oMo57tFhV6AgNpM+xv0PFZX16fo6YC?= =?iso-8859-1?q?amoThARalUqdKTXeZmeRoqVlcnfdN3crCXzN5SULn7hj3UGKajhzPadjFPgB?= =?iso-8859-1?q?L+CoyzzBQvTUOFNayCGzN8EZ1WfU0u0f1R1gvNJHl6vChWebiq560YMnAibK?= =?iso-8859-1?q?EIQZFrr4p3QIUkMGSdGWHFZyK2rbWQyjSH96NtYAIk/ns+sfSWKzuJcrQG97?= =?iso-8859-1?q?udPLJDqhtzcPHXQBkypyafYh71cCo0ui5GWwVYd7tNBL2GpslVE3T9+yf9G1?= =?iso-8859-1?q?0APd+u5iHDoFEUjk7fpmj5QK/RAhrZXXha9Dqoh9VUGr4AWYoRvIDFcQ1+yj?= =?iso-8859-1?q?gJysMdmqqBrFXCh48+4Bmk1joNRqmC11Srwpxbw5ck9lYu1E5YGo/K1saDSF?= =?iso-8859-1?q?VM4g9X35Zg59sJiz+BWvClxkpjMCF+GcNyZlrZ83vvWituevhwv18tYBmrKD?= =?iso-8859-1?q?7jxuSw34VdkrJSzGnyjHFPd3HMIVbj77CqBm5BINiiVTQw34BWgjRFlkLMdr?= =?iso-8859-1?q?VP4+XRtVfEnUdzk1/1klZXpL45w2cLO/zIfmD9o2xzwQ2HyXdfAyGpN4xEHt?= =?iso-8859-1?q?wLnpCMQqwhg/gLt4Pbw+uXh5D1FqtTmZHd3V8r2vZsL9sqxPLJC8DWAPyRAl?= =?iso-8859-1?q?j6CzE0MZ1Ec3psgrsnfWGaHYw3MMlf56kYkh9WlEpPs2I6MwWPFOJjzhHltq?= =?iso-8859-1?q?m1T8EtezVRS+Bx17z2ySYykz0lxi/zKXSO77OwnPe0xe+HjU9A1dWnlAxlYL?= =?iso-8859-1?q?xGf8MFd724ewdBmG2EYeuGtEen7st9DTvDS0lA+YFzbx3Z8fvBaB/8HB6lNW?= =?iso-8859-1?q?K+wLq4tI70Bb13oO+xS5Y++XLHFCeLk/FliBXtVHioc2QxmgMFfrexzB1RWc?= =?iso-8859-1?q?=3D?= Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: kFs+jeClq0ggQ9oXfkxYL4YpUxxUrBfvUTkNkwucLZELrnrcczyEAeu2uXCUej3p4unm9jXJdswpynRWNznI7fJDFNg+1w9/bcJUMbYldZOnBKe6wrHdsyKm6ucfllG85ji+XyWy5h7iE0e+VJNn/+aRS+DEUrj6dZHhe7EbdWhYL0PYaqWKkcbj1awKxJMbgBv4AF83FGBFNgBnZdCdeTT2l8NSp6cOT8i5qFP4tQ+EpASgGBCqPp20fsW+dgYyzrOhn+Loq8e3fukNgHy0mkHD/jPx3rm7uKwJsvIxxsMp3250fRM54LjfRWgIGEEMcK7K2McxgHyttfvjbew76iKWGiX/enby44DxdxKPxi21MWchsB/UK5QP8iqvbuxeYbDk1Sx8Es8ZYynOsvIlXcnlio6Ob4NqgHBS4XwGyrz2dIMJn0+ajlBQpNZgVEnUwMX9spCmlQj0qVb4tadZWDzawhFVLzB4uGIoFls2mjQbU3Tv1eszD/W8uXMNPfbgpeUA62d1D8CdhAWl7fQWYdeFljIRG03HK932RJ6zLTEye08MapwLY2eML78GJACypmCDVljJ4S8aA1AO1MVDuTcKZwJRj98gi/fSV48r7TTsvbBUmEb2t5aDsC2sB39Z 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: 8ae70fc4-0970-4d5f-43f9-08dcb6a4279f X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Aug 2024 05:45:33.4898 (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: Cuv05cX0z6D3Y4TqdSWIZvV0rOH9W6WWGA46UVIsND3g88DMjIG24lqcGFyQoGHsYKHNTH+y9skceAGvRLB5Ig== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR04MB7207 X-Proofpoint-GUID: VY3FTDEqLnsSgRnW_0UA0c3TVeAPO2UX X-Proofpoint-ORIG-GUID: VY3FTDEqLnsSgRnW_0UA0c3TVeAPO2UX X-Sony-Outbound-GUID: VY3FTDEqLnsSgRnW_0UA0c3TVeAPO2UX X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-07_02,2024-08-06_01,2024-05-17_01 After commit(11a347fb6cef exfat: change to get file size from DataLength), the remaining area or hole had been filled with zeros before calling exfat_direct_IO(), so there is no need to fallback to buffered write, and ->i_size_aligned is no longer needed, drop it. Signed-off-by: Yuezhang Mo --- fs/exfat/exfat_fs.h | 2 -- fs/exfat/file.c | 11 ------- fs/exfat/inode.c | 74 +++++++++------------------------------------ fs/exfat/namei.c | 1 - fs/exfat/super.c | 1 - 5 files changed, 15 insertions(+), 74 deletions(-) diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h index 40dec7c0e0a0..344c2f119e3d 100644 --- a/fs/exfat/exfat_fs.h +++ b/fs/exfat/exfat_fs.h @@ -309,8 +309,6 @@ struct exfat_inode_info { /* for avoiding the race between alloc and free */ unsigned int cache_valid_id; - /* block-aligned i_size (used in cont_write_begin) */ - loff_t i_size_aligned; /* on-disk position of directory entry or 0 */ loff_t i_pos; loff_t valid_size; diff --git a/fs/exfat/file.c b/fs/exfat/file.c index 8041bbe84745..8cd063a6de4c 100644 --- a/fs/exfat/file.c +++ b/fs/exfat/file.c @@ -74,7 +74,6 @@ static int exfat_cont_expand(struct inode *inode, loff_t size) /* Expanded range not zeroed, do not update valid_size */ i_size_write(inode, size); - ei->i_size_aligned = round_up(size, sb->s_blocksize); inode->i_blocks = round_up(size, sbi->cluster_size) >> 9; mark_inode_dirty(inode); @@ -244,8 +243,6 @@ void exfat_truncate(struct inode *inode) struct super_block *sb = inode->i_sb; struct exfat_sb_info *sbi = EXFAT_SB(sb); struct exfat_inode_info *ei = EXFAT_I(inode); - unsigned int blocksize = i_blocksize(inode); - loff_t aligned_size; int err; mutex_lock(&sbi->s_lock); @@ -263,14 +260,6 @@ void exfat_truncate(struct inode *inode) inode->i_blocks = round_up(i_size_read(inode), sbi->cluster_size) >> 9; write_size: - aligned_size = i_size_read(inode); - if (aligned_size & (blocksize - 1)) { - aligned_size |= (blocksize - 1); - aligned_size++; - } - - if (ei->i_size_aligned > i_size_read(inode)) - ei->i_size_aligned = aligned_size; mutex_unlock(&sbi->s_lock); } diff --git a/fs/exfat/inode.c b/fs/exfat/inode.c index 82a23b1beaf7..7c62fbc5027f 100644 --- a/fs/exfat/inode.c +++ b/fs/exfat/inode.c @@ -258,21 +258,6 @@ static int exfat_map_cluster(struct inode *inode, unsigned int clu_offset, return 0; } -static int exfat_map_new_buffer(struct exfat_inode_info *ei, - struct buffer_head *bh, loff_t pos) -{ - if (buffer_delay(bh) && pos > ei->i_size_aligned) - return -EIO; - set_buffer_new(bh); - - /* - * Adjust i_size_aligned if ondisk_size is bigger than it. - */ - if (exfat_ondisk_size(&ei->vfs_inode) > ei->i_size_aligned) - ei->i_size_aligned = exfat_ondisk_size(&ei->vfs_inode); - return 0; -} - static int exfat_get_block(struct inode *inode, sector_t iblock, struct buffer_head *bh_result, int create) { @@ -286,7 +271,6 @@ static int exfat_get_block(struct inode *inode, sector_t iblock, sector_t last_block; sector_t phys = 0; sector_t valid_blks; - loff_t pos; mutex_lock(&sbi->s_lock); last_block = EXFAT_B_TO_BLK_ROUND_UP(i_size_read(inode), sb); @@ -314,8 +298,6 @@ static int exfat_get_block(struct inode *inode, sector_t iblock, mapped_blocks = sbi->sect_per_clus - sec_offset; max_blocks = min(mapped_blocks, max_blocks); - pos = EXFAT_BLK_TO_B((iblock + 1), sb); - map_bh(bh_result, sb, phys); if (buffer_delay(bh_result)) clear_buffer_delay(bh_result); @@ -336,13 +318,7 @@ static int exfat_get_block(struct inode *inode, sector_t iblock, } /* The area has not been written, map and mark as new. */ - err = exfat_map_new_buffer(ei, bh_result, pos); - if (err) { - exfat_fs_error(sb, - "requested for bmap out of range(pos : (%llu) > i_size_aligned(%llu)\n", - pos, ei->i_size_aligned); - goto unlock_ret; - } + set_buffer_new(bh_result); ei->valid_size = EXFAT_BLK_TO_B(iblock + max_blocks, sb); mark_inode_dirty(inode); @@ -365,7 +341,7 @@ static int exfat_get_block(struct inode *inode, sector_t iblock, * The block has been partially written, * zero the unwritten part and map the block. */ - loff_t size, off; + loff_t size, off, pos; max_blocks = 1; @@ -376,7 +352,7 @@ static int exfat_get_block(struct inode *inode, sector_t iblock, if (!bh_result->b_folio) goto done; - pos -= sb->s_blocksize; + pos = EXFAT_BLK_TO_B(iblock, sb); size = ei->valid_size - pos; off = pos & (PAGE_SIZE - 1); @@ -464,14 +440,6 @@ static int exfat_write_end(struct file *file, struct address_space *mapping, int err; err = generic_write_end(file, mapping, pos, len, copied, pagep, fsdata); - - if (ei->i_size_aligned < i_size_read(inode)) { - exfat_fs_error(inode->i_sb, - "invalid size(size(%llu) > aligned(%llu)\n", - i_size_read(inode), ei->i_size_aligned); - return -EIO; - } - if (err < len) exfat_write_failed(mapping, pos+len); @@ -499,20 +467,6 @@ static ssize_t exfat_direct_IO(struct kiocb *iocb, struct iov_iter *iter) int rw = iov_iter_rw(iter); ssize_t ret; - if (rw == WRITE) { - /* - * FIXME: blockdev_direct_IO() doesn't use ->write_begin(), - * so we need to update the ->i_size_aligned to block boundary. - * - * But we must fill the remaining area or hole by nul for - * updating ->i_size_aligned - * - * Return 0, and fallback to normal buffered write. - */ - if (EXFAT_I(inode)->i_size_aligned < size) - return 0; - } - /* * Need to use the DIO_LOCKING for avoiding the race * condition of exfat_get_block() and ->truncate(). @@ -526,8 +480,18 @@ static ssize_t exfat_direct_IO(struct kiocb *iocb, struct iov_iter *iter) } else size = pos + ret; - /* zero the unwritten part in the partially written block */ - if (rw == READ && pos < ei->valid_size && ei->valid_size < size) { + if (rw == WRITE) { + /* + * If the block had been partially written before this write, + * ->valid_size will not be updated in exfat_get_block(), + * update it here. + */ + if (ei->valid_size < size) { + ei->valid_size = size; + mark_inode_dirty(inode); + } + } else if (pos < ei->valid_size && ei->valid_size < size) { + /* zero the unwritten part in the partially written block */ iov_iter_revert(iter, size - ei->valid_size); iov_iter_zero(size - ei->valid_size, iter); } @@ -667,14 +631,6 @@ static int exfat_fill_inode(struct inode *inode, struct exfat_dir_entry *info) i_size_write(inode, size); - /* ondisk and aligned size should be aligned with block size */ - if (size & (inode->i_sb->s_blocksize - 1)) { - size |= (inode->i_sb->s_blocksize - 1); - size++; - } - - ei->i_size_aligned = size; - exfat_save_attr(inode, info->attr); inode->i_blocks = round_up(i_size_read(inode), sbi->cluster_size) >> 9; diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c index 6313dee5c9bb..3e6c789a72c4 100644 --- a/fs/exfat/namei.c +++ b/fs/exfat/namei.c @@ -372,7 +372,6 @@ static int exfat_find_empty_entry(struct inode *inode, /* directory inode should be updated in here */ i_size_write(inode, size); - ei->i_size_aligned += sbi->cluster_size; ei->valid_size += sbi->cluster_size; ei->flags = p_dir->flags; inode->i_blocks += sbi->cluster_size >> 9; diff --git a/fs/exfat/super.c b/fs/exfat/super.c index 61d8377201f6..05fa638b411a 100644 --- a/fs/exfat/super.c +++ b/fs/exfat/super.c @@ -370,7 +370,6 @@ static int exfat_read_root(struct inode *inode) inode->i_blocks = round_up(i_size_read(inode), sbi->cluster_size) >> 9; ei->i_pos = ((loff_t)sbi->root_dir << 32) | 0xffffffff; - ei->i_size_aligned = i_size_read(inode); exfat_save_attr(inode, EXFAT_ATTR_SUBDIR); ei->i_crtime = simple_inode_init_ts(inode);