class FsckWorker
Defined at line 104 of file ../../src/storage/f2fs/fsck.h
Public Methods
void FsckWorker (const FsckWorker & )
Not copyable or movable
Defined at line 107 of file ../../src/storage/f2fs/fsck.h
FsckWorker & operator= (const FsckWorker & )
Defined at line 108 of file ../../src/storage/f2fs/fsck.h
void FsckWorker (FsckWorker && )
Defined at line 109 of file ../../src/storage/f2fs/fsck.h
zx_status_t ReadBlock (void * buffer, block_t bno)
Defined at line 110 of file ../../src/storage/f2fs/fsck.cc
FsckWorker & operator= (FsckWorker && )
Defined at line 110 of file ../../src/storage/f2fs/fsck.h
void FsckWorker (std::unique_ptr<BcacheMapper> bc, const FsckOptions & options)
Defined at line 111 of file ../../src/storage/f2fs/fsck.h
zx_status_t WriteBlock (void * buffer, block_t bno)
Defined at line 112 of file ../../src/storage/f2fs/fsck.cc
void ~FsckWorker ()
Defined at line 115 of file ../../src/storage/f2fs/fsck.h
NodeManager & GetNodeManager ()
For testing
Defined at line 282 of file ../../src/storage/f2fs/fsck.h
zx::result<NodeInfo> ReadNodeBlock (nid_t nid, BlockBuffer<Node> & block)
Even in a successful return, the returned pair can be |{*nullptr*, node_info}| if
|node_info.blkaddr| is |kNewAddr|.
Defined at line 285 of file ../../src/storage/f2fs/fsck.cc
zx_status_t ValidateNodeBlock (const Node & node_block, NodeInfo node_info, FileType ftype, NodeType ntype)
Defined at line 205 of file ../../src/storage/f2fs/fsck.cc
zx::result<bool> UpdateContext (const Node & node_block, NodeInfo node_info, FileType ftype, NodeType ntype)
This function checks the validity of a node block with respect to the traverse context and
updates the context. In a successful return, this function returns a bool value to indicate
whether the caller should traverse deeper.
Defined at line 230 of file ../../src/storage/f2fs/fsck.cc
void AddIntoInodeLinkMap (nid_t nid, uint32_t link_count)
Defined at line 114 of file ../../src/storage/f2fs/fsck.cc
zx_status_t FindAndIncreaseInodeLinkMap (nid_t nid)
Defined at line 122 of file ../../src/storage/f2fs/fsck.cc
bool IsValidSsaNodeBlock (nid_t nid, uint32_t block_address)
Defined at line 130 of file ../../src/storage/f2fs/fsck.cc
bool IsValidSsaDataBlock (uint32_t block_address, uint32_t parent_nid, uint16_t index_in_node, uint8_t version)
Defined at line 162 of file ../../src/storage/f2fs/fsck.cc
bool IsValidNid (nid_t nid)
Defined at line 186 of file ../../src/storage/f2fs/fsck.cc
bool IsValidBlockAddress (uint32_t addr)
Defined at line 191 of file ../../src/storage/f2fs/fsck.cc
block_t StartSummaryBlock ()
Defined at line 247 of file ../../src/storage/f2fs/fsck.h
block_t SummaryBlockAddress (int base, int type)
Defined at line 251 of file ../../src/storage/f2fs/fsck.h
void NodeInfoFromRawNat (NodeInfo & ni, RawNatEntry & raw_nat)
Defined at line 255 of file ../../src/storage/f2fs/fsck.h
std::unique_ptr<BcacheMapper> Destroy ()
Defined at line 270 of file ../../src/storage/f2fs/fsck.h
SegmentManager & GetSegmentManager ()
For testing
Defined at line 276 of file ../../src/storage/f2fs/fsck.h
SuperblockInfo & GetSuperblockInfo ()
For testing
Defined at line 288 of file ../../src/storage/f2fs/fsck.h
zx::result<TraverseResult> CheckNodeBlock (const Inode * inode, nid_t nid, FileType ftype, NodeType ntype)
This is the main logic of fsck.
It reads and validates a node block, updates the context and traverse along its child blocks.
Defined at line 316 of file ../../src/storage/f2fs/fsck.cc
zx_status_t TraverseInode (nid_t ino, FileType ftype)
Below traverse functions describe how to iterate over for each data structures.
Defined at line 631 of file ../../src/storage/f2fs/fsck.cc
zx::result<TraverseResult> TraverseInodeBlock (const Node & node_block, NodeInfo node_info, FileType ftype)
Defined at line 371 of file ../../src/storage/f2fs/fsck.cc
zx::result<TraverseResult> TraverseDnodeBlock (const Inode * inode, const Node & node_block, NodeInfo node_info, FileType ftype)
Defined at line 475 of file ../../src/storage/f2fs/fsck.cc
zx::result<TraverseResult> TraverseIndirectNodeBlock (const Inode * inode, const Node & node_block, FileType ftype)
Defined at line 496 of file ../../src/storage/f2fs/fsck.cc
zx::result<TraverseResult> TraverseDoubleIndirectNodeBlock (const Inode * inode, const Node & node_block, FileType ftype)
Defined at line 515 of file ../../src/storage/f2fs/fsck.cc
zx_status_t CheckDataBlock (uint32_t block_address, uint32_t & child_count, uint32_t & child_files, int last_block, FileType ftype, uint32_t parent_nid, uint16_t index_in_node, uint8_t ver)
Defined at line 595 of file ../../src/storage/f2fs/fsck.cc
zx_status_t CheckDentries (uint32_t & child_count, uint32_t & child_files, int last_block, const uint8_t * dentry_bitmap, const DirEntry * dentries, const uint8_t (*)[8] filename, size_t max_entries)
Defined at line 534 of file ../../src/storage/f2fs/fsck.cc
zx_status_t CheckDentryBlock (uint32_t block_address, uint32_t & child_count, uint32_t & child_files, int last_block)
Defined at line 587 of file ../../src/storage/f2fs/fsck.cc
void PrintRawSuperblockInfo ()
Defined at line 1208 of file ../../src/storage/f2fs/fsck.cc
void PrintCheckpointInfo ()
Defined at line 1248 of file ../../src/storage/f2fs/fsck.cc
void PrintInodeInfo (const Inode & inode)
Defined at line 1138 of file ../../src/storage/f2fs/fsck.cc
void PrintNodeInfo (const Node & node_block)
Defined at line 1192 of file ../../src/storage/f2fs/fsck.cc
zx_status_t DoMount ()
Fsck checks f2fs consistency as below.
1. It loads a valid superblock, and it obtains valid node/inode/block count information.
Defined at line 1953 of file ../../src/storage/f2fs/fsck.cc
zx_status_t Init ()
2. It builds three bitmap:
a) main_area_bitmap indicates valid blocks that DoFsck() will identify.
b) nat_area_bitmap indicates used NIDs retrieved from NAT.
Once DoFsck() identifies a valid NID, it clears the bit.
c) sit_area_bitmap indicates valid blocks retrieved from SIT.
DoFsck() references it for checking the block validity.
Defined at line 713 of file ../../src/storage/f2fs/fsck.cc
zx_status_t CheckOrphanNodes ()
3. It checks orphan nodes, and it updates nat_area_bitmap.
Defined at line 652 of file ../../src/storage/f2fs/fsck.cc
zx_status_t DoFsck ()
4. It traverses blocks from the root inode to leaf inodes to check the validity of
the data/node blocks based on SSA and SIT and to update nat_area_bitmap and main_area_bitmap.
In case of dir block, it checks the validity of child dentries and regarding inodes.
It tracks various count information as well.
Defined at line 1993 of file ../../src/storage/f2fs/fsck.cc
zx_status_t Verify ()
5. It determines the consistency:
a) main_area_bitmap must be the same as sit_area_bitmap
b) all bits in nat_area_bitmap must be clear. That is, no dangling NIDs.
c) The count information that DoFsck() retrieves must be the same as that in 1.
d) no unreachable links
Defined at line 759 of file ../../src/storage/f2fs/fsck.cc
zx_status_t Repair ()
If the repair option is set and Verify() fails,
fsck will call Repair() to repair specific filesystem flaws and bring consistency.
Defined at line 1119 of file ../../src/storage/f2fs/fsck.cc
zx_status_t RepairNat ()
RepairNat() nullifies unreachable NAT entries, including those in the journal.
Defined at line 874 of file ../../src/storage/f2fs/fsck.cc
zx_status_t RepairSit ()
RepairSit() nullifies unreachable bits in SIT entries, including those in the journal.
Defined at line 946 of file ../../src/storage/f2fs/fsck.cc
zx_status_t RepairCheckpoint ()
RepairCheckpoint() corrects members in the checkpoint, including
|valid_block_count|, |valid_node_count|, |valid_inode_count|, |cur_node_blkoff|,
|cur_data_blkoff|.
Defined at line 1026 of file ../../src/storage/f2fs/fsck.cc
zx_status_t RepairInodeLinks ()
RepairInodeLinks() iterates over inode link map and corrects link count for each inode.
Defined at line 1087 of file ../../src/storage/f2fs/fsck.cc
zx_status_t RepairDataExistFlag ()
RepairDataExistFlag() sets kDataExist for each inode that has inline data with the flag unset.
Defined at line 1103 of file ../../src/storage/f2fs/fsck.cc
void DoUmount ()
Defined at line 1983 of file ../../src/storage/f2fs/fsck.cc
zx_status_t Run ()
Defined at line 2018 of file ../../src/storage/f2fs/fsck.cc
zx_status_t GetValidSuperblock ()
Defined at line 1302 of file ../../src/storage/f2fs/fsck.cc
zx::result<std::pair<std::unique_ptr<BlockBuffer<Checkpoint>>, uint64_t>> ValidateCheckpoint (block_t cp_addr)
Defined at line 1313 of file ../../src/storage/f2fs/fsck.cc
zx_status_t GetValidCheckpoint ()
Defined at line 1364 of file ../../src/storage/f2fs/fsck.cc
zx_status_t InitNodeManager ()
Defined at line 1402 of file ../../src/storage/f2fs/fsck.cc
zx_status_t BuildNodeManager ()
Defined at line 1423 of file ../../src/storage/f2fs/fsck.cc
zx_status_t BuildSitInfo ()
Defined at line 1436 of file ../../src/storage/f2fs/fsck.cc
zx_status_t BuildCurseg ()
Defined at line 1614 of file ../../src/storage/f2fs/fsck.cc
zx_status_t BuildSegmentManager ()
Defined at line 1807 of file ../../src/storage/f2fs/fsck.cc
void BuildNatAreaBitmap ()
Defined at line 1886 of file ../../src/storage/f2fs/fsck.cc
void BuildSitAreaBitmap ()
Defined at line 1838 of file ../../src/storage/f2fs/fsck.cc
void BuildSitEntries ()
Defined at line 1781 of file ../../src/storage/f2fs/fsck.cc
zx_status_t ReadCompactedSummaries ()
Defined at line 1478 of file ../../src/storage/f2fs/fsck.cc
zx_status_t ReadNormalSummaries (CursegType type)
Defined at line 1541 of file ../../src/storage/f2fs/fsck.cc
zx_status_t RestoreNodeSummary (uint32_t segno, SummaryBlock & summary_block)
Given a node segment index |segno|,
this function reads each block's footer in the segment and
restores nid part of entries in |summary_block|.
Defined at line 1528 of file ../../src/storage/f2fs/fsck.cc
SegType GetSumBlockInfo (uint32_t segno, BlockBuffer<SummaryBlock> & summary_block)
Defined at line 1682 of file ../../src/storage/f2fs/fsck.cc
std::pair<SegType, Summary> GetSummaryEntry (uint32_t block_address)
Defined at line 1723 of file ../../src/storage/f2fs/fsck.cc
void ResetCurseg (CursegType type, int modified)
Defined at line 1469 of file ../../src/storage/f2fs/fsck.cc
zx_status_t RestoreCursegSummaries ()
Defined at line 1596 of file ../../src/storage/f2fs/fsck.cc
std::unique_ptr<BlockBuffer<SitBlock>> GetCurrentSitPage (uint32_t segno)
Defined at line 1629 of file ../../src/storage/f2fs/fsck.cc
void SegmentInfoFromRawSit (SegmentEntry & segment_entry, const SitEntry & raw_sit)
Defined at line 1666 of file ../../src/storage/f2fs/fsck.cc
void CheckBlockCount (uint32_t segno, const SitEntry & raw_sit)
Defined at line 1647 of file ../../src/storage/f2fs/fsck.cc
zx::result<RawNatEntry> LookupNatInJournal (nid_t nid)
Defined at line 1868 of file ../../src/storage/f2fs/fsck.cc
zx::result<RawNatEntry> GetNatEntry (nid_t nid)
Defined at line 1736 of file ../../src/storage/f2fs/fsck.cc
void CheckSegmentRange (uint32_t segno)
Defined at line 1624 of file ../../src/storage/f2fs/fsck.cc
SegmentEntry & GetSegmentEntry (uint32_t segno)
Defined at line 1677 of file ../../src/storage/f2fs/fsck.cc
uint32_t GetSegmentNumber (uint32_t block_address)
Defined at line 1718 of file ../../src/storage/f2fs/fsck.cc
zx::result<NodeInfo> GetNodeInfo (nid_t nid)
Defined at line 1768 of file ../../src/storage/f2fs/fsck.cc
zx_status_t VerifyCursegOffset (CursegType segtype)
Defined at line 726 of file ../../src/storage/f2fs/fsck.cc
zx::result<bool> CheckXattrBlock (uint32_t ino, uint32_t x_nid)
Defined at line 680 of file ../../src/storage/f2fs/fsck.cc