A file system disk space management method, device, equipment and medium

CN122985071APending Publication Date: 2026-10-27BEIJING YIHUI INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611171687.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-04
Publication Date
2026-10-27

AI Technical Summary

Technical Problem

[0004]然而,上述方式存在以下缺陷:一方面,删除大文件时需将数万甚至数十万个数据块逐一归还B+树,时间复杂度高达O(N×log M)(N为文件块数),删除操作耗时数秒甚至数十秒,严重影响系统实时性;另一方面,采用延迟回收策略时,统计空闲空间需遍历整个已删除索引节点链表,时间复杂度为O(K)(K为链表长度),每次统计需大量磁盘I/O,严重影响系统性能

Benefits of technology

[0016]本发明实施例的技术方案,当文件被删除时,判断所述文件占用的B+树层级是否大于0,若是则将所述文件的索引节点整体加入已删除索引节点链表,并保留所述索引节点的块索引结构完整;若否则将所述文件占用的所有磁盘块立即回收到全局空间管理结构中;通过B+树层级判断实现大文件与小文件的差异化处理,仅对大文件执行延迟回收,将大文件删除的时间复杂度由O(N×log M)降低至O(log M),避免了逐一回收数据块的高昂开销,显著提升了删除操作的响应速度;在所述索引节点加入所述已删除索引节点链表后,计算并记录所述索引节点占用的磁盘块总数作为自身块数;从所述已删除索引节点链表的头节点开始遍历已有节点,累加各已有节点占用的磁盘块数,将最终累加结果记录为所述索引节点的后续块数总和;通过在链表节点中记录自身块数和后续块数总和两个统计字段,将每个节点之后所有节点的空间占用信息固化在节点中,为O(1)复杂度的空间统计提供了数据基础;当需要获取所述已删除索引节点链表占用的总空间量时,读取所述已删除索引节点链表的头节点的自身块数与后续块数总和并求和,将求和结果确定为所述已删除索引节点链表当前占用的总空间量;通过读取头节点两个字段即可在O(1)时间内完成统计,将空闲空间统计的时间复杂度由O(K)降低至O(1),有效解决了高频删除场景下空间统计效率低下的问题。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122985071A_ABST
    Figure CN122985071A_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose a file system disk space management method, device, equipment and medium. The method comprises: when a file is deleted, judging whether the B+ tree level occupied by the file is greater than 0, if yes, adding the index node of the file to a deleted index node chain table, and keeping the block index structure of the index node complete; if not, recycling all disk blocks occupied by the file to a global space management structure; calculating and recording the total number of disk blocks occupied by the index node as the block number of the index node; starting from the head node of the deleted index node chain table, traversing the existing nodes, accumulating the number of disk blocks occupied by each existing node, and recording the accumulation result as the total number of subsequent blocks of the index node; when the total space amount needs to be obtained, reading the block number of the head node and the total number of subsequent blocks and summing them up, and determining the summation result as the total space amount currently occupied. Through the technical scheme of the embodiments of the present application, the system performance and response speed in the high-frequency deletion and large file operation scenarios are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer storage technology, and in particular to a method, apparatus, device and medium for managing disk space in a file system. Background Technology

[0002] In the field of computer storage technology, the disk space management efficiency of the file system directly affects the overall system performance. Especially in scenarios that are sensitive to response time, such as embedded real-time systems and high-frequency trading, the latency fluctuations of space management operations can seriously affect the quality of service.

[0003] Currently, mainstream file systems (such as ext4 and XFS) typically use a global free space management structure (i.e., a bitmap or B+ tree) to manage all unallocated disk blocks. When a file is deleted, all disk blocks occupied by that file need to be reclaimed into the global space management structure one by one. Each reclamation involves B+ tree searches, insertions, and possible node splitting and merging operations. When a user queries the remaining disk space, the system needs to traverse the linked list of deleted file indices, accumulate the number of disk blocks occupied by each deleted file, and then combine this information with the global space management structure to calculate the total remaining space.

[0004] However, the above method has the following drawbacks: On the one hand, when deleting large files, tens of thousands or even hundreds of thousands of data blocks need to be returned to the B+ tree one by one, with a time complexity of up to O(N×log M) (N is the number of file blocks). The deletion operation takes several seconds or even tens of seconds, which seriously affects the real-time performance of the system. On the other hand, when adopting the delayed reclamation strategy, counting the free space requires traversing the entire list of deleted index nodes, with a time complexity of O(K) (K is the length of the list). Each count requires a large amount of disk I / O, which seriously affects the system performance. Summary of the Invention

[0005] This invention provides a file system disk space management method, apparatus, device, and medium, which reduces the time complexity of deleting large files and the time complexity of free space statistics, and eliminates the need for repeated traversal when inserting new nodes, thereby improving system performance and response speed in high-frequency deletion and large file operation scenarios.

[0006] In a first aspect, embodiments of the present invention provide a file system disk space management method, comprising: When a file is deleted, determine whether the B+ tree level occupied by the file is greater than 0. If so, add the entire index node of the file to the list of deleted index nodes and preserve the integrity of the block index structure of the index node; otherwise, immediately reclaim all disk blocks occupied by the file into the global space management structure. After the index node is added to the list of deleted index nodes, the total number of disk blocks occupied by the index node is calculated and recorded as its own block count; starting from the head node of the list of deleted index nodes, the existing nodes are traversed, the number of disk blocks occupied by each existing node is accumulated, and the final accumulated result is recorded as the sum of the subsequent block counts of the index node; When it is necessary to obtain the total space occupied by the deleted index node linked list, the sum of the number of blocks of the head node and the number of blocks of the subsequent nodes of the deleted index node linked list is read and summed, and the summation result is determined as the total space currently occupied by the deleted index node linked list.

[0007] Optionally, the method further includes: starting from the head node of the deleted index node linked list, traversing the nodes. If the sum of the number of blocks of the currently traversed node and the sum of the number of blocks of its subsequent nodes have been recorded and are both greater than 0, then the traversal is terminated by accumulating the sum of the number of blocks of the currently traversed node and the sum of the number of blocks of its subsequent nodes; otherwise, the traversal continues by accumulating the number of blocks of the currently traversed node or the number of blocks calculated in real time.

[0008] Optionally, the method further includes: when disk blocks need to be allocated, prioritizing allocation from the block index structure of the current head node of the deleted index node linked list; if the blocks in the block index structure of the current head node are exhausted, then reclaiming the current head node and passing the sum of the subsequent blocks of the current head node to the successor node of the current head node, and continuing allocation from the successor node; if the deleted index node linked list is empty, then allocating disk blocks from the global space management structure.

