+ All Categories
Home > Documents > The Computer File System-3

The Computer File System-3

Date post: 14-Apr-2018
Category:
Upload: -
View: 215 times
Download: 0 times
Share this document with a friend

of 23

Transcript
  • 7/30/2019 The Computer File System-3

    1/23

    The computer file system

    - A file system is a clearly-defined method that thecomputer's operating system uses to store, catalog,and retrieve files.

    - Files are central to everything we use a computer

    for: all applications, images, movies, and documentsare files, and they all need to be stored somewhere.

    - For most computers, this place is the hard disk

    drive, but files can exist on all sorts of media: flashdrives, CD and DVD discs, or even tape backupsystems.

    1

  • 7/30/2019 The Computer File System-3

    2/23

    File systems need to keep track of not only thebits that make up the file itself and where they

    are logically placed on the hard drive, but alsostore information about the file.

    The most important thing it has to store is thefile's name. Without the name it will be nearly

    impossible for the humans to find the file again. Also, the file system has to know how to organize

    files in a hierarchy

    This hierarchy is usually called a directory. Thelast thing the file system has to worry about ismetadata

    2

  • 7/30/2019 The Computer File System-3

    3/23

    Metadata

    Metadata literally means "data about data.

    All file systems had to store at least some metadataalong with the file and file name.

    One important bit of metadata is the file'smodification.

    A bit of metadata that is unimportant to peoplebut

    crucial to the computeris the exact physical location(or locations) of the file on the storage device.

    Other examples of metadata include attributes, such ashidden or read-only, that the operating system uses todecide how to display the file and who gets to modifyit.

    Multiuser operating systems store file permissions asmetadata.

    3

  • 7/30/2019 The Computer File System-3

    4/23

    Advanced file system features

    As operating systems have matured, more and more

    features have been added to their file systems.

    the ability to index files for faster searches, newstorage designs that reduce file fragmentation, andmore robust error-correction abilities.

    One of the biggest advances in file systems has beenthe addition ofjournaling, which keeps a log ofchanges that the computer is about to make to eachfile.

    This means that if the computer crashes or the powergoes out halfway through the file operation, it will beable to check the log and either finish or abandon theoperation quickly without corrupting the file.

    4

  • 7/30/2019 The Computer File System-3

    5/23

    The file system goals

    to support the storage, searching, and modification of user

    data,

    to guarantee the correctness and integrity of the data,

    to optimize both the overall throughput (from the operating

    systems global

    view) and response time (from the users view).

    to provide transparent access to many different device

    types such as hard

    disks, CD-ROMs, and floppy disks, to provide a standardized set of I/O interface routines, to

    standardize the concepts of file, device and network access.

    5

  • 7/30/2019 The Computer File System-3

    6/23

    User RequirementsIn a multi-tasking, multi-user system the file management

    system must meet users requirements in the presence of

    different users. important requirements include: the recording of a primary owner of each file (for access

    controls and accounting),

    each file should be accessed by (at least) one symbolic name,

    each user should be able to create, delete, read, and modify files, users should have constrained access to the files of others,

    a files owner should be able to modify the types of access that may be

    performed by others,

    a facility to copy/backup files to identical or different forms of media,

    a secure logging and notification system if inappropriate access is

    attempted

    6

  • 7/30/2019 The Computer File System-3

    7/23

    Components of the File Management System

    The device drivers communicate directly with I/Ohardware. Device drivers commence I/O requests andreceive asynchronous notification of their completion (viaDMA).

    The basic file system exchanges fixed-sized pieces (blocks)of data with

    the device drivers, buffers those blocks in main memory,and maps blocks to their physical location.

    The I/O supervisor manages the choice of device, itsscheduling and status, and allocates I/O buffers toprocesses.

    The logical I/O layer maps I/O requests to blocks, andmaintains ownership and access information about files.

    7

  • 7/30/2019 The Computer File System-3

    8/23

    8

  • 7/30/2019 The Computer File System-3

    9/23

    The Role of Directory Structures

    All modern operating systems have adopted the hierarchicaldirectory model to represent collections of files.

    A directory itself is typically a special type of file storing

    information about the files (and hence directories) it contains.

    Although a directory is owned by a user, the directory istruly owned by the operating system itself.

    The operating system must constrain access to important, and

    often hidden, information in the directory itself.

    Although the owner of a directory may examine and(attempt to) modify it, true modification is only permitted

    through operating system primitives affecting the internal

    directory structure.

    9

  • 7/30/2019 The Computer File System-3

    10/23

    File-System Implementation

    1- File-System Structure Hard disks have two important properties that make

    them suitable for secondary storage of files in filesystems: (1) Blocks of data can be rewritten in place,and (2) they are direct access, allowing any block ofdata to be accessed with only ( relatively ) minormovements of the disk heads and rotational latency.

    Disks are usually accessed in physical blocks, ratherthan a byte at a time. Block sizes may range from 512bytes to 4K or larger.

    File systems organize storage on disk drives, and can beviewed as a layered design:

    10

  • 7/30/2019 The Computer File System-3

    11/23

    At the lowest layer are the physical devices, consistingof the magnetic media, motors & controls, and theelectronics connected to them and controlling them.

    Modern disk put more and more of the electroniccontrols directly on the disk drive itself, leavingrelatively little work for the disk controller card toperform.

    I/O Controlconsists ofdevice drivers, special softwareprograms ( often written in assembly ) whichcommunicate with the devices by reading and writingspecial codes directly to and from memory addressescorresponding to the controller card's registers. Eachcontroller card ( device ) on a system has a differentset of addresses ( registers, a.k.a.ports ) that it listensto, and a unique set of command codes and resultscodes that it understands.

    11

  • 7/30/2019 The Computer File System-3

    12/23

    The basic file system level works directly with the

    device drivers in terms of retrieving and storing rawblocks of data, without any consideration for what isin each block. Depending on the system, blocks maybe referred to with a single block number, ( e.g. block# 234234 ), or with head-sector-cylinder

    combinations. Thefile organization module knows about files and

    their logical blocks, and how they map to physicalblocks on the disk. In addition to translating from

    logical to physical blocks, the file organization modulealso maintains the list of free blocks, and allocatesfree blocks to files as needed.

    12

  • 7/30/2019 The Computer File System-3

    13/23

    The logical file system deals with all of the meta data

    associated with a file ( UID, GID, mode, dates, etc ), i.e.

    everything about the file except the data itself. This levelmanages the directory structure and the mapping of filenames tofile control blocks, FCBs, which contain all of themeta data as well as block number information for findingthe data on the disk.

    The layered approach to file systems means that much ofthe code can be used uniformly for a wide variety ofdifferent file systems, and only certain layers need tobe file system specific. Common file systems in useinclude the UNIX file system, UFS, the Berkeley Fast File

    System, FFS, Windows systems FAT, FAT32, NTFS, CD-ROM systems ISO 9660, and for Linux the extended filesystems ext2 and ext3 ( among 40 others supported. )

    13

  • 7/30/2019 The Computer File System-3

    14/23

    14

  • 7/30/2019 The Computer File System-3

    15/23

    2 File-System Implementation2.1 Overview

    File systems store several important data structures on

    the disk: A boot-control block, ( per volume ) a.k.a. the boot block

    in UNIX or thepartition boot sectorin Windows containsinformation about how to boot the system off of this disk.This will generally be the first sector of the volume if there

    is a bootable system loaded on that volume, or the blockwill be left vacant otherwise.

    A volume control block, ( per volume ) the master filetable in UNIX or the superblockin Windows, whichcontains information such as the partition table, number

    of blocks on each filesystem, and pointers to free blocksand free FCB blocks.

    A directory structure ( per file system ), containing filenames and pointers to corresponding FCBs. UNIX usesinode numbers, and NTFS uses a master file table.

    15

  • 7/30/2019 The Computer File System-3

    16/23

    - The File Control Block, FCB, ( per file ) containing detailsabout ownership, size, permissions, dates, etc. UNIX stores

    this information in inodes, and NTFS in the master file table as

    a relational database structure.

    16

  • 7/30/2019 The Computer File System-3

    17/23

    There are also several key data structures storedin memory:

    An in-memory mount table. An in-memory directory cache of recently accessed

    directory information.

    A system-wide open file table, containing a copy ofthe FCB for every currently open file in the system, aswell as some other related information.

    A per-process open file table, containing a pointer tothe system open file table as well as some otherinformation. ( For example the current file position

    pointer may be either here or in the system file table,depending on the implementation and whether thefile is being shared or not. )

    17

  • 7/30/2019 The Computer File System-3

    18/23

    When a new file is created, a new FCB is allocated andfilled out with important information regarding the newfile. The appropriate directory is modified with the new file

    name and FCB information. When a file is accessed during a program, the open( )

    system call reads in the FCB information from disk, andstores it in the system-wide open file table. An entry isadded to the per-process open file table referencing thesystem-wide table, and an index into the per-process tableis returned by the open( ) system call. UNIX refers to thisindex as afile descriptor, and Windows refers to it as afilehandle.

    If another process already has a file open when a newrequest comes in for the same file, and it is sharable, then

    a counter in the system-wide table is incremented and theper-process table is adjusted to point to the existing entryin the system-wide table.

    18

  • 7/30/2019 The Computer File System-3

    19/23

    19

  • 7/30/2019 The Computer File System-3

    20/23

    When a file is closed, the per-process table entry is

    freed, and the counter in the system-wide table is

    decremented. If that counter reaches zero, then the

    system wide table is also freed. Any data currentlystored in memory cache for this file is written out to

    disk if necessary.

    20

  • 7/30/2019 The Computer File System-3

    21/23

    2- Partitions and Mounting

    Physical disks are commonly divided into smaller unitscalled partitions. They can also be combined into largerunits.

    Partitions can either be used as raw devices ( with nostructure imposed upon them ), or they can beformatted to hold a filesystem ( i.e. populated with

    FCBs and initial directory structures as appropriate. )Raw partitions are generally used for swap space, andmay also be used for certain programs such asdatabases that choose to manage their own diskstorage system. Partitions containing filesystems can

    generally only be accessed using the file systemstructure by ordinary users, but can often be accessedas a raw device also by root.

    21

  • 7/30/2019 The Computer File System-3

    22/23

    The boot block is accessed as part of a raw partition, bythe boot program prior to any operating system beingloaded. Modern boot programs understand multiple

    OSes and filesystem formats, and can give the user achoice of which of several available systems to boot.

    The root partition contains the OS kernel and at leastthe key portions of the OS needed to complete theboot process. At boot time the root partition ismounted, and control is transferred from the bootprogram to the kernel found there. ( Older systemsrequired that the root partition lie completely withinthe first 1024 cylinders of the disk, because that was as

    far as the boot program could reach. Once the kernelhad control, then it could access partitions beyond the1024 cylinder boundary. )

    22

  • 7/30/2019 The Computer File System-3

    23/23

    Continuing with the boot process, additional

    filesystems get mounted, adding their information

    into the appropriate mount table structure. As a part

    of the mounting process the file systems may be

    checked for errors or inconsistencies, either because

    they are flagged as not having been closed properly

    the last time they were used, or just for generalprincipals. Filesystems may be mounted either

    automatically or manually. In UNIX a mount point is

    indicated by setting a flag in the in-memory copy of

    the inode, so all future references to that inode getre-directed to the root directory of the mounted

    filesystem.

    23


Recommended