Ext2 block allocation
Posted: Mon Feb 02, 2009 3:02 pm
I'm looking for some advice on block allocation.
For example, assuming blocksize is 1024, file is 0 bytes in length.
If do a 1k write starting at offset 0. I allocate a new block and stuff it in i_block[0], write the physical block to disk and update the inode. Job done.....
Then I write 1k starting at offset 4096 (4th block in inode obviously). Same procedure as above, but am I supposed to allocate the 2nd and 3rd blocks and zero fill??
It feels "wrong" not to, although it just seems wasteful.
For example, assuming blocksize is 1024, file is 0 bytes in length.
If do a 1k write starting at offset 0. I allocate a new block and stuff it in i_block[0], write the physical block to disk and update the inode. Job done.....
Then I write 1k starting at offset 4096 (4th block in inode obviously). Same procedure as above, but am I supposed to allocate the 2nd and 3rd blocks and zero fill??
It feels "wrong" not to, although it just seems wasteful.