File Storage Organization

Download Report

Transcript File Storage Organization

Files
• An operating system,
maintains descriptive
information about files
in a data structure
called a file
descriptor.
Name
Deletion control
Storage
Organization
Visibility Control
Identifier
Version Number
Owner
File History
Type
Current Use
Size
Location
Access
Restrictions
Record
Organization
Access type
Extension Control
Internal Structure of Files
• Unstructured series of bytes
J
o
h n
S m
i
t
h
1
2
3
8
8
9
3
2
1
Fixed length records
Record 1
Record 2
Record 3
Record 4
Physical Record,
The number of logical records that can be stored in a single physical
record is dependant upon the logical record length. If the physical block
size is 512k, and each record is 132 bytes then the number of records
that can be stored per physical block is:
512000 / 132 = 3878 with 104 bytes left over
Variable length records
3
R1
35
R2
Where is a files data stored within the physical blocks
allocated to it?
End of data
File Operations
• File operations are supported using two
internal data structures
– Buffers
– File control blocks
• Creating a file
– The file is created with no data
– An entry is recorded in the main directory
• Deleting a file
• Open
• Close
• Writing a file
• Reading a file
• Repositioning within a file (seek)
• Truncating a file
• Append
• Rename
File Storage Organization
• The majority of space on a device is
reserved for the storage of files.
• When files are created and modified
physical blocks are allocated to store the
files contents.
• The way that this allocation occurs, and
the way physical blocks are organized can
have an impact on the speed and
efficiency of file operations.
Simple contiguous Organization
In this method, space is
allocated to a file as a
series of contiguous
physical blocks. The
beginning address (on
disk) of the first block is
recorded as part of the
file’s file descriptor, in the
directory. This makes
directory contents small
and simple
File Descriptors
File 1
FREE
FREE
File 3
Random access is
efficient
A file can only grow in
size if adjacent free
blocks are free
File 2
Simple Contiguous with Extents
• In this organization, a file receives an
initial allocation as a series of adjacent
blocks.
• When the file grows beyond its initial
allocation, additional adjacent blocks are
allocated (possibly in a different area on
the disk) and their location recorded as a
separate entry in the directory.
The size of individual
extents is a multiple
of the physical block
size, and do not have
to be physically
adjacent to the space
already allocated to
the file.
Extents can also be
used when the file is
first created. If
sufficient space is
not available when
the file is created, a
series of extents can
be allocated to store
the file.
File 2 (2)
File 3
File 1 (2)
File 2
File 1
Blocked Organizations
• These are alternatives to algorithms that require
allocation of contiguous blocks.
• In this organization storage space is allocate in discrete
blocks, which are equal to or a multiple of the sector
size.
• The system keeps track of blocks that are free, and
those that have been allocated to individual size.
• When space is needed for a file, a series of blocks are
allocated, they need not be adjacent, and their
association with the file, and each other is recorded.
• With these algorithms, fragmentation is NOT a problem
Blocked Chained Organizations
File1
File2
Free Pointer
Blocked Indexed Organizations
In File
Descriptor