Skip to content

Commit

Permalink
Fix invalid oldest address assignment (#255)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
shihang-zhang and shihang zhang authored Oct 31, 2023
1 parent 7bdef5e commit a208b15
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/fdb_kvdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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;
}
Expand Down

0 comments on commit a208b15

Please sign in to comment.