A method for fast checking whether a qcow2 file has free data
By recursively merging linked list nodes, the time-consuming problem of traditional qcow2 file checking is solved, and the integrity and consistency of qcow2 files can be quickly checked, which is suitable for rapid fault diagnosis in cloud computing environments.
Patent Information
- Application Number
- CN202511143280.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-15
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2045-08-15
AI Technical Summary
Traditional methods for checking large-capacity qcow2 files consume a lot of time to calculate the continuity of linked lists, have low performance, and cannot quickly determine the integrity and consistency of files.
The method of recursively merging linked list nodes is adopted. By establishing a bidirectional linked list, recursive merging is performed according to specific rules when inserting linked list nodes, thereby reducing the length of the linked list and quickly checking whether there are free data blocks in the qcow2 file.
Significantly improves the inspection efficiency of large-capacity qcow2 files, making it suitable for rapid fault diagnosis in cloud computing environments.
Smart Images

Figure CN120631849B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data inspection, and in particular to a method for quickly inspecting whether a qcow2 file contains free data. Background Art
[0002] Qcow2 files are a type of virtual disk format widely used in cloud computing scenarios. During troubleshooting, it's often necessary to check for free data blocks within a Qcow2 file to determine file integrity and consistency. Traditional methods use linked list checks, but when checking large Qcow2 files, calculating linked list continuity is time-consuming and performance is poor. This invention significantly reduces linked list length and improves inspection performance by recursively merging linked list nodes. Summary of the Invention
[0003] The purpose of the present invention is to provide a method for quickly checking whether a qcow2 file contains free data, which can solve at least one of the above technical problems. The technical solution of the present invention is as follows:
[0004] A method for quickly checking whether a qcow2 file contains free data includes the following steps:
[0005] Step 1: Create an empty doubly linked list;
[0006] Step 2: Parse the qcow2 file and loop through all secondary table entries.
[0007] Step 3: Create a linked list node for each secondary table entry, which contains the start and end position information;
[0008] Step 4: Traverse the linked list and insert the new node into the linked list, performing recursive merging according to the following rules:
[0009] If the linked list is empty, the current node is used as the head of the linked list;
[0010] If the end address of the node to be inserted is less than the start address of the linked list node, the node to be inserted will be inserted in front of the linked list node;
[0011] If the end address of the node to be inserted is equal to the start address of the linked list node, merge the nodes and recursively check the predecessor node;
[0012] If the starting address of the node to be inserted is equal to the ending address of the linked list node, merge the nodes and recursively check the successor nodes;
[0013] If the starting address of the node to be inserted is greater than the ending address of the linked list node, the node to be inserted will be inserted after the linked list node;
[0014] Step 5: Repeat the insertion steps until all entries in the secondary table are inserted;
[0015] Step 6: Check the length of the linked list. If the length is not 1, it is determined that there is a free data block and the position of the free data block is calculated.
[0016] Furthermore, the starting position of the linked list node is the address of the secondary table entry record, and the ending position is the starting address plus 64K.
[0017] Furthermore, the recursive merging includes:
[0018] When the end address of the node to be inserted is equal to the start address of the linked list node, modify the start address of the linked list node to the start address of the node to be inserted, and recursively check the predecessor node;
[0019] When the starting address of the node to be inserted is equal to the ending address of the linked list node, the ending address of the linked list node is modified to the ending address of the node to be inserted, and the successor node is recursively checked.
[0020] Furthermore, the position of the free data block is obtained by subtracting the start address of the next node from the end address of the previous node in the linked list.
[0021] In summary, the present invention has the following beneficial effects compared to the prior art:
[0022] The present invention significantly reduces the length of linked lists by recursively merging linked list nodes, improves the inspection efficiency of large-capacity qcow2 files, and is suitable for rapid fault diagnosis in cloud computing environments. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 It is a schematic diagram of the process of the present invention. DETAILED DESCRIPTION
[0024] The present invention will be further described below with reference to the accompanying drawings and specific embodiments:
[0025] like Figure 1 A method for quickly checking whether a qcow2 file contains free data includes the following steps:
[0026] Step 1: Create an empty doubly linked list;
[0027] Step 2: Parse the qcow2 file and loop through all secondary table entries.
[0028] Step 3: Create a linked list node for each secondary table entry, which contains the start and end position information;
[0029] Step 4: Traverse the linked list and insert the new node into the linked list, performing recursive merging according to the following rules:
[0030] If the linked list is empty, the current node is used as the head of the linked list;
[0031] If the end address of the node to be inserted is less than the start address of the linked list node, the node to be inserted will be inserted in front of the linked list node;
[0032] If the end address of the node to be inserted is equal to the start address of the linked list node, merge the nodes and recursively check the predecessor node;
[0033] If the starting address of the node to be inserted is equal to the ending address of the linked list node, merge the nodes and recursively check the successor nodes;
[0034] If the starting address of the node to be inserted is greater than the ending address of the linked list node, the node to be inserted will be inserted after the linked list node;
[0035] Step 5: Repeat the insertion steps until all entries in the secondary table are inserted;
[0036] Step 6: Check the length of the linked list. If the length is not 1, it is determined that there is a free data block and the position of the free data block is calculated.
[0037] The starting position of the linked list node is the address of the secondary table entry record, and the ending position is the starting address plus 64K.
[0038] The recursive merging includes:
[0039] When the end address of the node to be inserted is equal to the start address of the linked list node, modify the start address of the linked list node to the start address of the node to be inserted, and recursively check the predecessor node;
[0040] When the starting address of the node to be inserted is equal to the ending address of the linked list node, the ending address of the linked list node is modified to the ending address of the node to be inserted, and the successor node is recursively checked.
[0041] The position of the free data block is obtained by subtracting the start address of the next node from the end address of the previous node in the linked list.
[0042] The basic principles, main features, and advantages of the present invention are shown and described above. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The above embodiments and descriptions are merely illustrative of the principles of the present invention. Various changes and modifications may be made to the present invention without departing from the spirit and scope of the present invention. Such changes and modifications are intended to fall within the scope of the present invention. The scope of protection claimed in the present invention is defined by the appended claims and their equivalents.
Claims
1. A method for quickly checking whether there is free data in a qcow2 file, characterized in that: The following steps are involved: Step 1: Create an empty doubly linked list; Step 2: Parse the qcow2 file and loop through all secondary table entries. Step 3: Create a linked list node for each secondary table entry, which contains the start and end position information; Step 4: Traverse the linked list and insert the new node into the linked list, performing recursive merging according to the following rules: If the linked list is empty, the current node is used as the head of the linked list; If the end address of the node to be inserted is less than the start address of the linked list node, the node to be inserted will be inserted in front of the linked list node; If the end address of the node to be inserted is equal to the start address of the linked list node, merge the nodes and recursively check the predecessor node; If the starting address of the node to be inserted is equal to the ending address of the linked list node, merge the nodes and recursively check the successor nodes; If the starting address of the node to be inserted is greater than the ending address of the linked list node, the node to be inserted will be inserted after the linked list node; Step 5: Repeat the insertion steps until all entries in the secondary table are inserted; Step 6: Check the length of the linked list. If the length is not 1, it is determined that there is a free data block and the position of the free data block is calculated.
2. A method for quickly checking whether there is free data in a qcow2 file according to claim 1, characterized in that The starting position of the linked list node is the address of the secondary table entry record, and the ending position is the starting address plus 64K.
3. A method for quickly checking whether there is free data in a qcow2 file according to claim 1, characterized in that The recursive merging includes: When the end address of the node to be inserted is equal to the start address of the linked list node, modify the start address of the linked list node to the start address of the node to be inserted, and recursively check the predecessor node; When the starting address of the node to be inserted is equal to the ending address of the linked list node, the ending address of the linked list node is modified to the ending address of the node to be inserted, and the successor node is recursively checked.
4. A method for quickly checking whether there is free data in a qcow2 file according to claim 1, characterized in that The position of the free data block is obtained by subtracting the start address of the next node from the end address of the previous node in the linked list.
Citation Information
Patent Citations
Virtual machine backup recovery method and device, computer equipment and storage medium
CN117033082A
Automatic NFV service chain failure recovery due to compute node failures
US20250045166A1