简体   繁体   中英

What is in-memory preallocation range in ext4 file system

I'm reading a paper called Ext4 block and inode allocator improvements , in which the author mentions

Like Ext3 reservation, Ext4 maintains an in-memory preallocation range for each file, and uses that to solve the fragmentation issues caused by concurrent allocation.

But I can't find any detailed information about the in-memory preallocation range.

According to my understanding of this paper, when the block allocator allocates blocks to a LARGE file, it will firstly try to allocate blocks referred by the in-memory preallocation space . if the space is not sufficient, it then will look at the per-block-group buddy cache . But I don't understand how does ext4 maintain the preallocation space, how does it calculate the size of the space to be preallocated for the next allocation?

how does ext4 maintain the preallocation space

As per the documentation of ext4 the preallocation space is maintained at two places:

  1. per inode.
  2. per locality/CPU group

    For small (while allocation is being done or post allocation) files prealloc blocks from per locality group are picked, for large files those from inode are referred.

how does it calculate the size of the space to be preallocated for the next allocation?

From the ext4 documentation:

Before allocating blocks via buddy cache we normalize the request blocks. This ensure we ask for more blocks that we needed. The extra blocks that we get after allocation is added to the respective prealloc list.

More details of the allocation algorithm (eg. how normalization of a alloc request is done) are explained quite well in the liked header file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM