Skip to content

Commit f24ff9f

Browse files
committed
Moved dir->count check before commit, limited to < 0xff
This matches the logic originally implemented in 48bd2bf, which was lost during the big no-recursion refactor 84da4c0. Other notes: - Checking >= 0xff matches the split logic during compaction (line 2158): end - split < 0xff - Grouping dir->erased || dir->count >= 0xff together makes it clear these share a common code path. - Checking for dir->count >= 0xff early avoids committing >8-bit ids to disk. The cat may already be out-of-the bag on this one, but opening the id space up to the full 10-bits should probably be on a non-patch release. Found by dschendt
1 parent 172a186 commit f24ff9f

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

lfs.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2264,7 +2264,7 @@ static int lfs_dir_relocatingcommit(lfs_t *lfs, lfs_mdir_t *dir,
22642264
}
22652265
}
22662266

2267-
if (dir->erased) {
2267+
if (dir->erased || dir->count >= 0xff) {
22682268
// try to commit
22692269
struct lfs_commit commit = {
22702270
.block = dir->pair[0],
@@ -2333,10 +2333,6 @@ static int lfs_dir_relocatingcommit(lfs_t *lfs, lfs_mdir_t *dir,
23332333
lfs->gdisk = lfs->gstate;
23342334
lfs->gdelta = (lfs_gstate_t){0};
23352335

2336-
if(dir->count == 0x3ff)
2337-
{
2338-
goto compact;
2339-
}
23402336
goto fixmlist;
23412337
}
23422338

0 commit comments

Comments
 (0)