Re: ext3 real disk occupation of a file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Aug 18, 2009 at 11:43:15PM +0200, Youness HAFFANE wrote:
> I see,
> So for only the first 12 blocks, there is no need for extra blocks, but I
> couldn't find any mathematical logic for the rest.
> I explain :
> I've tried to create many files to which I assigned a fixed number of
> blocks, and the results are :
> for a 13 block file till a 1036 block file I had 3 extra blocks added
> and then it's 4 extra blocks added (for example a 3060 block file)
> and for a 4000 block file, it's 5 extra blocks
> for 5000 it's 6
> and for 10 000 it's 11 blocks added!

All of this assumes a filesystem with a 4k block size....

In the inode there are 12 direct block pointers, and then one indirect
block pointer, one double indirect block pointer, and one triple
indirect block pointer.

A 4k block has room for 1024 block numbers.  Hence, so files that have
between 13 and 1036 data blocks (12+1024), will need a single indirect
block.  Beyond that a single double indirect block has room for 1024
indirect block pointers.  So for the next 1024 blocks, one double
indirect block, plus an indirect block is needed.  For the next 1024
data blocks, another indirect block is needed.  After the 1024 slots
in the double indirect blocks are filled, then we use a triple
indirect block, which has room for 1024 double indirect blocks, and so
on.

If the filesystem is using 1k block sizes, then there is room for 256
block numbers in each block, so the indirect block can address 256
data blocks, and then the double indirect block in the inode can can
address (256*256) data blocks while using 256 indirect numbers, and
the triple indirect block can address 256 double indirect blocks,
which when using 256*256 indirect blocks, can address up to
256*256*256 data blocks.

With sparse files, indirect blocks and double indirect blocks are
aren't needed to address data blocks won't be allocated.  But for
contiguous files it's relatively easy to predict in advance how much
space is needed for the indirect, double indirect, and triple indirect
blocks.

					- Ted

_______________________________________________
Ext3-users mailing list
Ext3-users@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/ext3-users

[Index of Archives]         [Linux RAID]     [Kernel Development]     [Red Hat Install]     [Video 4 Linux]     [Postgresql]     [Fedora]     [Gimp]     [Yosemite News]

  Powered by Linux