Module #11 – Linux Case Studycse325/Modules/Module11/module...4 Linux Virtual File System Flexible...
Transcript of Module #11 – Linux Case Studycse325/Modules/Module11/module...4 Linux Virtual File System Flexible...
![Page 1: Module #11 – Linux Case Studycse325/Modules/Module11/module...4 Linux Virtual File System Flexible – supports any file management system and file structure. VFS provides interface](https://reader036.fdocuments.net/reader036/viewer/2022081410/609d9911ac2033530a7bddfd/html5/thumbnails/1.jpg)
1
Module #11 – Linux Case Study
� Lecture #2
• Linux
� Readings: Silberschatz, 20.1-20.11
1
Linux Overview
2
![Page 2: Module #11 – Linux Case Studycse325/Modules/Module11/module...4 Linux Virtual File System Flexible – supports any file management system and file structure. VFS provides interface](https://reader036.fdocuments.net/reader036/viewer/2022081410/609d9911ac2033530a7bddfd/html5/thumbnails/2.jpg)
2
Files and File Systems
� The file system is the most visible aspect of an operating system – it provides the resource abstractions typically associated with secondary storage.
� Files are central to most programs – almost all programs read input and produce output.
� Files exist independent of any program – a particular file can be accessed by more than one program.
3
File Properties
� Long-term existence: stored on disk (or other secondary storage device) and information retained over time.
� Sharable: can be used by any process that has the appropriate access permissions.
� Structured: internal structure organized in a way that is convenient for the programs which use the file.
4
![Page 3: Module #11 – Linux Case Studycse325/Modules/Module11/module...4 Linux Virtual File System Flexible – supports any file management system and file structure. VFS provides interface](https://reader036.fdocuments.net/reader036/viewer/2022081410/609d9911ac2033530a7bddfd/html5/thumbnails/3.jpg)
3
File Management
� Many variants (evolution over time).
� Traditional UNIX:
• Tree-structured directory system
• Files viewed as a stream (sequence) of bytes
• File permissions and groups used to control access to files
• Inodes ("index nodes") used to manage files
5
File Types
� Regular: stream of bytes
� Directory: contains list of files (names and inodenumbers) in the directory
� Device: maps file name to physical device (such as terminal or printer)
� Symbolic link: contains path of target file
� Socket: access to networking protocols
6
![Page 4: Module #11 – Linux Case Studycse325/Modules/Module11/module...4 Linux Virtual File System Flexible – supports any file management system and file structure. VFS provides interface](https://reader036.fdocuments.net/reader036/viewer/2022081410/609d9911ac2033530a7bddfd/html5/thumbnails/4.jpg)
4
Linux Virtual File System
� Flexible – supports any file management system and file structure.
� VFS provides interface between user's view of the Linux file system and details of a specific file system (EXT4, NFS, AFS, FAT, IBM's JFS, etc).
� Maps Linux system calls to routines which are "native" to the specific file system.
7
Linux Virtual File System
8
![Page 5: Module #11 – Linux Case Studycse325/Modules/Module11/module...4 Linux Virtual File System Flexible – supports any file management system and file structure. VFS provides interface](https://reader036.fdocuments.net/reader036/viewer/2022081410/609d9911ac2033530a7bddfd/html5/thumbnails/5.jpg)
5
Linux Virtual File System
9
Linux Virtual File System
10
![Page 6: Module #11 – Linux Case Studycse325/Modules/Module11/module...4 Linux Virtual File System Flexible – supports any file management system and file structure. VFS provides interface](https://reader036.fdocuments.net/reader036/viewer/2022081410/609d9911ac2033530a7bddfd/html5/thumbnails/6.jpg)
6
Linux Virtual File System
� VFS independent of any specific file system.
� System calls related to files mapped to functions within the specific file system.
11
Secondary Storage Management
� A directory is a file (on disk) which contains pairs of file names and inode numbers.
� Copies of recently referenced directories are cached in memory (for fast access).
. 20333131
.. 9913609
Admin 20333126
example01 23353850
example01.c 23353851
example02 36472807
example02.c 36472808
12
![Page 7: Module #11 – Linux Case Studycse325/Modules/Module11/module...4 Linux Virtual File System Flexible – supports any file management system and file structure. VFS provides interface](https://reader036.fdocuments.net/reader036/viewer/2022081410/609d9911ac2033530a7bddfd/html5/thumbnails/7.jpg)
7
Secondary Storage Management
� An inode number is an index into the inode table (on disk, but not in a file).
� Each inode is a record (256 bytes).
� The inode table is created when the file system is initialized.
� Copies of recently referenced inodes are cached in memory (for fast access).
13
Inodes
� Directory entry contains inodenumber and file name.
� Inode contains all other information about the file.
� Data blocks contain contents of file.
14
![Page 8: Module #11 – Linux Case Studycse325/Modules/Module11/module...4 Linux Virtual File System Flexible – supports any file management system and file structure. VFS provides interface](https://reader036.fdocuments.net/reader036/viewer/2022081410/609d9911ac2033530a7bddfd/html5/thumbnails/8.jpg)
8
Inode Structure
Fields within an inode:
• owner (user, group)
• permissions (rwx for owner, group, world)
• time stamps (last access, last write, last modification to inode)
• file type: regular, directory, pipe, etc
• file size (in bytes)
• info on blocks where data is stored
15
Inode Structure
16
![Page 9: Module #11 – Linux Case Studycse325/Modules/Module11/module...4 Linux Virtual File System Flexible – supports any file management system and file structure. VFS provides interface](https://reader036.fdocuments.net/reader036/viewer/2022081410/609d9911ac2033530a7bddfd/html5/thumbnails/9.jpg)
9
Example
� Inode contains the meta information, as well as fifteen 8-byte block addresses:
• Twelve pointers to data blocks
• One "single indirect" pointer
• One "double indirect" pointer
• One "triple indirect" pointer
� Small files (12 or fewer data blocks) can be accessed directly; larger files require one or more levels of indirection.
17
direct (11)
18
![Page 10: Module #11 – Linux Case Studycse325/Modules/Module11/module...4 Linux Virtual File System Flexible – supports any file management system and file structure. VFS provides interface](https://reader036.fdocuments.net/reader036/viewer/2022081410/609d9911ac2033530a7bddfd/html5/thumbnails/10.jpg)
10
Example
� Block size: 4 Kbytes
� Block addresses: 8 bytes wide
� Maximum size file: 512+ Gbytes
Level Number of Blocks Number of Bytes
Direct 12 48K
Single Indirect 512 2M
Double Indirect 512 x 512 = 256K 1G
Triple Indirect 512 x 256K = 128M 512G
19
File Access Methods
� Linux approach (inodes, pointers to data blocks) supports both sequential access and direct access.
� Sequential access: move through the file, from first byte to last byte.
• location of first byte easily found
• system maps logical file position to offset in disk block
20
![Page 11: Module #11 – Linux Case Studycse325/Modules/Module11/module...4 Linux Virtual File System Flexible – supports any file management system and file structure. VFS provides interface](https://reader036.fdocuments.net/reader036/viewer/2022081410/609d9911ac2033530a7bddfd/html5/thumbnails/11.jpg)
11
File Access Methods
� Direct access: access arbitrary byte (move forward or backward in file).
• system maps logical file position to offset in disk block (current position)
• system calculates location of desired position
� System calls to support access methods
• fstat()
• lseek()
21
File System Layout
Disk drive divided into partitions (each with an integer number of cylinders)
22
![Page 12: Module #11 – Linux Case Studycse325/Modules/Module11/module...4 Linux Virtual File System Flexible – supports any file management system and file structure. VFS provides interface](https://reader036.fdocuments.net/reader036/viewer/2022081410/609d9911ac2033530a7bddfd/html5/thumbnails/12.jpg)
12
File System Layout
� Boot block: bootstrap code
� Superblock: describes state of file system
� Inode map: inodes free or in use
� Block bitmap: blocks free or in use
� Inode table: array of all inodes
� Data blocks: sectors on disk (each block can belong to one file)
23
Performance Issues
� Free list eventually becomes distributed randomly over the disk as files are created and destroyed; hence, files are widely distributed over disk.
� Files in same directory are not necessarily near one another.
� Inodes are not necessarily near their respective files.
24
![Page 13: Module #11 – Linux Case Studycse325/Modules/Module11/module...4 Linux Virtual File System Flexible – supports any file management system and file structure. VFS provides interface](https://reader036.fdocuments.net/reader036/viewer/2022081410/609d9911ac2033530a7bddfd/html5/thumbnails/13.jpg)
13
Disk Scheduling
� Earlier versions of Linux used a variant on LOOK (the Linux Elevator algorithm).
� More recent versions of Linux support multiple scheduling algorithms.
• CFQ (Completely Fair Queuing) Scheduling
• Deadline Scheduling
• NOOP scheduling
25
Disk Scheduling
26
![Page 14: Module #11 – Linux Case Studycse325/Modules/Module11/module...4 Linux Virtual File System Flexible – supports any file management system and file structure. VFS provides interface](https://reader036.fdocuments.net/reader036/viewer/2022081410/609d9911ac2033530a7bddfd/html5/thumbnails/14.jpg)
14
Disk Scheduling
27
Disk Scheduling
28
![Page 15: Module #11 – Linux Case Studycse325/Modules/Module11/module...4 Linux Virtual File System Flexible – supports any file management system and file structure. VFS provides interface](https://reader036.fdocuments.net/reader036/viewer/2022081410/609d9911ac2033530a7bddfd/html5/thumbnails/15.jpg)
15
Network Structure
� Key area of functionality for Linux
• Supports standard Internet protocols for UNIX to UNIX communications
• Supports protocols native to non-UNIX operating systems (such as Appletalk and IPX)
� Three layers in the Linux kernel:
• The socket interface
• Protocol drivers
• Network device drivers
29
Network Structure
� Most important set of protocols is the Internet protocol suite.
• It implements routing between different hosts anywhere on the network
• On top of the routing protocol are built the UDP, TCP and ICMP protocols
30