1.3 xv6 Big File System - KeonYeong/LKY GitHub Wiki
Basic Edits
Basically, the main functions that are amended are 'bmap()' and 'itrunc()' which are included in 'fs.c'. Originally, there was only 12 + 128 = 140 data blocks indicated by pointers in i-node usable for a file, however this time I deleted one direct pointer of data block and implemented a double array consist of 128 * 128 data blocks. As a result, data blocks are increased into 128*128 + 128 + 11 = 16523 data blocks, and the memory usable for one unit of file is increased into 8,459,776 bytes (which is about 8 Mbytes).
Main Implementation
-
bmap() : There were two condition codes in original version, but then new instruction making one pointer of i-node into array of pointers was added. If we refer to that pointers, they are again divided into 128 pointers of each pointing one data block. It's done by dividing the argument 'bn' by 'NINDIRECT (128)' and finding remainders from that division. Quotients are used as index of first array, and remainders are used as index of the second array.
-
itrunc() : Besides plenty of 'bfree()'s in the original version, double loop is newly added. In that, we iterate the double array sequentially and look for in-use data blocks, after than we free all the data blocks we found.
Other Implementation
- In 'fs.h', NDIRECT number is changed into 11, and any variables related to NDIRECT are also changed (including dinode structure). Moreover max size was fixed into NDIRECT + NINDIRECT + (NINDIRECT * NINDIRECT).
- In 'file.h', i-node structure is changed (NDIRECT part).
- In 'param.h', FSSIZE is implemented to 2000.