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.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Dec 3, 1:34 AM
Unknown Object (File)
Nov 29 2024, 3:02 AM
Unknown Object (File)
Nov 24 2024, 5:04 PM
Unknown Object (File)
Nov 24 2024, 4:33 AM
Unknown Object (File)
Oct 27 2024, 3:36 AM
Unknown Object (File)
Oct 9 2024, 12:03 AM
Unknown Object (File)
Oct 3 2024, 2:06 AM
Unknown Object (File)
Sep 28 2024, 6:35 PM
Subscribers

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 - subversion
Lint
Lint Not Applicable
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.