The Pedigree Project 0.1
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
Ext2Filesystem Class Reference

#include <Ext2Filesystem.h>

+ Inheritance diagram for Ext2Filesystem:
+ Collaboration diagram for Ext2Filesystem:

Classes

struct  AttributeRetirement
 
struct  AttributeWrite
 
class  SyncSnapshot
 

Public Member Functions

virtual bool initialise (Disk *pDisk)
 
virtual File * getRoot () const
 
virtual const String & getVolumeLabel () const
 
virtual bool getUuid (String &uuid) const
 
virtual FileHandleStatus encodeFileHandle (File &, FileHandle &)
 
virtual FileHandleStatus decodeFileHandle (const FileHandle &, RetainedFile &)
 
virtual FileHandleStatus fileHandleFsid (FileSystemId &)
 
virtual SyncStatus sync ()
 
virtual SyncStatus shutdown ()
 
virtual bool deviceRemoved (bool deviceAvailable=false)
 
virtual QuotaStatus quotaControl (const QuotaRequest &, QuotaResponse &, File *quotaFile=nullptr)
 
- Public Member Functions inherited from Filesystem
 Filesystem ()
 
virtual ~Filesystem ()
 
virtual File * find (const StringView &path)
 
virtual File * find (const String &path)
 
virtual File * find (const StringView &path, File *pStartNode)
 
virtual File * find (const String &path, File *pStartNode)
 
File * findRetained (const StringView &path, Directory::ChildLease &result, File *pStartNode=nullptr)
 
bool tryAcquireOperation (OperationBarrier::Lease &operation) const
 
bool isDeviceRemoved () const
 
bool createFile (const StringView &path, uint32_t mask, File *pStartNode=0)
 
bool createDirectory (const StringView &path, uint32_t mask, File *pStartNode=0)
 
bool createSymlink (const StringView &path, const String &value, File *pStartNode=0)
 
bool createLink (const StringView &path, File *target, File *pStartNode=0)
 
bool remove (const StringView &path, File *pStartNode=0)
 
bool remove (const StringView &path, File *pStartNode, File *expected)
 
bool rename (const StringView &oldPath, File *oldStart, const StringView &newPath, File *newStart, bool noReplace=false)
 
Disk * getDisk ()
 
bool isReadOnly ()
 
virtual bool isCaseSensitive ()
 
bool remove (File *parent, File *file)
 

Static Public Member Functions

static Filesystem * probe (Disk *pDisk)
 

Protected Member Functions

virtual bool createFile (File *parent, const String &filename, uint32_t mask)
 
virtual bool createDirectory (File *parent, const String &filename, uint32_t mask)
 
virtual bool createSymlink (File *parent, const String &filename, const String &value)
 
virtual bool createLink (File *parent, const String &filename, File *target)
 
virtual bool removeNode (File *parent, const String &filename, File *file)
 
virtual bool renameNode (Directory *oldParent, const String &oldName, File *source, Directory *newParent, const String &newName, File *replaced)
 
- Protected Member Functions inherited from Filesystem
bool beginDeviceRemoval (bool deviceAvailable)
 

Private Types

enum class  AttributeWriteKind { Payload , Allocation , Inode }
 

Private Member Functions

void releaseMetadata ()
 
QuotaStatus prepareQuotaInodeLocked (uint32_t inode)
 
QuotaStatus scanQuotaInodesLocked ()
 
QuotaStatus flushQuotaLocked (QuotaType type)
 
QuotaStatus flushQuotas ()
 
bool closeQuotaFiles (bool discardOnFailure=true)
 
bool beginWritableMount ()
 
bool isQuotaFile (uint32_t inode)
 
void releaseSyncState (uint32_t inode, Ext2InodeState *state)
 
Ext2InodeState * acquireInodeState (uint32_t inode, Inode *metadata)
 
Ext2InodeState * acquireInodeStateLocked (uint32_t inode, Inode *metadata)
 
FileHandleStatus validateHandleInodeLocked (uint32_t inode, uint32_t generation, Inode *&)
 
void releaseInodeState (uint32_t inode, Ext2InodeState *state, Ext2Node *lastNode)
 
void retireInodeLocked (uint32_t inode, Ext2Node *lastNode)
 
XattrStatus attributeFormatStatus () const
 
XattrStatus readAttributeBlockLocked (Inode *, AttributeRetirement &)
 
XattrStatus prepareAttributeRetirementLocked (Inode *, AttributeRetirement &)
 
void commitAttributeRetirementLocked (AttributeRetirement &)
 
XattrStatus allocateAttributeBlockLocked (uint32_t inode, AttributeRetirement &)
 
XattrStatus reserveAttributeWritesLocked (size_t additional)
 
