File System Modifications xv6-picoc

3.3 Filesystem modifications


Originally xv6 operating system would used to support at max 64 KB of file size. In order to port new linker and other system utilities to it we need to extend the filesize limit of this structure. Following section will give an overview of underlying filesystem structure along with the required changed that are to be done in order to maximize max file size to 8MB.

3.3.1 Original xv6 structure


Current version of xv6 filesystem has 6-layered structure consisting of system call inteface, pathname lookup, directory inodes, inode and block allocator, logging and buffer cache. Every file system has a strategy for where it stores inodes and content blocks on the disk. Current xv6 filesystem divides the disk into several sections. It does not use block 0 as it contains the boot sector. Block 1 is called the superblock. It contains information about the file system i.e. the file system size in blocks, the number of data blocks, the number of inodes, and the number of blocks in the log. All of the other blocks hold inodes, with multiple inodes per block. After these inodes blocks a block is reserved as bitmap block. This block is used to represent which data blocks are in use. All of the remaining blocks are data blocks which contains actual data content of files and directory structure. Some blocks at the end of the disk are reserved for logging mechanism, it is part of the transaction layer. The max size of any file on this filesystem can’t execed 70kB. This depends upon the number of data blocks (DIRECT AND INDICRECT both) allocated for each inode. This can be given by below formula:
max file size = [NDIRECT * BSIZE ] + [NINDIRECT * BSIZE]
which becomes 6KB + 64KB = 70 kB.
where NDIRECT is the number of direct blocks which is 12. BSIZE is size of each Block on disk 512 Bytes. NINDIRECT is number of indirect blocks which is currently 512/4 i.e. 128. The original file system with it’s data block arrangment is shown in above figure

3.3.2 Changes made to increase max file size limit


The size of max file size of every inode can be increased by adding more number of NINDIRECT blocks to current implementation of filesystem. So as to increase max file size to 8MB we added 1 double indirect block in the inode’s on disk structure. Details of code base changes are discussed in implementation section. The double indirect block is block whose every entry represents a block address of another block. Each entry of every such block represents the block address where actual data is stored. So this gives more space to every inode. But to maintain the overall memory size of inode structure we have cut down 1 NDI- RECT block from disc inode content. So that max filesize in modified filesystem can be given as:
max file size = [NINDIRECT * BSIZE + NDINDIRECT * NINDIRECT * BSIZE]
which become 8 MB + 64KB 8MB.
The modified file system is shown in below figure