From bb11617fe376b45cd0e203090e6fb5fd15bb11f9 Mon Sep 17 00:00:00 2001 From: Bryant Duffy-Ly Date: Wed, 16 Mar 2022 12:11:27 -0400 Subject: [PATCH] Fix EOF extent in last block Currently if there is an extent on the last block the code will only set EOF on ENOENT. In the case that the last block has an extent it wont go to the next iteration due to iblock <= last. This then doesnt set the EOF on the last block in these cases. We want to just allow the loop to keep looping and rely on if (ext.start > last) to protect us from infinite loop. --- kmod/src/data.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kmod/src/data.c b/kmod/src/data.c index 3aa8cc86..7b908bd7 100644 --- a/kmod/src/data.c +++ b/kmod/src/data.c @@ -1748,13 +1748,14 @@ int scoutfs_data_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, iblock = start >> SCOUTFS_BLOCK_SM_SHIFT; last = (start + len - 1) >> SCOUTFS_BLOCK_SM_SHIFT; - while (iblock <= last) { + while (true) { ret = scoutfs_ext_next(sb, &data_ext_ops, &args, iblock, 1, &ext); if (ret < 0) { - if (ret == -ENOENT) + if (ret == -ENOENT) { ret = 0; - last_flags = FIEMAP_EXTENT_LAST; + last_flags = FIEMAP_EXTENT_LAST; + } break; }