Beruflich Dokumente
Kultur Dokumente
12.1
Topics
Implementation issues Allocation Methods Free-Space Management Efficiency and Performance Recovery NFS
12.2
File-System Structure
File definition Logical storage unit Named collection of related information File system resides on secondary storage disks are convenient medium rewritable Direct access. Two design problems How the file system should look to the user. How to map the logical file system onto the secondary storage devices.
12.3
I/O control: acts as a translator using device drivers and interrupt handlers. Basic file system: commands device driver to read and write physical blocks File-organization module: translates logical block addresses to physical block addresses Logical file system: manages file-system structure, directory structure, protection and security.
12.4
Virtual File
same system call interface (the API) to be used for different types of file systems.
12.5
In-Memory Structure
The in-memory structure provides file-system management and improved performance via caching:
In-memory partition table: information about each mounted partition. In-memory directory structure: information about recently accessed directories. System-wide open-file table: copy of the FCB of each open file. Per-process open-file table: pointer to the entry in the system-wide open-file table.
12.6
Pass the file name Search the file in the directory structure Copy FCB into a systemwide open-file table.
File read:
-
Make an entry in a perprocess open-file table. Pointers to other fields (current location in the file, access mode)
File close:
Remove per-process entry and decrement the systemwide entrys open count.
12.7 B.B. Karki, LSU
On-Disk Structure
The on-disk structure for implementation of a file system includes:
Boot control block Information about how to boot an OS. e.g., boot block in UFS. Partition control block Partition details such as information about blocks, block and file pointers. e.g., superblock in UFS. Directory structure Organization of files. File control block File details. e.g., inode in UFS.
12.8
Directory Implementation
Linear list of file names with pointer to the data blocks. simple to program time-consuming to execute
Hash Table linear list with hash data structure. decreases directory search time collisions situations where two file names hash to the same location fixed size
12.9
12.10
Allocation Methods
Allocation method refers to how disk blocks are allocated to files so that disk space is used effectively and files can be accessed quickly:
12.11
Contiguous Allocation
Each file occupies a set of contiguous blocks on the disk. Simple only starting location (block #) and length (number of
12.12
12.13
Extent-Based Systems
scheme.
Initial continuous chunk of space Apply extra chunk of contiguous space, if needed.
Extent-based file systems allocate disk blocks in extents. An extent is a contiguous block of disks. Extents are
12.14
Linked Allocation
Each file is a linked list of disk blocks: blocks may be scattered
12.15
start at block 9, continue at block 16, then block 1, block 10, and finally block 25.
Each block contains a
12.16
File-Allocation Table
The table has one entry
12.17
Indexed Allocation
Brings all pointers (block
index box The ith entry points to the ith block of the file The directory contains the address of the index block. Logical view: Similar to a paging scheme.
12.18
Supports random access No external fragmentation Mapping from logical to physical in a file of maximum size of 256K
words and block size of 512 words. We need only 1 block for index table.
Mapping from logical to physical in a file of unbounded length (block
Linked scheme Link blocks of index table (no limit on size). Multilevel index Combined scheme
CSC 4103: Operating Systems 12.19 B.B. Karki, LSU
12.20
0 1
n-1
(number of bits per word) * (number of 0-value words) + offset of first 1 bit
block size = 212 bytes disk size = 230 bytes (1 gigabyte) n = 230/212 = 218 bits (or 32K bytes)
12.21
blocks.
Keep a pointer to the first free
12.22
Grouping A linked list of index blocks is kept Each index block contains addresses of n free blocks and a pointer to the next index block Provides address of a large number of free blocks quickly. Counting Keeps the address of the first free block and the number n of free contiguous blocks that follow the first block Each entry in the list contains a disk address and a count. Makes overall list shorter.
12.23
Efficiency
algorithms.
Some examples: UNIX inodes Clustering blocks Files directory entries Pointer sizes Dynamic allocation
12.24
Performance
Performance can still improved once basic file-system algorithms are
selected:
Caching approaches: Track cache Disk cache Page cache Virtual disk or RAM disk
Recovery
Files and directories are kept both in main memory and on disk. System failure can result in loss of data or in data inconsistency. Consistency checking Compares data in directory structure with data blocks on disk, and tries to fix inconsistencies. Back up and restore Use system programs to back up data from disk to another storage device (floppy disk, magnetic tape). Recover lost file or disk by restoring data from backup. Back-up cycle: Full back up followed by incremental backups at later times or days.
12.26
system as a transaction.
All transactions are written to a log. A transaction is
the file system. When the file system is modified, the transaction is removed from the log.
If the file system crashes, all remaining transactions in the
12.27
12.28
NFS (Cont.)
A set of interconnected workstations is viewed as a set of
directory.
The mounted directory looks like an integral subtree of the
local file system, replacing the subtree descending from the local directory. Files in the remote directory can then be accessed in a transparent manner. Subject to access-rights accreditation, potentially any file system (or directory within a file system), can be mounted remotely on top of any local directory.
12.29
NFS (Cont.)
NFS specifications are independent of the media: heterogeneous environment of different machines, operating systems, and network architectures. use of RPC primitives built on top of an External Data Representation (XDR) protocol. NFS specification distinguishes between the services
12.30
Mounting in NFS
Mounting S1 over U:
system can be mounted over another file system that is remotely mounted, not local. Mounts Cascading mounts
12.32
mount server running on server machine. Export list specifies local file systems that server exports for mounting, along with names of machines that are permitted to mount them. Following a mount request that conforms to its export list, the server
identify the mounted directory within the exported file system. The mount operation changes only the users view and does not affect the server side.
12.33
NFS Protocol
Provides a set of remote procedure calls for remote file operations. The
NFS servers are stateless; each request has to provide a full set of
arguments.
Modified data must be committed to the servers disk before results are
12.34
remote ones, and local files are further distinguished according to their file-system types.
The VFS activates file-system-specific operations to handle local
requests according to their file-system types. Calls the NFS protocol procedures for remote requests. NFS service layer bottom layer of the architecture; implements
12.35
12.36
Summary
File system resides on secondary storage Disk partitions to support multiple file systems which can be mounted onto a logical file system Layered file system structure Integrate different files systems Disk space can be allocated to files using contiguous, linked or
and counting.
NFS (network file systems) based on client-server paradigm allows
according to their file-system types. Calls the NFS protocol procedures for remote requests.
CSC 4103: Operating Systems 12.37 B.B. Karki, LSU
Example
I/O operations needed to insert a block in the middle of the file for the contiguous, linked and indexed allocation strategies. Assume that the FCB information and the block to be inserted are already in memory.
12.38
Example
Consider a file system on a disk that has both logical and physical
block sizes of 512 bytes. Assume that the information about each file is already in memory. For each of the three allocation strategies (contiguous, linked and indexed), answer these questions:
How is the logical-to-physical mapping accomplished in the system? (For
the indexed allocation, assume that a file is always less than 512 blocks long.) If we are currently at logical block 10 (the last block access was block 10) and want to access logical block 4, how many physical blocks must be read from the disk?
12.39