Allowed mdir overcompaction if we run out of space
This should allow mdir commits that would normally trigger a relocation
to continue if lfsr_mdir_alloc__ return LFS_ERR_NOSPC, though at least
with a logged warning.
This seems preferable to the alternative: locking up the filesystem.
Though this doesn't have tests yet, so take it with a grain of salt...
Code changes minimal:
code stack
before: 33470 2640
after: 33474 (+0.0%) 2640 (+0.0%)
This commit is contained in:
@@ -5931,7 +5931,17 @@ static int lfsr_mdir_swap__(lfs_t *lfs, lfsr_mdir_t *mdir_,
|
||||
// decide if we need to relocate
|
||||
if (!force && lfsr_rev_needsrelocation(lfs, rev)) {
|
||||
// alloc a new mdir
|
||||
return lfsr_mdir_alloc__(lfs, mdir_, mdir->mid);
|
||||
err = lfsr_mdir_alloc__(lfs, mdir_, mdir->mid);
|
||||
if (err != LFS_ERR_NOSPC) {
|
||||
return err;
|
||||
}
|
||||
|
||||
// no more blocks? wear-leveling falls apart here, but
|
||||
// we can not relocate
|
||||
LFS_WARN("Overcompacting mdir %"PRId32" "
|
||||
"0x{%"PRIx32",%"PRIx32"}",
|
||||
mdir->mid >> lfs->mdir_bits,
|
||||
mdir->rbyd.blocks[0], mdir->rbyd.blocks[1]);
|
||||
}
|
||||
|
||||
// swap our blocks
|
||||
|
||||
Reference in New Issue
Block a user