Skip to content

Commit

Permalink
Rolling erase: comment fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gongtao0607 committed Jan 16, 2025
1 parent 578ebbd commit 0df8b9c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions src/main/io/flashfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
#include "pg/blackbox.h"

/*
* How background erase works:
* How rolling erase works:
* 1. When start programming (flush) a page, if erase is needed and can be
* started, set FLASHFS_ROLLING_ERASE_PENDING.
* 2. No more flush can be done when FLASHFS_ROLLING_ERASE_PENDING.
Expand Down Expand Up @@ -298,13 +298,13 @@ static uint32_t flashfsWriteBuffers(uint8_t const **buffers, uint32_t *bufferSiz
/*
* Also bail out if we are running any of the erases.
* There are a few cases:
* * FLASHFS_ARMING_ERASING: logging is running ("switch" mode) and
* arming erase has triggered or running. We can't write.
* * FLASHFS_ROLLING_ERASE_PENDING: background erase is pending. We
* * FLASHFS_INITIAL_ERASING: logging is running ("switch" mode) and
* initial erase has triggered or running. We can't write.
* * FLASHFS_ROLLING_ERASE_PENDING: rolling erase is pending. We
* can't write. (If we write, those bytes will be discarded on
* erase).
* * FLASHFS_ROLLING_ERASING: technically we can write (under this
* state and flashIsReady()), because background erase erases only 1
* state and flashIsReady()), because rolling erase erases only 1
* sector. For simplicity, we wait for the task to update the state.
* * FLASHFS_ALL_ERASING: we can't write. We may land between erase
* sectors.
Expand All @@ -317,7 +317,7 @@ static uint32_t flashfsWriteBuffers(uint8_t const **buffers, uint32_t *bufferSiz
// Are we at EOF already? Abort.
if (flashfsIsEOF()) {
#ifdef USE_FLASHFS_LOOP
// If EOF, request an background erase unconditionally
// If EOF, request an rolling erase unconditionally
if (blackboxConfig()->rollingErase) {
flashfsState = FLASHFS_ROLLING_ERASE_PENDING;
}
Expand All @@ -330,7 +330,7 @@ static uint32_t flashfsWriteBuffers(uint8_t const **buffers, uint32_t *bufferSiz
#endif

#ifdef USE_FLASHFS_LOOP
// Check if background erase is needed. Why here? Because we can only
// Check if rolling erase is needed. Why here? Because we can only
// erase when a page (aligned) program is completed.
const uint32_t freeSpace = flashfsSize - flashfsGetOffset();
if (blackboxConfig()->rollingErase &&
Expand Down
6 changes: 3 additions & 3 deletions src/test/unit/flashfs_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ class FlashFSLoopInitialEraseTest : public FlashFSTestBase {

TEST_F(FlashFSLoopInitialEraseTest, Normal)
{
// Arming erase happens in the contiguous area.
// Initial erase happens in the contiguous area.
const uint16_t kBoundarySector = 4;
const uint32_t kEmptyStart =
kBoundarySector * sector_size_ - page_size_;
Expand Down Expand Up @@ -428,7 +428,7 @@ TEST_F(FlashFSLoopInitialEraseTest, Normal)

TEST_F(FlashFSLoopInitialEraseTest, Wrapped)
{
// Arming erase happens in the wrap boundary -- the last sector and the
// Initial erase happens in the wrap boundary -- the last sector and the
// first sector.
const uint16_t kBoundarySector = flash_emulator_->kFlashFSSizeInSectors - 1;
const uint32_t kEmptyStart = kBoundarySector * sector_size_ - page_size_;
Expand Down Expand Up @@ -549,7 +549,7 @@ TEST_F(FlashFSLoopRollingEraseTest, flashfsWriteOverFlashSize)
} while (written <= flash_emulator_->kFlashFSSize * 2);

// This test is non-deterministic.
// After writing the full flashfs space once, it will start background erasing,
// After writing the full flashfs space once, it will start rolling erasing,
// where a lot of writes can be silently dropped (we are writing way faster
// than the actual BBlog). In the end, we check if there's less than 2
// erased sector and call it success.
Expand Down

0 comments on commit 0df8b9c

Please sign in to comment.