xv6 operating system - Implementation of triple indirection

498 Views Asked by At

The xv6 mkfs.c file declare the variables:

int nblocks = 985;
int nlog = LOGSIZE;
int ninodes = 200;
int size = 1024;

That declaration should work properly with inode that have 12 direct blocks and 1 indirect block, what i don't understand is why nblocks is defined as 985? The number of blocks in one inode is 140 (128 for the indirect + 12 direct), so i don't fully understand where is 985 came from and also the size of 1024.

If i would understand that part i think i will be able to change the variables to support triple indirection.

Thanks!

1

There are 1 best solutions below

0
On BEST ANSWER

An inode takes only 32 bytes on disk (sizeof(struct inode)). Only when writing to an inode it starts to take more space (blocks) on disk.

Notice this block of code:

bitblocks = size/(512*8) + 1;
usedblocks = ninodes / IPB + 3 + bitblocks;
...
assert(nblocks + usedblocks + nlog == size);