The UNIX File System Jerry Breecher Contains sections on:

Slides:



Advertisements
Similar presentations
More on File Management
Advertisements

Chapter 4 : File Systems What is a file system?
Free Space and Allocation Issues
File Systems.
File Systems Examples.
COS 318: Operating Systems File Layout and Directories
10: File Systems1 Jerry Breecher OPERATING SYSTEMS FILE SYSTEMS.
File System Implementation: beyond the user’s view A possible file system layout on a disk.
Operating Systems File Systems (in a Day) Ch
File System Implementation CSCI 444/544 Operating Systems Fall 2008.
File Systems Implementation
1 Operating Systems Chapter 7-File-System File Concept Access Methods Directory Structure Protection File-System Structure Allocation Methods Free-Space.
Ceng Operating Systems
6/24/2015B.RamamurthyPage 1 File System B. Ramamurthy.
1 Outline File Systems Implementation How disks work How to organize data (files) on disks Data structures Placement of files on disk.
1 Friday, July 07, 2006 “Vision without action is a daydream, Action without a vision is a nightmare.” - Japanese Proverb.
File System Design David E. Culler CS162 – Operating Systems and Systems Programming Lecture 24 October 24, 2014 Reading: A&D 13.3 HW 4 due 10/27 Proj.
7/15/2015B.RamamurthyPage 1 File System B. Ramamurthy.
File Systems. Main Points File layout Directory layout.
Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D.
Naming and Directories. Recall from the last time… File system components Disk management organizes disk blocks into files. Many disk blocks management.
File Implementation. File System Abstraction How to Organize Files on Disk Goals: –Maximize sequential performance –Easy random access to file –Easy.
1Fall 2008, Chapter 11 Disk Hardware Arm can move in and out Read / write head can access a ring of data as the disk rotates Disk consists of one or more.
1 File Systems Chapter Files 6.2 Directories 6.3 File system implementation 6.4 Example file systems.
File System Implementation Chapter 12. File system Organization Application programs Application programs Logical file system Logical file system manages.
File System Review bottomupcs.com J. Kubiatowicz, UC Berkeley.
File Systems CSCI What is a file? A file is information that is stored on disks or other external media.
CSCI-375 Operating Systems Lecture Note: Many slides and/or pictures in the following are adapted from: slides ©2005 Silberschatz, Galvin, and Gagne Some.
File Systems Security File Systems Implementation.
Some basic concepts and information on file systems Portions taken and modified from books by ANDREW S. TANENBAUM.
File Systems. 2 What is a file? A repository for data Is long lasting (until explicitly deleted).
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems File systems.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems File systems.
File Systems Topics Design criteria History of file systems Berkeley Fast File System Effect of file systems on programs fs.ppt CS 105 “Tour of the Black.
Chapter 6 File Systems. Essential requirements 1. Store very large amount of information 2. Must survive the termination of processes persistent 3. Concurrent.
File Systems.  Issues for OS  Organize files  Directories structure  File types based on different accesses  Sequential, indexed sequential, indexed.
Lecture Topics: 11/22 HW 7 File systems –block allocation Unix and NT –disk scheduling –file caches –RAID.
W4118 Operating Systems Instructor: Junfeng Yang.
File Systems and Disk Management
29 July 2015 Charles Reiss
Chapter 11: File System Implementation
FileSystems.
File System Structure How do I organize a disk into a file system?
Filesystems.
CS162 Operating Systems and Systems Programming Lecture 18 File Systems October 30th, 2017 Prof. Anthony D. Joseph
Naming and Directories
EECE.4810/EECE.5730 Operating Systems
OPERATING SYSTEMS FILE SYSTEMS
File Systems and Disk Management
CS510 Operating System Foundations
Chapter 11: File-System Interface
File Systems: Fundamentals.
File System B. Ramamurthy B.Ramamurthy 11/27/2018.
Introduction to Operating Systems
File Systems and Disk Management
File Systems and Disk Management
File Systems and Disk Management
File System Implementation
File Systems and Disk Management
File Systems and Disk Management
File Systems and Disk Management
October 1st, 2017 Prof. Ion Stoica
File Systems: Fundamentals
File system : Disk Space Management
Naming and Directories
SE350: Operating Systems Lecture 12: File Systems.
CS 105 “Tour of the Black Holes of Computing”
Lecture 4: File-System Interface
Chapter 5 File Systems -Compiled for MCA, PU
October 5th, 2018 Prof. Ion Stoica
Presentation transcript:

The UNIX File System Jerry Breecher Contains sections on: -- Directory Structure (Inode) -- Storage Behavior -- Allocation Jerry Breecher

The UNIX File System Used since 1970’s on UNIX. Basis of today’s LINUX file systems Original inode format appeared in BSD 4.1 Berkeley Standard Distribution Unix Part of your heritage! Similar structure for Linux Ext2/3 File Number is index into inode arrays Multi-level index structure Great for little and large files Asymmetric tree with fixed sized blocks Metadata associated with the file Rather than in the directory that points to it UNIX Fast File System (FFS) BSD 4.2 Locality Heuristics: Block group placement Reserve space Scalable directory structure

File Concept Attributes of a File Name – only information kept in human-readable form Identifier – unique tag (number) identifies file within file system Type – needed for systems that support different types Location – pointer to file location on device Size – current file size Protection – controls who can do reading, writing, executing Time, date, and user identification – data for protection, security, and usage monitoring Information about files is kept in the directory structure, which is maintained on the disk.

