ext3 real disk occupation of a file

Youness HAFFANE youness254 at gmail.com
Tue Aug 18 23:09:20 UTC 2009


Now I can see great logic after this perfect explanation.

Thanks a lot Eric and Ted.

Best regards

youness

On Wed, Aug 19, 2009 at 12:03 AM, Theodore Tso <tytso at mit.edu> wrote:

> 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
>



-- 
Y.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/ext3-users/attachments/20090819/d525615b/attachment.htm>


More information about the Ext3-users mailing list