✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ File Systems: Disk Organization File Systems: Disk Organization CS 105 “Tour of the Black Holes of Computing” A disk is a sequence of 4096-byte sectors or blocks Can only read or write in block-sized units First comes boot block and partition table File Systems File Systems Partition table divides the rest of disk into partitions May appear to operating system as logical “disks” Useful for multiple OSes, etc. Topics Otherwise bad idea; hangover from earlier days Design criteria File system : partition structured to hold files (of data) History of file systems May aggregate blocks into segments or clusters � Typical size: 8K–128M bytes Berkeley Fast File System � Increases efficiency by reducing overhead Effect of file systems on programs � But may waste space if files are small CS 105 – 2 – Disk Geometry Disk Geometry Disk Geometry Disk Geometry (Muliple-Platter View) (Muliple-Platter View) Disks consist of stacked platters, each with two surfaces Aligned tracks form a cylinder (this view is outdated) Each surface consists of concentric rings called tracks cylinder k Each track consists of sectors separated by gaps surface 0 tracks platter 0 surface surface 1 track k gaps surface 2 platter 1 surface 3 surface 4 platter 2 surface 5 spindle spindle sectors CS 105 CS 105 – 3 – – 4 –
✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ Disk Operation (Single-Platter View) Disk Operation (Single-Platter View) Disk Operation (Multi-Platter View) Disk Operation (Multi-Platter View) The disk Read/write head surface is attached to end spins at a fixed of the arm and flies over rotational rate disk surface on thin cushion of air spindle spindle By moving radially, arm can position read/write head over any track CS 105 CS 105 – 5 – – 6 – Disk Access Time Disk Access Time Disk Access Time Example Disk Access Time Example Average time to access some target sector approximated by : Given: T access = T avg seek + T avg rotation + T avg transfer Rotational rate = 7200 RPM (typical desktop; laptops usually 5400) Average seek time = 9 ms (given by manufacturer) Seek time (T avg seek ) Avg # sectors/track = 400 Time to position heads over cylinder containing target sector Typical T avg seek = 9 ms Derived: T avg rotation = 1/2 x (60 secs/7200 RPM) x 1000 ms/sec = 4 ms Rotational latency (T avg rotation ) T avg transfer = 60/7200 RPM x 1/400 secs/track x 1000 ms/sec = 0.02 ms Time waiting for first bit of target sector to pass under read/write head T access = 9 ms + 4 ms + 0.02 ms T avg rotation = 1/2 x 1/RPMs x 60 sec/1 min Important points: Transfer time (T avg transfer ) Access time dominated by seek time and rotational latency Time to read the bits in the target sector. First bit in a sector is the most expensive, the rest are “free” T avg transfer = 1/RPM x 1/(avg # sectors/track) x 60 secs/1 min SRAM access time is about 4 ns/doubleword, DRAM about 60 ns Disk is about 40,000 times slower than SRAM, and 2,500 times slower then DRAM CS 105 CS 105 – 7 – – 8 –
✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ Logical Disk Blocks Logical Disk Blocks Block Access Block Access Modern disks present a simpler abstract view of the complex sector Disks can only read and write complete sectors (blocks) geometry: Not possible to work with individual bytes (or words or…) Set of available sectors is modeled as a sequence of b-sized logical blocks (0, 1, 2, File system data structures are usually smaller than a block ...) OS must pack structures together to create a block Mapping between logical blocks and actual (physical) sectors Disk treats all data as uninterpreted bytes (one block at a time) Maintained by hardware/firmware device called disk controller (partly on OS must read block into (byte) buffer and then convert into meaningful data motherboard, mostly in disk itself) structures Converts requests for logical blocks into (surface,track,sector) triples Conversion process is called serialization (for write) and deserialization Allows controller to set aside spare cylinders for each zone OS carefully arranges for this to happen by simple C type-casting Accounts for (some of) the difference in “formatted capacity” and “maximum Need to work in units of blocks affects file system design capacity” Writing (e.g.) a new file name inherently rewrites other data in same block But block writes are atomic � can update multiple values at once CS 105 CS 105 – 9 – – 10 – Aside: Solid-State Disks Aside: Solid-State Disks Design Problems Design Problems They aren’t disks! But for backwards compatibility they pretend to be… So, disks have mechanical delays (and SSDs have their own strange behaviors) SSDs are divided into erase blocks made up of pages Fundamental problem in file-system design: how to hide (or at least Typical page: 4K-8K bytes minimize) these delays? Typical erase block: 128K-512K Can only change bits from 1 to 0 when writing Side problems also critical: Erase sets entire block to all 1’s Making things reliable (in face of software and hardware failures) Erase is slow � People frown on losing data Can only erase 10 4 to 10 6 times Organizing data (e.g., in directories or databases) Must pre-plan erases and manage wear-out � Not finding stuff is almost as bad as losing it Enforcing security Net result: � System should only share what you want to share Reads are fast (and almost truly random-access) Writes are 100X slower (and have weird side effects) CS 105 CS 105 – 11 – – 12 –
✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ ✁ Typical Similarities Among File Systems Typical Similarities Among File Systems Typical Differences Between File Systems Typical Differences Between File Systems A (secondary) boot record Naming conventions: case, length, special symbols A top-level directory File size and placement Support for hierarchical directories Speed Management of free and used space Error recovery Metadata about files (e.g., creation date) Metadata details Protection and security Support for special files Snapshot support CS 105 CS 105 – 14 – – 15 – Case Study: Berkeley Fast File System Case Study: Berkeley Fast File System FFS Headers FFS Headers (FFS) (FFS) First public Unix (Unix V7) introduced many important concepts in Unix Boot block: first few sectors File System (UFS) Typically all of cylinder 0 is reserved for boot blocks, partition tables, etc. I-nodes Superblock: file system parameters, including Indirect blocks Size of partition (note that this is dangerously redundant) Unix directory structure and permissions system Location of root directory UFS was simple, elegant, and slow Block size Cylinder groups, each including Berkeley initiated project to solve the slowness Data blocks Many modern file systems are direct or indirect descendants of FFS List of inodes In particular, EXT2 through EXT4 Bitmap of used blocks and fragments in the group Replica of superblock (not always at start of group) CS 105 CS 105 – 16 – – 17 –
Recommend
More recommend