Fix invalid oldest address assignment (#255)
* fix: fix invalid oldest address assignment after gc the last traversed sector. * feat: always update oldest address after sector GC. --------- Co-authored-by: shihang zhang <shihang.zhang.ext@siemens.com>
This commit is contained in:
parent
7bdef5eab7
commit
a208b1555b
|
@ -1078,7 +1078,6 @@ static bool do_gc(kv_sec_info_t sector, void *arg1, void *arg2)
|
|||
struct gc_cb_args *gc = (struct gc_cb_args *)arg1;
|
||||
fdb_kvdb_t db = gc->db;
|
||||
|
||||
gc->traversed_len += db_sec_size(db);
|
||||
if (sector->check_ok && (sector->status.dirty == FDB_SECTOR_DIRTY_TRUE || sector->status.dirty == FDB_SECTOR_DIRTY_GC)) {
|
||||
uint8_t status_table[FDB_DIRTY_STATUS_TABLE_SIZE];
|
||||
/* change the sector status to GC */
|
||||
|
@ -1098,7 +1097,7 @@ static bool do_gc(kv_sec_info_t sector, void *arg1, void *arg2)
|
|||
gc->cur_free_size += db_sec_size(db) - SECTOR_HDR_DATA_SIZE;
|
||||
FDB_DEBUG("Collect a sector @0x%08" PRIX32 "\n", sector->addr);
|
||||
/* update oldest_addr for next GC sector format */
|
||||
db_oldest_addr(db) = get_next_sector_addr(db, sector, gc->traversed_len);
|
||||
db_oldest_addr(db) = get_next_sector_addr(db, sector, 0);
|
||||
if (gc->cur_free_size >= gc->setting_free_size)
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue