1. BITS Pilani
Pilani Campus
Data Storage Technologies
& Networks
Dr. Virendra Singh Shekhawat
Department of Computer Science and Information Systems
2. BITS Pilani, Pilani Campus
Topics
โข File Store Organization
โข OS Support for I/O
โ Device Drivers
โ Interrupt handling
โ Device Interface
โ Buffering
2
3. BITS Pilani, Pilani Campus
Organization of File store
โข Berkeley Fast File System (FFS) model:
โ A file system is described by its superblock
โข Located at the beginning of the file system
โข Possibly replicated for redundancy
โ A disk partition is divided into one or more cylinder
groups i.e. a set of consecutive cylinders:
โข Each group maintains book-keeping info. including
โ a redundant copy of superblock
โ Space for i-nodes
โ A bitmap of available blocks and
โ Summary usage info.
โข Cylinder groups are used to create clusters of
allocated blocks to improve locality.
3
4. BITS Pilani, Pilani Campus
Local File Store- Storage
Utilization
โข Data layout โ Performance requirement
โ Large blocks of data should be transferable in a single disk operation
โข So, logical block size must be large.
โ But, typical profiles primarily use small files.
โข Internal Fragmentation:
โ Increases from 1.1% for 512 bytes logical block size, 2.5% for 1KB, to
5.4% for 2KB, to an unacceptable 61% for 16KB
โข I-nodes also add to the space overhead:
โ But overhead due to i-nodes is about 6% for logical block sizes of
512B, 1KB and 2KB, reduces to about 3% for 4KB, and to 0.8% for
16KB.
โข One option to balance internal fragmentation against
improved I/O performance is
โ to maintain large logical blocks made of smaller fragments
4
5. BITS Pilani, Pilani Campus
Local File Store โ Layout [1]
โข Global Policies:
โ Use summary information to make decisions
regarding placement of i-nodes and disk blocks.
โข Routines responsible for deciding placement of new
directories and files.
โ Layout policies rely on locality to cluster information
for improved performance.
โข E.g. Cylinder group clustering
โข Local Allocation Routines.
โ Use locally optimal schemes for data block layouts.
5
6. BITS Pilani, Pilani Campus
Local File Store โ Layout [2]
โข Local allocators use a multi-level allocation strategy:
1. Use the next available block that is rotationally
closest to the requested block on the same cylinder
2. If no blocks are available in the same cylinder use
a block within the same cylinder group
3. If the cylinder group is full, choose another group
by quadratic hashing.
4. Search exhaustively.
6
7. BITS Pilani, Pilani Campus
OS Support for I/O
โข System calls form the interface between applications
and OS (kernel)
โ File System and I/O system are responsible for
โข Implementing system calls related to file management and handling
input/output.
โข Device drivers form the interface between the OS
(kernel) and the hardware
7
8. BITS Pilani, Pilani Campus
I/O in UNIX - Example
โข Application level operation
โ E.g. printf call
โข OS (kernel) level
โ System call bwrite
โข Device Driver level
โ Strategy entry point โ code for write operation
โข Device level
โ E.g. SCSI protocol command for write
8
9. BITS Pilani, Pilani Campus
I/O in UNIX - Devices
โข I/O system is used for
โ Network communication and virtual memory (Swap
space)
โข Two types of devices
โ Character devices
โข Terminals, line printers, main memory
โ Block devices
โข Disks and Tapes
โข Buffering done by kernel
9
10. BITS Pilani, Pilani Campus
I/O in UNIX โ Device Drivers
โข Device Driver Sections
โ Auto-configuration and initialization Routines
โข Probe and initialize the device
โ Routines for servicing I/O requests
โข Invoked because of system calls or VM requests
โข Referred to as the โtop-halfโ of the driver
โ Interrupt service routines
โข Invoked by interrupt from a device
โ Canโt depend on per-process state
โ Canโt block
โข Referred to as the โbottom-halfโ of the driver
10
11. BITS Pilani, Pilani Campus
I/O Queuing and Interrupt
Handling
โข Each device driver manages one or more queues
for I/O requests
โ Shared among asynchronous routines โ must be
synchronized.
โ Multi-process synchronization also required.
โข Interrupts are generated by devices
โ Signal status change (or completion of operation)
โ DD-ISR invoked through a glue routine that is
responsible for saving volatile registers.
โ ISR removes request from queue, notifies requestor
that the command has been executed.
11
12. BITS Pilani, Pilani Campus
I/O in UNIX โ Block Devices and I/O
โข Disk sector sized read/write
โ Conversion of random access to disk sector
read/write is known as block I/O
โ Kernel buffering reduces latency for multiple reads
and writes.
12
13. BITS Pilani, Pilani Campus
Device Driver to Disk Interface
โข Disk Interface:
โ Disk access requires an address:
โข device id, LBA OR
โข device id, cylinder #, head#, sector #.
โ Device drivers need to be aware of disk details for
address translation:
โข i.e. converting a logical address (say file system level address
such as i-node number) to a physical address (i.e. CHS) on the
disk;
โข they need to be aware of complete disk geometry if CHS
addressing is used.
โ Early device drivers had hard-coded disk geometries.
โข This results in reduced modularity โ
โ disks cannot be moved (data mapping is with the device driver);
โ device driver upgrades would require shutdowns and data copies.
13
14. BITS Pilani, Pilani Campus
Disk Labels
โข Disk Geometry and Data mapping is stored on
the disk itself.
โ Known as disk label.
โ Must be stored in a fixed location โ usually 0th
block i.e. 0th sector on head 0, cylinder 0.
โ Usually this is where bootstrap code is stored
โข In which case disk information is part of the bootstrap
code, because booting may require disk access.
14
15. BITS Pilani, Pilani Campus
Buffering
โข Buffer Cache
โ Memory buffer for data being transferred to and from
disks
โ Cache for recently used blocks
โข 85% hit rate is typical
โข Typical buffer size = 64KB virtual memory
โข Buffer pool โ hundreds of buffers
โข Consistency issue
โ Each disk block mapped to at most one buffer
โ Buffers have dirty bits associated
โ When a new buffer is allocated and if its disk blocks
overlap with that of an existing buffer, then the old buffer
must be purged.
15
16. BITS Pilani, Pilani Campus
Buffer Pool Management
โข Buffer pool is maintained as a (separately chained) hash table
indexed by a buffer id
โข The buffers in the pool are also in one of four lists:
โ Locked list:
โข buffers that are currently used for I/O and therefore locked and cannot be
released until operation is complete
โ LRU list:
โข A queue of buffers โ a recently used item is added at the rear of the queue
and when a buffer is needed one at the front of the queue is replaced.
โข Buffers staying in this queue long enough are migrated to an Aged list
โ Aged List:
โข Maintained as a list and any element may be used for replacement.
โ Empty List
โข When a new buffer is needed check in the following order:
โ Empty List, Aged List, LRU list
16