Unit VI File Management

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 41

Unit VI: File-System Management

• File Concept
• Access Methods
• File allocation methods
• Disk and Directory Structure
• Disk Organization
File Concept

• Contiguous logical address space


• Types:
– Data
• numeric
• character
• binary
– Program
• Contents defined by file’s creator
– Many types
• Consider text file, source file, executable file
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
• Information kept in the directory structure
File info Window on Mac OS X
File Operations

• File is an abstract data type


• Create
• Write – at write pointer location
• Read – at read pointer location
• Reposition within file - seek
• Delete
• Truncate
• Open(Fi) – search the directory structure on disk for
entry Fi, and move the content of entry to memory
• Close (Fi) – move the content of entry Fi in memory to
directory structure on disk
Open Files

• Several pieces of data are needed to manage


open files:
– Open-file table: tracks open files
– File pointer: pointer to last read/write location, per
process that has the file open
– File-open count: counter of number of times a file
is open – to allow removal of data from open-file
table when last processes closes it
– Disk location of the file: cache of data access
information
– Access rights: per-process access mode information
File Types – Name, Extension
File Structure

• File - sequence of words, bytes


• Simple record structure
– Lines
– Fixed length
– Variable length
• Complex Structures
– Formatted document
– Relocatable load file
Access Methods
Sequential-access File
Access Methods
• Sequential Access
read next
write next
reset

• Direct Access – file is fixed length logical records


read n
write n
position to n
read next
write next
rewrite n
n = relative block number
Simulation of Sequential Access on Direct-access File
Example of Index and Relative Files Access
Directory Structure

• A collection of nodes containing information about all files

Directory

Files
F1 F2 F4
F3
Fn

Both the directory structure and the files reside on disk


Directory Organization

The directory is organized 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, …)
Operations Performed on Directory

• Search for a file


• Create a file
• Delete a file
• List a directory
• Rename a file
• Traverse the file system
Single-Level Directory
• A single directory for all users

• Naming problem
• Grouping problem
Two-Level Directory

• Separate directory for each user

 Path name
 Can have the same file name for different user
 Efficient searching
 No grouping capability
Tree-Structured Directories
Tree-Structured Directories (Cont.)

• Efficient searching

• Grouping Capability

• Current directory (working directory)


– cd /spell/mail/prog
Tree-Structured Directories (Cont)

• Absolute or relative path name


• Creating a new file is done in current directory
• Delete a file
rm <file-name>
• Creating a new subdirectory is done in current directory
mkdir <dir-name>
Example: if in current directory /mail
mkdir count

Deleting “mail”  deleting the entire subtree rooted by “mail”


File Allocation Methods - Contiguous

• An allocation method refers to how disk


blocks are allocated for files:
• Contiguous allocation – each file occupies
set of contiguous blocks
– Best performance in most cases
– Simple – only starting location (block #) and
length (number of blocks) are required
– Problems include finding space for file,
knowing file size, external fragmentation, need
for compaction off-line (downtime) or on-line
Contiguous Allocation
Allocation Methods - Linked

• Linked allocation – each file a linked list of blocks


– File ends at nil pointer
– No external fragmentation
– Each block contains pointer to next block
– No compaction, external fragmentation
– Free space management system called when new
block needed
– Improve efficiency by clustering blocks into groups but
increases internal fragmentation
– Reliability can be a problem
– Locating a block can take many I/Os and disk seeks
Allocation Methods – Linked (Cont.)

• FAT (File Allocation Table) variation


– Beginning of volume has table, indexed by block
number
– Much like a linked list, but faster on disk and
cacheable
– New block allocation simple
Linked Allocation
Allocation Methods - Indexed

• Indexed allocation
– Each file has its own index block(s) of pointers to
its data blocks

• Logical view

index table
Indexed Allocation (Cont.)

• Need index table


• Random access
• Dynamic access without external
fragmentation, but have overhead of
index block
Example of Indexed Allocation
Disk Structure

• Disk can be subdivided into partitions


• Disks or partitions can be RAID protected against
failure
• Disk or partition can be used raw – without a file
system, or formatted with a file system
• Entity containing file system known as a volume
• Each volume containing file system also tracks that
file system’s info in device directory or volume table
of contents
• As well as general-purpose file systems there are
many special-purpose file systems, frequently all
within the same operating system or computer
A Typical File-system Organization
Partitions and Mounting
• Partition can be a volume containing a file system or raw –
just a sequence of blocks with no file system
• Boot block can point to boot volume or boot loader set of
blocks that contain enough code to know how to load the
kernel from the file system.
– Or a boot management program for multi-os booting
• Root partition contains the OS, other partitions can hold
other Oses, other file systems, or be raw
– Mounted at boot time
– Other partitions can mount automatically or manually
• At mount time, file system consistency checked
– Is all metadata correct?
• If not, fix it, try again
• If yes, add to mount table, allow access
Booting from a Disk in Windows
RAID Structure

• RAID – redundant array of inexpensive/independent disks


– multiple disk drives provides reliability via redundancy
It’s a technology that enables greater levels of
performance, reliability and/or large volumes when
dealing with data.

How?? By concurrent use of two or more ‘hard disk


drives’.

How Exactly?? Mirroring, Stripping (of data) and Error


correction techniques combined with multiple disk arrays
give you the reliability and performance.
RAID (Cont.)
• Disk striping uses a group of disks as one storage unit
• RAID is arranged into six different levels
• RAID schemes improve performance and improve the
reliability of the storage system by storing redundant data
– Mirroring or shadowing (RAID 1) keeps duplicate of each disk
– Striped mirrors (RAID 1+0) or mirrored stripes (RAID 0+1) provides
high performance and high reliability
– Block interleaved parity (RAID 4, 5, 6) uses much less redundancy
• RAID within a storage array can still fail if the array fails, so
automatic replication of the data between arrays is
common
• Frequently, a small number of hot-spare disks are left
unallocated, automatically replacing a failed disk and having
data rebuilt onto them
RAID Levels
RAID (0 + 1) and (1 + 0)
RAID 0
a. It splits data among two or more disks.
b. Provides good performance.
c. Lack of data redundancy means there is
no fail over support with this
configuration.
d. In the diagram to the right, the odd
blocks are written to disk 0 and the even
blocks to disk 1 such that A1, A2, A3, A4,
… would be the order of blocks read if
read sequentially from the beginning.
e. Used in read only NFS systems and
gaming systems.
RAID 1
•RAID1 is ‘data mirroring’.
•Two copies of the data are held on
two physical disks, and the data is
always identical.
• Twice as many disks are required to
store the same data when compared
to RAID 0.
•Array continues to operate so long
as at least one drive is functioning.
RAID 5
• RAID 5 is an ideal combination of
good performance, good fault
tolerance and high capacity and
storage efficiency.

• An arrangement of parity and CRC


to help rebuilding drive data in case
of disk failures.

• “Distributed Parity” is the key


word here.
RAID 10

a. Combines RAID 1 and RAID 0.


b. Which means having the
pleasure of both - good
performance and good failover
handling.
c. Also called ‘Nested RAID’.
RAID 6

a. It is seen as the best way to


guarantee data integrity as it
uses double parity.
b. Lesser MTBF compared to
RAID5.
c. It has a drawback though of
longer write time.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy