Page MenuHomeFreeBSD

[fifolog] Wrap to the beginning of the file once the end of the file is reached
ClosedPublic

Authored by adrian on Jun 26 2020, 9:23 PM.

Details

Summary

The fifolog code wasn't wrapping the record number, so once the
file filled up it would just continue filling.

This resets the record to the beginning of the file once it
hits the end.

Test Plan
  • run on a 256k fifolog, fill with content! Make sure it doesn't overflow!

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

allanjude added inline comments.
usr.sbin/fifolog/lib/fifolog_write_poll.c
248 ↗(On Diff #73718)

Is 'recno 1' actually f->recno = 0? or is this a typo and you meant f->recno=2?

usr.sbin/fifolog/lib/fifolog_write_poll.c
248 ↗(On Diff #73718)

Sorry yeah, comment is wrong. recno 0 is header.

Oops - update comment. Thanks jude!

I noticed we were off by one; the file size ended up being one record
longer than specified. This fixes it.

Yeah, that's clearly an oversight.

In the original application this code came from, the write error propagated up and was used to register how many times the flash had been written.

That code did not become part of the fifolog_writer(1) program, which silently ignores the errors from fifolog_write_record_poll().

Wrapping in the lib code probably makes most sense in this stand alone usage of the code, but fifolog_writer(1) should also report write errors back.

In D25478#562806, @phk wrote:

Yeah, that's clearly an oversight.

In the original application this code came from, the write error propagated up and was used to register how many times the flash had been written.

That code did not become part of the fifolog_writer(1) program, which silently ignores the errors from fifolog_write_record_poll().

Wrapping in the lib code probably makes most sense in this stand alone usage of the code, but fifolog_writer(1) should also report write errors back.

oh! that makes sense!

I'll tackle that as a follow-up if you don't mind. I may use this on some NAND device and having callbacks for write errors and record number wrapping would help.

This revision was not accepted when it landed; it landed in state Needs Review.Jun 28 2020, 6:53 AM
This revision was automatically updated to reflect the committed changes.