[0009] Optionally, the method further includes: when starting to allocate disk blocks from the current head node, clearing the block count of the current head node itself to zero, and clearing the sum of the block counts of the predecessor nodes of the current head node to zero.

[0010] Optionally, the method further includes: updating the sum of the number of subsequent blocks of the successor node to the sum of the number of subsequent blocks of the current head node minus the number of blocks of the successor node itself; removing the current head node from the list of deleted index nodes and releasing the index node blocks of the current head node.

[0011] Optionally, the method further includes: if there is a predecessor node at the insertion position of the index node, then updating the sum of the number of subsequent blocks of the predecessor node to the sum of the number of its own blocks and the sum of the number of subsequent blocks of the index node.

[0012] Secondly, embodiments of the present invention also provide a file system disk space management device, the device comprising: The deletion processing module is used to determine whether the B+ tree level occupied by the file is greater than 0 when the file is deleted. If so, the entire index node of the file is added to the list of deleted index nodes, and the block index structure of the index node is preserved. Otherwise, all disk blocks occupied by the file are immediately reclaimed into the global space management structure. The linked list management module is used to calculate and record the total number of disk blocks occupied by the index node as its own block count after the index node is added to the list of deleted index nodes; starting from the head node of the list of deleted index nodes, it traverses the existing nodes, accumulates the number of disk blocks occupied by each existing node, and records the final accumulation result as the sum of the subsequent block counts of the index node; The space statistics module is used to read the sum of the number of blocks of the head node of the deleted index node linked list and the number of blocks of the subsequent nodes when it is necessary to obtain the total space occupied by the deleted index node linked list. The summation result is determined as the total space currently occupied by the deleted index node linked list.

[0013] Thirdly, embodiments of the present invention also provide an electronic device, the electronic device comprising: One or more processors; Memory, used to store one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the file system disk space management method provided in any embodiment of the present invention.

[0014] Fourthly, embodiments of the present invention provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the file system disk space management method as provided in any embodiment of the present invention.

[0015] Fifthly, embodiments of the present invention provide a computer program product, including a computer program that, when executed by a processor, implements the file system disk space management method provided in any embodiment of the present invention.

[0016] The technical solution of this invention involves determining whether the B+ tree level occupied by the file is greater than 0 when a file is deleted. If so, the entire index node of the file is added to the list of deleted index nodes, and the block index structure of the index node is preserved. Otherwise, all disk blocks occupied by the file are immediately reclaimed into the global space management structure. Differential processing for large and small files is achieved through B+ tree level determination, with delayed reclamation only performed on large files. This reduces the time complexity of large file deletion from O(N×log M) to O(log M), avoiding the high overhead of reclaiming data blocks one by one, and significantly improving the response speed of the deletion operation. After the index node is added to the list of deleted index nodes, the total number of disk blocks occupied by the index node is calculated and recorded as its own block count. Starting from the head node of the list of deleted index nodes, existing nodes are traversed, and the number of disk blocks occupied by each existing node is accumulated. The final accumulated result is recorded as the sum of the subsequent block counts of the index node. By recording two statistical fields—its own block count and the sum of the subsequent block counts—in the linked list nodes, the space occupancy information of all nodes after each node is effectively managed. Information is fixed in the nodes, providing a data foundation for space statistics with O(1) complexity; when it is necessary to obtain the total space occupied by the deleted index node linked list, the sum of the number of its own blocks and the number of subsequent blocks of the head node of the deleted index node linked list is read and summed, and the summation result is determined as the total space currently occupied by the deleted index node linked list; by reading the two fields of the head node, the statistics can be completed in O(1) time, reducing the time complexity of free space statistics from O(K) to O(1), effectively solving the problem of low efficiency of space statistics in high-frequency deletion scenarios.

[0017] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description

[0018] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0019] Figure 1 This is a flowchart of a file system disk space management method provided in Embodiment 1 of the present invention; Figure 2 This is a flowchart of a file system disk space management method provided in Embodiment 2 of the present invention; Figure 3This is a schematic diagram of the structure of a file system disk space management device provided in Embodiment 3 of the present invention; Figure 4 This is a schematic diagram of the structure of an electronic device that implements the file system disk space management method of the present invention. Detailed Implementation

[0020] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.

[0021] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0022] Example 1 Figure 1 This is a flowchart illustrating a file system disk space management method according to Embodiment 1 of the present invention. This embodiment is applicable to situations involving the management of disk space within a file system (including space reclamation after file deletion and free space statistics). This method can be executed by a file system disk space management device, which can be implemented in hardware and / or software and can be configured in an electronic device. Figure 1 As shown, the method includes: S110. When a file is deleted, determine whether the B+ tree level occupied by the file is greater than 0. If so, add the entire index node of the file to the list of deleted index nodes and preserve the integrity of the block index structure of the index node; otherwise, immediately reclaim all disk blocks occupied by the file into the global space management structure.

[0023] In this embodiment of the disclosure, a file can refer to a basic object in a file system that stores user data or system data. Files can include ordinary files, directory files, device files, etc. Each file has a corresponding inode in the file system to describe its attributes. The B+ tree level can refer to the height or depth of the B+ tree structure in the file system used to manage the indexing of file data blocks. A B+ tree is a balanced multi-way search tree that can be used as an indexing structure in a file system. The level of a B+ tree refers to the path length from the root node to a leaf node. A level of 0 indicates that the B+ tree has only a root node (i.e., the file is small, and data blocks can be directly indexed by the root node), while a level greater than 0 indicates that the B+ tree has a multi-level node structure (i.e., the file is large, and data blocks are distributed across multiple levels of the index). An inode can refer to a data structure in the file system used to describe file metadata. Each file corresponds to one inode. The inode stores information such as file access permissions, owner, timestamp, file size, and the storage location of data blocks.