void recordAttributeWriteLocked (uint64_t, AttributeWriteKind, bool adoptPin=false)
 
void recordAttributeAllocationLocked (uint32_t block)
 
void recordAttributeInodeLocked (uint32_t inode)
 
void forgetAttributeBlockLocked (uint32_t block)
 
bool flushAttributeWritesLocked ()
 
void drainAttributeWrites ()
 
virtual bool createNode (File *parent, const String &filename, uint32_t mask, const String &value, size_t type, uint32_t inodeOverride=0)
 
 Ext2Filesystem (const Ext2Filesystem &)
 
void operator= (const Ext2Filesystem &)
 
uintptr_t readBlock (uint32_t block)
 
DiskReadView readBlockView (uint32_t block)
 
void writeBlock (uint32_t block)
 
bool pinBlock (uint64_t location)
 
void unpinBlock (uint64_t location)
 
bool syncBlock (uint32_t block, bool async)
 
bool syncInode (uint32_t inode, Ext2Node &node, bool includeNamespaceMetadata=false)
 
uint32_t findFreeBlock (uint32_t inode)
 
bool findFreeBlocks (uint32_t inode, size_t count, Vector< uint32_t > &blocks)
 
size_t findFreeBlocksInGroup (uint32_t group, size_t maxCount, Vector< uint32_t > &blocks)
 
uint32_t findFreeInode (uint32_t uid=0, uint32_t gid=0)
 
void releaseBlock (uint32_t block, uint32_t inode=0)
 
bool releaseInode (uint32_t inode, Ext2Node *retiringNode=nullptr)
 
Inode * getInode (uint32_t num)
 
void writeInode (uint32_t num)
 
bool ensureFreeBlockBitmapLoaded (size_t group)
 
bool ensureFreeInodeBitmapLoaded (size_t group)
 
uintptr_t loadInodeTableBlock (size_t group, size_t block)
 
void releaseBlockLocked (uint32_t block, uint32_t inode=0)
 
bool prepareBlockReleaseLocked (uint32_t block)
 
bool prepareInodeWrite (uint32_t inode)
 
bool checkOptionalFeature (size_t feature)
 
bool checkRequiredFeature (size_t feature)
 
bool checkReadOnlyFeature (size_t feature)
 
void increaseInodeRefcount (uint32_t inode)
 
bool decreaseInodeRefcount (uint32_t inode)
 

Static Private Member Functions

static bool quotaSucceeded (QuotaStatus status)
 
static QuotaStatus quotaIoStatus ()
 
static int currentIoError ()
 

Private Attributes

Ext2QuotaLedger m_Quota
 
Mutex m_QuotaControlLock
 
Mutex m_QuotaNamespaceLock
 
Ext2File * m_QuotaFiles [2] = {}
 
AttributeWrite m_AttributeWrites [MaximumAttributeWrites]
 
size_t m_AttributeWriteCount = 0
 
Mutex m_InodeStateLock
 
Tree< uint32_t, Ext2InodeState * > m_InodeStates
 
Superblock * m_pSuperblock
 
uint16_t m_MountState = 0
 
bool m_ShutdownComplete = false
 
bool m_TeardownFailed = false
 
GroupDesc ** m_pGroupDescriptors
 
Vector< size_t > * m_pInodeTables
 
Vector< size_t > * m_pInodeBitmaps
 
Vector< size_t > * m_pBlockBitmaps
 
uint32_t m_BlockSize
 
uint32_t m_InodeSize
 
size_t m_nGroupDescriptors
 
Mutex m_WriteLock
 
Mutex m_InodeTableLoadLock
 
File * m_pRoot
 
String m_VolumeLabel
 

Static Private Attributes

static constexpr size_t MaximumAttributeWrites = 64
 

Friends

class Ext2HandlesTestPeer
 
class Ext2XattrTestPeer
 
class Ext2FillCacheTestPeer
 
class Ext2WritebackTestPeer
 
class Ext2FilesystemSyncTestPeer
 
class Ext2DirectorySyncTestPeer
 
class Ext2AllocationTestPeer
 
class Ext2QuotaTestPeer
 
class Ext2File
 
class Ext2Node
 
class Ext2Directory
 
class Ext2Symlink
 
struct Ext2InodeState
 

Additional Inherited Members

- Public Types inherited from Filesystem
enum class  SyncStatus { Success , Unsupported , NoMemory , IoError }
 
typedef Filesystem *(* ProbeCallback) (Disk *)
 
- Protected Attributes inherited from Filesystem
bool m_bReadOnly
 
Disk * m_pDisk
 
DiskUse m_DiskUse
 
OperationBarrier m_Operations
 

Detailed Description

This class provides an implementation of the second extended filesystem.

Definition at line 46 of file Ext2Filesystem.h.

Member Enumeration Documentation

◆ AttributeWriteKind

enum class Ext2Filesystem::AttributeWriteKind
strongprivate

Definition at line 118 of file Ext2Filesystem.h.

Constructor & Destructor Documentation

◆ Ext2Filesystem() [1/2]

Ext2Filesystem::Ext2Filesystem ( )

Definition at line 67 of file Ext2Filesystem.cc.

◆ ~Ext2Filesystem()

Ext2Filesystem::~Ext2Filesystem ( )
virtual

Definition at line 83 of file Ext2Filesystem.cc.

◆ Ext2Filesystem() [2/2]

Ext2Filesystem::Ext2Filesystem ( const Ext2Filesystem &  )
private

Inaccessible copy constructor and operator=

Member Function Documentation

◆ acquireInodeState()

Ext2InodeState * Ext2Filesystem::acquireInodeState ( uint32_t  inode,
Inode *  metadata 
)
private

Definition at line 1198 of file Ext2Filesystem.cc.

◆ acquireInodeStateLocked()

Ext2InodeState * Ext2Filesystem::acquireInodeStateLocked ( uint32_t  inode,
Inode *  metadata 
)
private

Definition at line 1213 of file Ext2Filesystem.cc.

◆ allocateAttributeBlockLocked()

XattrStatus Ext2Filesystem::allocateAttributeBlockLocked ( uint32_t  inode,
AttributeRetirement &  plan 
)
private

Definition at line 175 of file Ext2Xattr-writeback.cc.

◆ attributeFormatStatus()

XattrStatus Ext2Filesystem::attributeFormatStatus ( ) const
private

Definition at line 20 of file Ext2Xattr-writeback.cc.

◆ beginWritableMount()

bool Ext2Filesystem::beginWritableMount ( )
private

Definition at line 15 of file Ext2Filesystem-sync.cc.

◆ checkOptionalFeature()

bool Ext2Filesystem::checkOptionalFeature ( size_t  feature)
private

Definition at line 1412 of file Ext2Filesystem.cc.

◆ checkReadOnlyFeature()

bool Ext2Filesystem::checkReadOnlyFeature ( size_t  feature)
private

Definition at line 1424 of file Ext2Filesystem.cc.

◆ checkRequiredFeature()

bool Ext2Filesystem::checkRequiredFeature ( size_t  feature)
private

Definition at line 1418 of file Ext2Filesystem.cc.

◆ closeQuotaFiles()

bool Ext2Filesystem::closeQuotaFiles ( bool  discardOnFailure = true)
private

Definition at line 295 of file Ext2Filesystem-quota.cc.

◆ commitAttributeRetirementLocked()

void Ext2Filesystem::commitAttributeRetirementLocked ( AttributeRetirement &  plan)
private

Definition at line 206 of file Ext2Xattr-writeback.cc.

◆ createDirectory()

bool Ext2Filesystem::createDirectory ( File *  parent,
const String &  filename,
uint32_t  mask 
)
protectedvirtual

createDirectory calls this after it has parsed the string path.

Implements Filesystem.

Definition at line 585 of file Ext2Filesystem.cc.

References createNode().

◆ createFile()

bool Ext2Filesystem::createFile ( File *  parent,
const String &  filename,
uint32_t  mask 
)
protectedvirtual

createFile calls this after it has parsed the string path.

Implements Filesystem.

Definition at line 581 of file Ext2Filesystem.cc.

References createNode().

◆ createLink()

bool Ext2Filesystem::createLink ( File *  parent,
const String &  filename,
File *  target 
)
protectedvirtual

createLink calls this after it has parsed the string path.

Reimplemented from Filesystem.

Definition at line 596 of file Ext2Filesystem.cc.

References createNode(), File::isDirectory(), and File::isSymlink().

◆ createNode()

bool Ext2Filesystem::createNode ( File *  parent,
const String &  filename,
uint32_t  mask,
const String &  value,
size_t  type,
uint32_t  inodeOverride = 0 
)
privatevirtual

◆ createSymlink()

bool Ext2Filesystem::createSymlink ( File *  parent,
const String &  filename,
const String &  value 
)
protectedvirtual

createSymlink calls this after it has parsed the string path.

Implements Filesystem.

Definition at line 592 of file Ext2Filesystem.cc.

References createNode().

◆ currentIoError()

int Ext2Filesystem::currentIoError ( )
staticprivate

Definition at line 20 of file Ext2Filesystem-quota.cc.

◆ decodeFileHandle()

FileHandleStatus Ext2Filesystem::decodeFileHandle ( const FileHandle &  handle,
RetainedFile &  result 
)
virtual

Reimplemented from Filesystem.

Definition at line 116 of file Ext2Handles.cc.

◆ decreaseInodeRefcount()

bool Ext2Filesystem::decreaseInodeRefcount ( uint32_t  inode)
private

Definition at line 1581 of file Ext2Filesystem.cc.

◆ deviceRemoved()

bool Ext2Filesystem::deviceRemoved ( bool  deviceAvailable = false)
virtual

Rejects backend operations and releases a removed device's ownership.

Reimplemented from Filesystem.

Definition at line 151 of file Ext2Filesystem.cc.

References Tree< K, E >::begin(), Filesystem::deviceRemoved(), Tree< K, E >::end(), Filesystem::m_bReadOnly, Filesystem::m_pDisk, and Disk::unpin().

◆ drainAttributeWrites()

void Ext2Filesystem::drainAttributeWrites ( )
private

Definition at line 160 of file Ext2Xattr-writeback.cc.

◆ encodeFileHandle()

FileHandleStatus Ext2Filesystem::encodeFileHandle ( File &  file,
FileHandle &  handle 
)
virtual

Caller holds a VFS mount operation through handle access and publication.

Reimplemented from Filesystem.

Definition at line 80 of file Ext2Handles.cc.

References Tree< K, E >::lookup(), m_pSuperblock, m_WriteLock, and File::supportsRegularFileOperations().

◆ ensureFreeBlockBitmapLoaded()

bool Ext2Filesystem::ensureFreeBlockBitmapLoaded ( size_t  group)
private

Definition at line 1430 of file Ext2Filesystem.cc.

◆ ensureFreeInodeBitmapLoaded()

bool Ext2Filesystem::ensureFreeInodeBitmapLoaded ( size_t  group)
private

Definition at line 1476 of file Ext2Filesystem.cc.

◆ fileHandleFsid()

FileHandleStatus Ext2Filesystem::fileHandleFsid ( FileSystemId &  result)
virtual

Reimplemented from Filesystem.

Definition at line 34 of file Ext2Handles.cc.

◆ findFreeBlock()

uint32_t Ext2Filesystem::findFreeBlock ( uint32_t  inode)
private

Definition at line 919 of file Ext2Filesystem.cc.

◆ findFreeBlocks()

bool Ext2Filesystem::findFreeBlocks ( uint32_t  inode,
size_t  count,
Vector< uint32_t > &  blocks 
)
private

Definition at line 928 of file Ext2Filesystem.cc.

◆ findFreeBlocksInGroup()

size_t Ext2Filesystem::findFreeBlocksInGroup ( uint32_t  group,
size_t  maxCount,
Vector< uint32_t > &  blocks 
)
private
Todo:
Endianness - to ensure correct operation, must ptr be little endian?
Todo:
save group descriptor block number elsewhere

Definition at line 993 of file Ext2Filesystem.cc.

References m_BlockSize, m_pBlockBitmaps, Filesystem::m_pDisk, m_pGroupDescriptors, m_pSuperblock, Vector< T >::pushBack(), Disk::write(), and writeBlock().

◆ findFreeInode()

uint32_t Ext2Filesystem::findFreeInode ( uint32_t  uid = 0,
uint32_t  gid = 0 
)
private

Definition at line 11 of file Ext2InodeAllocation.cc.

◆ flushAttributeWritesLocked()

bool Ext2Filesystem::flushAttributeWritesLocked ( )
private

Definition at line 143 of file Ext2Xattr-writeback.cc.

◆ flushQuotaLocked()

QuotaStatus Ext2Filesystem::flushQuotaLocked ( QuotaType  type)
private

Definition at line 113 of file Ext2Filesystem-quota.cc.

◆ flushQuotas()

QuotaStatus Ext2Filesystem::flushQuotas ( )
private

Definition at line 168 of file Ext2Filesystem-quota.cc.

◆ forgetAttributeBlockLocked()

void Ext2Filesystem::forgetAttributeBlockLocked ( uint32_t  block)
private

Definition at line 130 of file Ext2Xattr-writeback.cc.

◆ getInode()

Inode * Ext2Filesystem::getInode ( uint32_t  num)
private

Definition at line 1369 of file Ext2Filesystem.cc.

◆ getRoot()

File * Ext2Filesystem::getRoot ( ) const
virtual

Returns the root filesystem node.

Implements Filesystem.

Definition at line 352 of file Ext2Filesystem.cc.

References m_pRoot.

◆ getUuid()

bool Ext2Filesystem::getUuid ( String &  uuid) const
virtual

Returns the canonical filesystem UUID when this filesystem has one.

Reimplemented from Filesystem.

Definition at line 360 of file Ext2Filesystem.cc.

References m_pSuperblock.

◆ getVolumeLabel()

const String & Ext2Filesystem::getVolumeLabel ( ) const
virtual

Returns a string identifying the volume label.

Implements Filesystem.

Definition at line 356 of file Ext2Filesystem.cc.

References m_VolumeLabel.

◆ increaseInodeRefcount()

void Ext2Filesystem::increaseInodeRefcount ( uint32_t  inode)
private

Definition at line 1560 of file Ext2Filesystem.cc.

◆ initialise()

bool Ext2Filesystem::initialise ( Disk *  pDisk)
virtual

Populates this filesystem with data from the given Disk device.

Returns
true on success, false on failure.
Todo:
Check for journal required features.
Todo:
Todo:
Check all read-only features.
Todo:
Set g_pSparseBlock as read-only.

Implements Filesystem.

Definition at line 186 of file Ext2Filesystem.cc.

References Disk::getName(), TargetInfo::getPageSize(), m_BlockSize, Filesystem::m_bReadOnly, m_InodeSize, m_nGroupDescriptors, m_pBlockBitmaps, Filesystem::m_pDisk, m_pGroupDescriptors, m_pInodeBitmaps, m_pInodeTables, m_pRoot, m_pSuperblock, m_VolumeLabel, Disk::read(), readBlock(), and Disk::unpin().

◆ isQuotaFile()

bool Ext2Filesystem::isQuotaFile ( uint32_t  inode)
private

Definition at line 54 of file Ext2Filesystem-quota.cc.

◆ loadInodeTableBlock()

uintptr_t Ext2Filesystem::loadInodeTableBlock ( size_t  group,
size_t  block 
)
private

Definition at line 1522 of file Ext2Filesystem.cc.

◆ pinBlock()

bool Ext2Filesystem::pinBlock ( uint64_t  location)
private

Definition at line 718 of file Ext2Filesystem.cc.

◆ prepareAttributeRetirementLocked()

XattrStatus Ext2Filesystem::prepareAttributeRetirementLocked ( Inode *  inode,
AttributeRetirement &  plan 
)
private

Definition at line 65 of file Ext2Xattr-writeback.cc.

◆ prepareBlockReleaseLocked()

bool Ext2Filesystem::prepareBlockReleaseLocked ( uint32_t  block)
private

Definition at line 1118 of file Ext2Filesystem.cc.

◆ prepareInodeWrite()

bool Ext2Filesystem::prepareInodeWrite ( uint32_t  inode)
private

Definition at line 1128 of file Ext2Filesystem.cc.

◆ prepareQuotaInodeLocked()

QuotaStatus Ext2Filesystem::prepareQuotaInodeLocked ( uint32_t  inode)
private

Definition at line 60 of file Ext2Filesystem-quota.cc.

◆ probe()

Filesystem * Ext2Filesystem::probe ( Disk *  pDisk)
static

Definition at line 342 of file Ext2Filesystem.cc.

◆ quotaControl()

QuotaStatus Ext2Filesystem::quotaControl ( const QuotaRequest &  request,
QuotaResponse &  response,
File *  quotaFile = nullptr 
)
virtual

Reimplemented from Filesystem.

Definition at line 180 of file Ext2Filesystem-quota.cc.

◆ quotaIoStatus()

QuotaStatus Ext2Filesystem::quotaIoStatus ( )
staticprivate

Definition at line 30 of file Ext2Filesystem-quota.cc.

◆ quotaSucceeded()

bool Ext2Filesystem::quotaSucceeded ( QuotaStatus  status)
staticprivate

Definition at line 47 of file Ext2Filesystem-quota.cc.

◆ readAttributeBlockLocked()

XattrStatus Ext2Filesystem::readAttributeBlockLocked ( Inode *  inode,
AttributeRetirement &  plan 
)
private

Definition at line 32 of file Ext2Xattr-writeback.cc.

◆ readBlock()

uintptr_t Ext2Filesystem::readBlock ( uint32_t  block)
private

Reads a block of data from the disk.

Definition at line 676 of file Ext2Filesystem.cc.

References m_BlockSize, Filesystem::m_pDisk, Disk::read(), and Disk::unpin().

Referenced by Ext2Directory::addEntry(), initialise(), and Ext2Directory::removeEntryLocked().

+ Here is the caller graph for this function:

◆ readBlockView()

DiskReadView Ext2Filesystem::readBlockView ( uint32_t  block)
private

Definition at line 695 of file Ext2Filesystem.cc.

◆ recordAttributeAllocationLocked()

void Ext2Filesystem::recordAttributeAllocationLocked ( uint32_t  block)
private

Definition at line 107 of file Ext2Xattr-writeback.cc.

