Presentation is loading. Please wait.

Presentation is loading. Please wait.

FileSystems.

Similar presentations


Presentation on theme: "FileSystems."— Presentation transcript:

1 FileSystems

2 HW Review Hard Disks are electro-mechanical (mechanical = moving parts!) Modern Operating Systems, 3rd ed., Andrew Tanenbuam 

3 HW Review (2) Modern Operating Systems, 3rd ed., Andrew Tanenbuam 

4 User Perspective File Systems provide long term storage, with files of vastly different size. Provides non-volatile storage (files persist between cycling power unlike RAM). Multiple processes can access files can access same file concurrently.

5 File Types Regular files Directory files Character special files
Block Special files.

6 File Operations Create Delete Open Close Read Write

7 How are files stored? Three kinds of files (a) byte sequence
(b) record sequence (c) tree Modern Operating Systems, 3rd ed., Andrew Tanenbuam 

8 How can we implement directories?
Modern Operating Systems, 3rd ed., Andrew Tanenbuam 

9 Contiguous File Allocation

10 Contiguous File System
(a) Contiguous allocation of disk space for 7 files. (b) State of the disk after files D and F have been removed. Modern Operating Systems, 3rd ed., Andrew Tanenbuam 

11 Problems? What is this similar to?
We encounter the same problems as contiguous memory allocation. Disk becomes fragmented How to find a hole large enough What happens if file is larger than RAM?

12 Linked List Modern Operating Systems, 3rd ed., Andrew Tanenbuam 

13 Linked List tradeoffs Advantages: Disadvantages:
Each block in memory can be used (no external fragmentation)‏ Files can grow easily Disadvantages: Stealing file room (can not use whole block)‏ Must traverse entire list (random access file?)‏ Alternative: Keep a table in memory

14 Linked list allocation using a file allocation table in RAM
Modern Operating Systems, 3rd ed., Andrew Tanenbuam 

15 File Allocation Table Tradeoffs
Advantages: Can use whole block for data Traversing takes place in memory now Disadvantages: Grows in size with disk 20GB disk & 1 KB block size means 20 million entries, 3 or 4 bytes a piece, 60 or 80 MB for table. Must keep entire table in memory (although we can page it).

16 I-Nodes

17 I-Nodes File Allocation Table is global table (one per system).
Grows linearly with Disk Sizes. Most files are not open at any one point in time (so why keep their information around). Per file table: I-Node.

18 I-Nodes Maps virtual file block to physical file block.
Uses chaining: Last pointer points to another I-Node. Modern Operating Systems, 3rd ed., Andrew Tanenbuam 

19 I-Node Tradeoffs Advantages: Disadvantages:
Only need particular I-Node when that file is open. Can make I-Node size 1 disk block. Disadvantages: More complicated structure

20 Single, double or Triple Indirect
Unix V7 File System I-Node. Modern Operating Systems, 3rd ed., Andrew Tanenbuam 

21 File System Performance

22 Problems with Common file systems
Information is spread around disk introducing too many small accesses Directory info. File attributes (I-node)‏ Data At least four accesses for creating a file I-node for directory, directory data, I-node for file, file data Synchronous write for metadata

23 File System Performance (1)
Caching Much the same way as paging in VM Use Hashing to improve access. H(disk address) = location in cache LRU? How about file system consistency? Block Read Ahead Many files are read sequentially. So read ahead… If files are accessed randomly, doesn’t help.

24 Reducing Disk Arm Motion
Place related blocks physically together Arm scheduling algorithms Place “hot blocks” (I-nodes) in the middle

25 Interleaving No interleaving Single interleaving Double interleaving
Modern Operating Systems, 3rd ed., Andrew Tanenbuam 

26 Disk Arm Scheduling Algorithms
Time required to read or write a disk block determined by 3 factors Seek time Rotational delay Actual transfer time Seek time dominates Error checking is done by controllers

27 Shortest Seek First (SSF)
IIInitital Position Pending Requests Modern Operating Systems, 3rd ed., Andrew Tanenbuam 

28 Elevator Algorithm Modern Operating Systems, 3rd ed., Andrew Tanenbuam 

29 The Organ Pipe Distribution
Create a histogram of the disk block usage (count the number of times that disk blocks are used). Place most used blocks in the middle track. This reduces average seek time.

30 Log Structure File System

31 What are the trends? CPU: faster exponentially
Disk: improvement on mostly cost and size but not performance Memory: cost and size; some performance improvement

32 Log-Structured File Systems
With CPUs faster, memory larger disk caches can also be larger increasing number of read requests can come from cache thus, most disk accesses will be writes Each write is very small LFS Strategy structures entire disk as a log segment have all writes initially buffered in memory periodically write these to the end of the disk log when file opened, locate i-node, then find blocks

33 How to accomplish? Needs large contiguous disk space…
HD space is not infinite Idea: Use segments and segment cleaner

34 Log-Structured File Systems
A segment can contain: I-nodes, directory blocks, data blocks, etc. Segment summary: at the start of each segment– telling what can be found in the segment Notice that I-nodes are scattered all over the disk.

35 Log-Structured File Systems
Modern Operating Systems, 3rd ed., Andrew Tanenbuam 

36 Cleaner Process Cleaner process How often? Continuously? Or overnight?
How many segments to clean one time? Which segment to clean? Most fragmented one? How do we reorganize data within segments? Locality of reference

37 Directory Implementation

38 Directories From the user perspective, directories provide a way to logically organize files. For the OS, directories provide the mapping from the human readable filename to the location on disk of the file. Directories can also store other file attributes (r/w, ownership, last update time, etc).

39 Directories Directories are files as well.
How do we keep track of where the directory file is stored on disk? Using the same mechanism as other files. But then how do we know where the root directory is stored…? Typically stored in a special sector on disk.

40 Implementing Directories
(a) A simple directory fixed size entries disk addresses and attributes in directory entry (b) Directory in which each entry just refers to an i- node Modern Operating Systems, 3rd ed., Andrew Tanenbuam 

41 Implementing Directories
Two ways of handling long file names in directory (a) In-line (b) In a heap Modern Operating Systems, 3rd ed., Andrew Tanenbuam 

42


Download ppt "FileSystems."

Similar presentations


Ads by Google