• Keine Ergebnisse gefunden

File System

N/A
N/A
Protected

Academic year: 2022

Aktie "File System"

Copied!
32
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

File System

(2)

Outlook

File-System Interface

Allocation-Methods

Free Space Management

(3)

File System Interface

(4)

File Concept

File system is the most visible part of an OS

Files – storing related data

Directory structure – organize and provide information about files

Information stored on various storage media

File system provides a uniform logical view of information storage

File system implementation has two major issues

How should it look to the user

(attributes, operations, structure)

(5)

Typical File Attributes

Each file is named  human readable form which identifies the file

Identifier – unique tag identifying the file within the file system

Type – support different types of files

Location – pointer to a device and the location on that device

Size – current size in bytes, words, blocks

Protection – who can do reading, writing, executing

Time, date, and user identification – kept for creation, last modification, last use

Useful for protection, security, usage monitoring

Information is kept in a directory structure

(6)

Sequential File Access

Information passed in order, one record after another (tape model)

read: read the next portion of data; advance a read pointer

write: append data to the end of the file;

advance the file end

reset: skip file pointer forward/backward

(7)

Direct Access

File consists of fixed-length logical records;

readable/writable with no particular order (disk model)

Operations: read n, write n

Alternatively position n and read/write

Block numbers are generally an index relative to the beginning of a file

Request for record N with L being the record length

Start I/O at location L*N

(8)

Directory Structure

Disk can be used for more than one file system

Disk storage can be split into partitions (slices, minidisks)

Each can hold a different file system

Possibly other things like swap space, or

raw disk space

(9)

Directory Structure

Each file system needs a directory storing

file name, location, size, type, …

(10)

Tree Structured Directories

(11)

File-System Mounting

File system may be built from multiple volumes

 Mounting

Name of the device

Mount point (typically an empty directory)

Possible implementations

Allow the same file system to be mounted repeatedly

One mount point per file system

Automatic mounting or explicit mounting

(12)

File-System Mounting

Possible implementations

Disallow nonempty mount points

Obscure the nonempty directory files

(13)

File Sharing

Requires more directory and file attributes

Most common model: user, group, others

Owner – can change attributes and grant access

Group – can share access to the file

Others – the remaining system users

When a user issues a command

User ID = owner ID  user permissions

Group ID = file group ID  group permissions

Otherwise  other permissions

(14)

Allocation Methods

(15)

Allocation Methods

How to allocate disk space to files so that

Disk space is allocated efficiently

Files can be accessed quickly

Three major methods

Contiguous

Linked

Indexed

(16)

Contiguous Allocation

Each file

occupies a set of contiguous

blocks

Reading a block b+1 after block b requires no head movement except for

Last block in a cylinder requires one step to the next one

(17)

Contiguous Allocation

Access is easy to implement

Sequential access: remember current block; read next one if necessary

Direct access of block i of file starting at n: load block n+i

Problem: finding space for a new file

First fit, best fit, worst fit

External fragmentation problem

Older solution: copy disk on a temporary device; write back by allocating contiguous space

Time is the major concern on large devices

(18)

Contiguous Allocation

Contiguous allocation requires estimating the space needed for file creation

Solutions in case of size exceeded

Terminate the writing process

Relocate file blocks to a greater hole  slows down the performance but does not disturb file operation

Slow growing file causes a large amount of

internal fragmentation

(19)

Linked Allocation

File is organized as a linked list of blocks

create – add “dir entry

nil”

write – add a free block at the end

read – traverse the list

No external fragmentation

File size need not be known in advance

No compactation required

(20)

Linked Allocation

Problems

Direct access to a given block requires traversal of the list

Next pointer in each block consumes space

Each block may require a seek

Solution

Allocate clusters (a set of blocks)

Expense: internal fragmentation

Further problems

Loss of a link or link error

Improvement

Doubly linked list

(21)

Linked Allocation: File-Allocation Table (FAT)

(22)

Indexed Allocation

(23)

Indexed Allocation

Supports direct access

No external fragmentation

Index block has to satisfy the largest possible file

Problem: index block wastes space

E.g. a file using only one block?

Solutions

Linked scheme – link index blocks together

Multilevel index – index block referring to second level index blocks (possibly more than two levels)

Combined scheme – UNIX inodes (see next)

(24)

Indexed Allocation: UNIX inodes

(25)

Free-Space Management

(26)

Free-Space Management

System has to keep track of free disk space

Use a free-space list

Creating a file – search free space list for

required amount of space; allocate that space

Deleting a file – free allocated blocks and add to free space list again

Implementation

Bit vector

Linked list

(27)

Free-Space Management: Bit Vectors

Each block represented by one bit

1=free, 0=allocated

Example: free-space bit map for

2,3,4,5,8,9,10,11,12,13,17,18,25,26,27 results in 001111001111110001100000011100000 …

Special hardware instructions make this scheme efficient

Check a word for 0

Find the index of the first 1-Bit in a word

Entire vector has to be kept in main memory

 limited to small disks (e.g. 40 GB and 1 KB

blocks  over 5 MB bit vector size)

(28)

Free-Space Management: Linked List

Not efficient if more blocks are needed

However,

traversing the list is not a frequent

action

In general, only

one next block is

required

(29)

Free-Space Management

Grouping

Block can store n pointers

Store addresses of n-1 free blocks and the address of the next n-free-block

Counting

Reasonable for contiguous allocation scheme

Store in the first block the number of the following free ones

 Size of the linked list is reduced

(30)

Summary and References

(31)

Summary

File System is the most visible part of the OS

Provides access to data on secondary storage (sequential access, random access)

Organizing Files in directories

Mounting, sharing, remote access

The most important data structure: file concept

Major task of the OS with file systems: mapping of logical file concept onto physical storage devices

Major components (discussed here)

Allocation methods (contiguous, linked, indexed)

Free space management (bitmap, linked list, (grouping, counting))

(32)

References

Silberschatz, Galvin, Gagne, „Operating

System Concepts“, Seventh Edition, Wiley, 2005

Chapter 10 „File-System Interface“ (Section 10.1.1, 10.2, 10.4, 10.5, 10.6)

Chapter 11 „File-System Implementation“

(Section 11.1, 11.4, 11.5)

Referenzen

ÄHNLICHE DOKUMENTE

Fluxes of soil organic carbon from eroding permafrost coasts, Canadian Beaufort Sea.. PhD thesis, Department of Geography,

Case 4: attach is TRUE, toName is local and fromName is remote | Like case 2 except that instead of an actual transfer of contents and properties the local name is attached to

Then insert the newly created CP/M operations diskette in disk drive A, and insert the NEVADA SOFTWARE distribution diskette in drive Band type (ctl-c) to

account names and security codes stored in both the account's user identification item (in the SYSTEM dictionary) and the. individual file definition items within

In addition to providing expanded file storage space, the file server is a mechanism for user sharing and exchange of files/documents. As indicated, the server

The hierarchy of the Directory is described by 3 types of record structures stored within the Directory - file records, directory records and thread records.. A

NortTlally the 1 K byte RAM buffer is set up to contain the rleader of the sector to be read and the disk state machine state compares this to the data stream corn ing off

This paper provides an overview of Auspex's hardware architecture and details one aspect of NS 5000 software architecture--the separation of the Unix file and storage