[0024] In this embodiment, the deleted index node list can refer to a linked list structure used to temporarily store index nodes that have been deleted but whose disk space has not yet been reclaimed. The head pointer of this linked list is stored in the file system superblock, and each deleted index node points to the next node in the linked list through a pointer field (such as DeletedNext). The block index structure can refer to an index structure in the index node used to record the distribution location of file data blocks on the disk. In this embodiment, the index structure is specifically a B+ tree structure. Each node of the B+ tree corresponds to a disk block, and efficient search, insertion, and deletion operations on file data blocks can be achieved through the B+ tree. A disk block can refer to the smallest allocation unit for the file system to manage disk space. Each disk block has a fixed size (such as 4KB). File data is stored on the disk in units of disk blocks, and the index node indexes the file data by recording the disk block number. The global space management structure can refer to a data structure in the file system used to manage all unallocated disk blocks. For example, the global space management structure can be a bitmap. Each bit corresponds to a disk block, used to mark whether the block has been allocated; it can also be a B+ tree, which organizes all free disk blocks by the starting address or block number of the disk block, supporting efficient free block allocation and reclamation operations.

[0025] Specifically, when a user or the system initiates a file deletion operation, the file system first checks the file's reference count. When the file's reference count drops to 0, the file deletion process is triggered. At this point, the file system obtains the file's inode and reads the B+ tree structure information of the file data blocks recorded in the inode, thereby determining the level of the B+ tree.

[0026] If the B+ tree level is greater than 0 (indicating that the file is a large file occupying a large number of disk blocks, and its data block index is distributed across multiple levels of B+ tree nodes), then the following delayed reclamation strategy is executed: the entire inode of the file is added to the list of deleted inodes. During this process, the complete B+ tree block index structure within the inode is preserved, and all data blocks occupied by the file are not returned to the global space management structure. In other words, the inode itself and all the disk blocks it indexes remain in their original state; the file is only marked as deleted by adding the inode to the linked list.

[0027] If the B+ tree level is not greater than 0 (i.e., the level is equal to 0, indicating that the file is very small and its data block index only exists in the root node of the B+ tree, without involving a multi-level index structure), then the following immediate reclamation strategy is executed: all disk blocks occupied by the file (including data blocks and index node blocks themselves) are reclaimed one by one into the global space management structure to complete the immediate release of space.

[0028] For example, suppose the file system manages a large file that occupies 10,000 disk blocks, and the file's B+ tree level is 3 (root node + intermediate nodes + leaf nodes). When the file is deleted, according to S110, since the B+ tree level 3 > 0, the file system adds the entire inode of the file to the list of deleted inodes, without having to reclaim all 10,000 disk blocks into the global space management structure one by one, thus avoiding a large number of B+ tree insertion operations.

[0029] This step distinguishes between large and small files by determining whether the B+ tree level is greater than 0, and only performs delayed recycling on large files. This reduces the time complexity of large file deletion operations from O(N×log M) (where N is the number of blocks occupied by the file and M is the number of existing entries in the B+ tree) in the traditional scheme to O(1) (requiring only one linked list insertion operation). This significantly reduces the time spent on large file deletion and improves the response speed of the file system, especially in scenarios that are sensitive to response time, such as embedded real-time systems.

[0030] S120. After adding the index node to the list of deleted index nodes, calculate and record the total number of disk blocks occupied by the index node as its own block count; start from the head node of the list of deleted index nodes and traverse the existing nodes, accumulate the number of disk blocks occupied by each existing node, and record the final accumulation result as the sum of the subsequent block counts of the index node.

[0031] In this embodiment of the disclosure, the total number of disk blocks can refer to the total number of disk blocks managed by an inode. The total number of disk blocks can include all data blocks used by the inode to store file data and the inode blocks themselves. An inode block refers to the disk block that stores the inode data structure itself. The number of blocks of a node itself can refer to the total number of disk blocks occupied by a node in the deleted inode list (i.e., the inode of a deleted file). This value is recorded in a specific field of the node (such as the FreeBlk field) to represent the amount of reclaimable space contributed by the node alone. The head node can refer to the first node in the deleted inode list. In the linked list structure, the head node is the entry point for space allocation and space statistics. Existing nodes can refer to nodes that already exist in the deleted inode list, that is, all inodes that were already in the list before the new node was added. The number of disk blocks can refer to the number of disk blocks occupied by each existing node, that is, the total number of disk blocks managed by the inode of each deleted file. The cumulative result can refer to the cumulative value obtained by adding the number of disk blocks occupied by each existing node during the traversal of existing nodes. The total number of subsequent blocks can refer to the total number of disk blocks occupied by all nodes after a certain node in the deleted inode list. This value is recorded in a specific field of the node (such as the FreeBlkSum field) to achieve space statistics with O(1) complexity.

[0032] Specifically, when an index node is added to the list of deleted index nodes, the first step is to calculate the total number of disk blocks occupied by that index node. Specifically, the B+ tree index structure of that index node is read, all nodes of the B+ tree are traversed, the number of all data blocks recorded in each node is accumulated, and then the number of blocks occupied by the index node itself (1 block) is added to obtain the total number of disk blocks occupied by that index node, and this value is recorded as the number of blocks occupied by that node itself.

[0033] Next, it is necessary to calculate the total number of blocks following the new node, that is, the total number of disk blocks occupied by all existing nodes in the linked list after this node. Specifically, starting from the original head node of the deleted index node linked list (i.e., the first node in the linked list before insertion), traverse each existing node one by one, accumulating the number of disk blocks occupied by each existing node. For each existing node, if the node has recorded its own block count, then directly read that value and accumulate it; if the node's own block count has not yet been recorded (e.g., the node is in the process of being allocated), then read the node's B+ tree index structure in real time and calculate its total number of blocks. After traversing all existing nodes, the accumulated result is recorded as the total number of blocks following the new node.

[0034] For example, suppose the linked list already contains node A (occupying 100 disk blocks), and a new node B (occupying 50 disk blocks) is added. When calculating the total number of blocks following B, the list is traversed starting from the head (node ​​A). A's own block count of 100 is read, and the sum is accumulated to obtain sum = 100. This sum = 100 is then recorded as the total number of blocks following B. The linked list state is: Head → [B: own block count = 50, total number of blocks following = 100] → [A: own block count = 100, total number of blocks following = 0] → NULL.

[0035] This step records two statistical fields in the linked list node: the number of its own blocks and the total number of blocks after it. This solidifies the space occupancy information of all nodes after each node in the node with a storage overhead of O(1), laying the foundation for subsequent space statistics with O(1) complexity. This avoids the inefficiency of traditional solutions that require traversing the entire linked list for each statistical analysis.

