From 24305a9c76e735e89ad0d973a09f161edbc4279e Mon Sep 17 00:00:00 2001 From: shihang-zhang <77595854+shihang-zhang@users.noreply.github.com> Date: Fri, 22 Mar 2024 00:51:56 -0500 Subject: [PATCH] [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 --- src/fdb_kvdb.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/fdb_kvdb.c b/src/fdb_kvdb.c index c668e44..d6211f3 100644 --- a/src/fdb_kvdb.c +++ b/src/fdb_kvdb.c @@ -1397,6 +1397,13 @@ fdb_err_t fdb_kv_set_default(fdb_kvdb_t db) /* lock the KV cache */ 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 */ for (addr = 0; addr < db_max_size(db); addr += db_sec_size(db)) { result = format_sector(db, addr, SECTOR_NOT_COMBINED);