Fixed incorrect calculation of extra space needed in mdir blocks
Despite the comment being correct, the calculation is somehow off by a word, meaning something must have been missed. Maybe the space for the move-delete was missed since that was added later to avoid losing move-deletes during relocations. This was found with the new exhaustive power-loss searching added to the test framework with -P2. The exact failure was test_dirs_many_reentrant:2gg2cb:k4o6. This must be the first test that ends up with all possible extra state in a single mdir block.
This commit is contained in:
@@ -1931,11 +1931,20 @@ static int lfs_dir_splittingcompact(lfs_t *lfs, lfs_mdir_t *dir,
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
// space is complicated, we need room for tail, crc, gstate,
|
// space is complicated, we need room for:
|
||||||
// cleanup delete, and we cap at half a block to give room
|
//
|
||||||
// for metadata updates.
|
// - tail: 4+2*4 = 12 bytes
|
||||||
|
// - gstate: 4+3*4 = 16 bytes
|
||||||
|
// - move delete: 4 = 4 bytes
|
||||||
|
// - crc: 4+4 = 8 bytes
|
||||||
|
// total = 40 bytes
|
||||||
|
//
|
||||||
|
// And we cap at half a block to avoid degenerate cases with
|
||||||
|
// nearly-full metadata blocks.
|
||||||
|
//
|
||||||
if (end - split < 0xff
|
if (end - split < 0xff
|
||||||
&& size <= lfs_min(lfs->cfg->block_size - 36,
|
&& size <= lfs_min(
|
||||||
|
lfs->cfg->block_size - 40,
|
||||||
lfs_alignup(
|
lfs_alignup(
|
||||||
(lfs->cfg->metadata_max
|
(lfs->cfg->metadata_max
|
||||||
? lfs->cfg->metadata_max
|
? lfs->cfg->metadata_max
|
||||||
|
|||||||
Reference in New Issue
Block a user