Page 455 - DCAP103_Principle of operating system
P. 455

Principles of Operating Systems



                   Notes
                                        Figure 14.34: The Relation between the File Descriptor Table, the Open File
                                                       Description Table, and the I-node Table



































                                 However, if an unrelated process opens the file, it gets its own open file description entry, with
                                 its own file position, which is precisely what is needed. Thus the whole point of the open file
                                 description table is to allow a parent and child to share a file position, but to provide unrelated
                                 processes with their own values.
                                 Getting back to the problem of doing the read, we have now shown how the file position and
                                 i-node are located. The i-node contains the disk addresses of the first 12 blocks of the file. If the
                                 file position falls in the first 12 blocks, the block is read and the data are copied to the user. For
                                 files longer than 12 blocks, a field in the i-node contains the disk address of a single indirect
                                 block, as shown in Figure 14.34. This block contains the disk addresses of more disk blocks.
                                 For example, if a block is 1 KB and a disk address is 4 bytes, the single indirect block can hold
                                 256 disk addresses. Thus this scheme works for files of up to 268 KB in total. Beyond that, a
                                 double indirect block is used. It contains the addresses of 256 single indirect blocks, each of
                                 which holds the addresses of 256 data blocks. This mechanism is sufficient to handle files up to
                                 10 ??216 blocks (67,119,104 bytes). If even this is not enough, the i-node has space for a triple
                                 indirect block. Its pointers point to many double indirect blocks. This addressing scheme can
                                 handle file sizes of 224 1 KB blocks (16 GB). For 8 KB block sizes, the addressing scheme can
                                 support file sizes up to 64 TB.
                                 14.6.6 Linux Ext3 File System

                                 In  order  to  prevent  data  loss  after  system  crashes  and  power  failures,  the  ext2  file  system
                                 would have to write out each data block to disk as soon as it was created. The latency incurred
                                 during the required disk head seek operation would be so high that the performance would
                                 be intolerable. Therefore, writes are delayed, and changes may not be committed to disk for
                                 up to 30 sec, which is a very long time interval in the context of modern computer hardware.
                                 To improve the robustness of the file system, Linux relies on journaling file systems. Ext3, a
                                 follow-on of the ext2 file system, is an example of a journaling file system.




        448                               LOVELY PROFESSIONAL UNIVERSITY
   450   451   452   453   454   455   456   457   458   459   460