Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log_fcb walk back #3295

Merged
merged 6 commits into from
Sep 11, 2024
Merged

log_fcb walk back #3295

merged 6 commits into from
Sep 11, 2024

Conversation

kasjer
Copy link
Contributor

@kasjer kasjer commented Aug 7, 2024

This adds functionality to walk back in fcb and in log_fcb
Additional options to log cmd
-s <n> skips n logs before prints are started
-r start printing from the latest logs (work only for FCB based logs)

log -n 10 -r reboot_log

will print 10 latest logs from reboot log

log -s 1000 reboot_log

will print logs skipping first 1000 from reboot_log

Signed-off-by: Jerzy Kasenberg [email protected]

@github-actions github-actions bot added the size/l label Aug 7, 2024
@kasjer kasjer force-pushed the kasjer/fcb-walk-back branch 5 times, most recently from 1eacd5f to e790f32 Compare August 13, 2024 13:27
@kasjer kasjer marked this pull request as ready for review August 13, 2024 13:33
}
}

if (cache->cache_data) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could use some comment:
elem_size is converted to host, but other params (ix, offset) are used as is
also elem_size is (32bit size?) int but it is stored into cache_data which is uint16

If cache is kept in host order, maybe this function should get all params in host order?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inconsistent endianness removed.
function argument change to uint16_t to match calling argument

Option -s allows to skip number of logs from the start

Usage:
log [-n <number>] [-s <skip_number> ]

i.e.:
log -s 100 -n 10

will print at most 10 entries from each log skipping first 100 entries

Signed-off-by: Jerzy Kasenberg <[email protected]>
This extends fcb_entry structure with field that can change
direction of the walk.

fcb_getnext() function can now walk in backward direction.

Signed-off-by: Jerzy Kasenberg <[email protected]>
Previously fcb sequence to write FCB entry was:
fcb_append(fcb, len, loc)
flash_area_write(fa,...)
fcb_finish(fcb, loc)

This adds function fcb_write() that should be used instead
of direct call to flash_area_write to make it more consistent.

Signed-off-by: Jerzy Kasenberg <[email protected]>
This adds field to log_offset that allows to specify log
walk back direction.

For now only log_fcb/fcb use implement walking back.

Signed-off-by: Jerzy Kasenberg <[email protected]>
fcb_walk initialize only certain fields of fcb_entry
before walking.
This could lead to unpredictable behaviour if additional
fields were utilized.

Signed-off-by: Jerzy Kasenberg <[email protected]>
Variable cnt and len were reused leading to some inconsistencies.

1.
cnt was number of bytes needed to store len but it was later
changed to store number of bytes in flash to store len (that
can be larger when flash alignment restrictions are applied).
Later it was used to actually write len filed to flash, however
if alignment was not 1 or 2 some random data would be written to
flash (starting from tmp_str but extending to other values on stack).
No there is separate variable to keep track how many bytes in
flash are needed.

2.
calculating whether entry will fit in current sector,
fcb_disk_area was not aligned correctly that could lead to
problems for flash that has alignment that is higher then 8.

3.
append_loc was partially updated but fe_data_len was never filled
leaving structure in inconsistent state.

4.
active->fe_data_len could have incorrect value (rounded up to alignment)
This was small inconsistency that probably would not result in any
problem

Signed-off-by: Jerzy Kasenberg <[email protected]>
@kasjer kasjer merged commit f3bd574 into apache:master Sep 11, 2024
19 checks passed
@kasjer kasjer deleted the kasjer/fcb-walk-back branch September 11, 2024 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants