sofs19  0.1
FUSE based file system
freelists

Functions to manage the list of free inodes and the list of free blocks. More...

Functions

uint32_t soAllocInode (uint32_t type, uint32_t perm)
 Allocate a free inode. More...
 
void soFreeInode (uint32_t in)
 Free the referenced inode. More...
 
uint32_t soAllocDataBlock ()
 Allocate a free data block. More...
 
void soFreeDataBlock (uint32_t bn)
 Free the referenced data block. More...
 
void soReplenishHeadCache ()
 Replenish the head cache. More...
 
void soDepleteTailCache ()
 Deplete the tail cache. More...
 

Detailed Description

Functions to manage the list of free inodes and the list of free blocks.

Remarks
In case an error occurs, every function throws an SOException.

Function Documentation

◆ soAllocInode()

uint32_t sofs19::soAllocInode ( uint32_t  type,
uint32_t  perm 
)

Allocate a free inode.

An inode is retrieved from the list of free inodes and is properly initialized.

Parameters
[in]typethe inode type
[in]permpermissions of the newly allocated inode
Remarks
  • type must represent either a file (S_IFREG), a directory (S_IFDIR), or a symbolic link (S_IFLNK); if not, error EINVAL is thrown;
  • perm must represent a valid permission pattern (a octal value in the range 0000 to 0777); if not, error EINVAL is thrown;
  • if there are no free inodes, error ENOSPC is thrown;
  • when calling a function of any layer, the version with prefix so is used.
Returns
the reference (number) of the inode allocated

◆ soFreeInode()

void sofs19::soFreeInode ( uint32_t  in)

Free the referenced inode.

The inode is cleaned, marked as free, and inserted into the list of free inodes:

Parameters
[in]innumber (reference) of the inode to be freed
Remarks
  • when calling a function of any layer, the version with prefix so is used.

◆ soAllocDataBlock()

uint32_t sofs19::soAllocDataBlock ( )

Allocate a free data block.

A data block reference is retrieved from the head cache:

Remarks
  • if there are no free data blocks, error ENOSPC is thrown;
  • if the head cache is empty, it is replenished before the retrieval takes place;
  • when calling a function of any layer, the version with prefix so is used.
Returns
the number (reference) of the data block allocated

◆ soFreeDataBlock()

void sofs19::soFreeDataBlock ( uint32_t  bn)

Free the referenced data block.

The data block reference is inserted into the tail cache:

Parameters
bnthe number (reference) of the data block to be freed
Remarks
  • if the cache is full, it is depleted before the insertion takes place;
  • when calling a function of any layer, the version with prefix so is used.

◆ soReplenishHeadCache()

void sofs19::soReplenishHeadCache ( )

Replenish the head cache.

References to free data blocks should be transferred from the head reference data block or from the tail cache, if no reference data blocks exist, to the head cache:

Remarks
  • nothing is if the cache is not empty;
  • the tail cache is only used if there are no reference data blocks;
  • only a single block is processed, even if it is not enough to fulfill the head cache;
  • the block processed is the one pointed to by the head_blk field of the superblock;
  • after transferring a reference from A to B, the value in A becomes NullReference;
  • if after the replenish the head reference data block gets empty, the head passes to the next, if one exists, and the previous is freed;
  • in the previous situation, all entries of the freed data block sre set to NullReference;
  • when calling a function of any layer, the version with prefix so is used.

◆ soDepleteTailCache()

void sofs19::soDepleteTailCache ( )

Deplete the tail cache.

References to free data blocks should be transferred from the tail cache to the tail reference data block.

Remarks
  • nothing is done if the cache is not full;
  • only a single block is processed, even if it has no room to empty the tail cache;
  • the block processed is the one pointed to by the tail_blk field of the superblock;
  • if the previous block is full, a new reference data block is allocated, which becomes the new tail reference data block;
  • if no reference data blocks exist, a new reference data block is allocated, which becomes the new head and tail reference data block;
  • when calling a function of any layer, the version with prefix so is used.