◆ recordAttributeInodeLocked()

void Ext2Filesystem::recordAttributeInodeLocked ( uint32_t  inode)
private

Definition at line 122 of file Ext2Xattr-writeback.cc.

◆ recordAttributeWriteLocked()

void Ext2Filesystem::recordAttributeWriteLocked ( uint64_t  location,
AttributeWriteKind  kind,
bool  adoptPin = false 
)
private

Definition at line 90 of file Ext2Xattr-writeback.cc.

◆ releaseBlock()

void Ext2Filesystem::releaseBlock ( uint32_t  block,
uint32_t  inode = 0 
)
private

Definition at line 1110 of file Ext2Filesystem.cc.

◆ releaseBlockLocked()

void Ext2Filesystem::releaseBlockLocked ( uint32_t  block,
uint32_t  inode = 0 
)
private
Todo:
save group descriptor block number elsewhere

Definition at line 1142 of file Ext2Filesystem.cc.

References Dec, Hex, m_BlockSize, m_pBlockBitmaps, Filesystem::m_pDisk, m_pGroupDescriptors, m_pSuperblock, Disk::write(), and writeBlock().

◆ releaseInode()

bool Ext2Filesystem::releaseInode ( uint32_t  inode,
Ext2Node *  retiringNode = nullptr 
)
private

Releases the given inode, returns true if the inode had no more links.

Definition at line 1257 of file Ext2Filesystem.cc.

References Tree< K, E >::lookup(), m_WriteLock, Filesystem::remove(), and retireInodeLocked().

Referenced by createNode(), and Ext2Directory::removeEntryLocked().

+ Here is the caller graph for this function:

◆ releaseInodeState()

void Ext2Filesystem::releaseInodeState ( uint32_t  inode,
Ext2InodeState *  state,
Ext2Node *  lastNode 
)
private

Definition at line 1230 of file Ext2Filesystem.cc.

◆ releaseMetadata()

void Ext2Filesystem::releaseMetadata ( )
private

Definition at line 97 of file Ext2Filesystem.cc.

◆ releaseSyncState()

void Ext2Filesystem::releaseSyncState ( uint32_t  inode,
Ext2InodeState *  state 
)
private

Definition at line 111 of file Ext2Filesystem-sync.cc.

◆ removeNode()

bool Ext2Filesystem::removeNode ( File *  parent,
const String &  filename,
File *  file 
)
protectedvirtual

Remove a backing node while the VFS holds the parent's namespace lock. A successful implementation must retire the parent's cached entry before returning and must recheck directory emptiness while holding the child's namespace lock.

Todo:
save group descriptor block number elsewhere

Implements Filesystem.

Definition at line 623 of file Ext2Filesystem.cc.

References String::compare(), File::isDirectory(), File::isSymlink(), m_BlockSize, m_pGroupDescriptors, m_pSuperblock, m_WriteLock, Ext2Directory::removeEntry(), and writeBlock().

◆ renameNode()

bool Ext2Filesystem::renameNode ( Directory *  oldParent,
const String &  oldName,
File *  source,
Directory *  newParent,
const String &  newName,
File *  replaced 
)
protectedvirtual

Change backing entries while the VFS reserves both names and owns their namespace locks. Do not call ordinary lookup/add/remove APIs here. Failure must leave both names unchanged; the VFS publishes cache changes on success.

Reimplemented from Filesystem.

Definition at line 155 of file Ext2Rename.cc.

References File::isDirectory(), File::isSymlink(), and File::m_WriteLock.

◆ reserveAttributeWritesLocked()

XattrStatus Ext2Filesystem::reserveAttributeWritesLocked ( size_t  additional)
private

Definition at line 82 of file Ext2Xattr-writeback.cc.

◆ retireInodeLocked()

void Ext2Filesystem::retireInodeLocked ( uint32_t  inode,
Ext2Node *  lastNode 
)
private
Todo:
save group descriptor block number elsewhere

Definition at line 1276 of file Ext2Filesystem.cc.

References m_BlockSize, Filesystem::m_pDisk, m_pGroupDescriptors, m_pInodeBitmaps, m_pSuperblock, Ext2Node::wipe(), Disk::write(), and writeBlock().

Referenced by releaseInode().

+ Here is the caller graph for this function:

◆ scanQuotaInodesLocked()

QuotaStatus Ext2Filesystem::scanQuotaInodesLocked ( )
private

Definition at line 76 of file Ext2Filesystem-quota.cc.

◆ shutdown()

Filesystem::SyncStatus Ext2Filesystem::shutdown ( )
virtual

After all users drain, finish teardown writes before backend destruction.

Reimplemented from Filesystem.

Definition at line 33 of file Ext2Filesystem-sync.cc.

