+ All Categories
Home > Documents > Chapter 11: File System Implementation

Chapter 11: File System Implementation

Date post: 31-Dec-2015
Category:
Upload: uriah-holmes
View: 13 times
Download: 0 times
Share this document with a friend
Description:
Chapter 11: File System Implementation. Chapter 11: File System Implementation. File System Structure File System Implementation Directory Implementation Allocation Methods Free-Space Management Efficiency and Performance Recovery Log-Structured File Systems. File-System Structure. - PowerPoint PPT Presentation
48
Silberschatz, Galvin and Gagne ©2009 perating System Concepts – 8 th Edition, Chapter 11: File Chapter 11: File System Implementation System Implementation
Transcript

Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8th Edition,

Chapter 11: File System Chapter 11: File System ImplementationImplementation

12.2 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

Chapter 11: File System ImplementationChapter 11: File System Implementation

File System Structure

File System Implementation

Directory Implementation

Allocation Methods

Free-Space Management

Efficiency and Performance

Recovery

Log-Structured File Systems

12.3 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

File-System StructureFile-System Structure

File structure Logical storage unit

Collection of related information

File system resides on secondary storage (disks).

File system organized into layers.

12.4 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

Layered File SystemLayered File System

Transfer information between the main memory and the disk system

Issue generic commands to the appropriate device driver to read and write physical blocks of the disk

Knows about files and their logical blocks as well as physical blocks

Manages meta-data (all of the file-system structure, excluding the content of the files)

12.5 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

File-System ImplementationFile-System Implementation

Boot control block contains info needed by system to boot OS from that volume

Volume control block contains volume details

Directory structure organizes the files

Per-file File Control Block (FCB) contains many details about the file

12.6 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

A Typical File Control BlockA Typical File Control Block

(access control lists))

12.7 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

Virtual File SystemsVirtual File Systems

The problem: How does an operating system

allow multiple types of file systems to be integrated into a directory structure?

Virtual File Systems (VFS) provide an object-oriented way of implementing file systems.

VFS allows the same system call interface (the API) to be used for different types of file systems.

The API is to the VFS interface, rather than any specific type of file system.

12.8 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

Directory ImplementationDirectory Implementation

The selection of directory-allocation and directory management algorithm has a large effect on efficiency, performance and reliability

Possible implementation (1) - Linear list of file names with pointer to the data blocks. simple to program

time-consuming to execute

Possible implementation (2) - 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 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

Disk StructureDisk Structure

Disk drives are addressed as large 1-dimensional arrays of logical blocks, where the logical block is the smallest unit of transfer.

The 1-dimensional array of logical blocks is mapped into the sectors of the disk sequentially.

Sector 0 is the first sector of the first track on the outermost cylinder.

Mapping proceeds in order through that track, then the rest of the tracks in that cylinder, and then through the rest of the cylinders from outermost to innermost.

12.10 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

Magnetic disksMagnetic disks

Magnetic disks – rigid metal or glass platters covered with magnetic recording material

Disk surface is logically divided into tracks, which are subdivided into sectors.

The disk controller determinesthe logical interaction between

the device and the computer.

12.11 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

Allocation MethodsAllocation Methods

An allocation method refers to how disk blocks are allocated for files

The challenge – utilizing the disk efficiently and access files quickly

Methods: Contiguous allocation

Linked allocation

Indexed allocation

12.12 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

Contiguous AllocationContiguous Allocation

Each file occupies a set of contiguous blocks on the disk.

Simple – only starting location (block #) and length (number of blocks) are required.

Random access.

Wasteful of space (dynamic storage-allocation problem), fragmentation – can be resolved with (expensive) compaction (requires down time)

Files cannot grow.

12.13 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

Contiguous Allocation of Disk SpaceContiguous Allocation of Disk Space

12.14 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

Extent-Based SystemsExtent-Based Systems

Many newer file systems (I.e. Veritas File System) use a modified contiguous allocation scheme.

Extent-based file systems allocate disk blocks in extents.

An extent is a contiguous block of sectors. Extents are allocated for file allocation. A file consists of one or more extents.

Fragmentation: Internal (if extent is too large)

External (if extents of varying sizes are used)

12.15 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

Linked AllocationLinked Allocation

Each file is a linked list of disk blocks: blocks may be scattered anywhere on the disk.

pointerblock =

12.16 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

Linked Allocation (Cont.)Linked Allocation (Cont.)

Simple – need only starting address Free-space management system – no waste

of space (no need to declare file size, no compaction, no fragmentation)

No random access

Reliability problem (what if a pointer is lost?)

File-allocation table (FAT) – disk-space allocation used by MS-DOS and OS/2.

12.17 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

File-Allocation TableFile-Allocation Table

Allocation of a new block – simply find the first one who has zero

12.18 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

Indexed AllocationIndexed Allocation

Brings all pointers together into the index block.

Logical view.

index table

12.19 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

Example of Indexed AllocationExample of Indexed Allocation

12.20 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

Indexed Allocation (Cont.)Indexed Allocation (Cont.)

Enables random access Without external fragmentation, but have overhead of index

block.

When file is created, all pointers in the index block are set to nil

Any free block on the disk may satisfy a request for more space

12.21 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

Indexed Allocation – Mapping (Cont.)Indexed Allocation – Mapping (Cont.)

outer-index

index table file

12.22 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

Combined Scheme: UNIX (4K bytes per block)Combined Scheme: UNIX (4K bytes per block)

12.23 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

Free-Space ManagementFree-Space Management

Bit vector (n blocks)

0 1 2 n-1

bit[i] = 0 block[i] free

1 block[i] occupied

Block number calculation

(number of bits per word) *(number of 0-value words) +offset of first 1 bit

Since disk space is limited, we need to reuse the space from deleted files for new files (if possible)

12.24 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

Free-Space Management (Cont.)Free-Space Management (Cont.)

Bit map requires extra space. Example:

block size = 212 bytes

disk size = 230 bytes (1 gigabyte)

n = 230/212 = 218 bits (or 32K bytes)

Easy to get contiguous files

Linked list (free list) – see figure Cannot get contiguous space easily

Grouping – allocate the first free block for storing the addresses of N free blocks (quickly find the addresses of a large number of free blocks when needed)

Counting – store the address of a new free block and the number of subsequent free blocks

12.25 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

Linked Free Space List on DiskLinked Free Space List on Disk

12.26 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

Efficiency and PerformanceEfficiency and Performance

Efficiency dependent on: disk allocation and directory algorithms

types of data kept in file’s directory entry

Performance disk cache – separate section of main memory for frequently used

blocks

free-behind and read-ahead (instead of LRU) – techniques to optimize sequential access: Remove page from the buffer as soon as the next page is requested

Read and cash requested page and several subsequent pages of file

improve PC performance by dedicating section of memory as virtual disk (RAM disk) – accepts all standard file operations but perform them in memory

12.27 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

RecoveryRecovery

Consistency checking – compares data in directory structure with data blocks on disk, and tries to fix inconsistencies.

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.

12.28 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

Log Structured File SystemsLog Structured File Systems

Log structured (or journaling) file systems record each update to the file system as a transaction.

All transactions are written to a log. A transaction is considered committed once it is written to the log. However, the file system may not yet be updated.

The transactions in the log are asynchronously written to the file system. When the file system is modified, the transaction is removed from the log.

12.29 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

Disk SchedulingDisk Scheduling

The operating system is responsible for using hardware efficiently — for the disk drives, this means having a fast access time and disk bandwidth.

Access time has two major components

Seek time is the time for the disk are to move the heads to the cylinder containing the desired sector.

Rotational latency is the additional time waiting for the disk to rotate the desired sector to the disk head.

Seek time seek distance

Disk bandwidth is the total number of bytes transferred, divided by the total time between the first request for service and the completion of the last transfer.

12.30 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

Disk Scheduling (Cont.)Disk Scheduling (Cont.)

Several algorithms exist to schedule the servicing of disk I/O requests.

We illustrate them with a request queue (0-199).

98, 183, 37, 122, 14, 124, 65, 67

Head pointer 53

12.31 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

FCFSFCFS

Illustration shows total head movement of 640 cylinders.

12.32 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

SSTF – shortest seek time firstSSTF – shortest seek time first

Selects the request with the minimum seek time from the current head position.

SSTF scheduling is a form of SJF scheduling; may cause starvation of some requests.

Illustration shows total head movement of 236 cylinders.

12.33 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

SSTF (Cont.)SSTF (Cont.)

12.34 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

SCANSCAN

The disk arm starts at one end of the disk, and moves toward the other end, servicing requests until it gets to the other end of the disk, where the head movement is reversed and servicing continues.

Sometimes called the elevator algorithm.

Illustration shows total head movement of 208 cylinders.

12.35 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

SCAN (Cont.)SCAN (Cont.)

12.36 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

C-SCANC-SCAN

Provides a more uniform wait time than SCAN.

The head moves from one end of the disk to the other. servicing requests as it goes. When it reaches the other end, however, it immediately returns to the beginning of the disk, without servicing any requests on the return trip.

Treats the cylinders as a circular list that wraps around from the last cylinder to the first one.

12.37 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

C-SCAN (Cont.)C-SCAN (Cont.)

12.38 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

C-LOOKC-LOOK

Version of C-SCAN

Arm only goes as far as the last request in each direction, then reverses direction immediately, without first going all the way to the end of the disk.

12.39 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

C-LOOK (Cont.)C-LOOK (Cont.)

12.40 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

Selecting a Disk-Scheduling AlgorithmSelecting a Disk-Scheduling Algorithm

SSTF is common and has a natural appeal

SCAN and C-SCAN perform better for systems that place a heavy load on the disk.

Performance depends on the number and types of requests.

Requests for disk service can be influenced by the file-allocation method.

The disk-scheduling algorithm should be written as a separate module of the operating system, allowing it to be replaced with a different algorithm if necessary.

Either SSTF or LOOK is a reasonable choice for the default algorithm.

12.41 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

ReliabilityReliability

A fixed disk drive is likely to be more reliable than a removable disk or tape drive.

A head crash in a fixed hard disk generally destroys the data, whereas the failure of a tape drive or optical disk drive often leaves the data unharmed.

12.42 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

שאלהשאלה

מסוג אופטיים WORM (write-once-read-many)דיסקיםבאופן מידע של גדולות כמויות איחסון לצורך חברות משמשים

ורשומות ) פיננסי מידע למשל לשנותו שניתן ומבלי קבוע , .) יכול ריק סקטור כל אלו בדיסקים למוחקן ניתן שלא חשבונאיותלקריאה זמין להיות הופך הוא ולאחריה בלבד אחת פעם להיכתב

