Pergunta

How can I increase the depth of an extent tree? How much space should be allocated? To be more precise I only need the depth to be more than 1.

Foi útil?

Solução

In ext4, an inode uses 60 bytes to address 4 extents by default (12bytes for the header + 4*12bytes for the extents). Every extent can hold data up to 128MiB (by default). If a file is larger than 4*128MiB (> 512MiB) ext4 is building an extent tree for that. So you'll reach depth = 1 with that.

Now the question is when will you reach depth=2. I tried with a file of ~700MiB and checked the extent depth which was 1. Then I opened the fs-block indexed by the extent and analysed the header.

    0A F3 06 00 54 01 00 00 00 00 00 00 00

It has the typical magic number of f30A and the next two bytes should indicate the number of extents. (in this case=6 which makes sense because 700/128 = 6). The next 2 bytes 0154 should indicate the maximum number of extents (according to the header information) which comes up to 340 in my case.

-> so why 340? If we look at the actual fs-block size of ext4 the default is 4096 bytes. Each index consists of 12 bytes. 340*12 = 4080 + 12 for the header = 4092 so it is the max number of extent-info that can fit into this fs-block.

If I interpret this correctly, you can save up to 340 other pointers/leaves/indexes in this fs-block. Each of these 340 refer to an extent (which can hold up to 128MiB) -> so it comes to: 340*128MiB ~ 43,5 GiB

Additionally each inode can hold up to 4 extents. So I guess this number needs to be multiplied by 4 even though.

    -> so I think your file should be > 4*340*128MiB ~ 174GiB to reach depth=2

I have not yet tested this hypothesis, but I will try it soon. Meanwhile if someone can proove me wrong, I'm happy as well. :)

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top