References Tree< K, E >::begin(), Tree< K, E >::clear(), Tree< K, E >::end(), m_BlockSize, Filesystem::m_bReadOnly, Filesystem::m_pDisk, m_pRoot, m_pSuperblock, sync(), Disk::sync(), Disk::syncAll(), and Disk::write().

◆ sync()

Filesystem::SyncStatus Ext2Filesystem::sync ( )
virtual

Completes data, metadata and device writeback for changes made before entry.

Reimplemented from Filesystem.

Definition at line 118 of file Ext2Filesystem-sync.cc.

References Tree< K, E >::begin(), Tree< K, E >::count(), Tree< K, E >::end(), m_BlockSize, Filesystem::m_bReadOnly, Filesystem::m_pDisk, m_pSuperblock, m_WriteLock, and Disk::syncAll().

Referenced by shutdown().

+ Here is the caller graph for this function:

◆ syncBlock()

bool Ext2Filesystem::syncBlock ( uint32_t  block,
bool  async 
)
private

Definition at line 732 of file Ext2Filesystem.cc.

◆ syncInode()

bool Ext2Filesystem::syncInode ( uint32_t  inode,
Ext2Node &  node,
bool  includeNamespaceMetadata = false 
)
private

Definition at line 751 of file Ext2Filesystem.cc.

◆ unpinBlock()

void Ext2Filesystem::unpinBlock ( uint64_t  location)
private

Definition at line 725 of file Ext2Filesystem.cc.

◆ validateHandleInodeLocked()

FileHandleStatus Ext2Filesystem::validateHandleInodeLocked ( uint32_t  inode,
uint32_t  generation,
Inode *&  inode 
)
private

Definition at line 48 of file Ext2Handles.cc.

◆ writeBlock()

void Ext2Filesystem::writeBlock ( uint32_t  block)
private

Writes a block of data to the disk.

Definition at line 707 of file Ext2Filesystem.cc.

References m_BlockSize, Filesystem::m_pDisk, and Disk::write().

Referenced by Ext2Directory::addEntry(), createNode(), Ext2Node::ensureLargeEnough(), findFreeBlocksInGroup(), releaseBlockLocked(), Ext2Directory::removeEntryLocked(), removeNode(), and retireInodeLocked().

+ Here is the caller graph for this function:

◆ writeInode()

void Ext2Filesystem::writeInode ( uint32_t  num)
private

Definition at line 1399 of file Ext2Filesystem.cc.

Friends And Related Symbol Documentation

◆ Ext2AllocationTestPeer

friend class Ext2AllocationTestPeer
friend

Definition at line 53 of file Ext2Filesystem.h.

◆ Ext2Directory

friend class Ext2Directory
friend

Definition at line 57 of file Ext2Filesystem.h.

◆ Ext2DirectorySyncTestPeer

friend class Ext2DirectorySyncTestPeer
friend

Definition at line 52 of file Ext2Filesystem.h.

◆ Ext2File

friend class Ext2File
friend

Definition at line 55 of file Ext2Filesystem.h.

◆ Ext2FilesystemSyncTestPeer

friend class Ext2FilesystemSyncTestPeer
friend

Definition at line 51 of file Ext2Filesystem.h.

◆ Ext2FillCacheTestPeer

friend class Ext2FillCacheTestPeer
friend

Definition at line 49 of file Ext2Filesystem.h.

◆ Ext2HandlesTestPeer

friend class Ext2HandlesTestPeer
friend

Definition at line 47 of file Ext2Filesystem.h.

◆ Ext2InodeState

friend struct Ext2InodeState
friend

Definition at line 59 of file Ext2Filesystem.h.

◆ Ext2Node

friend class Ext2Node
friend

Definition at line 56 of file Ext2Filesystem.h.

◆ Ext2QuotaTestPeer

friend class Ext2QuotaTestPeer
friend

Definition at line 54 of file Ext2Filesystem.h.

◆ Ext2Symlink

friend class Ext2Symlink
friend

Definition at line 58 of file Ext2Filesystem.h.

◆ Ext2WritebackTestPeer

friend class Ext2WritebackTestPeer
friend

Definition at line 50 of file Ext2Filesystem.h.

◆ Ext2XattrTestPeer

friend class Ext2XattrTestPeer
friend

Definition at line 48 of file Ext2Filesystem.h.

Member Data Documentation

◆ m_AttributeWriteCount

size_t Ext2Filesystem::m_AttributeWriteCount = 0
private

Definition at line 126 of file Ext2Filesystem.h.

◆ m_AttributeWrites

AttributeWrite Ext2Filesystem::m_AttributeWrites[MaximumAttributeWrites]
private