, אותו. לכתוב יש מסויים בלוק של שינוי לצורך מכך כנגזר בלבדלשמור מנת על הנדרשות ההתאמות כל את ולבצע חדש כבלוק

. בדיסק הקובץ ארגון מבנה על

דיסק של הקבצים מערכת את לתכנן נדרש כך WORMהינך - . ב להשתמש תבחר האם אופטימלי יהיה בדיסק המקום שניצול

) הנכונה) התשובה את contiguous file allocation,, linkedהקףfile allocation - ב) שימוש ? indexed file allocationאו( FATהנח

האחרות השיטות משתי יותר טובה שבחרת השיטה מדוע נמקמסוג דיסק .WORMעבור

12.43 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

תשובהתשובה היא ביותר הטובה שכאשר. indexedהשיטה היא לכך הסיבה

, ובמידת חדשים בלוקים השינוי לטובת להקצות ניתן משתנה הקובץ . אם זה באופן החדש האינדקס בלוק את מחדש לכתוב הצורך

, שינויים של קטן מספר בו שיש או חדשים בלוקים מוסיף רק הקובץ. מחדש להיכתב צריכים לא משתנה שאיננו המידע של הבלוקים

- ה - contiguousשיטת השארת ידי על לשימוש זה במקרה ניתנת , כך קובץ כל בסוף ריקים הקובץ בלוקים בסוף מידע לא שתוספת

, יחייב לקובץ אחר שינוי כל אולם הקובץ של מחדש כתיבה מחייבת. הדיסק על שלו חדש עותק יצירת

- ה - linked allocationשיטת ה שטבלת משום כאן מתאימה לאFAT ( וכידוע משתנה שהקובץ פעם בכל מחדש להיכתב תצטרך

- ה (. FATטבלת היינו לא אם גם בדיסק הבלוקים לכל היא - ב כתיבה FATמשתמשים מחייב היה מסויים בבלוק ששינוי הרי

. בשרשרת שלפניו הבלוקים כל של מחדש

12.44 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

שאלהשאלה

12.45 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

תשובהתשובה

10

12.46 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

12.47 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

12.48 Silberschatz, Galvin and Gagne ©2003Operating System Concepts with Java

1


Recommended