The application relates to a
file system space management method and
system, and efficient management of
disk space is realized by constructing double AVL trees, the double AVL trees are both taken as disk segments as nodes, the disk segments are defined by starting positions and ending positions and follow the left-closed right-open rule, wherein the disk offset
AVL tree is sorted according to the starting positions, and the free length
AVL tree is sorted according to the lengths. When space is allocated, whether the maximum free length of the free length
AVL tree meets the requested allocation length is judged, continuous space is preferentially allocated, and non-continuous space is combined when the continuous space is insufficient; after the allocation, the allocated disk segments in the double AVL trees are synchronously deleted, and the tree balance is maintained. When space is released, the continuity of the to-be-released segment and the existing free segment is detected, the new free segment is combined or directly inserted into the double AVL trees, and the balance is maintained. The
time complexity of the space operation is optimized to O(logN), the storage cost is greatly reduced, the
file storage continuity is guaranteed, the read-write performance and the space
utilization rate are improved, the large-capacity storage scene is adapted, and many defects of the existing
Bitmap scheme are solved.