SlideShare a Scribd company logo
1 of 100
Chapter 4
File Systems
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
• Many important applications need to store more
information then have in virtual address space of
a process
• The information must survive the termination of
the process using it.
• Multiple processes must be able to access the
information concurrently.
File Systems
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
• Disks are used to store files
• Information is stored in blocks on the disks
• Can read and write blocks
File Systems
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
• Use file system as an abstraction to deal with accessing
the information kept in blocks on a disk
• Files are created by a process
• Thousands of them on a disk
• Managed by the OS
File Systems
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
• OS structures them, names them, protects them
• Two ways of looking at file system
• User-how do we name a file, protect it, organize the
files
• Implementation-how are they organized on a disk
• Start with user, then go to implementer
File Systems
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
• The user point of view
• Naming
• Structure
• Directories
File Systems
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
 One to 8 letters in all current OS’s
 Unix, MS-DOS (Fat16) file systems discussed
 Fat (16 and 32) were used in first Windows systems
 Latest Window systems use Native File System
 All OS’s use suffix as part of name
 Unix does not always enforce a meaning for the
suffixes
 DOS does enforce a meaning
Naming
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
.
Suffix Examples
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
 Byte sequences
 Maximum flexibility-can put anything in
 Unix and Windows use this approach
 Fixed length records (card images in the old days)
 Tree of records- uses key field to find records in the
tree
File Structure
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Three kinds of files. (a) Byte sequence.
(b) Record sequence. (c) Tree.
File Structure
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
• Regular- contains user information
• Directories
• Character special files- model serial (e.g. printers) I/O
devices
• Block special files-model disks
File Types
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
• ASCII or binary
• ASCII
• Printable
• Can use pipes to connect programs if they
produce/consume ASCII
Regular Files
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
• Two Unix examples
• Executable (magic field identifies file as being
executable)
• Archive-compiled, not linked library procedures
• Every OS must recognize its own executable
Binary File Types
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
(a) An executable file (magic # identifiies it as an
executable file)
Binary File Types (Early Unix)
Tanenbaum, Modern Operating Systems 3 e, ©
(b)An archive-library
procedures compiled but
not linked
• Sequential access- read from the beginning, can’t skip
around
• Corresponds to magnetic tape
• Random access- start where you want to start
• Came into play with disks
• Necessary for many applications, e.g. airline
reservation system
File Access
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
File Attributes (hypothetical OS)
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
:
System Calls for files
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
• Create -with no data, sets some attributes
• Delete-to free disk space
• Open- after create, gets attributes and disk addresses
into main memory
• Close- frees table space used by attributes and
addresses
• Read-usually from current pointer position. Need to
specify buffer into which data is placed
• Write-usually to current position
:
System Calls for files
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
• Append- at the end of the file
• Seek-puts file pointer at specific place in file.
Read or write from that position on
• Get Attributes-e.g. make needs most recent
modification times to arrange for group
compilation
• Set Attributes-e.g. protection attributes
• Rename
How can system calls be used?
An example-copyfile abc xyz
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
• Copies file abc to xyz
• If xyz exists it is over-written
• If it does not exist, it is created
• Uses system calls (read, write)
• Reads and writes in 4K chunks
• Read (system call) into a buffer
• Write (system call) from buffer to output file
.
Directories
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
•Files which are used to organize a collection of
files
•Also called folders in weird OS’s
A single-level directory system containing four files.
Single Level Directory Systems
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Hierarchical Directory Systems
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Path names
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
• Absolute /usr/carl/cs310/miderm/answers
• Relative cs310/midterm/answers
• . Refers to current (working) directory
• .. Refers to parent of current directory
A UNIX directory tree.
Path Names
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Directory Operations
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
•MD – Make directory
•CD - Creates directory
•RD – Remove empty directory
•REN – Rename Directory.
•Create Files.
•Copy Files
•Move Files.
•Rename Files.
•Erase Files.
File Implementation
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
• Files stored on disks. Disks broken up into one or
more partitions, with separate fs on each partition
• Sector 0 of disk is the Master Boot Record
• Used to boot the computer
• End of MBR has partition table. Has starting and
ending addresses of each partition.
• One of the partitions is marked active in the master
boot table
File Implementation
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
• Boot computer => BIOS reads/executes MBR
• MBR finds active partition and reads in first block
(boot block)
• Program in boot block locates the OS for that
partition and reads it in
• All partitions start with a boot block
A Possible File System Layout
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
File System Layout
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
• Superblock contains info about the fs (e.g. type of
fs, number of blocks, …)
• i-nodes contain info about files
Allocating Blocks to files
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
• Most important implementation issue
• Methods
• Contiguous allocation
• Linked list allocation
• Linked list using table
• I-nodes
(a) Contiguous allocation of disk space for 7 files.
(b) The state of the disk after files D and F have been removed.
Contiguous Allocation
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Contiguous Allocation
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
The good
• Easy to implement
• Read performance is great. Only need one seek to
locate the first block in the file. The rest is easy.
The bad-disk becomes fragmented over time
• CD-ROM’s use contiguous allocation because the fs size
is known in advance
• DVD’s are stored in a few consecutive 1 GB files
because standard for DVD only allows a 1 GB file max
Storing a file as a linked list of disk blocks.
Linked List Allocation
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Linked Lists
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
The good
• Gets rid of fragmentation
The bad
• Random access is slow. Need to chase pointers to get to
a block
Linked lists using a table in memory
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
• Put pointers in table in memory
• File Allocation Table (FAT)
• Windows
Figure 4-12. Linked list allocation using a file allocation table
in main memory.
The Solution-Linked List Allocation Using a
Table in Memory
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Linked lists using a table in memory
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
• The bad-table becomes really big
• E.g 200 GB disk with 1 KB blocks needs a 600 MB table
• Growth of the table size is linear with the growth of the
disk size
I-nodes
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
• Keep data structure in memory only for active files
• Data structure lists disk addresses of the blocks and
attributes of the files
• K active files, N blocks per file => k*n blocks max!!
• Solves the growth problem
I-nodes
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
• How big is N?
• Solution: Last entry in table points to disk block which
contains pointers to other disk blocks
Figure 4-13. An example i-node.
I-nodes
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
File Management
Implementing Directories
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
 Open file, path name used to locate directory
 Directory specifies block addresses by providing
 Address of first block (contiguous)
 Number of first block (linked)
 Number of i-node
