什么是 ext4 文件系统中的内存预分配范围

What is in-memory preallocation range in ext4 file system

我正在阅读一篇名为 Ext4 block and inode allocator improvements 的论文,其中作者提到了

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.

但是我找不到关于内存预分配范围的任何详细信息。

根据我对本文的理解,当块分配器将块分配给LARGE文件时,它会首先尝试分配in引用的块- 内存预分配 space。如果 space 不够,它将查看 per-block-group 伙伴缓存 。但是我不明白ext4如何维护预分配space,它如何计算下一次分配要预分配的space的大小?

how does ext4 maintain the preallocation space

根据 ext4 的 documentation,预分配 space 保留在两个位置:

  1. 每个索引节点。

  2. 每locality/CPU组

    对于 small(在分配完成或 post 分配时)从每个位置组中选择文件预分配块,对于大文件,引用来自 inode 的文件。

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

来自 ext4 文档:

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.

分配算法的更多细节(例如,分配请求的规范化是如何完成的)在喜欢的头文件中有很好的解释。