[0036] As an optional implementation of this disclosure, traversing existing nodes starting from the head node of the deleted index node list and accumulating the number of disk blocks occupied by each existing node may specifically include: starting from the head node of the deleted index node list, if the sum of the number of blocks of the currently traversed node and the sum of the number of blocks of its subsequent nodes have been recorded and are both greater than 0, then the sum of the number of blocks of the currently traversed node and the sum of the number of blocks of its subsequent nodes is accumulated and the traversal is terminated; otherwise, the sum of the number of blocks of the currently traversed node or the number of blocks calculated in real time is accumulated and the traversal of the next node continues.

[0037] In this embodiment of the disclosure, the currently traversed node can refer to the node currently being visited during the traversal of the deleted index node linked list. The real-time calculated block count can refer to the total number of disk blocks occupied by a node during the traversal process, when the block count of an existing node has not yet been recorded, obtained by reading the B+ tree index structure of that node and accumulating the number of all data blocks therein in real time (plus the index node block itself). The next node can refer to the successor node of the currently traversed node in the deleted index node linked list (i.e., the next node in the linked list).

[0038] Specifically, in the process of traversing existing nodes from the head of the linked list to calculate the total number of subsequent blocks of the new node, the following judgment and processing are performed for each node X currently traversed.

[0039] First, check if node X has both its own block count and the total number of subsequent blocks recorded, and both values ​​are greater than 0. If so, it means that the statistics for node X are complete, and the total space usage of all nodes after node X has been accurately recorded through the "total number of subsequent blocks" field of X. In this case, simply add X's own block count to the total number of subsequent blocks, add it to the sum, and immediately terminate the traversal. Since the total number of subsequent blocks of X already covers the space usage of all nodes after X, there is no need to continue traversing.

[0040] If node X does not meet the above conditions (i.e., at least one of its own block count and the sum of its subsequent block counts is not recorded or is equal to 0), then the statistical information of X cannot be directly reused. In this case, if X's own block count has been recorded and is greater than 0, then that own block count is used for accumulation; if X's own block count is not recorded or is equal to 0, then X's B+ tree index structure is read in real time, the total number of blocks occupied by X (total number of data blocks + 1) is calculated, and this real-time calculated value is used for accumulation. After accumulation, the next node is traversed.

[0041] For example, suppose the deleted linked list state is: Head → [C: its own block count = 200, total subsequent block count = 150] → [B: its own block count = 50, total subsequent block count = 100] → [A: its own block count = 100, total subsequent block count = 0] → NULL. When a new node D is added to the linked list and the total subsequent block count is calculated, traversal starts from the head C. Since the original block count of C (200) and the total subsequent block count (150) have both been recorded and are both greater than 0, we can directly accumulate 200 + 150 = 350 and terminate the traversal without continuing to traverse to B and A, thus achieving incremental calculation optimization.

[0042] This optional implementation adopts an incremental calculation strategy of "reusing and terminating the traversal directly once a node with complete statistical information is encountered", which avoids traversing the entire linked list every time a new node is inserted. This makes the average traversal depth of the new node insertion operation approach O(1) in steady-state operation, further improving the system's operating efficiency.

[0043] As an optional implementation of this disclosure, the method further includes: after recording the final accumulation result as the sum of the number of subsequent blocks of the index node, if there is a predecessor node at the insertion position of the index node, updating the sum of the number of subsequent blocks of the predecessor node to the sum of the number of its own blocks and the sum of the number of subsequent blocks of the index node.

[0044] In this embodiment of the disclosure, the insertion position can refer to the insertion point of the new index node in the list of deleted index nodes. The new node can be inserted at the head of the list (becoming the new head node) or after a node in the list. The predecessor node can refer to the node in the list of deleted index nodes that precedes the newly inserted node. If the new node is inserted at the head of the list, there is no predecessor node.

[0045] Specifically, once the sum of the number of blocks in the new index node and the number of blocks in its subsequent nodes has been calculated and recorded, the node is inserted into the corresponding position in the linked list of deleted index nodes. If the new node is inserted at the head of the linked list (i.e., becomes the new head node), there is no predecessor node, so there is no need to perform a predecessor node update operation; only the head pointer of the linked list in the superblock needs to be updated to point to the new node.

[0046] If a predecessor node exists at the insertion location of the new node (i.e., the new node is inserted after an existing node), the total number of blocks following the predecessor node needs to be updated. Specifically, the update method is to update the total number of blocks following the predecessor node to the sum of the number of blocks of the new node itself and the total number of blocks following the new node. This is because the total number of blocks following the predecessor node is defined as the total number of disk blocks occupied by all nodes after that node. Since the new node becomes one of the successors of the predecessor node after insertion, the total number of blocks following the predecessor node needs to include the space occupied by the new node and all its subsequent nodes in the calculation.

[0047] For example, following the example in S120, assume the deleted linked list state is: Head→[B: number of blocks = 50, total number of subsequent blocks = 100]→[A: number of blocks = 100, total number of subsequent blocks = 0]→NULL. When a new node C (number of blocks = 200, total number of subsequent blocks = 150) is added to the linked list and inserted at the head, since the insertion position is at the head of the linked list (no predecessor node), only the head pointer of the superblock needs to be updated to point to C. The linked list state becomes: Head→[C: number of blocks = 200, total number of subsequent blocks = 150]→[B: number of blocks = 50, total number of subsequent blocks = 100]→[A: number of blocks = 100, total number of subsequent blocks = 0]→NULL. If a new node is inserted after B (i.e., B is the predecessor node), then the total number of subsequent blocks of B will be updated to the number of blocks of C itself (200) + the total number of subsequent blocks of C (150) = 350.

[0048] This optional implementation ensures that the statistical field of each node in the linked list always accurately reflects the space occupancy of all its subsequent nodes by synchronously updating the total number of subsequent blocks of the predecessor node after the insertion of a new node, thus maintaining the consistency and correctness of the linked list statistical information.

[0049] As another optional implementation of this disclosure, in scenarios where further simplification of linked list management complexity is required, all newly deleted index nodes are inserted at the head of the linked list, and all reclaimed nodes are deleted from the head of the linked list. This simplification completely avoids the lookup and update operations of predecessor nodes, and the maintenance of the linked list only involves updating the head pointer in the superblock.

[0050] Specifically, the simplified node insertion process is as follows: When a file is deleted and the B+ tree level is greater than 0, the entire index node P of that file is added to the head of the list of deleted index nodes. First, calculate the number of blocks of P itself: the number of blocks of P itself = the total number of blocks recorded in P's B+ tree + 1 (the index node block itself). Then, starting from the head of the current list, traverse the existing nodes and accumulate the number of disk blocks occupied by each existing node. If the sum of the number of blocks of the currently traversed node and the sum of the number of blocks of its subsequent nodes have both been recorded and are both greater than 0, then directly accumulate the sum of the two and terminate the traversal; otherwise, accumulate the number of blocks of the node itself or the number of blocks calculated in real time and continue traversing the next node. Record the final accumulated result as the sum of the number of blocks of P's subsequent nodes.