(a) fixed-size entries with the disk addresses and attributes (DOS)
(b) each entry refers to an i-node. Directory entry contains
attributes. (Unix)
Implementing Directories
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Implementing Directories
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
 How do we deal with variable length names?
 Problem is that names have gotten very long
 Two approaches
 Fixed header followed by variable length names
 Heap-pointer points to names
Two ways of handling long file names in a directory. (a) In-line. (b)
In a heap.
Implementing Directories
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
File system containing a shared file. File systems is a directed
acyclic tree (DAG)
Shared Files
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Shared files
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
 If B or C adds new blocks, how does other owner find
out?
 Use special i-node for shared files-indicates that file
is shared
 Use symbolic link - a special file put in B’s directory if
C is the owner. Contains the path name of the file to
which it is linked
I-node problem
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
 If C removes file, B’s directory still points to i-node for
shared file
 If i-node is re-used for another file, B’s entry points to
wrong i-node
 Solution is to leave i-node and reduce number of owners
(a) Situation prior to linking. (b) After the link is created. (c) After
the original owner removes the file.
I node problem and solution
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Symbolic links
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
 Symbolic link solves problem
 Can have too many symbolic links and they take time to
follow
 Big advantage-can point to files on other machines
CPU’s faster, disks and memories bigger (much) but
disk seek time has not decreased
• Caches bigger-can do reads from cache
• Want to optimize writes because disk needs to be updated
• Structure disk as a log-collect writes and periodically send
them to a segment in the disk . Writes tend to be very
small
• Segment has summary of contents (i-nodes,
directories….).
• Keep i-node map on disk and cache it in memory to locate
i-nodes
Log Structured File System
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
• Cleaner thread compacts log. Scans segment for current
i-nodes, discarding ones not in use and sending current
ones to memory.
• Writer thread writes current ones out into new segment.
• Works well in Unix. Not compatible with most file systems
• Not used
Log Structured File System
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Want to guard against lost files when there are
crashes. Consider what happens when a file has
to be removed.
• Remove the file from its directory.
• Release the i-node to the pool of free i-nodes.
• Return all the disk blocks to the pool of free disk blocks
• If there is a crash somewhere in this process, have a
mess.
Journaling File Systems
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
o Keep a journal (i,.e. list) of actions before you take them,
write journal to disk, then perform actions. Can recover
from a crash!
o Need to make operations idempotent. Must arrange data
structures to do so.
o Mark block n as free is an idempotent operation.
o Adding freed blocks to the end of a list is not
idempotent
o NTFS (Windows) and Linux use journaling
Journaling File Systems
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
o Have multiple fs on same machine
o Windows specifies fs (drives)
o Unix integrates into VFS
o Vfs calls from user
o Lower calls to actual fs
o Supports Network File System-file can be on a remote
machine
Virtual File Systems
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Virtual File Systems (1)
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
o File system registers with VFS (e.g. at boot time)
o At registration time, fs provides list of addresses of
function calls the vfs wants
o Vfs gets info from the new fs i-node and puts it in a v-node
o Makes entry in fd table for process
o When process issues a call (e.g. read), function pointers
point to concrete function calls
VFS-how it works
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
. A simplified view of the data structures and code used by
the VFS and concrete file system to do a read.
Virtual File Systems
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
o Disk space management
o File System Backups
o File System Consistency
o File System Performance
File System Management and Optimization-
the dirty work
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
o Disk space management-use fixed size blocks which don’t
have to be adjacent
o If stored as consecutive bytes and file grows it will
have to be moved
o What is optimum (good) block size? Need information on
file size distribution.
o Don’t have it when building fs.
Disk Space Management
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Figure 4-20. Percentage of files smaller than a given size
(in bytes).
Disk Space Management Block Size (1)
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Figure 4-21. The solid curve (left-hand scale) gives the data rate
of a disk. The dashed curve (right-hand scale) gives the disk
space efficiency. All files are 4 KB.
Disk Space Management Block Size (2)
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
o Bigger block size results in better space utilization, but
worse transfer utilization
o trade-off is space vs data rate
o There is no good answer (Nature wins this time)
o Might as well use large (64 KB) block size as disks are
getting much bigger and stop thinking about it
Disk Space Management
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Figure 4-22. (a) Storing the free list on a linked list. (b) A bitmap.
Keeping Track of Free Blocks (1)
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
o Links-need ~1.9 million blocks
o Bit-map~need 60,000 blocks
o If free blocks come in runs, could keep track of beginning
and block and run length. Need nature to cooperate for
this to work.
o Only need one block of pointers in main memory at a time.
Fills up=>go get another
How to keep track of free blocks
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Figure 4-23. (a) An almost-full block of pointers to free disk blocks
in memory and three blocks of pointers on disk. (b) Result of
freeing a three-block file. (c) An alternative strategy for
handling the three free blocks. The shaded entries represent
pointers to free disk blocks.
Keeping Track of Free Blocks (2)
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
o Entry in open file table points to quota table
o One entry for each open file
o Places limits (soft, hard) on users disk quota
o Illustration on next slide
Disk Quotas-you can’t have it all
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Figure 4-24. Quotas are kept track of on a per-user basis
in a quota table.
Disk Quotas
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Backups to tape are generally made to handle
one of two potential problems:
• Recover from disaster (e.g. disk crash, pit bull eats
computer)
• Recover from stupidity (e.g. pit bull removes file by
stepping on keyboard)
• Morale: (1)don’t allow pit bulls near computers (2)
back up your files
• Tapes hold hundreds of gigabytes and are very
cheap
File System Backups (1)
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
o Don’t want to back up whole file
o Can get binaries from manufacturer’s CD’s
o Temporary files don’t need to be backed
up
o Special files (I/O) don’t need it
File System Backups (1)
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
o Complete dump weekly/monthly and daily
dump of modified files since big dump
o =>to restore fs need to start with full dump
and include modified files => need better
algorithms
o Problem-want to compress data before
dumping it, but if part of the tape is bad…..
o Problem-hard to dump when system is being
used. Snapshot algorithms are available
Back up Incrementally
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
o Physical-dump the whole thing.
o The good –it is simple to implement
o Don’t want to dump
o unused blocks => program needs access
to the unused block list and must write
block number for used blocks on tape
o bad blocks. Disk controller must detect and
replace them or the program must know
where they are (they are kept in a bad
block area by the OS)
Dumping strategies
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
o The good-easy to implement
o The bad
o Can’t skip a particular directory
o Can’t make incremental dumps
o Can’t restore individual files
o Not used
o Use logical dumps
Good vs Bad
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
o Starts at directory and recursively dumps all
files/directories below it which have changed
since a given time
o Examine standard algorithm used by Unix.
Dumps files/directories on path to modified
file/directory because
o Can restore path on different computer
o Have the ability to restore a single file
Logical Dumps
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Figure 4-25. A file system to be dumped. Squares are directories,
circles are files. Shaded items have been modified since last
dump. Each directory and file is labeled by its i-node number.
File System Backups
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
o Uses bitmap indexed by i-node
o 4 phases
o Phase 1-starts at root and marks bits for
modified files and all directories (a)
o Phase 2-walks the tree, unmarks directories
without modified files in/under them (b)
o Phase 3-go through i-nodes and dump
marked directories (c)
o Phase 4-dump files (d)
Logical Dump Algorithm
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Bitmaps used by the logical dumping algorithm.
File System Backups
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
o Start with empty fs on disk
o Restore most recent full dump. Directories
first, then files.
o Then do restore incremental dumps (they are
in order on the tape)
Restoring file on disk
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
o Free block list must be reconstructed. Easy to
do-it is the complement of the used blocks
o Links to files have to be carefully restored
o Files can have holes in them. Don’t want to
restore files with lots of zeroes in them
o Pipes can’t be dumped
o Tape density is not increasing => need lots of
tapes and robots to get at them. Soon will
need disks to be the back-ups!!!
Restoring file on disk-issues
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
o Crash before blocks written out results in an
inconsistent state=>
o Need utility program to check for consistency
in blocks and files
(fsck in Unix, scandisk in Windows)
o Uses two tables
o How many times is block present in a file
o How many times block is present in free
list
o Device then reads all of the i-nodes,
increments counters
File System Consistency
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Figure 4-27. File system states. (a) Consistent. (b) Missing block.
(c) Duplicate block in free list. (d) Duplicate data block.
File System Consistency
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
o Missing block (b)-put on free list
o Block occurs twice on free list (c)-re-build free
list
o Block occurs twice on blocks in use (d)- notify
user. (If one file is removed, then block
appears on both lists)
Solutions
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
o Look at files instead of blocks
o Use table of counters, one per file
o Start at root directory, descend, increment
counter each time file shows up in a directory
o Compares counts with link counts from the i-
nodes. Have to be the same to be consistent
File Consistency
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
o Read word from memory: 32 nsec
o Disk: 5-10 msec seek + 100 MB/sec transfer
o Cache blocks in memory
o Hash table (device, disk address) to manage
o Need algorithm to replace cache blocks-use
paging algorithms, e.g LRU (Least Recently
Used)
File System Performance
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Figure 4-28. The buffer cache data structures.
Caching (1)
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
o Problem with LRU-some blocks are
infrequently used, but have to be in memory
o i-node-needs to be re-written to disk if
modified. Crash could leave system in
inconsistent state
o Modify LRU
o Is block likely to be used again?
o Is block essential to consistency of file
system?
Replacement
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
o Use categories-i-nodes,indirect blocks,
directory blocks,full data blocks,partial data
blocks
o Put ones that will be needed at the rear
o If block is needed and is modified, write it to
disk asap
Replacement
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
o In order to put modified blocks on disk asap
o UNIX sync-forces all modified blocks to
disk. Issued every 30 secs by update
program
o Windows-modify block, write to disk
immediately (Write through cache)
Replacement
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
o Block read-ahead-if read in block k to cache,
read in k+1 if it is not already there
o Only works for sequential files
o Use a bit to determine if file is sequential or
random. Do a seek, flip the bit.
Block read ahead
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
o Try to put blocks which are to be accessed
sequentially close to one another.
o Easy to do with a bitmap in memory, need to
place blocks consecutively with free list
Allocate storage from free list in 2 KB
chunks when cache blocks are 1 KB
o Try to put consecutive blocks in same
cylinder
o i-nodes-place them to reduce seek time (next
slide)
Reducing arm motion
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Figure 4-29. (a) I-nodes placed at the start of the disk.
(b) Disk divided into cylinder groups, each with its own blocks
and i-nodes.
i-nodes-Reducing Disk Arm Motion
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
o In the beginning, files are placed contiguously
on the disk
o Over time holes appear
o Windows defrag program to puts together
disparate blocks of a file
o Linux doesn’t get as many holes
Defragging Disks
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Figure 4-30. The ISO 9660 directory entry.
The ISO 9660 File System
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Rock Ridge extension fields:
• PX - POSIX attributes.
• PN - Major and minor device numbers.
• SL - Symbolic link.
• NM - Alternative name.
• CL - Child location.
• PL - Parent location.
• RE - Relocation.
• TF - Time stamps.
Rock Ridge Extensions
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Joliet extension fields:
• Long file names.
• Unicode character set.
• Directory nesting deeper than eight levels.
• Directory names with extensions
Joliet Extensions
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
.
The MS-DOS File System-directory entry
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Figure 4-32. Maximum partition size for different block sizes. The
empty boxes represent forbidden combinations.
The MS-DOS File System –maximum
partition size
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Figure 4-33. A UNIX V7 directory entry.
The UNIX V7 File System (1)
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Figure 4-34. A UNIX i-node.
The UNIX V7 File System (2)
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Figure 4-35. The steps in looking up /usr/ast/mbox.
The UNIX V7 File System (3)
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

