1 / 19

UNIX File System (UFS)

UNIX File System (UFS). Chapter Five. Topics. Background: Old System V File System On Disk Format inodes fragments block allocation Consistency Issues. Features. Traditional BSD Local File System Compatible with Berkeley 4.3 Tahoe release Digital Enhancements

anson
Télécharger la présentation

UNIX File System (UFS)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. UNIX File System (UFS) Chapter Five

  2. Topics • Background: Old System V File System • On Disk Format • inodes • fragments • block allocation • Consistency Issues

  3. Features • Traditional BSD Local File System • Compatible with Berkeley 4.3 Tahoe release • Digital Enhancements • increased file and path sizes • file block clustering • File on File Layer for STREAMS • Unified Buffer Cache Integration • Support for Enhanced File Attributes

  4. History: The old System V File System Layout Boot Block Super Block Inode Table Data

  5. Boot Block Super Block Alternate Super Block Cylinder Group Block Inode Table Data Data Alternate Super Block Cylinder Group Block Inode Table Data Cylinder Group 0 Cylinder Group N Partition UNIX File System Layout

  6. UFS Block Types • bootblocks • superblocks • inodes • data blocks • cylinder group information

  7. Inodes • State of an individual file • disk inode • stored on disk • sized to fit evenly in a disk block • incore inode • in-memory • disk inode information plus information related to being a currently open file • for UFS, vnode v_data private is an incore inode

  8. Common to all File Systems Specific to this File System Mode Link Count UID GID Size Access Date Modify Date Create Date 15 Pointers Actual Block Count Gener- ation Number 0 127 Data Block Pointers Level of Indirection 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 (not implemented) Data Block Indirection Block Indirection Block Indirection Block Data Block Indirection Block Indirection Block Sticky SUID SGID File type User Group Other Data Block Indirection Block Data Block Disk Inode

  9. Inode Numbers • Inodes numbered from 1 • Position #1, • originally an inode for bad data blocks, no longer used for that purpose. • Position #2 • inode for the root directory of the file system • UFS file identity is <device, inumber>

  10. X X X X X X X X FILE 1 Small Blocks Require More Overhead X FILE 2 X X X X X X X X FILE 1 Large Blocks Waste Space X FILE 2 X X X X X X X X FILE 1 Large Blocks and Small Fragments X FILE 2 Fragments (1)

  11. Fragments (2) • UFS Blocks are 8192 Bytes • good for modern disk drives • bad for small files • space wasted with internal fragmentation • Fragment • Subdivision of a Block • 1024 Bytes • Consecutive fragments are use for the last partial block of small files

  12. Fragment (3) • Cylinder Group Block has one bit set for each fragment in the cylinder group 117 118 119 Block # free bits 01101011 11111111 00010000

  13. Disk Block Allocation • Whenever Possible • First 96KB Direct Block Allocation • in cylinder containing inode • Each Additional 2 Meg • cylinder groups with "lots" of free space • Allocate consecutive disk blocks • Works well until disk reaches 90% full

  14. Inode Allocation • Regular Files • in cylinder group of parent directory • Directories • in different cylinder group than parent directory

  15. Directories in UFS • Collection of inode:file_name pairs • four byte inode number • two byte length of entry • two byte length of name • null terminated name • padding to next four byte boundary • Deleted entries become padding for previous • Entries must fit in a 512-byte sector so disk write is atomic

  16. Symbolic Links • Hard Links: ln • new directory entry added referencing an existing inode • link count in existing inode incremented • Soft Links: ln -s • new directory entry added referencing a new inode • new inode is of type sym link • if link path short enough • stored in data block map area of inode • referred to as a fast link • else • link path stored in a data block

  17. UFS Consistency • If Machine Crashes • writes to data blocks may be lost • Disaster if the lost block • is an indirect block containing the disk addresses of newly written data blocks already on disk. • is a directory block containing new file references newly created files with written inodes. • contains free list information about newly allocated blocks.

  18. UFS Solution • Some Writes are Synchronous • Any changed block that refers to other blocks • 30 second update process sync's all mounted file systems • Directory entries are not written across sector boundaries • fsck utility after reboot • must know usual order of UFS synchronous writes

  19. Source References • kernel/ufs/fs.h • definitions of super block (struct fs) and cylinder groups (struct csum) • kernel/ufs/dinode.h • definition on disk inode (struct dinode) • kernel/ufs/inode.h • definition of in-memory inode (struct inode) • kernel/ufs/ufs_vnops.c • implementation of vnode ops for ufs • kernel/ufs/ufsmount.h • definition of the ufs mount structure • kernel/ufs/ufs_vfsops.c • implementation of the ufs vfs ops.

More Related