[0051] Since P is inserted at the head of the linked list, P has no predecessor node, so no predecessor node update operation needs to be performed. Finally, the pointer of P to the next node is set to the original head node of the linked list, and the head pointer of the linked list in the superblock is updated to point to P.

[0052] Specifically, the simplified node reclamation process is as follows: After all data blocks in the block index structure of the head node P of the linked list have been allocated, a reclamation operation is performed from the head. The successor node Next (i.e., the second node in the linked list) of P is obtained, and the sum of the number of subsequent blocks in Next is updated to the sum of the number of subsequent blocks in P minus the number of blocks in Next itself. Then, P is removed from the linked list, the head pointer of the linked list in the superblock is updated to point to Next, and the index node block of P is released.

[0053] Since the node being recycled is always the head node of the linked list, there is no need to maintain any pointers to the predecessor nodes or update the statistical fields of the predecessor nodes, which significantly reduces the implementation complexity of the algorithm.

[0054] This simplified implementation is fully compatible with the core statistical mechanisms of the aforementioned implementations. The number of blocks in each node in the linked list and the sum of the number of blocks in subsequent nodes still accurately reflect the space occupancy of each node and its subsequent nodes. Space statistics can still be completed by reading only two fields from the head node, and the time complexity remains O(1). This simplified method is particularly suitable for scenarios with high requirements for code conciseness or where the linked list length is usually short.

[0055] S130. When it is necessary to obtain the total space occupied by the deleted index node linked list, read the sum of the number of blocks of the head node of the deleted index node linked list and the number of blocks of the subsequent nodes, and sum the sums to determine the total space currently occupied by the deleted index node linked list.

[0056] In this embodiment of the disclosure, the total space occupied can refer to the total number of disk blocks occupied by all nodes in the deleted inode list, that is, the total disk space occupied by the inodes of all deleted files in the list and the data blocks they index. The summation result can refer to the value obtained by adding the number of blocks of the head node itself to the sum of the number of blocks of the head node and the number of blocks of the subsequent nodes.

[0057] Specifically, when the file system needs to obtain the total space currently occupied by the list of deleted inodes (such as in response to the statfs system call to calculate remaining disk space), the file system first obtains the pointer to the head node of the list of deleted inodes (stored in the superblock). Then, it reads the head node's own block number field and the total number of subsequent blocks field. These two values ​​are added together to obtain the total number of disk blocks occupied by all nodes in the entire list of deleted inodes.

[0058] According to the recursive relation, for any node i in the linked list, the total number of subsequent blocks (i) = the number of blocks of node (i+1) itself + the total number of subsequent blocks of node (i+1). Therefore, the total number of subsequent blocks of the head node already covers the space occupied by the second node and all subsequent nodes in the linked list. Adding the number of blocks of the head node itself, we can obtain the total space occupied by the entire linked list. If the linked list is empty after deleting the index node (i.e., the head node pointer is null), then the total space is zero.

[0059] For example, following the previous example, the deleted linked list state is: Head → [C: number of blocks of its own = 200, total number of blocks of subsequent nodes = 150] → [B: number of blocks of its own = 50, total number of blocks of subsequent nodes = 100] → [A: number of blocks of its own = 100, total number of blocks of subsequent nodes = 0] → NULL. When it is necessary to obtain the total space occupied by the linked list, read the number of blocks of the head node C (200) and the total number of blocks of subsequent nodes (150), and sum them up to get 350, which is the total space occupied by the entire linked list. This result is completely consistent with the result of accumulating each node (200 + 50 + 100 = 350).

[0060] This step can complete the total space of the deleted linked list in O(1) time complexity by reading two fields of the head node. There is no need to traverse every node of the linked list. The time complexity of free space statistics is reduced from O(K) (K is the length of the linked list) in the traditional scheme to O(1), which greatly reduces the number of disk I / O operations required for the statistics operation and significantly improves the system performance in high-frequency deletion scenarios.

[0061] The technical solution of this invention, when a file is deleted, determines whether the B+ tree level occupied by the file is greater than 0. If so, the entire index node of the file is added to the list of deleted index nodes, and the block index structure of the index node is preserved. Otherwise, all disk blocks occupied by the file are immediately reclaimed into the global space management structure. By determining the B+ tree level, differentiated processing of large and small files is achieved, and delayed reclamation is performed only for large files, reducing the time complexity of large file deletion from O(N×log M) to O(log M). M), avoiding the high overhead of reclaiming data blocks one by one, significantly improving the response speed of deletion operations; after the index node is added to the list of deleted index nodes, the total number of disk blocks occupied by the index node is calculated and recorded as its own block count; starting from the head node of the list of deleted index nodes, the existing nodes are traversed, the number of disk blocks occupied by each existing node is accumulated, and the final accumulated result is recorded as the sum of the subsequent block counts of the index node; by recording the two statistical fields of its own block count and the sum of the subsequent block counts in the linked list node, the space occupancy information of all nodes after each node is solidified in the node, providing a data foundation for space statistics with O(1) complexity; when it is necessary to obtain the total space occupied by the list of deleted index nodes, the number of its own block count and the sum of the subsequent block counts of the head node of the list of deleted index nodes are read and summed, and the sum is determined as the current total space occupied by the list of deleted index nodes; by reading the two fields of the head node, the statistics can be completed in O(1) time, reducing the time complexity of free space statistics from O(K) to O(1), effectively solving the problem of low efficiency of space statistics in high-frequency deletion scenarios.

[0062] Example 2 Figure 2 This is a flowchart of a file system disk space management method provided in Embodiment 2 of the present invention. This embodiment describes the disk space allocation process in detail based on the above embodiments. Explanations of terms that are the same as or corresponding to those in the above embodiments are not repeated here. Figure 2 As shown, the method includes: S210. When a file is deleted, determine whether the B+ tree level occupied by the file is greater than 0. If so, add the entire index node of the file to the list of deleted index nodes and preserve the integrity of the block index structure of the index node; otherwise, immediately reclaim all disk blocks occupied by the file into the global space management structure.

