File Systems and Management Ppt

download File Systems and Management Ppt

of 66

Transcript of File Systems and Management Ppt

  • 8/4/2019 File Systems and Management Ppt

    1/66

    File System and managementFile systems: What is a file, user view of files

    file types and file operations, file types in Unix/Linux and

    Microsoft

    file operation commands, file access rights,

    file storage management,

    Inode or FAT structure, file control blocks,

    root file system ,directory

    file paths, blocks ,

    impact of block size selection

    Allocation Techniques -: contiguous allocation, chained andindexed allocations,

    , file related system services, disk access control

    and scheduling.

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    2/66

    Role Of Operating System

    The operating system has various roles:

    Management of the processor:

    Management of the random access memory

    Management of input/output:

    Management of execution of applications:

    Management of authorizations:

    File management:

    Information management

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    3/66

    File systems: What is a file

    A file is a collection of data stored in one unit, identified by a filename.It can be a document, picture, audio or video stream, data library,

    application, or other collection of data.

    A file system is a method of storing and organizing computer files andtheir data. Essentially, it organizes these files into a database for thestorage, organization, manipulation, and retrieval by the computer's

    operating system.

    File systems are used on data storage devices such as a hard disksor CD-ROMs to maintain the physical location of the files.

    A named collection of related infoConsists of asequence of bits, bytes, lines, orrecords

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    4/66

    File Attributes

    Name

    only information kept in human-readable form Identifier unique tag (number) identifies file within file

    system

    Type needed for systems that support different types

    Location

    pointer to file location on device Size current file size

    Protection controls who can do reading, writing, executing

    Time, date, and user identification data for protection,

    security, and usage monitoring

    Information about files are kept in the directory structure,which is maintained on the disk

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    5/66

    File Operations

    File is an abstract data type Create

    Write

    Read

    Reposition within file Delete

    Truncate

    Open(Fi) search the directory structure on disk

    for entry Fi, and move the content of entry tomemory

    Close (Fi) move the content of entry Fi inmemory to directory structure on disk

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    6/66

    Open Files

    Several pieces of data are needed to manageopen files:

    File pointer: pointer to last read/write location,per process that has the file open

    File-open count: counter of number of times afile is open to allow removal of data fromopen-file table when last processes closes it

    Disk location of the file: cache of data accessinformation

    Access rights: per-process access modeinformation

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    7/66

    Linux/UNIX File Types

    Regular file

    Text or binary data (e.g. an image).

    Directory Contains other files and directories.

    Device special file

    An interface to a piece of hardware, such as aprinter. You don't have to worry about this.

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    8/66

    Microsoft File Types

    .doc Microsoft Word File

    .xls Microsoft Excel File

    .exe Executable File - one that starts up a software application,for instance

    .txt A plain text file, can be read by Word, Notepad, Wordpadmany others

    .bmpA full detail (ie large file size)

    picture.jpg A compressed (ie smaller file size) picture.wav A full

    detail (ie large file size) sound file.mp3 A compressed (ie smaller file size) sound file

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    9/66

    File Types Name, Extension

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    10/66

    Access Methods

    Sequential Access

    Direct Access

    Indexed Access

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    11/66

    Sequential Access

    The simplest access method is sequential access. Informationin the file is processed in order, one record after the other.This mode of access is by far the

    editors and compilers usually access files in this fashion.

    Reads and writes make up the bulk of the operations on a file.A read operationread nextreads the next portion of thefile and automatically advances a file pointer, which tracks theI/O location.

    Similarly, the write operationwrite nextappends to theend of the file and advances to the end of the newly writtenmaterial

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    12/66

    Sequential-access File

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    13/66

    Simulation of Sequential Access on a

    Direct-access File

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    14/66

    Direct Access

    Another method is direct access (or relative access). A file ismade up of fixed length

    logical records that allow programs to read and write recordsrapidly

    in no particular order. The direct-access method is based on adisk model of a file, since disks allow random access to any fileblock.

    For direct access, the file is viewed as a numbered sequenceof blocks or records. Thus, we may read

    block 14, then read block 53, and then write block 7. Ther

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    15/66

    Access Methods

    Sequential Accessread nextwrite nextresetno read after last write

    (rewrite)

    Direct Accessread nwrite n

    position to nread nextwrite next

    rewrite n

    n= relative block numberNotes Compiled by BJ

    I d d R l ti Fil

  • 8/4/2019 File Systems and Management Ppt

    16/66

    Index and Relative FilesThe index, like an index in the back of a book, contains pointersto the various blocks. To find a record in the file, we first search

    the index and then use the pointer to access the file directly andto find the desired record.

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    17/66

    File operation CommandsCatTouch

    Vi

    ChmodUmask

    Rm

    rmdir

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    18/66

    Root File System

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    19/66

    Allocation Methods

    An allocation method refers to how disk blocks

    are allocated for files:

    Contiguous allocation

    Linked allocation

    Indexed allocation

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    20/66

    Contiguous Allocation Contiguous allocation requires that each file occupy a set of

    contiguous blocks on the disk. Disk addresses define a linearordering on the disk. With this ordering, assuming that only onejob is accessing the disk, accessing block b + 1 after block b

    normally requires no head movement. When head movement isneeded (from the last sector of one cylinder to the first sector ofthe next cylinder), the head need only move from one track tothe next. Thus, the number of disk seeks required for accessing

    contiguously allocated files is minimal. The IBM VM/CMS operating system uses contiguous allocation

    because it provides such good performance.

    Contiguous allocation of a file is defined by the disk address andlength (in block units) of the first block. If the file is n blocks long

    and starts at location b, then it occupies blocks b, b + 1, b + 2, ...,b + n1. The directory entry for each file indicates the addressof the starting block and the length of the area allocated for thisfile

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    21/66

    Contiguous Allocation of Disk Space

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    22/66

    DISADVANTAGES Contiguous allocation has some problems, One

    difficulty is finding space for a new file. Wasteful of space (dynamic storage-Allocation

    problem) Files cannot grow

    All these algorithms suffer from the problem ofexternal fragmentation. As files are allocated and deleted, the free disk

    space is broken into little pieces. Externalfragmentation exists whenever free space isbroken into chunks. It becomes a problem whenthe largest contiguous chunk is insufficient for arequest;

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    23/66

    Linked allocation

    Linked allocation solves all problems of contiguous allocation.

    With linked allocation, each file is a linked list of disk blocks; thedisk blocks may be scattered anywhere on the disk. Thedirectory contains a pointer to the first and last blocks of thefile.

    To create a new file, we simply create a new entry in the

    directory. With linked allocation, each directory entry has apointer to the first disk block of the file. This pointer is initializedto nil(the end-of-list pointer value) to signify an empty file. Thesize field is also set to 0.

    A write to the file causes the free-space management system tofind a free block, and this new block is written to and is linked tothe end of the file.

    To read a file, we simply read blocks by following the pointersfrom block to block. So there is no external fragmentation

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    24/66

    Linked Allocation

    a file of five blocks might start at block 9 and continue at block16, then block 1, then block 10, and finally block 25. Each blockcontains a pointer to the next block.

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    25/66

    Disadvantages The major problem is that it can be used effectively only for

    sequential-access files.

    To find the ith block of a file, we must start at the beginning ofthat file and follow the pointers until we get to the ith block.

    Each access to a pointer requires a disk read, and some require adisk seek.

    Another disadvantage is the space required for the pointers. If apointer requires 4 bytes out of a 512-byte block, then 0.78 percentof the disk is being used for pointers, rather than for information.

    another problem of linked allocation is reliability what wouldhappen if a pointer were lost or damaged

    A bug in the operating-system software or a disk hardware failuremight result in picking up the wrong pointer. This error could inturn result in linking into the free-space list or into another file.

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    26/66

    Indexed allocation Linked allocation solves the external-fragmentation and size-

    declaration problems of contiguous allocation but linked

    allocation cannot support efficient direct access, since thepointers to the blocks are scattered with the blocks themselvesall over the disk and must be retrieved in order.

    Indexed allocation solves this problem by bringing all thepointers together into one location: the index block.

    Each file has its own index block, which is an array of disk-blockaddresses.

    The /"' entry in the index block points to the /"' block of the file.The directory contains the address of the index block

    To find and read the /th block, we use the pointer in the /"'

    index-block entry When the file is created, all pointers in theindex block are set to nil.

    Each file has its own index block, which is an array of disk-blockaddresses.

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    27/66

    Indexed Allocation

    Brings all pointers together into theindex block.

    Logical view.

    index table

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    28/66

    Indexed Allocation

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    29/66

    Indexed allocation

    Indexed allocation supports direct access, without suffering from

    external fragmentation, because any free block on the disk can

    satisfy a request for more space.

    Indexed allocation does suffer from wasted space, however. The

    pointer overhead of the index block is generally greater than the

    pointer overhead of linked allocation

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    30/66

    Disadvantages

    Indexed-allocation schemes suffer from some

    of the same performance problems as does

    linked allocation. Specifically, the index blocks

    can be cached in memory, but the data blocksmay be spread all over a volume.

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    31/66

    Mode of access: read, write, execute

    Three classes of users

    RWXa) owner access 7 1 1 1

    RWX

    b) group access 6 1 1 0

    RWX

    c) public access 1 0 0 1 Ask manager to create a group (unique name), say G, and

    add some users to the group.

    For a particular file (say game) or subdirectory, define anappropriate access.

    owner group public

    chmod 761 game

    Attach a group to a file

    chgrp G game

    Access Rights

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    32/66

    Directory Structure A collection of nodes containing information about all files.

    F 1 F 2F 3

    F 4

    F n

    Directory

    Files

    Both the directory structure and the files reside on disk.Backups of these two structures are kept on tapes.

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    33/66

    file paths

    Absolute or relative path name

    Creating a new file is done in current directory

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    34/66

    Information in a Device Directory Name

    Type Address

    Current length

    Maximum length

    Date last accessed (for archival) Date last updated (for dump)

    Owner ID (who pays)

    Protection information (discuss later)

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    35/66

    Operations Performed on Directory

    Search for a file

    Create a file

    Delete a file

    List a directory

    Rename a file

    Traverse the file system

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    36/66

    Organize the Directory (Logically) to

    Obtain

    Efficiency locating a file quickly.

    Naming convenient to users.

    Two users can have same name for different files.

    The same file can have several different names.

    Grouping logical grouping of files by

    properties, (e.g., all Java programs, all games,

    )

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    37/66

    Single-Level Directory

    A single directory for all users.

    Naming problem

    Grouping problem

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    38/66

    Two-Level Directory

    Separate directory for each user.

    Path nameCan have the same file name for different user

    Efficient searching

    No grouping capability

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    39/66

    Tree-Structured Directories

    Efficient searching

    Grouping Capability Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    40/66

    File Storage Management

    OS need to maintain several piece of info that

    can assist management of files

    Like when file was last updated and whom

    Unix have audit trail which maintain record of

    who has accessed when and did what

    audit trail useful from recovering from crash

    also detect unauthorized access

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    41/66

    A Typical File-system Organization

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    42/66

    Storage Structure

    Main memory only large storage media that the CPU can

    access directly

    Secondary storage extension of main memory that provides

    large nonvolatile storage capacity

    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 determines the logical interaction

    between the device and the computer

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    43/66

    Storage Hierarchy

    Storage systems organized in hierarchy

    Speed

    Cost

    Volatility

    Caching copying information into faster

    storage system; main memory can be viewed

    as a ast cache for secondary storage

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    44/66

    Access latency

    1 ns

    25 ns

    50 ns

    5 ms

    50 sec

    < 1 KB

    1 MB

    256 MB40 GB

    > 1 TB

    Capacity

    Storage pyramid

    Registers

    Cache (SRAM)

    Main memory (DRAM)

    Magnetic disk

    Magnetic tape

    Goal: really large memory with very low latency Latencies are smaller at the top of the hierarchy

    Capacities are larger at the bottom of the hierarchy

    Solution: move data between levels to create illusion of largememory with low latency

    Better

    Better

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    45/66

    Overview of Storage Structure Magnetic disks provide bulk of secondary storage of modern computers

    Drives rotate at 60 to 200 times per second

    Transfer rate is rate at which data flow between drive and computer

    Positioning time (random-access time) is time to move disk arm todesired cylinder (seek time) and time for desired sector to rotate underthe disk head (rotational latency)

    Head crash results from disk head making contact with the disk surface

    Thats bad Disks can be removable

    Drive attached to computer via I/O bus

    Busses vary, including EIDE, ATA, SATA, USB, Fibre Channel, SCSI

    Host controller in computer uses bus to talk to disk controller built into

    drive or storage array

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    46/66

    Disk drive structure

    sector

    cylinder

    platter

    spindle

    track

    head

    actuator

    surfaces

    Data stored on surfaces Up to two surfaces per

    platter

    One or more platters per disk

    Data in concentric tracks Tracks broken into sectors

    256B-1KB per sector

    Cylinder: corresponding

    tracks on all surfaces

    Data read and written byheads

    Actuator moves heads

    Heads move in unison

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    47/66

    Moving-head Disk Machanism

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    48/66

    To read a given sector we first move the heads

    to that sector's cylinder (seek time), then wait

    for the sector to rotate under the head

    (latency time), then copy data off of disk intomemory (transfer time).

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    49/66

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    50/66

    Booting from a Disk

    Notes Compiled by BJ

    d d

  • 8/4/2019 File Systems and Management Ppt

    51/66

    Index Node

    Notes Compiled by BJ

    Indexed Allocation Mapping (Cont )

  • 8/4/2019 File Systems and Management Ppt

    52/66

    Indexed Allocation Mapping (Cont.)

    outer-index

    index table file

    Notes Compiled by BJ

    INODE

  • 8/4/2019 File Systems and Management Ppt

    53/66

    INODE

    The inode pointer structure is a structure adopted by the inode of a file inthe Unix File System (UFS) or other related file systems to list the

    addresses of a file's data blocks. In the past, the structure may have consisted of eleven or thirteen

    pointers, but most modern file systems use fifteen pointers. Thesepointers consist of (assuming 12 pointers in the inode)

    Twelve pointers that directly point to blocks of the file's data (directpointers)

    One singly indirect pointer (a pointer that points to a block of pointers thatthen point to blocks of the file's data)

    One doubly indirect pointer (a pointer that points to a block of pointersthat point to other blocks of pointers that then point to blocks of the file'sdata)

    One triply indirect pointer (a pointer that points to a block of pointers that

    point to other blocks of pointers that point to other blocks of pointers thatthen point to blocks of the file's data)

    The structure allows for inodes to describe very large files in a file systemswith a fixed logical block size

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    54/66

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    55/66

    INODE

    The inode pointer structure not only allows for files to easilybe allocated to non-contiguous blocks, it also allows the dataat a particular location inside a file to be easily located. This ispossible because the logical block size is fixed. For example, ifeach block is 8 kB, file data at 120 to 128 kB would be pointedto by the fourth pointer of the first indirect block

    The number of pointers in the indirect blocks are dependenton the block size and size of block pointers. Example: with a512 byte block size, and 4 byte block pointers, each indirect

    block can consist of 128 (512 / 4) pointers

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    56/66

    File Control Block

    In Microsoft environment counterpart of

    inode is File Control Block It stores Filename, Location of secondary

    Storage, length of file in bytes, date and time

    of creation, last access etc. Advantage of fcb is that it store file noting

    which application created it

    Uses extension name like .txt ,.doc to identifyhow file was created

    Uses Simple cluster to store files

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    57/66

    File Control Block

    Notes Compiled by BJ

    File Allocation Table

  • 8/4/2019 File Systems and Management Ppt

    58/66

    File-Allocation Table

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    59/66

    Disk Scheduling Policies

    First-in, first-out (FIFO)

    Process request sequentially

    Fair to all processes

    Approaches random scheduling in performance if

    there are many processes

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    60/66

    Notes Compiled by BJ

    we assume that the disk head is initially located attrack 100. we assume a disk with 200 tracks and that thedisk request queue has random requests in it. Therequested tracks, in the order receivedby the disk scheduler, are 55, 58, 39, 18, 90, 160, 150,38, 184.

  • 8/4/2019 File Systems and Management Ppt

    61/66

    Disk Scheduling Policies

    Shortest Service Time First

    Select the disk I/O request that requires the least

    movement of the disk arm from its current

    position Always choose the minimum seek time

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    62/66

    Notes Compiled by BJ

    we assume that the disk head is initially located attrack 100. we assume a disk with 200 tracks and that thedisk request queue has random requests in it. Therequested tracks, in the order receivedby the disk scheduler, are 55, 58, 39, 18, 90, 160, 150,38, 184.

  • 8/4/2019 File Systems and Management Ppt

    63/66

    Disk Scheduling Policies

    SCAN

    Arm moves in one direction only, satisfying all

    outstanding requests until it reaches the last track

    in that direction Direction is reversed

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    64/66

    Notes Compiled by BJ

    we assume that the disk head is initially located attrack 100. we assume a disk with 200 tracks and that thedisk request queue has random requests in it. Therequested tracks, in the order receivedby the disk scheduler, are 55, 58, 39, 18, 90, 160, 150,38, 184.

  • 8/4/2019 File Systems and Management Ppt

    65/66

    Disk Scheduling Policies

    C-SCAN

    Restricts scanning to one direction only

    When the last track has been visited in one

    direction, the arm is returned to the opposite endof the disk and the scan begins again

    Notes Compiled by BJ

  • 8/4/2019 File Systems and Management Ppt

    66/66

    we assume that the disk head is initially located attrack 100. we assume a disk with 200 tracks and that thedisk request queue has random requests in it. Therequested tracks, in the order receivedby the disk scheduler, are 55, 58, 39, 18, 90, 160, 150,38, 184.