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)
Fri, Apr 19, 1:14 PM
Unknown Object (File)
Feb 23 2024, 10:38 AM
Unknown Object (File)
Feb 17 2024, 7:05 PM
Unknown Object (File)
Jan 31 2024, 8:22 PM
Unknown Object (File)
Dec 23 2023, 1:02 AM
Unknown Object (File)
Dec 22 2023, 9:20 AM
Unknown Object (File)
Dec 11 2023, 11:04 AM
Unknown Object (File)
Dec 3 2023, 12:06 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 Passed
Unit
No Test Coverage
Build Status
Buildable 31994
Build 29537: arc lint + arc unit

Event Timeline

allanjude added inline comments.
usr.sbin/fifolog/lib/fifolog_write_poll.c
248

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

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.