[0063] S220. After adding the index node to the list of deleted index nodes, calculate and record the total number of disk blocks occupied by the index node as its own block count; starting from the head node of the list of deleted index nodes, traverse the existing nodes, accumulate the number of disk blocks occupied by each existing node, and record the final accumulation result as the sum of the subsequent block counts of the index node.

[0064] S230. When it is necessary to obtain the total space occupied by the deleted index node linked list, read the sum of the number of blocks of the head node of the deleted index node linked list and the number of blocks of the subsequent nodes, and sum the sums to determine the total space currently occupied by the deleted index node linked list.

[0065] S240. When disk blocks need to be allocated, disk blocks are allocated first from the block index structure of the current head node of the deleted index node linked list. If the blocks in the block index structure of the current head node are exhausted, the current head node is reclaimed and the sum of the number of subsequent blocks of the current head node is passed to the successor node of the current head node, and allocation continues from the successor node. If the deleted index node linked list is empty, disk blocks are allocated from the global space management structure.

[0066] In this embodiment of the disclosure, allocating disk blocks can refer to the operation of a file system acquiring one or more disk blocks from available storage space to meet file writing or expansion needs. The current head node can refer to the current head node of the deleted indices list. During space allocation, the head node of the list changes as nodes are reclaimed. "Blocks exhausted" can mean that all data blocks recorded in the B+ tree index structure of a certain indices have been allocated. The indices no longer possess any allocable data blocks. The successor node can refer to the node located after a certain node in the deleted indices list.

[0067] Specifically, when the file system needs to allocate disk blocks (such as when a user writes new data or expands an existing file), it first checks if the list of deleted inodes is empty. If the list is not empty, it prioritizes allocating the required disk blocks from the B+ tree block index structure of the current head node of the list. Since the B+ tree index structure of the deleted inodes remains intact, the allocation operation can directly utilize the efficient search capability of the B+ tree to locate and allocate blocks.

[0068] During the allocation of disk blocks from the B+ tree of the head node, if there are still enough free blocks in the head node's B+ tree, the allocation proceeds normally, and the process ends after allocation. If all data blocks in the head node's B+ tree have been allocated (i.e., the blocks are exhausted), then the head node itself needs to be reclaimed. This involves removing the head node from the linked list and passing the sum of its subsequent block counts to the head node's successor node, and then continuing the allocation from the successor node.

[0069] If the list of deleted inodes is empty (i.e., there are no inodes of deleted files available for reuse), then disk blocks are allocated from the global space management structure (i.e., bitmap or B+ tree).

[0070] For example, suppose the deleted linked list state is: Head → [C: number of blocks = 200, total number of subsequent blocks = 150] → [B: number of blocks = 50, total number of subsequent blocks = 100] → [A: number of blocks = 100, total number of subsequent blocks = 0] → NULL. When 350 disk blocks need to be allocated, firstly, 200 blocks are allocated from the B+ tree of the head node C (all data blocks of C are exhausted), the C node is reclaimed and the total number of subsequent blocks of C, 150, is passed to B; then, 50 blocks are allocated from the B+ tree of B (all data blocks of B are exhausted), the B node is reclaimed and the total number of subsequent blocks of B, 100, is passed to A; finally, the remaining 100 blocks are allocated from the B+ tree of A.

[0071] This step prioritizes reusing space from the deleted linked list, allowing the disk blocks occupied by deleted files to be directly reused without going through the two-step process of recycling to the global space management structure and then allocating from the global space management structure, thus reducing the number of B+ tree operations. At the same time, since the B+ tree index structure of the deleted index node remains intact, the time complexity of allocating blocks from it is only O(log M), which is comparable to the efficiency of allocating from the global space management structure, but avoids the high recycling overhead during deletion.

[0072] As an optional implementation of this disclosure, the method further includes: when starting to allocate disk blocks from the current head node, clearing the current head node's own block count to zero, and clearing the sum of the subsequent block counts of the current head node's predecessor nodes to zero.

[0073] In this embodiment of the disclosure, clearing can refer to the operation of setting the value of a certain field to 0.

[0074] Specifically, when the file system begins allocating disk blocks from the current head node of the list of deleted inodes, the head node's own block count will no longer be accurate. This is because, as allocation progresses, the disk blocks managed by this node are gradually removed, and the total number of disk blocks it occupies is constantly decreasing. At this point, clearing the head node's own block count to zero indicates that the node's own block count no longer reflects the actual number of disk blocks it occupies.

[0075] At the same time, the total number of subsequent blocks of the predecessor node will no longer be accurate. This is because the total number of subsequent blocks of the predecessor node originally included the space occupied by the head node and all subsequent nodes, and the space occupied by the head node is changing. Therefore, the total number of subsequent blocks of the predecessor node is also cleared to zero, indicating that the statistical value is outdated.

[0076] For example, suppose the linked list state is: Head → [C: number of blocks of its own = 200, total number of blocks of subsequent nodes = 150] → [B: number of blocks of its own = 50, total number of blocks of subsequent nodes = 100] → [A: number of blocks of its own = 100, total number of blocks of subsequent nodes = 0] → NULL, and the predecessor node of C is Prev. When disk blocks are allocated from C, the number of blocks of C itself is cleared to zero (C.number of blocks of its own = 0), and the total number of blocks of Prev is cleared to zero (Prev.total number of blocks of subsequent nodes = 0).

[0077] This optional implementation effectively avoids the use of outdated statistical data by clearing the relevant statistical fields in a timely manner at the start of allocation, ensuring the correctness of space statistics and maintaining the consistency of linked list statistical information during dynamic allocation.

[0078] As an optional implementation of this disclosure, reclaiming the current head node and passing the sum of the number of subsequent blocks of the current head node to the successor node of the current head node may specifically include: updating the sum of the number of subsequent blocks of the successor node to the sum of the number of subsequent blocks of the current head node minus the number of blocks of the successor node itself; removing the current head node from the list of deleted index nodes and releasing the index node blocks of the current head node.

[0079] In this embodiment of the disclosure, an inode block can refer to a disk block used to store the inode data structure itself. Each inode occupies one disk block, which records the file's metadata and data block index information.

[0080] Specifically, once all data blocks in the B+ tree of the current head node P of the deleted index node linked list have been allocated, P needs to be reclaimed from the linked list. The reclamation process includes the following operations.

[0081] First, obtain the successor node Next of P. Then, update the total number of blocks following Next to the total number of blocks following P minus the number of blocks of Next itself. The derivation of this update formula is as follows: Before reclamation, the total number of blocks following P = the number of blocks of Next itself + the total number of blocks following Next + the number of blocks of all subsequent nodes. After reclamation of P, Next becomes the new head node (or the successor of the new predecessor node), and the total number of blocks following Next should be equal to the total number of blocks following P minus the number of blocks of Next itself.

[0082] Next, remove P from the linked list: update the pointer of P's predecessor node (or update the head pointer of the linked list in the superblock) to point to Next. Finally, release the inode block of P and reclaim it into the global space management structure.

[0083] For example, suppose the linked list state is: Head → [P: number of blocks of its own = 100, total number of blocks of subsequent nodes = 250] → [Next: number of blocks of its own = 50, total number of blocks of subsequent nodes = 200] → [subsequent nodes...] → NULL. When all data blocks of P have been allocated and P needs to be reclaimed, the total number of blocks of subsequent nodes of Next is updated to 250 - 50 = 200 (consistent with the original total number of blocks of subsequent nodes of Next, 200, verifying the correctness of the propagation formula), and then P is removed from the linked list and the index node block of P is released.

[0084] This optional implementation ensures that the statistical fields of the remaining nodes in the linked list accurately reflect the space occupancy of all subsequent nodes by correctly passing the sum of the number of subsequent blocks of the reclaimed node, thus maintaining the continuity of the linked list statistical information. At the same time, by releasing the index node blocks, the final reclamation of disk space is achieved, ensuring the integrity of the space management cycle.

[0085] The technical solution of this invention, when disk blocks need to be allocated, prioritizes allocating disk blocks from the block index structure of the current head node of the deleted index node linked list; by prioritizing the reuse of the B+ tree index structure completely preserved by the index nodes in the deleted linked list during space allocation, direct reuse of disk blocks is achieved, avoiding the extra overhead of first recycling blocks to the global space management structure and then reallocating them; if the blocks in the block index structure of the current head node are exhausted, the current head node is recycled and the sum of the number of subsequent blocks of the current head node is passed to the successor node of the current head node, and allocation continues from the successor node; by correctly passing the sum of the number of subsequent blocks to the successor node when the node is recycled, the continuity of the linked list statistics is guaranteed, so that subsequent space statistics can still be completed with O(1) complexity; if the deleted index node linked list is empty, disk blocks are allocated from the global space management structure; when there is no available space in the deleted linked list, it reverts to the traditional allocation method, ensuring the integrity and reliability of space allocation, and since the B+ tree index structure of the deleted index nodes remains intact, the time complexity of the allocation operation is only O(log M), which is comparable to the efficiency of allocation from the global space management structure, achieves a balance between deletion efficiency and allocation efficiency.

[0086] The following are embodiments of the file system disk space management device provided in this invention. This device and the file system disk space management method of the above embodiments belong to the same inventive concept. For details not described in detail in the embodiments of the file system disk space management device, please refer to the embodiments of the above file system disk space management method.

[0087] Example 3 Figure 3 This is a schematic diagram of a file system disk space management device provided in Embodiment 3 of the present invention. Figure 3As shown, the device includes: a deletion processing module 310, a linked list management module 320, and a space statistics module 330.

[0088] The deletion processing module 310 is used to determine whether the B+ tree level occupied by the file is greater than 0 when the file is deleted. If so, the entire index node of the file is added to the list of deleted index nodes, and the block index structure of the index node is preserved. Otherwise, all disk blocks occupied by the file are immediately reclaimed into the global space management structure. The list management module 320 is used to calculate and record the total number of disk blocks occupied by the index node as its own block count after the index node is added to the list of deleted index nodes. Starting from the head node of the list of deleted index nodes, the module traverses the existing nodes, accumulates the number of disk blocks occupied by each existing node, and records the final accumulation result as the sum of the subsequent block counts of the index node. The space statistics module 330 is used to read the sum of the number of its own blocks and the sum of the subsequent block counts of the head node of the list of deleted index nodes when it is necessary to obtain the total space occupied by the list of deleted index nodes. The sum is then used to determine the total space currently occupied by the list of deleted index nodes.

[0089] The technical solution of this invention, when a file is deleted, determines whether the B+ tree level occupied by the file is greater than 0. If so, the entire index node of the file is added to the list of deleted index nodes, and the block index structure of the index node is preserved. Otherwise, all disk blocks occupied by the file are immediately reclaimed into the global space management structure. By determining the B+ tree level, differentiated processing of large and small files is achieved, and delayed reclamation is performed only for large files, reducing the time complexity of large file deletion from O(N×log M) to O(log M). M), avoiding the high overhead of reclaiming data blocks one by one, significantly improving the response speed of deletion operations; after the index node is added to the list of deleted index nodes, the total number of disk blocks occupied by the index node is calculated and recorded as its own block count; starting from the head node of the list of deleted index nodes, the existing nodes are traversed, the number of disk blocks occupied by each existing node is accumulated, and the final accumulated result is recorded as the sum of the subsequent block counts of the index node; by recording the two statistical fields of its own block count and the sum of the subsequent block counts in the linked list node, the space occupancy information of all nodes after each node is solidified in the node, providing a data foundation for space statistics with O(1) complexity; when it is necessary to obtain the total space occupied by the list of deleted index nodes, the number of its own block count and the sum of the subsequent block counts of the head node of the list of deleted index nodes are read and summed, and the sum is determined as the current total space occupied by the list of deleted index nodes; by reading the two fields of the head node, the statistics can be completed in O(1) time, reducing the time complexity of free space statistics from O(K) to O(1), effectively solving the problem of low efficiency of space statistics in high-frequency deletion scenarios.

[0090] Optionally, the linked list management module 320 is specifically used to: start traversing from the head node of the linked list of deleted index nodes; if the sum of the number of its own blocks and the number of blocks of subsequent nodes of the currently traversed node has been recorded and is greater than 0, then the sum of the number of its own blocks and the number of blocks of subsequent nodes of the currently traversed node is added and the traversal is terminated; otherwise, the sum of the number of its own blocks or the number of blocks calculated in real time is added and the traversal of the next node continues.

[0091] Optionally, the device further includes: The disk allocation module is used to allocate disk blocks first from the block index structure of the current head node of the deleted index node linked list when disk blocks need to be allocated; if the block index structure of the current head node has exhausted its blocks, the current head node is reclaimed and the sum of the number of subsequent blocks of the current head node is passed to the successor node of the current head node, and allocation continues from the successor node; if the deleted index node linked list is empty, disk blocks are allocated from the global space management structure.

[0092] Optionally, the device further includes: The zeroing module is used to zero out the block count of the current head node and the sum of the block counts of the predecessor nodes of the current head node when disk blocks are allocated from the current head node.

[0093] Optionally, the disk allocation module is specifically used to: update the total number of subsequent blocks of the successor node to the total number of subsequent blocks of the current head node minus the number of blocks of the successor node itself; remove the current head node from the list of deleted inodes and release the inode blocks of the current head node.

[0094] Optionally, the device further includes: The subsequent block count update module is used to update the subsequent block count of the index node to the sum of the index node's own block count and the subsequent block count of the index node if there is a predecessor node at the index node insertion position after the final accumulation result is recorded as the subsequent block count of the index node.

[0095] The file system disk space management device provided in the embodiments of the present invention can execute the file system disk space management method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of executing the file system disk space management method.

[0096] It is worth noting that in the above embodiments of file system disk space management, the various units and modules included are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be achieved; in addition, the specific names of each functional unit are only for easy distinction between each other and are not used to limit the scope of protection of the present invention.

[0097] Example 4 Figure 4A schematic diagram of an electronic device 10, which can be used to implement embodiments of the present invention, is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.

[0098] like Figure 4 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 can also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0099] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.

[0100] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, digital signal processors (DSPs), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as file system disk space management methods.

[0101] In some embodiments, the file system disk space management method may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the file system disk space management method described above may be performed. Alternatively, in other embodiments, processor 11 may be configured to perform the file system disk space management method by any other suitable means (e.g., by means of firmware).

[0102] Various implementations of the systems and techniques described above herein can be implemented in digital circuit systems, integrated circuits, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-chips (SoCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.

[0103] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.

[0104] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0105] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).

[0106] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or middleware components (e.g., application servers), or frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.

[0107] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.

[0108] This invention also provides a computer program product, including a computer program that, when executed by a processor, implements the file system disk space management method provided in any embodiment of this application.

[0109] In implementing the computer program product, computer program code for performing the operations of this invention can be written in one or more programming languages ​​or a combination thereof. Programming languages ​​include object-oriented programming languages ​​such as Java, Smalltalk, and C++, as well as conventional procedural programming languages ​​such as C or similar languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider). This program product belongs to the same inventive concept as the file system disk space management method disclosed in the embodiments of this application, and therefore will not be described further here.

[0110] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.

[0111] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.

Claims

1. A file system disk space management method, characterized in that, include: When a file is deleted, determine whether the B+ tree level occupied by the file is greater than 0. If so, add the entire index node of the file to the list of deleted index nodes and preserve the integrity of the block index structure of the index node; otherwise, immediately reclaim all disk blocks occupied by the file into the global space management structure. After the index node is added to the list of deleted index nodes, the total number of disk blocks occupied by the index node is calculated and recorded as its own block count; starting from the head node of the list of deleted index nodes, the existing nodes are traversed, the number of disk blocks occupied by each existing node is accumulated, and the final accumulated result is recorded as the sum of the subsequent block counts of the index node; When it is necessary to obtain the total space occupied by the deleted index node linked list, the sum of the number of blocks of the head node and the number of blocks of the subsequent nodes of the deleted index node linked list is read and summed, and the summation result is determined as the total space currently occupied by the deleted index node linked list.

2. The method according to claim 1, characterized in that, The step of traversing the existing nodes starting from the head node of the deleted index node linked list and accumulating the number of disk blocks occupied by each existing node includes: Starting from the head node of the list of deleted index nodes, if the sum of the number of blocks of the currently traversed node and the number of blocks of its subsequent nodes has been recorded and is greater than 0, then the sum of the number of blocks of the currently traversed node and the number of blocks of its subsequent nodes is added and the traversal is terminated; otherwise, the sum of the number of blocks of the currently traversed node or the number of blocks calculated in real time is added and the traversal continues to the next node.

3. The method according to claim 1, characterized in that, The method further includes: When disk blocks need to be allocated, they are preferentially allocated from the block index structure of the current head node of the deleted index node linked list. If the block index structure of the current head node is exhausted, the current head node is reclaimed and the sum of the number of subsequent blocks of the current head node is passed to the successor node of the current head node, and allocation continues from the successor node. If the deleted index node linked list is empty, disk blocks are allocated from the global space management structure.

4. The method according to claim 3, characterized in that, The method further includes: When disk blocks are allocated from the current head node, the block count of the current head node is cleared to zero, and the sum of the block counts of the predecessor nodes of the current head node is cleared to zero.

5. The method according to claim 3, characterized in that, The step of reclaiming the current head node and passing the sum of the subsequent blocks of the current head node to the successor node of the current head node includes: Update the sum of the number of subsequent blocks of the successor node to the sum of the number of subsequent blocks of the current head node minus the number of blocks of the successor node itself; Remove the current head node from the list of deleted index nodes and release the index node block of the current head node.

6. The method according to claim 1, characterized in that, After recording the final accumulated result as the sum of the number of subsequent blocks of the index node, the method further includes: If a predecessor node exists at the insertion position of the index node, the sum of the number of subsequent blocks of the predecessor node is updated to the sum of the number of blocks of the index node itself and the sum of the number of subsequent blocks.

7. A file system disk space management device, characterized in that, The device includes: The deletion processing module is used to determine whether the B+ tree level occupied by the file is greater than 0 when the file is deleted. If so, the entire index node of the file is added to the list of deleted index nodes, and the block index structure of the index node is preserved. Otherwise, all disk blocks occupied by the file are immediately reclaimed into the global space management structure. The linked list management module is used to calculate and record the total number of disk blocks occupied by the index node as its own block count after the index node is added to the list of deleted index nodes; starting from the head node of the list of deleted index nodes, it traverses the existing nodes, accumulates the number of disk blocks occupied by each existing node, and records the final accumulation result as the sum of the subsequent block counts of the index node; The space statistics module is used to read the sum of the number of blocks of the head node of the deleted index node linked list and the number of blocks of the subsequent nodes when it is necessary to obtain the total space occupied by the deleted index node linked list. The summation result is determined as the total space currently occupied by the deleted index node linked list.

8. An electronic device, characterized in that, The electronic device includes: One or more processors; Memory, used to store one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the file system disk space management method as described in any one of claims 1-6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by the processor, the program implements the file system disk space management method as described in any one of claims 1-6.

10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the file system disk space management method as described in any one of claims 1-6.