From 6a1c6e38083bdaed49357ea46816c28aba0c5170 Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Wed, 2 Jul 2025 16:11:29 -0700 Subject: [PATCH] Allow punch-offline to punch regions properly. The current code here only works if the passed in start block is exactly the start of an offline extent. On top of that, it only will punch a single extent, ever, due to the test used after finding an extent. The reason is that we break the loop if the start isn't exactly the first block of the extent, even if the last block of the extent is within the wanted hole. With this change, it doesn't matter if the start is either part of an offline extent, or a hole, and, we can punch holes that encompass multiple extents separated by holes, punching all of them away. Signed-off-by: Auke Kok --- kmod/src/data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kmod/src/data.c b/kmod/src/data.c index 7181960f..a61d85c1 100644 --- a/kmod/src/data.c +++ b/kmod/src/data.c @@ -1560,7 +1560,7 @@ int scoutfs_data_punch_offline(struct inode *inode, u64 iblock, u64 last, u64 da for (i = 0; i < 32 && (iblock <= last); i++) { ret = scoutfs_ext_next(sb, &data_ext_ops, &args, iblock, 1, &ext); - if (ret == -ENOENT || ext.start > iblock) { + if (ret == -ENOENT || ext.start > last) { iblock = last + 1; ret = 0; break;