Skip to content

Commit

Permalink
sys/log, fs/fcb: Address some review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
vrahane committed Feb 18, 2025
1 parent 142177c commit 25e4f20
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 95 deletions.
6 changes: 3 additions & 3 deletions fs/fcb/include/fcb/fcb.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,16 @@ int fcb_getnext(struct fcb *, struct fcb_entry *loc);
* Get first entry in the provided flash area
*
* @param fcb Pointer to FCB
* @param fa Optional pointer to flash area
* @param fap Optional pointer to flash area
* @param loc Pointer to first FCB entry in the provided flash area
*
* @return 0 on success, non-zero on failure
*/
int fcb_getnext_in_area(struct fcb *fcb, struct flash_area *fa,
int fcb_getnext_in_area(struct fcb *fcb, struct flash_area *fap,
struct fcb_entry *loc);

/**
* Get next area pointer from the FCB pointer to by fcb pointer
* Get next area pointer from the FCB pointer
*
* @param fcb Pointer to the FCB
* @param fap Pointer to the flash_area
Expand Down
6 changes: 3 additions & 3 deletions fs/fcb/src/fcb_getnext.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ fcb_start_offset(struct fcb *fcb)
}

int
fcb_getnext_in_area(struct fcb *fcb, struct flash_area *fa,
fcb_getnext_in_area(struct fcb *fcb, struct flash_area *fap,
struct fcb_entry *loc)
{
int rc;

/* If a flash area is specified, find first entry in that area */
if (fa) {
loc->fe_area = fa;
if (fap) {
loc->fe_area = fap;
loc->fe_elem_off = fcb_len_in_flash(fcb, sizeof(struct fcb_disk_area));
loc->fe_elem_ix = 0;
loc->fe_data_len = 0;
Expand Down
10 changes: 3 additions & 7 deletions sys/log/full/include/log/log_fcb.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,31 +39,27 @@ struct log_fcb_bmark {
#endif
/* The index of the log entry that the FCB entry contains. */
uint32_t lfb_index;
/* Is this a sector boundary bookmark */
bool lfb_sect_bmark;
};

/** A set of fcb log bookmarks. */
struct log_fcb_bset {
/** Array of bookmarks. */
struct log_fcb_bmark *lfs_bmarks;

/** Enable sector bookmarks */
bool lfs_en_sect_bmarks;

/** The maximum number of bookmarks. */
int lfs_cap;

/** The number of currently used non-sector bookmarks. */
int lfs_non_s_size;
int lfs_non_sect_size;

/** The number of currently usable bookmarks. */
int lfs_size;

/** The index where the next bookmark will get written. */
uint32_t lfs_next;

/** The index where the next non-sector bmark will get written */
uint32_t lfs_next_non_s;
uint32_t lfs_next_non_sect;
};

/**
Expand Down
5 changes: 4 additions & 1 deletion sys/log/full/src/log_fcb.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,13 @@ fcb_walk_back_find_start(struct fcb *fcb, struct log *log,
* ignored; the "index" field is used instead.
*
* XXX: We should rename "timestamp" or make it an actual timestamp.
* If bmark is found, fill up min_diff.
*
* The "index" field corresponds to a log entry index.
*
* If bookmark is found with the minimum difference in indexes, min_diff contains
* the difference else it will contain -1 if no bookmark is found. min_diff is 0
* means an exact match.
*
* If bookmarks are enabled, this function uses them in the search.
*
* @return 0 if an entry was found
Expand Down
7 changes: 5 additions & 2 deletions sys/log/full/src/log_fcb2.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ static int log_fcb2_rtr_erase(struct log *log);
*
* The "index" field corresponds to a log entry index.
*
* If bookmarks are enabled, this function uses them in the search.
*
* If bookmark is found with the minimum difference in indexes, min_diff contains
* the difference else it will contain -1 if no bookmark is found. min_diff is 0
* means an exact match.
*
* @return 0 if an entry was found
* SYS_ENOENT if there are no suitable entries.
Expand Down Expand Up @@ -185,7 +188,7 @@ log_fcb2_start_append(struct log *log, int len, struct fcb2_entry *loc)
* bookmarks
*/
log_fcb_init_bmarks(fcb_log, fcb_log->fl_bset.lfs_bmarks,
fcb_log->fl_bset.lfs_cap);
fcb_log->fl_bset.lfs_cap, true);
#endif

#if MYNEWT_VAL(LOG_STORAGE_WATERMARK)
Expand Down
Loading

0 comments on commit 25e4f20

Please sign in to comment.