Definition at line 125 of file Ext2Filesystem.h.

◆ m_BlockSize

uint32_t Ext2Filesystem::m_BlockSize
private

◆ m_InodeSize

uint32_t Ext2Filesystem::m_InodeSize
private

Size of an Inode.

Definition at line 219 of file Ext2Filesystem.h.

Referenced by initialise().

◆ m_InodeStateLock

Mutex Ext2Filesystem::m_InodeStateLock
private

Definition at line 149 of file Ext2Filesystem.h.

◆ m_InodeStates

Tree<uint32_t, Ext2InodeState*> Ext2Filesystem::m_InodeStates
private

Definition at line 150 of file Ext2Filesystem.h.

◆ m_InodeTableLoadLock

Mutex Ext2Filesystem::m_InodeTableLoadLock
private

Protects first publication of a lazily loaded inode table.

Definition at line 231 of file Ext2Filesystem.h.

◆ m_MountState

uint16_t Ext2Filesystem::m_MountState = 0
private

Definition at line 200 of file Ext2Filesystem.h.

◆ m_nGroupDescriptors

size_t Ext2Filesystem::m_nGroupDescriptors
private

Number of group descriptors.

Definition at line 222 of file Ext2Filesystem.h.

Referenced by Ext2File::allocateFileRange(), and initialise().

◆ m_pBlockBitmaps

Vector<size_t>* Ext2Filesystem::m_pBlockBitmaps
private

Free block bitmaps, indexed by group descriptor.

Definition at line 213 of file Ext2Filesystem.h.

Referenced by findFreeBlocksInGroup(), initialise(), and releaseBlockLocked().

◆ m_pGroupDescriptors

GroupDesc** Ext2Filesystem::m_pGroupDescriptors
private

Group descriptors, in a tree because each GroupDesc* may be in a different block.

Definition at line 206 of file Ext2Filesystem.h.

Referenced by createNode(), findFreeBlocksInGroup(), initialise(), releaseBlockLocked(), removeNode(), and retireInodeLocked().

◆ m_pInodeBitmaps

Vector<size_t>* Ext2Filesystem::m_pInodeBitmaps
private

Free inode bitmaps, indexed by group descriptor.

Definition at line 211 of file Ext2Filesystem.h.

Referenced by initialise(), and retireInodeLocked().

◆ m_pInodeTables

Vector<size_t>* Ext2Filesystem::m_pInodeTables
private

Inode tables, indexed by group descriptor.

Definition at line 209 of file Ext2Filesystem.h.

Referenced by initialise().

◆ m_pRoot

File* Ext2Filesystem::m_pRoot
private

The root filesystem node.

Definition at line 235 of file Ext2Filesystem.h.

Referenced by getRoot(), initialise(), and shutdown().

◆ m_pSuperblock

Superblock* Ext2Filesystem::m_pSuperblock
private

◆ m_Quota

Ext2QuotaLedger Ext2Filesystem::m_Quota
private

Definition at line 103 of file Ext2Filesystem.h.

◆ m_QuotaControlLock

Mutex Ext2Filesystem::m_QuotaControlLock
private

Definition at line 104 of file Ext2Filesystem.h.

◆ m_QuotaFiles

Ext2File* Ext2Filesystem::m_QuotaFiles[2] = {}
private

Definition at line 106 of file Ext2Filesystem.h.

◆ m_QuotaNamespaceLock

Mutex Ext2Filesystem::m_QuotaNamespaceLock
private

Definition at line 105 of file Ext2Filesystem.h.

◆ m_ShutdownComplete

bool Ext2Filesystem::m_ShutdownComplete = false
private

Definition at line 201 of file Ext2Filesystem.h.

◆ m_TeardownFailed

bool Ext2Filesystem::m_TeardownFailed = false
private

Definition at line 202 of file Ext2Filesystem.h.

◆ m_VolumeLabel

String Ext2Filesystem::m_VolumeLabel
private

Cached volume label.

Definition at line 238 of file Ext2Filesystem.h.

Referenced by getVolumeLabel(), and initialise().

◆ m_WriteLock

Mutex Ext2Filesystem::m_WriteLock
private

Write lock - we're finding some inodes and updating the superblock and block group structures. Filesystem-global metadata is the innermost lock: do not acquire a directory or node lock while holding it.

Definition at line 228 of file Ext2Filesystem.h.

Referenced by Ext2File::allocateFileRange(), createNode(), encodeFileHandle(), releaseInode(), removeNode(), and sync().

◆ MaximumAttributeWrites

constexpr size_t Ext2Filesystem::MaximumAttributeWrites = 64
staticconstexprprivate

Definition at line 124 of file Ext2Filesystem.h.


The documentation for this class was generated from the following files: