[kvdb] Clear cache before setting kv to default (#282)

* fix: clear cache.

* Update fdb_kvdb.c, remove sector cache clear.

---------

Co-authored-by: shihang zhang <shihang.zhang.ext@siemens.com>
This commit is contained in:
shihang-zhang 2024-03-22 00:51:56 -05:00 committed by GitHub
parent 64b07d7c4c
commit 24305a9c76
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 0 deletions

View File

@ -1397,6 +1397,13 @@ fdb_err_t fdb_kv_set_default(fdb_kvdb_t db)
/* lock the KV cache */ /* lock the KV cache */
db_lock(db); db_lock(db);
#ifdef FDB_KV_USING_CACHE
for (i = 0; i < FDB_KV_CACHE_TABLE_SIZE; i++) {
db->kv_cache_table[i].addr = FDB_DATA_UNUSED;
}
#endif /* FDB_KV_USING_CACHE */
/* format all sectors */ /* format all sectors */
for (addr = 0; addr < db_max_size(db); addr += db_sec_size(db)) { for (addr = 0; addr < db_max_size(db); addr += db_sec_size(db)) {
result = format_sector(db, addr, SECTOR_NOT_COMBINED); result = format_sector(db, addr, SECTOR_NOT_COMBINED);