More Related Content

What's hot

NTFS file system
NTFS file systemNTFS file system
NTFS file systemRavi Yasas
 
File Management in Operating Systems
File Management in Operating SystemsFile Management in Operating Systems
File Management in Operating Systemsvampugani
 
File management
File managementFile management
File managementMohd Arif
 
The unix file system
The unix file systemThe unix file system
The unix file systemgsandeepmenon
 
Free Space Management, Efficiency & Performance, Recovery and NFS
Free Space Management, Efficiency & Performance, Recovery and NFSFree Space Management, Efficiency & Performance, Recovery and NFS
Free Space Management, Efficiency & Performance, Recovery and NFSUnited International University
 
ITFT_File system interface in Operating System
ITFT_File system interface in Operating SystemITFT_File system interface in Operating System
ITFT_File system interface in Operating SystemSneh Prabha
 
File implementation
File implementationFile implementation
File implementationMohd Arif
 
Disk and File System Management in Linux
Disk and File System Management in LinuxDisk and File System Management in Linux
Disk and File System Management in LinuxHenry Osborne
 
linux file sysytem& input and output
linux file sysytem& input and outputlinux file sysytem& input and output
linux file sysytem& input and outputMythiliA5
 
Ch11 file system implementation
Ch11   file system implementationCh11   file system implementation
Ch11 file system implementationWelly Dian Astika
 

