mirror of
https://github.com/apache/nuttx.git
synced 2026-08-16 09:53:23 +00:00
mtdconfig/nvs: clean up block without valid data during GC
Invalid data is cleared during garbage collection rather than deleted during initialization, thus accelerating the initialization speed. Signed-off-by: zhaoxingyu1 <zhaoxingyu1@xiaomi.com>
This commit is contained in:
parent
dd60589895
commit
2061ef5d2b
1 changed files with 0 additions and 19 deletions
|
|
@ -1548,25 +1548,6 @@ static int nvs_startup(FAR struct nvs_fs *fs)
|
|||
fs->data_wra);
|
||||
}
|
||||
|
||||
/* If the ate_wra is pointing to the first ate write location in a
|
||||
* block and data_wra is not 0, erase the block as it contains no
|
||||
* valid data (this also avoids closing a block without any data).
|
||||
*/
|
||||
|
||||
if (((fs->ate_wra + 2 * ate_size) == fs->blocksize) &&
|
||||
(fs->data_wra != (fs->ate_wra & NVS_ADDR_BLOCK_MASK)))
|
||||
{
|
||||
rc = nvs_flash_erase_block(fs, fs->ate_wra);
|
||||
if (rc)
|
||||
{
|
||||
return rc;
|
||||
}
|
||||
|
||||
fs->data_wra = fs->ate_wra & NVS_ADDR_BLOCK_MASK;
|
||||
finfo("erase due to no data, data_wra=0x%" PRIx32 "\n",
|
||||
fs->data_wra);
|
||||
}
|
||||
|
||||
/* Check if there exists an old entry with the same id and key
|
||||
* as the newest entry.
|
||||
* If so, power loss occurred before writing the old entry id as expired.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue