Problem with the Traditional File System
In a file system, the attributes of files are usually located separate from file. This arrangement requires more seek operation. A seek operation is time consuming and hence increases the access times of files. Usually in a file system, Write operation is performed synchronously that is applications which has issued write request must wait until writing operation is performed between disk and main memory/ cache rather than continuing its operation where writing is performed asynchronously in the background. So, access time of file is large.
Concept of Log Structured File System
Log Structured file system is used to reduce the access time of files. In Log Structured file system, all files are in main memory and updation of file is performed in main memory. Then these updated files are asynchronously placed on disk in the form of a sequential structure called LOG in one write operation. The information present in log is datablocks, file related information such as file name, file type, disk address of blocks, access rights etc. In a file system, for each file a structure is maintained at fixed location containing disk addresses of all blocks corresponding to that file.
As a resultof it, there is no need for sequentially searching a log in order to retrieve blocks of a particular file. Example: In SPRITE File System in the log, an INODE is placed containing file anme, file attributes and disk address of upto 10 updated blocks of that file. An Inode map structure is used which contains the current address of all inodes of that file. Since it is compact, it can also be cached in main memory. Crash Recovery is also easier in Log structured file system since in order to maintain the consistancy of files ( during client/server creash ) only the last log is to be examined. While in case of traditional file system the entire disk is to be searched for these blocks of files which were recently under updation when system creashes.
Disk Space Management
In order to place logs on disk, large free disk spaces are required. During frequent allocation and deallocation of files this free space gets fragmented and it can be reclaimed by using the following two approaches:
Approach 1: Threading
In threading, if the block so selected for new log contains some live data then this data will be kept as such and the log will spread among the remaining free space. Problem with this scheme is that even for a single write request, a number of disk seek occurs thereby increasing the access time of file and the performance of Log Structured file system will be almost similar to traditional file system.
Approach 2: Copying
In this scheme, if the block so selected for New log contains some live data then this live data will be kept out of log thereby generating a continuous free space. This scheme will not increase the disk seek but it suffers from the cost of copying.
Sprite File System
In Sprite file system, both threading and copying is used. Disk space is divided into large segments. Logs are threaded through segments within a segment. Writing begins from start to end and if nay live data is present in it then it will be cpied out of log. Copying process begins when number of free space falls below a threshold value (such as upto 10 segments) and this process ends when number of free segments exceeds threshold value (between 50 to 100 segments). The segments so selected for freeing up are read out in main memory. The live blocks are then divided into two categories: HOT BLOCK: These blocka are frequently used. There are more chnaces of free space in such blocks. COLD BLOCK: These blocks are not frequently used. These blocks will retain live data for linger period. Hot Blocks are mainly used for generating free space.