What's hot (20)

Ch11 file system interface
Ch11 file system interfaceCh11 file system interface
Ch11 file system interface
 
NTFS file system
NTFS file systemNTFS file system
NTFS file system
 
File Management in Operating Systems
File Management in Operating SystemsFile Management in Operating Systems
File Management in Operating Systems
 
OSCh12
OSCh12OSCh12
OSCh12
 
File management
File managementFile management
File management
 
The unix file system
The unix file systemThe unix file system
The unix file system
 
NTFS and Inode
NTFS and InodeNTFS and Inode
NTFS and Inode
 
Chapter 3
Chapter 3Chapter 3
Chapter 3
 
Free Space Management, Efficiency & Performance, Recovery and NFS
Free Space Management, Efficiency & Performance, Recovery and NFSFree Space Management, Efficiency & Performance, Recovery and NFS
Free Space Management, Efficiency & Performance, Recovery and NFS
 
ITFT_File system interface in Operating System
ITFT_File system interface in Operating SystemITFT_File system interface in Operating System
ITFT_File system interface in Operating System
 
File implementation
File implementationFile implementation
File implementation
 
Disk and File System Management in Linux
Disk and File System Management in LinuxDisk and File System Management in Linux
Disk and File System Management in Linux
 
Ext filesystem4
Ext filesystem4Ext filesystem4
Ext filesystem4
 
Chapter 04
Chapter 04Chapter 04
Chapter 04
 
linux file sysytem& input and output
linux file sysytem& input and outputlinux file sysytem& input and output
linux file sysytem& input and output
 
Windows file system
Windows file systemWindows file system
Windows file system
 
File Management
File ManagementFile Management
File Management
 
Ch11 file system implementation
Ch11   file system implementationCh11   file system implementation
Ch11 file system implementation
 
File system
File systemFile system
File system
 
File management
File management File management
File management
 

Similar to File Management

Similar to File Management (20)

file systems-CUSAT
 file systems-CUSAT file systems-CUSAT
file systems-CUSAT
 
Memory Management
Memory ManagementMemory Management
Memory Management
 
tan2.ppt
tan2.ppttan2.ppt
tan2.ppt
 
File000128
File000128File000128
File000128
 
Chapter 06
Chapter 06Chapter 06
Chapter 06
 
Access Methods and File System Mounting.pptx
Access Methods and File System Mounting.pptxAccess Methods and File System Mounting.pptx
Access Methods and File System Mounting.pptx
 
Unix cmc
Unix cmcUnix cmc
Unix cmc
 
Windowsforensics
WindowsforensicsWindowsforensics
Windowsforensics
 
ch11
ch11ch11
ch11
 
File system
File systemFile system
File system
 
11 linux filesystem copy
11 linux filesystem copy11 linux filesystem copy
11 linux filesystem copy
 
9781111306366 ppt ch11
9781111306366 ppt ch119781111306366 ppt ch11
9781111306366 ppt ch11
 
db
dbdb
db
 
11. Storage and File Structure in DBMS
11. Storage and File Structure in DBMS11. Storage and File Structure in DBMS
11. Storage and File Structure in DBMS
 
Db
DbDb
Db
 
Case Study 1: Linux
Case Study 1: LinuxCase Study 1: Linux
Case Study 1: Linux
 
File and fat
File and fatFile and fat
File and fat
 
File Management & Access Control
File Management & Access Control File Management & Access Control
File Management & Access Control
 
filesystem-120405093921-phpapp02 (1).pdf
filesystem-120405093921-phpapp02 (1).pdffilesystem-120405093921-phpapp02 (1).pdf
filesystem-120405093921-phpapp02 (1).pdf
 
File and fat 2
File and fat 2File and fat 2
File and fat 2
 

More from Munazza-Mah-Jabeen (20)

Virtual Functions
Virtual FunctionsVirtual Functions
Virtual Functions
 
The Standard Template Library
The Standard Template LibraryThe Standard Template Library
The Standard Template Library
 
Object-Oriented Software
Object-Oriented SoftwareObject-Oriented Software
Object-Oriented Software
 
Templates and Exceptions
 Templates and Exceptions Templates and Exceptions
Templates and Exceptions
 
Dictionaries and Sets
Dictionaries and SetsDictionaries and Sets
Dictionaries and Sets
 
More About Strings
More About StringsMore About Strings
More About Strings
 
Streams and Files
Streams and FilesStreams and Files
Streams and Files
 
Lists and Tuples
Lists and TuplesLists and Tuples
Lists and Tuples
 
Files and Exceptions
Files and ExceptionsFiles and Exceptions
Files and Exceptions
 
Functions
FunctionsFunctions
Functions
 
Pointers
PointersPointers
Pointers
 
Repitition Structure
Repitition StructureRepitition Structure
Repitition Structure
 
Inheritance
InheritanceInheritance
Inheritance
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator Overloading
 
Memory Management
Memory ManagementMemory Management
Memory Management
 
Arrays and Strings
Arrays and StringsArrays and Strings
Arrays and Strings
 
Objects and Classes
Objects and ClassesObjects and Classes
Objects and Classes
 
Functions
FunctionsFunctions
Functions
 
Structures
StructuresStructures
Structures
 
Loops and Decisions
Loops and DecisionsLoops and Decisions
Loops and Decisions
 

Recently uploaded

KARNAADA.pptx made by - saransh dwivedi ( SD ) - SHALAKYA TANTRA - ENT - 4...
KARNAADA.pptx  made by -  saransh dwivedi ( SD ) -  SHALAKYA TANTRA - ENT - 4...KARNAADA.pptx  made by -  saransh dwivedi ( SD ) -  SHALAKYA TANTRA - ENT - 4...
KARNAADA.pptx made by - saransh dwivedi ( SD ) - SHALAKYA TANTRA - ENT - 4...M56BOOKSTORE PRODUCT/SERVICE
 
