From nobody Thu Oct 2 19:01:41 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 E2FBC274B23 for ; Fri, 12 Sep 2025 09:38:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757669931; cv=none; b=g4pJt+5SOsQaHlMY12z6KF+LIz5Ron1f5DFcyl52GGQ19Fpt0c84JPfuPNZSusI79bzHt98uwSTkKMx/9lt8M3ODkyAIjr82ssZ9CkbsCrJ3hpzA639So1kob92vVBZv45R2/vWcprx+cEVT4Eh/tdNk8p7pjuOst2bn8YIcU+M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757669931; c=relaxed/simple; bh=C2C7RcRgI+D6tUKplepFjuIGNKR+l3pPP2sgq1FegGs=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=bNEDmDUn+vECLsX41Fse3WAMuVCtPVgS9Gf5Z0zeDRrGhVsSNGISN6AOFdl8klVEBtr1B5hH71Z68Zz7gI2xHuaaFH87Imto4pSUN1ptALe70ZcDxfBpDHrQOvdiOW53LmD5Gx8fqumsVzxl6ku3Mu9azVgOtbcCrQ1c/5POH+o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=L3GZr48l; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="L3GZr48l" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A87B1C4CEF1; Fri, 12 Sep 2025 09:38:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757669930; bh=C2C7RcRgI+D6tUKplepFjuIGNKR+l3pPP2sgq1FegGs=; h=From:To:Cc:Subject:Date:From; b=L3GZr48lQ48DqpOQds2/ux8pi30yfFwp6lMWAKNU33jL0GOujdt4zW+qs1tu2yB2O TJDufuG8i1SDQPae5lPD7tvKrIWBbn20JyZxcyNkBj+4hfbr4Rr0Dsq1AjYj6rTvg3 b5AF6aupMKeZe7jvhdz2qZSubqtORlb18uC893UeIAtg7mKYi039/ywcbHCsBiwBBk yPvmN6EfBmrXOrDL/ET/zC/d1/kolJW+Zvk8VJXcAqVa55x5St416xpgh2Kycfnve0 hishI/KsPfRcfEBoHR8QRPWLHLo1NVJk739O8lh3ZZOAJPg1/vXre3VwRHHo9HpF9a /FL2qx+PYnzLw== From: Chao Yu To: jaegeuk@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Yu Subject: [PATCH v2] f2fs: fix to update map->m_next_extent correctly in f2fs_map_blocks() Date: Fri, 12 Sep 2025 16:12:50 +0800 Message-Id: <20250912081250.44383-1-chao@kernel.org> X-Mailer: git-send-email 2.40.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Script to reproduce: mkfs.f2fs -O extra_attr,compression /dev/vdb -f mount /dev/vdb /mnt/f2fs -o mode=3Dlfs,noextent_cache cd /mnt/f2fs f2fs_io write 1 0 1024 rand dsync testfile xfs_io testfile -c "fsync" f2fs_io write 1 0 512 rand dsync testfile xfs_io testfile -c "fsync" cd / umount /mnt/f2fs mount /dev/vdb /mnt/f2fs f2fs_io precache_extents /mnt/f2fs/testfile umount /mnt/f2fs Tracepoint output: f2fs_update_read_extent_tree_range: dev =3D (253,16), ino =3D 4, pgofs =3D = 0, len =3D 512, blkaddr =3D 1055744, c_len =3D 0 f2fs_update_read_extent_tree_range: dev =3D (253,16), ino =3D 4, pgofs =3D = 513, len =3D 351, blkaddr =3D 17921, c_len =3D 0 f2fs_update_read_extent_tree_range: dev =3D (253,16), ino =3D 4, pgofs =3D = 864, len =3D 160, blkaddr =3D 18272, c_len =3D 0 During precache_extents, there is off-by-one issue, we should update map->m_next_extent to pgofs rather than pgofs + 1, if last blkaddr is valid and not contiguous to previous extent. Fixes: c4020b2da4c9 ("f2fs: support F2FS_IOC_PRECACHE_EXTENTS") Signed-off-by: Chao Yu --- v2: - clean up codes fs/f2fs/data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 6bb03add93fe..d747850e765f 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -1782,7 +1782,7 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_= map_blocks *map, int flag) map->m_len - ofs); } if (map->m_next_extent) - *map->m_next_extent =3D pgofs + 1; + *map->m_next_extent =3D is_hole ? pgofs + 1 : pgofs; } f2fs_put_dnode(&dn); unlock_out: --=20 2.40.1