File Concept What can we find out about a Linux File? jbreecher@younger:~$ stat A_File File: `A_File' Size: 6491 Blocks: 16 IO Block: 4096 regular file Device: 14h/20d Inode: 20938754 Links: 1 Access: (0600/-rw-------) Uid: ( 1170/jbreecher) Gid: ( 100/ users) Access: 2006-11-15 15:38:17.000000000 -0500 Modify: 2006-09-27 17:44:10.000000000 -0400 Change: 2006-09-27 17:44:10.000000000 -0400 jbreecher@younger:~/public/os/Code$ stat protos.h File: `protos.h' Size: 2889 Blocks: 8 IO Block: 4096 regular file Device: 14h/20d Inode: 28442631 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 1170/jbreecher) Gid: ( 100/ users) Access: 2006-11-16 03:56:17.000000000 -0500 Modify: 2006-08-27 12:45:57.000000000 -0400 Change: 2006-08-27 13:25:24.000000000 -0400

File Concept Expanded on next page Note: The command “LDE” – Linux Disk Editor – does amazing things but requires root privilege. -rw-rw-rw- 1 jbreecherusers 56243 Mon Dec 18 14:25:40 2006 TYPE: regular file LINKS: 1 DIRECT BLOCKS= 0x002462CA MODE: \0666 FLAGS: \10 0x002462CB UID: 01170(jbreecher)ID: 00100(users) 0x002462CC SIZE: 56243 SIZE(BLKS): 128 0x002462CD 0x002462CE ACCESS TIME: Mon Dec 18 14:35:35 2006 0x002462CF CREATION TIME: Mon Dec 18 14:25:40 2006 0x002462D0 MODIFICATION TIME: Mon Dec 18 14:25:40 2006 0x002462D1 DELETION TIME: Wed Dec 31 19:00:00 1969 0x002462D2 0x002462D3 0x002462D4 0x002462D5 INDIRECT BLOCK= 0x002462D6 2x INDIRECT BLOCK= 3x INDIRECT BLOCK= Expanded on next page

File Concept lde v2.6.1 : ext2 : /dev/mapper/VolGroup00-LogVol01 Inode: 1170636 (0x0011DCCC) Block: 2384586 (0x002462CA) 0123456789!@$%^ 462CA000 74 68 69 73 20 6D 61 6E : 79 20 6E 6F 74 20 77 6F this many not wo 462CA010 72 6B 20 74 68 69 73 20 : 6D 61 6E 79 20 6E 6F 74 rk this many not 462CA020 20 77 6F 72 6B 20 74 68 : 69 73 20 6D 61 6E 79 20 work this many 462CA030 6E 6F 74 20 77 6F 72 6B : 20 74 68 69 73 20 6D 61 not work this ma 462CA040 6E 79 20 6E 6F 74 20 77 : 6F 72 6B 20 74 68 69 73 ny not work this 462CA050 20 6D 61 6E 79 20 6E 6F : 74 20 77 6F 72 6B 0A 74 many not work.t 462CA060 68 69 73 20 6D 61 6E 79 : 20 6E 6F 74 20 77 6F 72 his many not wor lde v2.6.1 : ext2 : /dev/mapper/VolGroup00-LogVol01 Inode: 1170636 (0x0011DCCC) Block: 2384598 (0x002462D6) 0123456789!@$%^ 462D6000 D7 62 24 00 D8 62 24 00 : 00 00 00 00 00 00 00 00 .b$..b$......... 462D6010 00 00 00 00 00 00 00 00 : 00 00 00 00 00 00 00 00 ................ 462D6020 00 00 00 00 00 00 00 00 : 00 00 00 00 00 00 00 00 ................

Meet the Inode file_number

Inode Metadata User Group 9 basic access control bits - UGO x RWX Setuid bit - execute at owner permissions rather than user Setgid bit - execute at group’s permissions

Data Storage Small files: 12 pointers direct to data blocks Direct pointers 4kB blocks  sufficient for files up to 48KB Histogram of files by size

Data Storage Large files: 1,2,3 level indirect pointers - point to a disk block containing only pointers - 4 kB blocks => 1024 ptrs => 4 MB @ level 2 => 4 GB @ level 3 => 4 TB @ level 4 48 KB +4 MB +4 GB +4 TB

Data Storage Uses bitmap allocation in place of freelist Attempts to allocate files contiguously 10% reserved disk space Skip-sector positioning (mentioned next slide) Problem: When creating a file, don’t know how big it will become (in UNIX, most writes are by appending) How much contiguous space do you allocate for a file? Just find some range of free blocks Put each new file at the front of different range To expand a file, you first try successive blocks in bitmap, then choose new range of blocks Store files from same directory near each other

Modern Disks are Clever! Today’s disks read ahead. So if the OS asks for only one block, the disk continues reading around the track and stores the remainder of the track in a Track Buffer. The user (or the OS) can then ask for the next disk block, and instead of having to rotate all the way around to get the next block, the disk can take it out of its buffer. Skip Sector Track Buffer (Holds complete track)

Modern Disks are Clever! In early UNIX and DOS/Windows’ FAT file system, headers stored in special array in outermost cylinders Header not stored anywhere near the data blocks To read a small file, seek to get header, seek back to data Fixed size, set when disk is formatted At formatting time, a fixed number of inodes are created Each is given a unique number, called an “inumber”

Linux is Clever! Move the header information to be closer to the data blocks Often, inode for file stored in same “cylinder group” as parent directory of the file (makes an ls of that directory run fast) Pros: For small directories, can fit all data, file headers, etc. in same cylinder  no seeks! File headers much smaller than whole block (a few hundred bytes), so multiple headers fetched from disk at same time Reliability: whatever happens to the disk, you can find many of the files (even if directories disconnected)

Linux Disk Allocation Fills in the small holes at the start of block group Avoids fragmentation, leaves contiguous free space at end