From nobody Wed Dec 31 16:20:34 2025 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 98541C4332F for ; Wed, 1 Nov 2023 16:38:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344082AbjKAQib (ORCPT ); Wed, 1 Nov 2023 12:38:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232819AbjKAQi1 (ORCPT ); Wed, 1 Nov 2023 12:38:27 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3899FD; Wed, 1 Nov 2023 09:38:25 -0700 (PDT) Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3A1GMKnt005565; Wed, 1 Nov 2023 16:38:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=30VE8h6m1wLRe773DqtdEN8cCwLPLvKHKL337+GsgNc=; b=qo1kALzb6Tgs+L97t/SoyKHGC/pG21bC3Pv0nnY9a33WHbq3OTMxNRHu2Y3xdw36e65R p1IWJRfir/2GHhIs1OkpIl29UUxCpadI+9P7j3mINFokFAMZ3TqXrrfUGq9KnVA5n6xM HcyJhQVGt8AUJTJQZFEp5Nx1q4/T0TRqfas9mK25+0zN1cU0Bo/3huILDNyuZRfKX8qY HjTGLf+5FKR3f3GkvJS0dh95ifvULvW7Cr/noaJUvLbCRVTtbfLl728IGIoD2maFFQfj rmcsAecLCLhSb0hO8r4n4oYlFxNO01lurhul5KHUokwfqgjdEwFV7/eMZ9upem97CfHe EA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u3t4w8kc9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 01 Nov 2023 16:38:21 +0000 Received: from m0353729.ppops.net (m0353729.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3A1GNVNP008087; Wed, 1 Nov 2023 16:38:20 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u3t4w8kbr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 01 Nov 2023 16:38:20 +0000 Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3A1Ebi3X000583; Wed, 1 Nov 2023 16:38:19 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3u1cmt92jh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 01 Nov 2023 16:38:19 +0000 Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3A1GcHU919989114 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 1 Nov 2023 16:38:17 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C3D2720043; Wed, 1 Nov 2023 16:38:17 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4250D20040; Wed, 1 Nov 2023 16:38:16 +0000 (GMT) Received: from li-bb2b2a4c-3307-11b2-a85c-8fa5c3a69313.ibm.com.com (unknown [9.43.9.163]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 1 Nov 2023 16:38:16 +0000 (GMT) From: Ojaswin Mujoo To: linux-ext4@vger.kernel.org, "Theodore Ts'o" Cc: Ritesh Harjani , linux-kernel@vger.kernel.org, Jan Kara Subject: [PATCH v2 1/2] ext4: treat end of range as exclusive in ext4_zero_range() Date: Wed, 1 Nov 2023 22:08:10 +0530 Message-Id: X-Mailer: git-send-email 2.39.3 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: BapsqX8aZUGVEIYkMStMKts2RP8P9jry X-Proofpoint-GUID: qxYIvFvSjSF-FIBk-HLGmkKg2hECJSbx X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-01_15,2023-11-01_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 spamscore=0 impostorscore=0 adultscore=0 phishscore=0 mlxlogscore=999 suspectscore=0 mlxscore=0 bulkscore=0 clxscore=1015 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311010131 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The call to filemap_write_and_wait_range() assumes the range passed to be inclusive, so fix the call to make sure we follow that. Signed-off-by: Ojaswin Mujoo Reviewed-by: Jan Kara --- fs/ext4/extents.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 880f383df684..265ae30a51b9 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -4522,7 +4522,8 @@ static long ext4_zero_range(struct file *file, loff_t= offset, * Round up offset. This is not fallocate, we need to zero out * blocks, so convert interior block aligned part of the range to * unwritten and possibly manually zero out unaligned parts of the - * range. + * range. Here, start and partial_begin are inclusive, end and + * partial_end are exclusive. */ start =3D round_up(offset, 1 << blkbits); end =3D round_down((offset + len), 1 << blkbits); @@ -4608,7 +4609,8 @@ static long ext4_zero_range(struct file *file, loff_t= offset, * disk in case of crash before zeroing trans is committed. */ if (ext4_should_journal_data(inode)) { - ret =3D filemap_write_and_wait_range(mapping, start, end); + ret =3D filemap_write_and_wait_range(mapping, start, + end - 1); if (ret) { filemap_invalidate_unlock(mapping); goto out_mutex; --=20 2.39.3