class SegmentManager
Defined at line 141 of file ../../src/storage/f2fs/segment.h
Public Methods
void SegmentManager (F2fs * fs)
Defined at line 129 of file ../../src/storage/f2fs/segment.cc
void SegmentManager (SuperblockInfo & info)
Defined at line 130 of file ../../src/storage/f2fs/segment.cc
const SegmentEntry & GetSegmentEntry (uint32_t segno)
Defined at line 132 of file ../../src/storage/f2fs/segment.cc
void SegmentManager (const SegmentManager & )
Not copyable or moveable
Defined at line 144 of file ../../src/storage/f2fs/segment.h
SegmentManager & operator= (const SegmentManager & )
Defined at line 145 of file ../../src/storage/f2fs/segment.h
void SegmentManager (SegmentManager && )
Defined at line 146 of file ../../src/storage/f2fs/segment.h
SegmentManager & operator= (SegmentManager && )
Defined at line 147 of file ../../src/storage/f2fs/segment.h
void SegmentManager ()
Defined at line 148 of file ../../src/storage/f2fs/segment.h
void GetSitBitmap (void * dst_addr)
Defined at line 220 of file ../../src/storage/f2fs/segment.cc
bool CompareValidBlocks (uint32_t blocks, uint32_t segno, bool section)
Defined at line 137 of file ../../src/storage/f2fs/segment.cc
uint32_t GetValidBlocks (uint32_t segno, bool section)
Defined at line 142 of file ../../src/storage/f2fs/segment.cc
bool IsValidBlock (uint32_t segno, uint64_t offset)
Defined at line 202 of file ../../src/storage/f2fs/gc.cc
block_t GetSectionCountForCheckpoint ()
Defined at line 230 of file ../../src/storage/f2fs/segment.cc
block_t FreeSections ()
Defined at line 241 of file ../../src/storage/f2fs/segment.cc
block_t FreeSegments ()
Defined at line 225 of file ../../src/storage/f2fs/segment.cc
zx::result<uint32_t> GetVictimByDefault (GcType gc_type, CursegType type, AllocMode alloc_mode)
GetVictimByDefault() is called for two purposes:
1) One is to select a victim segment for garbage collection, and
2) the other is to find a dirty segment used for SSR.
For GC, it tries to find a victim segment that might require less cost
to secure free segments among all types of dirty segments.
The gc cost can be calculated in two ways according to GcType.
In case of GcType::kFgGc, it is typically triggered in the middle of user IO path,
and thus it selects a victim with a less valid block count (i.e., GcMode::kGcGreedy)
as it hopes the migration completes more quickly.
In case of GcType::kBgGc, it is triggered at a idle time,
so it uses a cost-benefit method (i.e., GcMode:: kGcCb) rather than kGcGreedy for the victim
selection. kGcCb tries to find a cold segment as a victim as it hopes to mitigate a block
thrashing problem.
Meanwhile, SSR is to reuse invalid blocks for new block allocation, and thus
it uses kGcGreedy to select a dirty segment with more invalid blocks
among the same type of dirty segments as that of the current segment.
If it succeeds in finding an eligible victim, it returns the segment number of the selected
victim. If it fails, it returns ZX_ERR_UNAVAILABLE.
Defined at line 105 of file ../../src/storage/f2fs/gc.cc
zx::result<uint32_t> GetGcVictim (GcType gc_type, CursegType type)
Defined at line 197 of file ../../src/storage/f2fs/gc.cc
size_t GetMaxCost (const VictimSelPolicy & policy)
This function calculates the maximum cost for a victim in each GcType
Any segment with a less cost value becomes a victim candidate.
Defined at line 79 of file ../../src/storage/f2fs/gc.cc
VictimSelPolicy GetVictimSelPolicy (GcType gc_type, CursegType type, AllocMode alloc_mode)
This method determines GcMode for GetVictimByDefault
Defined at line 55 of file ../../src/storage/f2fs/gc.cc
uint32_t GetBackgroundVictim ()
Defined at line 89 of file ../../src/storage/f2fs/gc.cc
size_t GetGcCost (uint32_t segno, const VictimSelPolicy & policy)
This method calculates the gc cost for each dirty segment
Defined at line 16 of file ../../src/storage/f2fs/gc.cc
size_t GetCostBenefitRatio (uint32_t segno)
Defined at line 27 of file ../../src/storage/f2fs/gc.cc
zx_status_t DoGarbageCollect (uint32_t segno, GcType gc_type)
Defined at line 207 of file ../../src/storage/f2fs/gc.cc
block_t GetMainAreaStartBlock ()
Defined at line 246 of file ../../src/storage/f2fs/segment.h
block_t PrefreeSegments ()
Defined at line 246 of file ../../src/storage/f2fs/segment.cc
CursegInfo * CURSEG_I (CursegType type)
Defined at line 247 of file ../../src/storage/f2fs/segment.h
const CursegInfo * CURSEG_I (CursegType type)
Defined at line 248 of file ../../src/storage/f2fs/segment.h
uint32_t CheckPrefreeSegments (int ofs_unit, CursegType type)
size_t GetAvailableBlockCountOnCurseg (CursegType type)
Defined at line 251 of file ../../src/storage/f2fs/segment.h
block_t DirtySegments ()
Defined at line 251 of file ../../src/storage/f2fs/segment.cc
block_t StartBlock (uint32_t segno)
Defined at line 254 of file ../../src/storage/f2fs/segment.h
block_t NextFreeBlkAddr (CursegType type)
Defined at line 257 of file ../../src/storage/f2fs/segment.h
block_t GetSegOffFromSeg0 (block_t blk_addr)
Defined at line 261 of file ../../src/storage/f2fs/segment.h
block_t ReservedSections ()
Defined at line 261 of file ../../src/storage/f2fs/segment.cc
uint32_t GetSegNoFromSeg0 (block_t blk_addr)
Defined at line 262 of file ../../src/storage/f2fs/segment.h
uint32_t GetSegmentNumber (block_t blk_addr)
Defined at line 265 of file ../../src/storage/f2fs/segment.h
bool NeedSSR ()
Defined at line 269 of file ../../src/storage/f2fs/segment.cc
uint32_t GetSecNo (uint32_t segno)
Defined at line 270 of file ../../src/storage/f2fs/segment.h
uint32_t GetZoneNoFromSegNo (uint32_t segno)
Defined at line 271 of file ../../src/storage/f2fs/segment.h
block_t GetSumBlock (uint32_t segno)
Defined at line 274 of file ../../src/storage/f2fs/segment.h
uint32_t SitEntryOffset (uint32_t segno)
Defined at line 275 of file ../../src/storage/f2fs/segment.h
block_t TotalSegs ()
Defined at line 277 of file ../../src/storage/f2fs/segment.h
uint32_t Utilization ()
Defined at line 316 of file ../../src/storage/f2fs/segment.cc
void DisableFgGc ()
for tests and fsck
Defined at line 320 of file ../../src/storage/f2fs/segment.h
void EnableFgGc ()
Defined at line 321 of file ../../src/storage/f2fs/segment.h
bool CanGc ()
Defined at line 322 of file ../../src/storage/f2fs/segment.h
void SetCurVictimSec (uint32_t secno)
Defined at line 323 of file ../../src/storage/f2fs/segment.h
uint32_t GetCurVictimSec ()
Defined at line 324 of file ../../src/storage/f2fs/segment.h
block_t GetSegmentsCount ()
Defined at line 326 of file ../../src/storage/f2fs/segment.h
SitInfo & GetSitInfo ()
Defined at line 327 of file ../../src/storage/f2fs/segment.h
void SetSitInfo (std::unique_ptr<SitInfo> && info)
Defined at line 328 of file ../../src/storage/f2fs/segment.h
uint32_t CursegSegno (int type)
Defined at line 330 of file ../../src/storage/f2fs/segment.cc
bool NeedInplaceUpdate (bool is_dir)
Defined at line 323 of file ../../src/storage/f2fs/segment.cc
block_t GetMainSegmentsCount ()
Defined at line 325 of file ../../src/storage/f2fs/segment.h
FreeSegmapInfo & GetFreeSegmentInfo ()
Defined at line 331 of file ../../src/storage/f2fs/segment.h
void SetFreeSegmentInfo (std::unique_ptr<FreeSegmapInfo> && info)
Defined at line 332 of file ../../src/storage/f2fs/segment.h
DirtySeglistInfo & GetDirtySegmentInfo ()
Defined at line 335 of file ../../src/storage/f2fs/segment.h
uint8_t CursegAllocType (int type)
Defined at line 335 of file ../../src/storage/f2fs/segment.cc
void SetDirtySegmentInfo (std::unique_ptr<DirtySeglistInfo> && info)
Defined at line 336 of file ../../src/storage/f2fs/segment.h
void SetSegmentEntryType (size_t target_segno, CursegType type)
Defined at line 339 of file ../../src/storage/f2fs/segment.h
uint16_t CursegBlkoff (int type)
Defined at line 340 of file ../../src/storage/f2fs/segment.cc
uint32_t GetLastVictim (int mode)
Defined at line 342 of file ../../src/storage/f2fs/segment.h
void SetLastVictim (int mode, uint32_t last_victim)
Defined at line 343 of file ../../src/storage/f2fs/segment.h
void CheckSegRange (uint32_t segno)
Defined at line 345 of file ../../src/storage/f2fs/segment.cc
void SetSegment0StartBlock (const block_t addr)
Defined at line 346 of file ../../src/storage/f2fs/segment.h
void SetMainAreaStartBlock (const block_t addr)
Defined at line 347 of file ../../src/storage/f2fs/segment.h
void SetSSAreaStartBlock (const block_t addr)
Defined at line 348 of file ../../src/storage/f2fs/segment.h
void SetSegmentsCount (const block_t count)
Defined at line 349 of file ../../src/storage/f2fs/segment.h
void SetMainSegmentsCount (const block_t count)
Defined at line 350 of file ../../src/storage/f2fs/segment.h
void SetReservedSegmentsCount (const block_t count)
Defined at line 351 of file ../../src/storage/f2fs/segment.h
void SetOPSegmentsCount (const block_t count)
Defined at line 352 of file ../../src/storage/f2fs/segment.h
zx_status_t BuildFreeSegmap ()
Defined at line 1458 of file ../../src/storage/f2fs/segment.cc
zx_status_t BuildSegmentManager ()
Defined at line 1587 of file ../../src/storage/f2fs/segment.cc
void DestroySegmentManager ()
Defined at line 1636 of file ../../src/storage/f2fs/segment.cc
bool HasNotEnoughFreeSecs (size_t freed_sections, size_t needed_blocks)
It check if there are enough free sections to write a checkpoint pack when adding
|freed_sections| of free sections and |needed_blocks| of dirty data pages.
Defined at line 490 of file ../../src/storage/f2fs/segment.cc
zx::result<> HasEnoughSsrBlocks (size_t needed_blocks)
It check if there are enough blocks to write a checkpoint pack in ssr mode when
adding |needed_blocks| of dirty data pages.
Defined at line 432 of file ../../src/storage/f2fs/segment.cc
void CheckBlockCount (uint32_t segno, SitEntry & raw_sit)
Summary block is always treated as invalid block
Defined at line 362 of file ../../src/storage/f2fs/segment.cc
pgoff_t CurrentSitAddr (uint32_t start)
Defined at line 381 of file ../../src/storage/f2fs/segment.cc
pgoff_t NextSitAddr (pgoff_t block_addr)
Defined at line 394 of file ../../src/storage/f2fs/segment.cc
void SetToNextSit (uint32_t start)
Defined at line 404 of file ../../src/storage/f2fs/segment.cc
uint64_t GetMtime ()
Defined at line 413 of file ../../src/storage/f2fs/segment.cc
block_t StartSumBlock ()
Defined at line 418 of file ../../src/storage/f2fs/segment.cc
block_t SumBlkAddr (int base, int type)
Defined at line 423 of file ../../src/storage/f2fs/segment.cc
bool SecUsageCheck (uint32_t secno)
Defined at line 428 of file ../../src/storage/f2fs/segment.cc
void LocateDirtySegment (uint32_t segno, enum DirtyType dirty_type)
Defined at line 502 of file ../../src/storage/f2fs/segment.cc
void RemoveDirtySegment (uint32_t segno, enum DirtyType dirty_type)
Defined at line 527 of file ../../src/storage/f2fs/segment.cc
void LocateDirtySegment (uint32_t segno)
Should not occur error such as ZX_ERR_NO_MEMORY.
Adding dirty entry into seglist is not critical operation.
If a given segment is one of current working segments, it won't be added.
Defined at line 553 of file ../../src/storage/f2fs/segment.cc
void SetPrefreeAsFreeSegments ()
Should call clear_prefree_segments after checkpoint is done.
Defined at line 573 of file ../../src/storage/f2fs/segment.cc
void ClearPrefreeSegments ()
Defined at line 583 of file ../../src/storage/f2fs/segment.cc
void MarkSitEntryDirty (uint32_t segno)
Defined at line 641 of file ../../src/storage/f2fs/segment.cc
void SetSitEntryType (CursegType type, uint32_t segno, bool modified)
Defined at line 648 of file ../../src/storage/f2fs/segment.cc
void UpdateSitEntry (block_t blkaddr, int del)
Defined at line 655 of file ../../src/storage/f2fs/segment.cc
void UpdateInvalidBlocks (int32_t delta, bool is_node)
Defined at line 1638 of file ../../src/storage/f2fs/segment.cc
void RefreshSitEntry (block_t old_blkaddr, block_t new_blkaddr)
Defined at line 705 of file ../../src/storage/f2fs/segment.cc
void InvalidateBlocks (block_t addr)
Defined at line 711 of file ../../src/storage/f2fs/segment.cc
void AddSumEntry (CursegType type, Summary * sum, uint16_t offset)
This function should be resided under the curseg_mutex lock
Defined at line 727 of file ../../src/storage/f2fs/segment.cc
int NpagesForSummaryFlush ()
Calculate the number of current summary pages for writing
Defined at line 733 of file ../../src/storage/f2fs/segment.cc
zx_status_t GetSumPage (uint32_t segno, LockedPage * out)
Caller should put this summary page
Defined at line 760 of file ../../src/storage/f2fs/segment.cc
void WriteSumPage (SummaryBlock * sum_blk, block_t blk_addr)
Defined at line 764 of file ../../src/storage/f2fs/segment.cc
zx_status_t SetSummaryBlock (CursegType type, SummaryCallback callback)
Defined at line 1319 of file ../../src/storage/f2fs/segment.cc
zx_status_t GetSummaryBlock (CursegType type, SummaryCallback callback)
Defined at line 1326 of file ../../src/storage/f2fs/segment.cc
void GetNewSegment (uint32_t * newseg, bool new_sec)
Find a new segment from the free segments bitmap to right order
This function should be returned with success, otherwise BUG
TODO: after LFS allocation available, raise out of space event of inspect tree when new segment
cannot be allocated.
Defined at line 775 of file ../../src/storage/f2fs/segment.cc
void ResetCurseg (CursegType type, bool modified)
Defined at line 841 of file ../../src/storage/f2fs/segment.cc
void NewCurseg (CursegType type, bool new_sec)
Allocate a current working segment.
This function always allocates a free segment in LFS manner.
Defined at line 861 of file ../../src/storage/f2fs/segment.cc
void NextFreeBlkoff (CursegInfo * seg, block_t start)
Defined at line 871 of file ../../src/storage/f2fs/segment.cc
void RefreshNextBlkoff (CursegInfo * seg)
If a segment is written by LFS manner, next block offset is just obtained
by increasing the current block offset. However, if a segment is written by
SSR manner, next block offset obtained by calling __next_free_blkoff
Defined at line 885 of file ../../src/storage/f2fs/segment.cc
void ChangeCurseg (CursegType type, bool reuse)
This function always allocates a used segment (from dirty seglist) by SSR
manner, so it should recover the existing segment information of valid blocks
Defined at line 895 of file ../../src/storage/f2fs/segment.cc
void AllocateSegmentByDefault (CursegType type, bool force)
Allocate a segment for new block allocations in CURSEG_I(type).
This function is supposed to be successful. Otherwise, BUG.
Defined at line 921 of file ../../src/storage/f2fs/segment.cc
void AllocateNewSegments ()
Defined at line 937 of file ../../src/storage/f2fs/segment.cc
bool HasCursegSpace (CursegType type)
Defined at line 948 of file ../../src/storage/f2fs/segment.cc
block_t GetBlockAddrOnSegment (LockedPage & page, block_t old_blkaddr, Summary * sum, PageType p_type)
Defined at line 953 of file ../../src/storage/f2fs/segment.cc
void RecoverDataPage (Summary & sum, block_t old_blkaddr, block_t new_blkaddr)
Defined at line 996 of file ../../src/storage/f2fs/segment.cc
zx_status_t ReadCompactedSummaries ()
Defined at line 1036 of file ../../src/storage/f2fs/segment.cc
zx_status_t ReadNormalSummaries (int type)
Defined at line 1090 of file ../../src/storage/f2fs/segment.cc
int RestoreCursegSummaries ()
Defined at line 1166 of file ../../src/storage/f2fs/segment.cc
zx_status_t RestoreNodeSummary (uint32_t segno, SummaryBlock & sum)
Defined at line 1148 of file ../../src/storage/f2fs/segment.cc
void WriteCompactedSummaries (block_t blkaddr)
Defined at line 1184 of file ../../src/storage/f2fs/segment.cc
void WriteNormalSummaries (block_t blkaddr, CursegType type)
Defined at line 1230 of file ../../src/storage/f2fs/segment.cc
void WriteDataSummaries (block_t start_blk)
Defined at line 1246 of file ../../src/storage/f2fs/segment.cc
void WriteNodeSummaries (block_t start_blk)
Defined at line 1254 of file ../../src/storage/f2fs/segment.cc
bool FlushSitsInJournal ()
Defined at line 1300 of file ../../src/storage/f2fs/segment.cc
zx_status_t FlushSitEntries ()
CP calls this function, which flushes SIT entries including SitJournal,
and moves prefree segs to free segs.
Defined at line 1335 of file ../../src/storage/f2fs/segment.cc
Friends
class GcTester
class F2fsFakeDevTestFixture