How to Create a Toggle Button in Odoo 17
How to Create a Toggle Button in Odoo 17How to Create a Toggle Button in Odoo 17
How to Create a Toggle Button in Odoo 17Celine George
 
Optical Fibre and It's Applications.pptx
Optical Fibre and It's Applications.pptxOptical Fibre and It's Applications.pptx
Optical Fibre and It's Applications.pptxPurva Nikam
 
Department of Health Compounder Question ‍Solution 2022.pdf
Department of Health Compounder Question ‍Solution 2022.pdfDepartment of Health Compounder Question ‍Solution 2022.pdf
Department of Health Compounder Question ‍Solution 2022.pdfMohonDas
 
How to Send Emails From Odoo 17 Using Code
How to Send Emails From Odoo 17 Using CodeHow to Send Emails From Odoo 17 Using Code
How to Send Emails From Odoo 17 Using CodeCeline George
 
3.26.24 Race, the Draft, and the Vietnam War.pptx
3.26.24 Race, the Draft, and the Vietnam War.pptx3.26.24 Race, the Draft, and the Vietnam War.pptx
3.26.24 Race, the Draft, and the Vietnam War.pptxmary850239
 
Clinical Pharmacy Introduction to Clinical Pharmacy, Concept of clinical pptx
Clinical Pharmacy  Introduction to Clinical Pharmacy, Concept of clinical pptxClinical Pharmacy  Introduction to Clinical Pharmacy, Concept of clinical pptx
Clinical Pharmacy Introduction to Clinical Pharmacy, Concept of clinical pptxraviapr7
 
Work Experience for psp3 portfolio sasha
Work Experience for psp3 portfolio sashaWork Experience for psp3 portfolio sasha
Work Experience for psp3 portfolio sashasashalaycock03
 
Riddhi Kevadiya. WILLIAM SHAKESPEARE....
Riddhi Kevadiya. WILLIAM SHAKESPEARE....Riddhi Kevadiya. WILLIAM SHAKESPEARE....
Riddhi Kevadiya. WILLIAM SHAKESPEARE....Riddhi Kevadiya
 
How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17Celine George
 
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...Nguyen Thanh Tu Collection
 
Over the counter (OTC)- Sale, rational use.pptx
Over the counter (OTC)- Sale, rational use.pptxOver the counter (OTC)- Sale, rational use.pptx
Over the counter (OTC)- Sale, rational use.pptxraviapr7
 
How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17Celine George
 
HED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdfHED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdfMohonDas
 
ARTICULAR DISC OF TEMPOROMANDIBULAR JOINT
ARTICULAR DISC OF TEMPOROMANDIBULAR JOINTARTICULAR DISC OF TEMPOROMANDIBULAR JOINT
ARTICULAR DISC OF TEMPOROMANDIBULAR JOINTDR. SNEHA NAIR
 
AUDIENCE THEORY -- FANDOM -- JENKINS.pptx
AUDIENCE THEORY -- FANDOM -- JENKINS.pptxAUDIENCE THEORY -- FANDOM -- JENKINS.pptx
AUDIENCE THEORY -- FANDOM -- JENKINS.pptxiammrhaywood
 
5 charts on South Africa as a source country for international student recrui...
5 charts on South Africa as a source country for international student recrui...5 charts on South Africa as a source country for international student recrui...
5 charts on South Africa as a source country for international student recrui...CaraSkikne1
 
How to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 SalesHow to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 SalesCeline George
 
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdfP4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdfYu Kanazawa / Osaka University
 

Recently uploaded (20)

KARNAADA.pptx made by - saransh dwivedi ( SD ) - SHALAKYA TANTRA - ENT - 4...
KARNAADA.pptx  made by -  saransh dwivedi ( SD ) -  SHALAKYA TANTRA - ENT - 4...KARNAADA.pptx  made by -  saransh dwivedi ( SD ) -  SHALAKYA TANTRA - ENT - 4...
KARNAADA.pptx made by - saransh dwivedi ( SD ) - SHALAKYA TANTRA - ENT - 4...
 
How to Create a Toggle Button in Odoo 17
How to Create a Toggle Button in Odoo 17How to Create a Toggle Button in Odoo 17
How to Create a Toggle Button in Odoo 17
 
Optical Fibre and It's Applications.pptx
Optical Fibre and It's Applications.pptxOptical Fibre and It's Applications.pptx
Optical Fibre and It's Applications.pptx
 
Department of Health Compounder Question ‍Solution 2022.pdf
Department of Health Compounder Question ‍Solution 2022.pdfDepartment of Health Compounder Question ‍Solution 2022.pdf
Department of Health Compounder Question ‍Solution 2022.pdf
 
How to Send Emails From Odoo 17 Using Code
How to Send Emails From Odoo 17 Using CodeHow to Send Emails From Odoo 17 Using Code
How to Send Emails From Odoo 17 Using Code
 
3.26.24 Race, the Draft, and the Vietnam War.pptx
3.26.24 Race, the Draft, and the Vietnam War.pptx3.26.24 Race, the Draft, and the Vietnam War.pptx
3.26.24 Race, the Draft, and the Vietnam War.pptx
 
Clinical Pharmacy Introduction to Clinical Pharmacy, Concept of clinical pptx
Clinical Pharmacy  Introduction to Clinical Pharmacy, Concept of clinical pptxClinical Pharmacy  Introduction to Clinical Pharmacy, Concept of clinical pptx
Clinical Pharmacy Introduction to Clinical Pharmacy, Concept of clinical pptx
 
Work Experience for psp3 portfolio sasha
Work Experience for psp3 portfolio sashaWork Experience for psp3 portfolio sasha
Work Experience for psp3 portfolio sasha
 
Riddhi Kevadiya. WILLIAM SHAKESPEARE....
Riddhi Kevadiya. WILLIAM SHAKESPEARE....Riddhi Kevadiya. WILLIAM SHAKESPEARE....
Riddhi Kevadiya. WILLIAM SHAKESPEARE....
 
How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17
 
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
 
Over the counter (OTC)- Sale, rational use.pptx
Over the counter (OTC)- Sale, rational use.pptxOver the counter (OTC)- Sale, rational use.pptx
Over the counter (OTC)- Sale, rational use.pptx
 
