- Block size.
- The fs allocates storage in units called blocks.
- A block cannot be less than a sector, but it is often several.
- Typical sector, 512 bytes; block 4K.
- Larger block sizes can waste file space, but reduce time spent on I/O.
- Author's file size study.
- Trade-off of space and time efficiency:
no good compromise.
- Recording free space.
- Just create a special file made up of the free space.
- Organized however files are organized.
- Windows NT does this.
- Linked list.
- Only takes space when there's plenty available.
- LIFO access. Keep the head in memory.
- Bit map
- Naturally sorted so free blocks can be allocated together.
- Uses space even when the file system is full.
- Keeping Free
- Quotas. Described in the text.
- Per-user space limits.
- Now days not used much, or sometimes enforced at application layer.
- Backups.
- The data is generally much more valuable than the machine that holds it.
- Purposes of a backup.
- Recover from disaster.
- Recover from stupidity. (Like you can do that.)
- Media.
- Tape is still important here, believe it or not.
Removable, high-density media.
- Optical media. Need a fancy jukebox, or cheap help that likes
to stay up all night.
- Remote server/Cloud.
- After a thorough disaster, you won't have an Internet connection.
- Security issues.
- Full v. incremental.
- Full: backup everything.
- Incremental: backup what's changed.
- Physical or logical.
- Physical: make copies of all the disk blocks.
- Works well with any file system.
- Carefully backs up all the empty space.
- Logical: make copies of all the files.
- Caching
- Area of OS contains in-memory copies of disk blocks called a
buffer cache.
- Cache is managed by a modified LRU policy.
- Blocks heuristically unlikely to be used again go to the front of the
queue.
- Parts of the file system structure are given priority.
- When a disk block is needed, check the cache first.
- If it's there, avoids a disk I/O.
- If not, bring it in, replacing the least-recently-used one.
- Writes modify blocks in the cache.
- Changes made in memory must be written to disk.
- Write-back cache: the changes periodically written to disk.
- Write-through cache: all changes are committed to disk immediately.
- Write-back produces more disk traffic, but better survives crashes.
- Readahead. Tries to read blocks before they are needed.
- When several blocks have been read sequentially, mark the file as
sequential.
- When an out-of-order read occurs, clear the sequential mark.
- When an application reads a block from a sequential file
(hopefully already in the cache), issue a read for the next one and
add it there.
- If reading pattern changes, there is some waste, but not an error.
- Sometimes the page cache (in-memory pages) and buffer cache are
unified.
- Reducing seek time
- Try to keep parts of file near each other on disk.
- Can allocate free space in units larger than the block size.
- Other operations are based on the block size, as usual.
- Each allocation of new space to a file is several adjacent blocks.
- Cylinder groups.
- Divide disk into sections.
- Each has its own free list.
- Allocate space new file space from the same CG until it becomes
fuller than some parameter. Then pick a relatively empty one.
- Doesn't matter with a flash drive.