File System Cse316
File System Cse316
OPERATING SYSTEM
Your Name :
School of Computer Science and Engineering, Lovely
Professional University, Phagwara, India
[email protected]
Abstract:
The file system provides the mechanism for online extend. The file system developers are hesitant to
storage and access to file contents, including data make major changes to them, because file system
and programs. This paper covers the high-level bugs may corrupt all the data on the secondary
details of file systems, as well as related topics such storage device. It is a difficult and time consuming
as the disk cache, the file system interface to the job to develop a file system. A file system may be a
kernel, and the user-level APIs that use the features general purpose, caching, cryptographic,
of the file system. It will give you a thorough compressing, or a replicated one which provides
understanding of how a file system works in consistency control among the copies spread across
general. The main component of the operating the file systems. The Figure 1 shows all the
system is the file system. It is used to create, possible layers including hardware and the virtual
manipulate, store, and retrieve data. At the highest views of spaces namely user space and the kernel
level, a file system is a way to manage information spaces by the operating systems. This figure is
on a secondary storage medium. There are so many further explained in detail in the following sections.
layers under and above the file system. All the A file system is that part of an operating system
layers are to be fully described here. This paper that controls the storage and manipulation of files
will give the explanatory knowledge of the file on media, such as disks. At first thought, that may
system designers and the researchers in the area. seem like a rather straightforward task. However, to
The complete path from the user process to carry out this function, a file system supporting a
secondary storage device is to be mentioned. File multiuser operating system must perform a variety
system is the area where the researchers are doing of difficult jobs. A successful file system must do
lot of job and there is always a need to do more the following:
work. The work is going on for the efficient, Impose upon a blank medium a structure capable of
secure, energy saving techniques for the file representing highly organized data,
systems. As we know that the hardware is going to Be able to multiplex the use of storage units among
be fast in performance and low-priced day by day. many concurrent processes,
The software is not built to comeback with the Contain internal synchronization for all processes,
hardware technology. So there is a need to do Enforce security by allowing data access only to
research in this area to bridge the technology gap. those who have legitimate authority,
Manage the sharing of individual files by multiple
Keywords: processes concurrently,
File System, OS Component, Disk Controller, Isolate faults stemming from imperfect physical
Buffer Cache, Hard Disk, Device Drivers. media or improper access (This implies minimizing
the potential for data loss due to hardware faults.),
Introduction: and
Data management is an important functionality Provide a standard set of interface routines to upper
provided by the operating system. File systems are layers of the operating system and user programs
tasked with volume of data management, including and make them apply equally to devices with
storing data on the disk or over the network, and dissimilar interfaces.
naming. These are complex and very difficult to
In conclusion, a file system must do all these things
with minimal impact on system performance.
FILE SYSTEMS ELEMENTARY the file and any other data associated with the
TERMINOLOGY file. The term “inode” (which we will use in
this book) is historical and originated in
UNIX. An inode is also known as a file
When we talk about file systems then there are many
control block (FCB) or file record.
terms for referring to certain concepts, and so it is
Extent: A starting block number and a length
necessary to define how we will refer to the specific
of successive blocks on a disk. For example
concepts that make up a file system. We list the terms
an extent might always contiguous. Extents
from the ground up, each definition building on the
are also known as block runs.
previous. Partition: A subset of all the blocks on a disk.
A start at block 1000 and continue for 150
Disk: A permanent storage medium of a blocks. Extents are disk can have several
certain size. A disk also has a sector or block partitions.
size, which is the minimum unit that the disk Volume: The name we give to a collection of
can read or write. The block size of most blocks on some storage medium (i.e., a disk).
modern hard disks is 512 bytes. That is, a volume may be all of the blocks on
Block: The smallest unit writable by a disk or a single disk, some portion of the total number
file system. Everything a file system does is of blocks on a disk, or it may even span
composed of operations done on blocks. A file multiple disks and be all the blocks on several
system block is always the same size as or disks. The term “volume” is used to refer to a
larger (in integer multiples) than the disk disk or partition that has been initialized with
block size. a file system.
Inode: The place where a file system stores all Superblock: The area of a volume where a file
the necessary metadata about a file. The inode system stores its critical volume wide
also provides the connection to the contents of information. A superblock usually contains
information such as how large a volume is, the name of a volume, and so on.
Metadata: A general term referring to presence of power failures or unexpected
information that is about something but not reboots.
directly part of it. For example, the size of a Attribute: A name (as a text string) and value
file is very important information about a file, associated with the name. The value may have
but it is not part of the data in the file. a defined type (string, integer, etc.), or it may
Journaling: A method of insuring the just be arbitrary data.
correctness of file system metadata even in the
Device Driver
The device drivers have many definitions. These are
written by the programmers. Essentially, it is simply a Character
way to “abstract out” the details of peripheral hardware Block
so the application programmer doesn’t have to worry Network
about them. In simple systems a driver may be nothing
more than a library of functions linked directly to the The principal distinction between character and
application. In general purpose operating systems, block is that the latter, such as disks, are randomly
device drivers are often independently loaded programs accessible, that is, you can move back and forth
that communicate with applications through some OS- within a stream of characters. Furthermore data on
specific protocol. In multitasking systems, the driver block devices is usually transferred in one or more
should be capable of establishing multiple “channels” to blocks at a time and pre fetched and cached. With
the device originating from different application character devices the stream moves in one direction
processes. In all cases though the driver is described in only. You can’t for example go back and reread a
terms of an application programming interface (API) character from a serial port. Block devices
that defines the services the driver is expected to generally have a file system associated with them
support. whereas character devices do not. Network devices
are different in that they handle “packets” of data
The device driver paradigm takes on additional for multiple protocol clients rather than a “stream”
significance in a protected mode environment such as of data for a single client. Furthermore, data arrives
Linux. There are two reasons for this. First, User Space at a network device asynchronously from sources
application code is normally not allowed to execute I/O outside the system. These differences necessitate a
instructions. This can only be done in Kernel Space at different interface between the kernel and the
Privilege Level 0. So a set of device driver functions device driver.
linked directly to the application simply would not
work. The driver must execute in Kernel Space.
Actually, there are some loops we can jump through to BUFFER CACHE
allow I/O access from User Space but it is better to
avoid them. The second problem is that User Space is The purpose of the buffer cache is to increase
swappable. This means that while an I/O operation is in system throughput by minimizing the time the CPU
process, the user’s data buffer could get swapped out to has to wait for disk I/O to complete. It does this by
disk. And when that page gets swapped back in, it will caching recently used data in the systems memory
very likely be at a different physical address. (read caching) and by delaying write operation
(write caching).
So data to be transferred to or from a peripheral device
must reside in Kernel Space, which is not swappable. The buffer cache is implemented as four queues of
The driver then has to take care of transferring that data buffers, the locked queue, the clean queue, the dirty
between Kernel Space and User Space. queue and the empty queue. A buffer contains
information about the cached data such as the
logical block number (The logical block number is
an offset into the file, i. e. zero for the first block
1. DEVICE DRIVERS CATEGORIES and one for the second etc.) and the physical disk
block number and a pointer to the cached data. drawback of write caching is that in case of a
Each buffer can be used to cache between 512 byte system crash all unwritten data is lost. The risk of
(a sector) and 64 kilobyte worth of data but the file data loss is minimized by a special synchronization
systems usually only reads and writes in complete process that flushes all dirty blocks to disk every 30
file system blocks (defaults to 8 kilo byte for Fast seconds. Data in the dirty queue can also be flushed
File System). by a buffer cleaner process if the number of dirty
pages exceeds 25 percent or the number of clean
The locked queue is used for important data and the pages is less than 5 percent. The empty queue is for
buffers on this queue can’t be recycled they are buffers that don’t have any memory pages tied to
always in memory. The clean queue is for buffers them. The buffer cache interface is presented in
that have invalid data, valid but unchanged data or Figure 1. In general a file system reads data with
data that has already been committed to the disk. bread or if the file is being read sequentially with
The buffers in the clean queue are stored in Least breadn. This means that if a file is read in logical
recently Used (LRU) order which means that block number order when block number n is read it
heavily accessed buffers will be stored longer in the also starts to read block number n + 1
cache and less used buffers will be recycled asynchronous so that when the user actually read
quickly. The buffers in the dirty queue are also block n + 1 it is already in memory. File systems
stored in LRU-order and it contains data that needs write data with the bdwrite function to increase
to be written to disk. Write operations are delayed performance but critical data is written with bwrite
because a buffer that has been written to are likely to maintain file system consistency in case of a
to be written to again and by submitting all dirty crash. The bawrite is used by the buffer cleaner to
buffers to the device driver simultaneous it can sort start write operations on dirty buffers.
the write operation to minimize the seek time. The
In this subsection we introduce the terminology one surface is on a track, the heads for the other
related to hard disks. In the Figure 5.1, important surfaces are also on the corresponding tracks. All
parts of the hard disk are shown. It consists of one the corresponding tracks taken together are called a
or more circular aluminum platters, of which either cylinder. It takes time to move the heads from one
or both surfaces are coated with a magnetic track (cylinder) to another, so by placing the data
substance used for recording the data. For each that is often accessed together (say, a file) so that it
surface, there is a read-write head that examines or is within one cylinder, it is not necessary to move
alters the recorded data. The platters rotate on a the heads to read all of it. This improves
common axis; typical rotation speed is 5400 or performance. It is not always possible to place files
7200 rotations per minute, although high- like this; files that are stored in several places on
performance hard disks have higher speeds and the disk are called fragmented. The number of
older disks may have lower speeds. The heads surfaces and the number of heads is the same thing.
move along the radius of the platters; this The cylinders, and sectors vary a lot; the
movement combined with the rotation of the specification of the number of each is called the
platters allows the head to access all parts of the geometry of a hard disk. The geometry is usually
surfaces. stored in a special, battery-powered memory
location called the CMOS RAM, from where the
The processor (CPU) and the actual disk operating system can fetch it during boot up or
communicate through a disk controller that is driver initialization.
discussed in the previous subsection. This relieves
the rest of the computer from knowing how to use Unfortunately, the Basic Input Output System
the drive, since the controllers for different types of (BIOS) has a design limitation, which makes it
disks can be made to use the same interface impossible to specify a track number that is larger
towards the rest of the computer. The controller than 1024 in the CMOS RAM, which is too little
may also do other things, such as caching, or for a large hard disk. To overcome this, the hard
automatic bad sector replacement. disk controller lies about the geometry, and
translates the addresses given by the computer into
The above is usually all one needs to understand something that fits reality. For example, a hard disk
about the hardware. There are also other things, might have 8 heads, 2048 tracks, and 35 sectors per
such as the motor that rotates the platters and track. Its controller could lie to the computer and
moves the heads, and the electronics that control claim that it has 16 heads, 1024 tracks, and 35
the operation of the mechanical parts, but they are sectors per track, thus not exceeding the limit on
mostly not relevant for understanding the working tracks, and translates the address that the computer
principles of a hard disk. gives it by halving the head number, and doubling
The surfaces are usually divided into concentric the track number.
rings, called tracks, and these in turn are divided The mathematics can be more complicated in
into sectors. This division is used to specify reality, because the numbers are not as nice as here.
locations on the hard disk and to allocate disk space This translation distorts the operating system's view
to files. To find a given place on the hard disk, one of how the disk is organized, thus making it
might say ``surface 6, track 1, sector 9''. Usually impractical to use the alldata-on-one-cylinder trick
the number of sectors is the same for all tracks, but to boost performance.
some hard disks put more sectors in outer tracks
(all sectors are of the same physical size, so more Hard disk drives have been the main device for
of them fit in the longer outer tracks). Typically, a secondary storage of data in general purpose
sector will hold 512 bytes of data. The disk itself computers since the early 1960s. They have
can't handle smaller amounts of data than one maintained this position because advances in their
sector. recording capacity, cost, reliability, and speed have
kept pace with the requirements for secondary
Each surface is divided into tracks (and sectors) in storage.
the same way. This means that when the head for
DISK CONTROLLER our computer to communicate with the hard drives
attached to the computer. The most common hard
Storage is an important part of our computer system. In disk controllers are Intelligent Drive Electronics
fact, most personal computers have one or more of the (IDE) and Small computer system interconnect
following storage devices: (SCSI). IDE controllers are used in personal
computers while SCSI is used in high end PCs,
Floppy drive
professional workstations, and network file
Hard drive
servers.
CD-ROM drive
The disk controller has its own CPU with Random
Usually, these devices connect to the computer
Access Memory (RAM) buffer. It also has a
through an Integrated Drive Electronics (IDE)
Programmable Read Only Memory (PROM) that
interface. Essentially, an IDE interface is a
adds disk commands to Extended Color BASIC, a
standard way for a storage device to connect to a
disk controller chip, and a little glue to make it all
computer. IDE is actually not the true technical
work.
name for the interface standard. The original name,
Advanced Technology Attachment (ATA), It is the interface that enables the computer to read
signified that the interface was initially developed and write information to the hard disk drive.
for the IBM AT computer. Today, hard disk drives have the controller built on
to them, usually a circuit board that covers the
The disk controller is the circuit which enables the
bottom or on the back portion of the drive.
Central Processing Unit (CPU) to communicate
with a hard disk, floppy disk or other kind of disk Early disk controllers were identified by their
drive. It is a file that lets the operating system of storage methods and data encoding. They were
typically implemented on a separate controller
card. Modified frequency modulation (MFM)
controllers were the most common type in small
computers, used for both floppy disk and hard disk
drives. Run length limited (RLL) controllers used
data compression to increase storage capacity by REFERENCES
about 50%. Priam created a proprietary storage
algorithm that could double the disk storage. [1.] E. Zadok, R. Iyer, N. Joukov, G. Sivathanu,
Shugart Associates Systems Interface (SASI) was and C. P. Wright (2006), “On Incremental File
a predecessor to SCSI. System Development”, ACM Transaction on
Storage, Vol. 2, No. 2, pp. 1-33.
Modern disk controllers are integrated into the disk
drive. For example, disks called "SCSI disks" have [2.] M. A. Halcrow (2004), “Demands, Solutions,
built-in SCSI controllers. In the past, before most and Improvements for Linux Filesystem Security”,
SCSI controller functionality was implemented in in the proceedings of the Linux symposium,
a single chip, separate SCSI controllers interfaced Ottawa, Canada, pp. 269-286.
disks to the SCSI bus.
[3.] E. Zadok et. al (1999), “Extending File
The most common types of interfaces provided Systems Using Stackable Templates”, in
nowadays by disk controllers are Parallel proceedings of the annual USENIX Technical
Advanced Technology Attachment (PATA IDE) Conference, USENIX Association, Monterey, CA,
and Serial ATA for home use. High-end disks use pp. 57-70.
SCSI, Fiber Channel or Serial Attached SCSI.
[4.] Brian Carrier (2005), “File System Forensic
As can be seen in the above Figure 6.1, the bottom Analysis”, Addison Wesley Professional, ISBN 0-
of the drive has a circuit board, which contains the 32-126817-2.
hard disk controller of the laptop hard drive.
[5.] Steve D. Pate (2003), “UNIX Filesystems:
Evolution, Design, and Implementation”, Wiley
Publishing, Inc., ISBN: 0-471-16483-6.