How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17
 
HED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdfHED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdf
 
ARTICULAR DISC OF TEMPOROMANDIBULAR JOINT
ARTICULAR DISC OF TEMPOROMANDIBULAR JOINTARTICULAR DISC OF TEMPOROMANDIBULAR JOINT
ARTICULAR DISC OF TEMPOROMANDIBULAR JOINT
 
March 2024 Directors Meeting, Division of Student Affairs and Academic Support
March 2024 Directors Meeting, Division of Student Affairs and Academic SupportMarch 2024 Directors Meeting, Division of Student Affairs and Academic Support
March 2024 Directors Meeting, Division of Student Affairs and Academic Support
 
AUDIENCE THEORY -- FANDOM -- JENKINS.pptx
AUDIENCE THEORY -- FANDOM -- JENKINS.pptxAUDIENCE THEORY -- FANDOM -- JENKINS.pptx
AUDIENCE THEORY -- FANDOM -- JENKINS.pptx
 
5 charts on South Africa as a source country for international student recrui...
5 charts on South Africa as a source country for international student recrui...5 charts on South Africa as a source country for international student recrui...
5 charts on South Africa as a source country for international student recrui...
 
How to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 SalesHow to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 Sales
 
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdfP4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
 

File Management

  • 1. Chapter 4 File Systems Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 2. • Many important applications need to store more information then have in virtual address space of a process • The information must survive the termination of the process using it. • Multiple processes must be able to access the information concurrently. File Systems Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 3. • Disks are used to store files • Information is stored in blocks on the disks • Can read and write blocks File Systems Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 4. • Use file system as an abstraction to deal with accessing the information kept in blocks on a disk • Files are created by a process • Thousands of them on a disk • Managed by the OS File Systems Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 5. • OS structures them, names them, protects them • Two ways of looking at file system • User-how do we name a file, protect it, organize the files • Implementation-how are they organized on a disk • Start with user, then go to implementer File Systems Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 6. • The user point of view • Naming • Structure • Directories File Systems Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 7.  One to 8 letters in all current OS’s  Unix, MS-DOS (Fat16) file systems discussed  Fat (16 and 32) were used in first Windows systems  Latest Window systems use Native File System  All OS’s use suffix as part of name  Unix does not always enforce a meaning for the suffixes  DOS does enforce a meaning Naming Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 8. . Suffix Examples Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 9.  Byte sequences  Maximum flexibility-can put anything in  Unix and Windows use this approach  Fixed length records (card images in the old days)  Tree of records- uses key field to find records in the tree File Structure Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 10. Three kinds of files. (a) Byte sequence. (b) Record sequence. (c) Tree. File Structure Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 11. • Regular- contains user information • Directories • Character special files- model serial (e.g. printers) I/O devices • Block special files-model disks File Types Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 12. • ASCII or binary • ASCII • Printable • Can use pipes to connect programs if they produce/consume ASCII Regular Files Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 13. • Two Unix examples • Executable (magic field identifies file as being executable) • Archive-compiled, not linked library procedures • Every OS must recognize its own executable Binary File Types Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 14. (a) An executable file (magic # identifiies it as an executable file) Binary File Types (Early Unix) Tanenbaum, Modern Operating Systems 3 e, © (b)An archive-library procedures compiled but not linked
  • 15. • Sequential access- read from the beginning, can’t skip around • Corresponds to magnetic tape • Random access- start where you want to start • Came into play with disks • Necessary for many applications, e.g. airline reservation system File Access Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 16. File Attributes (hypothetical OS) Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 17. : System Calls for files Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639 • Create -with no data, sets some attributes • Delete-to free disk space • Open- after create, gets attributes and disk addresses into main memory • Close- frees table space used by attributes and addresses • Read-usually from current pointer position. Need to specify buffer into which data is placed • Write-usually to current position
  • 18. : System Calls for files Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639 • Append- at the end of the file • Seek-puts file pointer at specific place in file. Read or write from that position on • Get Attributes-e.g. make needs most recent modification times to arrange for group compilation • Set Attributes-e.g. protection attributes • Rename
  • 19. How can system calls be used? An example-copyfile abc xyz Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639 • Copies file abc to xyz • If xyz exists it is over-written • If it does not exist, it is created • Uses system calls (read, write) • Reads and writes in 4K chunks • Read (system call) into a buffer • Write (system call) from buffer to output file
  • 20. . Directories Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639 •Files which are used to organize a collection of files •Also called folders in weird OS’s
  • 21. A single-level directory system containing four files. Single Level Directory Systems Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 22. Hierarchical Directory Systems Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 23. Path names Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639 • Absolute /usr/carl/cs310/miderm/answers • Relative cs310/midterm/answers • . Refers to current (working) directory • .. Refers to parent of current directory
  • 24. A UNIX directory tree. Path Names Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 25. Directory Operations Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639 •MD – Make directory •CD - Creates directory •RD – Remove empty directory •REN – Rename Directory. •Create Files. •Copy Files •Move Files. •Rename Files. •Erase Files.
  • 26. File Implementation Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639 • Files stored on disks. Disks broken up into one or more partitions, with separate fs on each partition • Sector 0 of disk is the Master Boot Record • Used to boot the computer • End of MBR has partition table. Has starting and ending addresses of each partition. • One of the partitions is marked active in the master boot table
  • 27. File Implementation Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639 • Boot computer => BIOS reads/executes MBR • MBR finds active partition and reads in first block (boot block) • Program in boot block locates the OS for that partition and reads it in • All partitions start with a boot block
  • 28. A Possible File System Layout Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 29. File System Layout Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639 • Superblock contains info about the fs (e.g. type of fs, number of blocks, …) • i-nodes contain info about files
  • 30. Allocating Blocks to files Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639 • Most important implementation issue • Methods • Contiguous allocation • Linked list allocation • Linked list using table • I-nodes
  • 31. (a) Contiguous allocation of disk space for 7 files. (b) The state of the disk after files D and F have been removed. Contiguous Allocation Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 32. Contiguous Allocation Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639 The good • Easy to implement • Read performance is great. Only need one seek to locate the first block in the file. The rest is easy. The bad-disk becomes fragmented over time • CD-ROM’s use contiguous allocation because the fs size is known in advance • DVD’s are stored in a few consecutive 1 GB files because standard for DVD only allows a 1 GB file max
  • 33. Storing a file as a linked list of disk blocks. Linked List Allocation Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 34. Linked Lists Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639 The good • Gets rid of fragmentation The bad • Random access is slow. Need to chase pointers to get to a block
  • 35. Linked lists using a table in memory Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639 • Put pointers in table in memory • File Allocation Table (FAT) • Windows
  • 36. Figure 4-12. Linked list allocation using a file allocation table in main memory. The Solution-Linked List Allocation Using a Table in Memory Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 37. Linked lists using a table in memory Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639 • The bad-table becomes really big • E.g 200 GB disk with 1 KB blocks needs a 600 MB table • Growth of the table size is linear with the growth of the disk size
  • 38. I-nodes Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639 • Keep data structure in memory only for active files • Data structure lists disk addresses of the blocks and attributes of the files • K active files, N blocks per file => k*n blocks max!! • Solves the growth problem
  • 39. I-nodes Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639 • How big is N? • Solution: Last entry in table points to disk block which contains pointers to other disk blocks
  • 40. Figure 4-13. An example i-node. I-nodes Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 42. Implementing Directories Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639  Open file, path name used to locate directory  Directory specifies block addresses by providing  Address of first block (contiguous)  Number of first block (linked)  Number of i-node
  • 43. (a) fixed-size entries with the disk addresses and attributes (DOS) (b) each entry refers to an i-node. Directory entry contains attributes. (Unix) Implementing Directories Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 44. Implementing Directories Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639  How do we deal with variable length names?  Problem is that names have gotten very long  Two approaches  Fixed header followed by variable length names  Heap-pointer points to names
  • 45. Two ways of handling long file names in a directory. (a) In-line. (b) In a heap. Implementing Directories Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 46. File system containing a shared file. File systems is a directed acyclic tree (DAG) Shared Files Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 47. Shared files Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639  If B or C adds new blocks, how does other owner find out?  Use special i-node for shared files-indicates that file is shared  Use symbolic link - a special file put in B’s directory if C is the owner. Contains the path name of the file to which it is linked
  • 48. I-node problem Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639  If C removes file, B’s directory still points to i-node for shared file  If i-node is re-used for another file, B’s entry points to wrong i-node  Solution is to leave i-node and reduce number of owners
  • 49. (a) Situation prior to linking. (b) After the link is created. (c) After the original owner removes the file. I node problem and solution Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 50. Symbolic links Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639  Symbolic link solves problem  Can have too many symbolic links and they take time to follow  Big advantage-can point to files on other machines
  • 51. CPU’s faster, disks and memories bigger (much) but disk seek time has not decreased • Caches bigger-can do reads from cache • Want to optimize writes because disk needs to be updated • Structure disk as a log-collect writes and periodically send them to a segment in the disk . Writes tend to be very small • Segment has summary of contents (i-nodes, directories….). • Keep i-node map on disk and cache it in memory to locate i-nodes Log Structured File System Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 52. • Cleaner thread compacts log. Scans segment for current i-nodes, discarding ones not in use and sending current ones to memory. • Writer thread writes current ones out into new segment. • Works well in Unix. Not compatible with most file systems • Not used Log Structured File System Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 53. Want to guard against lost files when there are crashes. Consider what happens when a file has to be removed. • Remove the file from its directory. • Release the i-node to the pool of free i-nodes. • Return all the disk blocks to the pool of free disk blocks • If there is a crash somewhere in this process, have a mess. Journaling File Systems Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 54. o Keep a journal (i,.e. list) of actions before you take them, write journal to disk, then perform actions. Can recover from a crash! o Need to make operations idempotent. Must arrange data structures to do so. o Mark block n as free is an idempotent operation. o Adding freed blocks to the end of a list is not idempotent o NTFS (Windows) and Linux use journaling Journaling File Systems Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 55. o Have multiple fs on same machine o Windows specifies fs (drives) o Unix integrates into VFS o Vfs calls from user o Lower calls to actual fs o Supports Network File System-file can be on a remote machine Virtual File Systems Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 56. Virtual File Systems (1) Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 57. o File system registers with VFS (e.g. at boot time) o At registration time, fs provides list of addresses of function calls the vfs wants o Vfs gets info from the new fs i-node and puts it in a v-node o Makes entry in fd table for process o When process issues a call (e.g. read), function pointers point to concrete function calls VFS-how it works Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 58. . A simplified view of the data structures and code used by the VFS and concrete file system to do a read. Virtual File Systems Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 59. o Disk space management o File System Backups o File System Consistency o File System Performance File System Management and Optimization- the dirty work Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 60. o Disk space management-use fixed size blocks which don’t have to be adjacent o If stored as consecutive bytes and file grows it will have to be moved o What is optimum (good) block size? Need information on file size distribution. o Don’t have it when building fs. Disk Space Management Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 61. Figure 4-20. Percentage of files smaller than a given size (in bytes). Disk Space Management Block Size (1) Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 62. Figure 4-21. The solid curve (left-hand scale) gives the data rate of a disk. The dashed curve (right-hand scale) gives the disk space efficiency. All files are 4 KB. Disk Space Management Block Size (2) Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 63. o Bigger block size results in better space utilization, but worse transfer utilization o trade-off is space vs data rate o There is no good answer (Nature wins this time) o Might as well use large (64 KB) block size as disks are getting much bigger and stop thinking about it Disk Space Management Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 64. Figure 4-22. (a) Storing the free list on a linked list. (b) A bitmap. Keeping Track of Free Blocks (1) Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 65. o Links-need ~1.9 million blocks o Bit-map~need 60,000 blocks o If free blocks come in runs, could keep track of beginning and block and run length. Need nature to cooperate for this to work. o Only need one block of pointers in main memory at a time. Fills up=>go get another How to keep track of free blocks Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 66. Figure 4-23. (a) An almost-full block of pointers to free disk blocks in memory and three blocks of pointers on disk. (b) Result of freeing a three-block file. (c) An alternative strategy for handling the three free blocks. The shaded entries represent pointers to free disk blocks. Keeping Track of Free Blocks (2) Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 67. o Entry in open file table points to quota table o One entry for each open file o Places limits (soft, hard) on users disk quota o Illustration on next slide Disk Quotas-you can’t have it all Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 68. Figure 4-24. Quotas are kept track of on a per-user basis in a quota table. Disk Quotas Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 69. Backups to tape are generally made to handle one of two potential problems: • Recover from disaster (e.g. disk crash, pit bull eats computer) • Recover from stupidity (e.g. pit bull removes file by stepping on keyboard) • Morale: (1)don’t allow pit bulls near computers (2) back up your files • Tapes hold hundreds of gigabytes and are very cheap File System Backups (1) Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 70. o Don’t want to back up whole file o Can get binaries from manufacturer’s CD’s o Temporary files don’t need to be backed up o Special files (I/O) don’t need it File System Backups (1) Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 71. o Complete dump weekly/monthly and daily dump of modified files since big dump o =>to restore fs need to start with full dump and include modified files => need better algorithms o Problem-want to compress data before dumping it, but if part of the tape is bad….. o Problem-hard to dump when system is being used. Snapshot algorithms are available Back up Incrementally Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 72. o Physical-dump the whole thing. o The good –it is simple to implement o Don’t want to dump o unused blocks => program needs access to the unused block list and must write block number for used blocks on tape o bad blocks. Disk controller must detect and replace them or the program must know where they are (they are kept in a bad block area by the OS) Dumping strategies Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 73. o The good-easy to implement o The bad o Can’t skip a particular directory o Can’t make incremental dumps o Can’t restore individual files o Not used o Use logical dumps Good vs Bad Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 74. o Starts at directory and recursively dumps all files/directories below it which have changed since a given time o Examine standard algorithm used by Unix. Dumps files/directories on path to modified file/directory because o Can restore path on different computer o Have the ability to restore a single file Logical Dumps Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 75. Figure 4-25. A file system to be dumped. Squares are directories, circles are files. Shaded items have been modified since last dump. Each directory and file is labeled by its i-node number. File System Backups Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 76. o Uses bitmap indexed by i-node o 4 phases o Phase 1-starts at root and marks bits for modified files and all directories (a) o Phase 2-walks the tree, unmarks directories without modified files in/under them (b) o Phase 3-go through i-nodes and dump marked directories (c) o Phase 4-dump files (d) Logical Dump Algorithm Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 77. Bitmaps used by the logical dumping algorithm. File System Backups Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 78. o Start with empty fs on disk o Restore most recent full dump. Directories first, then files. o Then do restore incremental dumps (they are in order on the tape) Restoring file on disk Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 79. o Free block list must be reconstructed. Easy to do-it is the complement of the used blocks o Links to files have to be carefully restored o Files can have holes in them. Don’t want to restore files with lots of zeroes in them o Pipes can’t be dumped o Tape density is not increasing => need lots of tapes and robots to get at them. Soon will need disks to be the back-ups!!! Restoring file on disk-issues Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 80. o Crash before blocks written out results in an inconsistent state=> o Need utility program to check for consistency in blocks and files (fsck in Unix, scandisk in Windows) o Uses two tables o How many times is block present in a file o How many times block is present in free list o Device then reads all of the i-nodes, increments counters File System Consistency Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 81. Figure 4-27. File system states. (a) Consistent. (b) Missing block. (c) Duplicate block in free list. (d) Duplicate data block. File System Consistency Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 82. o Missing block (b)-put on free list o Block occurs twice on free list (c)-re-build free list o Block occurs twice on blocks in use (d)- notify user. (If one file is removed, then block appears on both lists) Solutions Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 83. o Look at files instead of blocks o Use table of counters, one per file o Start at root directory, descend, increment counter each time file shows up in a directory o Compares counts with link counts from the i- nodes. Have to be the same to be consistent File Consistency Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 84. o Read word from memory: 32 nsec o Disk: 5-10 msec seek + 100 MB/sec transfer o Cache blocks in memory o Hash table (device, disk address) to manage o Need algorithm to replace cache blocks-use paging algorithms, e.g LRU (Least Recently Used) File System Performance Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 85. Figure 4-28. The buffer cache data structures. Caching (1) Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 86. o Problem with LRU-some blocks are infrequently used, but have to be in memory o i-node-needs to be re-written to disk if modified. Crash could leave system in inconsistent state o Modify LRU o Is block likely to be used again? o Is block essential to consistency of file system? Replacement Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 87. o Use categories-i-nodes,indirect blocks, directory blocks,full data blocks,partial data blocks o Put ones that will be needed at the rear o If block is needed and is modified, write it to disk asap Replacement Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 88. o In order to put modified blocks on disk asap o UNIX sync-forces all modified blocks to disk. Issued every 30 secs by update program o Windows-modify block, write to disk immediately (Write through cache) Replacement Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 89. o Block read-ahead-if read in block k to cache, read in k+1 if it is not already there o Only works for sequential files o Use a bit to determine if file is sequential or random. Do a seek, flip the bit. Block read ahead Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 90. o Try to put blocks which are to be accessed sequentially close to one another. o Easy to do with a bitmap in memory, need to place blocks consecutively with free list Allocate storage from free list in 2 KB chunks when cache blocks are 1 KB o Try to put consecutive blocks in same cylinder o i-nodes-place them to reduce seek time (next slide) Reducing arm motion Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 91. Figure 4-29. (a) I-nodes placed at the start of the disk. (b) Disk divided into cylinder groups, each with its own blocks and i-nodes. i-nodes-Reducing Disk Arm Motion Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 92. o In the beginning, files are placed contiguously on the disk o Over time holes appear o Windows defrag program to puts together disparate blocks of a file o Linux doesn’t get as many holes Defragging Disks Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 93. Figure 4-30. The ISO 9660 directory entry. The ISO 9660 File System Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 94. Rock Ridge extension fields: • PX - POSIX attributes. • PN - Major and minor device numbers. • SL - Symbolic link. • NM - Alternative name. • CL - Child location. • PL - Parent location. • RE - Relocation. • TF - Time stamps. Rock Ridge Extensions Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 95. Joliet extension fields: • Long file names. • Unicode character set. • Directory nesting deeper than eight levels. • Directory names with extensions Joliet Extensions Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 96. . The MS-DOS File System-directory entry Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 97. Figure 4-32. Maximum partition size for different block sizes. The empty boxes represent forbidden combinations. The MS-DOS File System –maximum partition size Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 98. Figure 4-33. A UNIX V7 directory entry. The UNIX V7 File System (1) Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 99. Figure 4-34. A UNIX i-node. The UNIX V7 File System (2) Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
  • 100. Figure 4-35. The steps in looking up /usr/ast/mbox. The UNIX V7 File System (3) Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639