A virtual disk space recovery method, device and medium

By obtaining the bitmap file of the disk space of the virtual machine and recycling data blocks based on the change information, the limitations of virtual machines needing to be turned on and disks needing to be mounted in the existing technology are solved, and efficient disk space recycling is achieved, avoiding the impact on the performance of the virtual machine.

CN114995756BActive Publication Date: 2025-08-19JINAN INSPUR DATA TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210590450.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-27
Publication Date
2025-08-19
Estimated Expiration
2042-05-27

AI Technical Summary

Technical Problem

Existing disk space recovery technology requires the virtual machine to be powered on and the disk is mounted, which may have a negative impact on the performance of the virtual machine and is inefficient.

Method used

By obtaining the disk space bitmap file of the virtual machine, obtaining the data blocks to be recycled based on the change information in the bitmap file, and erasing their data for recycling, using CBT technology to monitor the change information and generate bitmap files when the virtual machine is running, and setting the disk space recycling cycle to reduce the impact on the virtual machine.

Benefits of technology

It realizes efficient recycling of disk space in the virtual machine shutdown state or disk mount state, reduces the negative impact on virtual machine performance, and improves recycling efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114995756B_ABST
    Figure CN114995756B_ABST
Patent Text Reader

Abstract

The present application discloses a virtual disk space recovery method, device and medium, which relate to the field of computer technology. By obtaining a bitmap file of the virtual machine's disk space; wherein the bitmap file contains change information of each data block in the disk space; obtaining the data block to be recovered according to the change information in the bitmap file; erasing the data in the data block to be recovered, so as to reclaim the disk space. It can be seen that the above scheme determines the data block to be recovered in the disk space by obtaining the bitmap file of the disk space, and reclaims it. The scheme acts directly on the physical disk of the virtual machine and does not depend on the operating system of the virtual machine; when the virtual machine is in a shut down state or the virtual machine disk is in a mounted state, it can still be recovered normally, will not have a negative impact on the performance of the virtual machine, and has higher recovery efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a method, device, and medium for recovering virtual disk space. Background Art

[0002] When a traditional disk drive deletes a disk file, the corresponding disk space is simply marked as unused and is not completely cleared. At this point, although the system displays the deleted file as deleted, the host's storage space is still occupied. For virtual machines in cloud products, deleted data on the disk still occupies host space, which means that the efficiency of the cloud product's storage pool is correspondingly reduced. In addition, the operating system only marks deleted data blocks as unused, and the underlying storage cannot determine which data blocks can be used directly and which data blocks need to be erased before use. Therefore, when writing data again, an erase operation is required first, which reduces disk write performance. Existing disk space recovery technologies, such as the trim and fstrim commands used by solid-state drives (SSDs) to manage storage, reclaim unused data blocks or those containing invalid data and return them to the general storage pool for reuse.

[0003] However, existing disk space reclamation technologies require the virtual machine to be powered on and the disk to be mounted, which can negatively impact virtual machine performance. Furthermore, reclaiming disk space from deleted data in each virtual machine individually is also limited by disk drives, resulting in low efficiency.

[0004] In view of the above problems, designing a virtual disk space recovery method is an issue that needs to be urgently resolved by technical personnel in this field. Summary of the Invention

[0005] The purpose of this application is to provide a virtual disk space recovery method, device and medium to solve the problem that disk space recovery is subject to the state of the virtual machine and is inefficient.

[0006] To solve the above technical problems, the present application provides a method for reclaiming virtual disk space, comprising:

[0007] Obtaining a bitmap file of a disk space of a virtual machine; wherein the bitmap file includes change information of each data block in the disk space;

[0008] Acquire the data block to be recycled according to the change information in the bitmap file;

[0009] Erasing the data in the data block to be reclaimed to reclaim the disk space.

[0010] Preferably, the step of obtaining a bitmap file of the disk space of the virtual machine includes:

[0011] Generate an initial bitmap; wherein the initial bitmap does not contain the change information of each data block in the disk space;

[0012] When the virtual machine is running, monitoring the change information of each data block in the disk space by using CBT technology, and writing the change information into the initial bitmap;

[0013] Determine whether the preset conditions are met;

[0014] If so, the initial bitmap in which the change information is written is exported to generate the bitmap file, so as to facilitate obtaining the bitmap file.

[0015] Preferably, after exporting the initial bitmap in which the change information is written to generate the bitmap file, the method further includes:

[0016] A new initial bitmap is generated to continue monitoring the change information of each data block in the disk space.

[0017] Preferably, obtaining the data block to be recycled according to the change information in the bitmap file includes:

[0018] Obtaining a disk space recycling cycle; wherein the disk space recycling cycle indicates that recycling of the disk space is triggered when a preset number of bitmap files are accumulated;

[0019] Determining whether to obtain the data block to be recycled according to the bitmap file according to the disk space recycling cycle;

[0020] If so, obtaining the change information of each data block in each bitmap file within the disk space recovery period;

[0021] The data block to be recycled is obtained according to the change information of each data block in each bitmap file.

[0022] Preferably, after the disk space is reclaimed, the method further comprises:

[0023] The latest bitmap file in the disk space reclamation cycle is retained, and the other bitmap files in the disk space reclamation cycle are deleted.

[0024] Preferably, the determining whether a preset condition is met includes:

[0025] Determine whether the monitoring change information reaches a preset time;

[0026] If so, proceed to the step of exporting the initial bitmap written with the change information to generate the bitmap file.

[0027] Preferably, the change information includes a no-operation state, a data-writing state, a data-deleting state, and a data-modifying state.

[0028] To solve the above technical problems, the present application also provides a virtual disk space recovery device, comprising:

[0029] A first acquisition module is configured to acquire a bitmap file of a disk space of a virtual machine; wherein the bitmap file includes change information of each data block in the disk space;

[0030] A second acquisition module, configured to acquire the data block to be recycled according to the change information in the bitmap file;

[0031] The recycling module is used to erase the data in the data block to be recycled, so as to recycle the disk space.

[0032] Preferably, the first acquisition module includes:

[0033] A first generating module is configured to generate an initial bitmap; wherein the initial bitmap does not include change information of each data block in the disk space;

[0034] A monitoring module, configured to monitor the change information of each data block in the disk space by using CBT technology when the virtual machine is running, and write the change information into the initial bitmap;

[0035] The first judgment module is used to judge whether the preset conditions are met; if so, trigger the second generation module;

[0036] The second generating module is configured to export the initial bitmap written with the change information to generate the bitmap file, so as to facilitate obtaining the bitmap file.

[0037] Preferably, the first acquisition module further includes:

[0038] The third generating module is used to generate a new initial bitmap to continue monitoring the change information of each data block in the disk space.

[0039] Preferably, the second acquisition module includes:

[0040] A third acquisition module is configured to acquire a disk space reclamation period, wherein the disk space reclamation period indicates that the reclamation of the disk space is triggered when a preset number of bitmap files are accumulated;

[0041] A second judgment module is configured to judge whether to obtain the data block to be recovered according to the bitmap file based on the disk space recovery cycle; if so, trigger a fourth acquisition module;

[0042] The fourth acquisition module is configured to acquire the change information of each data block in each bitmap file during the disk space recovery period;

[0043] A fifth acquisition module is configured to acquire the data block to be recycled according to the change information of each data block in each bitmap file.

[0044] Preferably, it also includes:

[0045] The bitmap processing module is used to retain the latest bitmap file in the disk space recovery cycle and delete the other bitmap files in the disk space recovery cycle.

[0046] Preferably, the first judgment module is used to judge whether the monitoring of the change information reaches a preset time; if so, trigger the second generation module.

[0047] Preferably, the change information includes a no-operation state, a data-writing state, a data-deleting state, and a data-modifying state.

[0048] To solve the above technical problems, the present application also provides another virtual disk space recovery device, comprising:

[0049] memory for storing computer programs;

[0050] The processor is configured to implement the steps of the above-mentioned virtual disk space recovery method when executing the computer program.

[0051] To solve the above technical problems, the present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned virtual disk space recovery method are implemented.

[0052] The virtual disk space recovery method provided in the present application is achieved by obtaining a bitmap file of the virtual machine's disk space; wherein the bitmap file contains change information of each data block in the disk space; obtaining the data block to be recovered based on the change information in the bitmap file; erasing the data in the data block to be recovered, so as to recycle the disk space. It can be seen that the above scheme determines the data block to be recovered in the disk space by obtaining the bitmap file of the disk space, and recycles it. The scheme acts directly on the physical disk of the virtual machine and does not depend on the operating system of the virtual machine; it can still be recovered normally when the virtual machine is in a shut down state or the virtual machine disk is in a mounted state, and will not have a negative impact on the performance of the virtual machine, and the recovery efficiency is higher.

[0053] In addition, the embodiment of the present application also provides a virtual disk space recovery device and a computer-readable storage medium, which have the same effects as above. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] In order to more clearly illustrate the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0055] Figure 1 A flowchart of a virtual disk space recovery method provided in an embodiment of the present application;

[0056] Figure 2 A schematic diagram of an initial bitmap provided in an embodiment of the present application;

[0057] Figure 3 A flowchart of another virtual disk space recovery method provided in an embodiment of the present application;

[0058] Figure 4 A schematic diagram of the structure of a virtual disk space recovery device provided in an embodiment of the present application;

[0059] Figure 5 A schematic diagram of the structure of another virtual disk space recovery device provided in an embodiment of the present application;

[0060] Figure 6 This is a flowchart of the virtual disk space recovery method provided in an embodiment of the present application in an application scenario. DETAILED DESCRIPTION

[0061] The following will be combined with the accompanying drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0062] The core of this application is to provide a virtual disk space recovery method, device and medium.

[0063] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below with reference to the accompanying drawings and specific implementation methods.

[0064] Existing disk space reclamation technologies reclaim data blocks that are unused or contain invalid data, returning them to a common storage pool for reuse. However, existing disk space reclamation technologies require the virtual machine to be powered on and the disk to be mounted, which may negatively impact virtual machine performance. Furthermore, reclaiming disk space for deleted data from a virtual machine one by one is also constrained by the disk drive, resulting in low efficiency. Therefore, the present application provides a virtual disk space reclamation method to address the issue of virtual machine constraints and low efficiency during disk reclamation. Figure 1 This is a flow chart of a virtual disk space recovery method provided in an embodiment of the present application. Figure 1 As shown, the method includes:

[0065] S10: Obtain a bitmap file of the disk space of the virtual machine; wherein the bitmap file contains change information of each data block in the disk space.

[0066] S11: Obtain the data block to be recycled according to the change information in the bitmap file.

[0067] S12: Erasing data in the data block to be reclaimed to reclaim the disk space.

[0068] It is understandable that disk space is typically composed of many data blocks. Reclaiming disk space is actually reclaiming the space of the data blocks within the disk space. To reclaim virtual disk space, it is necessary to determine which data blocks are eligible for reclamation. In practice, to determine which data blocks are eligible for reclamation, a bitmap file of the virtual machine's disk space is first obtained; this bitmap file contains change information for each data block within the disk space. The data block change information records the usage of each data block during virtual machine operation. When the change information records that the data in the data block has been deleted, the data block is considered eligible for reclamation.

[0069] It's important to note that the bitmap file in this embodiment is a bitmap; a bit is the smallest unit of data in a computer system. A bit's value is either 0 or 1. Therefore, a bitmap can be understood as a data structure that stores specific data using an array of bits. The basic principle of a bitmap is to use a single bit to mark the value corresponding to an element, with the key being that element. Therefore, in this embodiment, a bitmap file is used to record and register changes to each data block in the virtual machine's disk space. Figure 2 This is a schematic diagram of an initial bitmap provided in an embodiment of the present application. Figure 2As shown in the figure, the virtual machine disk is divided into multiple data blocks in 4KB units. The bitmap records the change information of each virtual machine block in 2 bits. For example, the change information in the bitmap corresponding to data block A is AA'. When AA' is 00, data block A is in the no-operation state. When AA' is 11, data block A is in the deleted state and can be recycled.

[0070] Furthermore, the bitmap files for the data blocks on the virtual disk are initially in an inactive state, meaning that the change information corresponding to each data block is 00. During virtual machine operation, as the disk space is used, the bitmap files record data block change information. Therefore, it is understood that, in the actual recording of changes, a single bitmap file can continuously record data block change information; or multiple bitmap files can exist, each recording data block change information for different time periods. This embodiment does not impose any restrictions on the process of obtaining the bitmap files, which will be determined based on specific implementation circumstances.

[0071] After obtaining the bitmap file of the disk space, the data blocks to be recovered can be obtained according to the change information in the bitmap file, that is, the data blocks with change information 11 in the bitmap file are obtained, thereby erasing the data in these data blocks to realize disk space recovery.

[0072] It should be noted that during virtual machine operation, disk space usage is high. Real-time disk space recovery not only increases system power consumption but also has a certain impact on disk space storage. Therefore, when acquiring data blocks to be recovered, acquisition can be performed within a preset time period, or data blocks with low utilization rates can be acquired to delay the data block recovery process. In the case of multiple bitmap files, it is necessary to combine change information from multiple bitmap files to acquire data blocks to be recovered. Therefore, in this embodiment, the specific process of acquiring data blocks to be recovered based on change information in bitmap files is not limited and will be determined based on specific implementation circumstances.

[0073] In this embodiment, a bitmap file of the virtual machine's disk space is obtained; the bitmap file contains change information for each data block in the disk space; the data blocks to be reclaimed are obtained based on the change information in the bitmap file; and the data in the data blocks to be reclaimed are erased to reclaim the disk space. Thus, it can be seen that the above scheme determines the data blocks to be reclaimed in the disk space by obtaining the bitmap file of the disk space and reclaims them. This scheme directly operates on the virtual machine's physical disk and is independent of the virtual machine's operating system. It can still be recycled normally even when the virtual machine is powered off or the virtual machine disk is mounted, without negatively impacting the virtual machine's performance and achieving higher recycling efficiency.

[0074] Figure 3 This is a flow chart of another virtual disk space recovery method provided by an embodiment of the present application. Figure 3 As shown, the bitmap file for obtaining the disk space of the virtual machine includes:

[0075] S101: Generate an initial bitmap; wherein the initial bitmap does not contain change information of each data block in the disk space.

[0076] S102: When the virtual machine is running, the change information of each data block in the disk space is monitored by the CBT technology, and the change information is written into the initial bitmap.

[0077] S103: Determine whether the preset conditions are met; if so, proceed to S104.

[0078] S104: Export the initial bitmap in which the change information is written to generate a bitmap file, so as to facilitate obtaining the bitmap file.

[0079] It is understood that the above embodiment does not limit the process of obtaining the bitmap file, and the process depends on the specific implementation. As a preferred embodiment, in this embodiment, to obtain the bitmap file, an initial bitmap must first be generated. The initial bitmap does not contain the change information of each data block in the disk space, that is, the change information corresponding to each data block is 00.

[0080] Furthermore, when the virtual machine starts running, the disk space is called; at this time, the change information of each data block in the disk space is monitored through CBT technology, and the change information is written into the initial bitmap, so that each data block in the initial bitmap is changed from a no-operation state, that is, the change information of each data block is generated in the initial bitmap.

[0081] It's important to note that Changing Block Tracking (CBT) technology tracks modified disk sectors on a virtual machine. This means that when the backup software performs a backup, it can request that only the data blocks since the last backup or the blocks currently in use be transferred. Therefore, CBT technology can detect changes to each data block on the virtual machine's disk space while the virtual machine is running and write this information to the initial bitmap.

[0082] After obtaining the bitmap containing the change information, it is necessary to determine whether the preset conditions are met. In this embodiment, the preset conditions can be the virtual machine shutting down, the reaching of a preset time period, or the receipt of a user-issued instruction to export a bitmap file. In this embodiment, there are no restrictions on the preset conditions, which will be determined based on the specific implementation. After the preset conditions are met, the initial bitmap containing the change information is exported to generate a bitmap file and saved in a specified path, so that the bitmap file can be retrieved from the saved path.

[0083] In this embodiment, an initial bitmap is generated; the initial bitmap does not contain change information for each data block in the disk space. While the virtual machine is running, the change information for each data block in the disk space is monitored using CBT technology and written into the initial bitmap. A determination is made as to whether a preset condition is met. If so, the initial bitmap containing the change information is exported to generate a bitmap file. This enables the generation of the bitmap file, making it easier to obtain the bitmap file, and thus retrieve the data blocks to be recycled based on the change information in the bitmap file.

[0084] Based on the above embodiment:

[0085] As a preferred embodiment, after exporting the initial bitmap in which the change information is written to generate a bitmap file, the method further includes:

[0086] Generate a new initial bitmap to continue monitoring the change information of each data block in the disk space.

[0087] It will be appreciated that in the above embodiment, the initial bitmap containing the change information is exported to generate a bitmap file. To further record changes to disk space data blocks during subsequent virtual machine operations, a new initial bitmap is generated after the initial bitmap containing the change information is exported to generate a bitmap file, continuing to track changes to the virtual machine's disk data blocks. As can be seen from the above embodiment, until the preset conditions are met, the new initial bitmap containing the change information is exported to generate a new bitmap file.

[0088] In this embodiment, after the initial bitmap in which the change information is written is exported to generate a bitmap file, a new initial bitmap is generated, thereby achieving continuous tracking of changes in virtual machine disk data blocks.

[0089] Based on the above embodiment:

[0090] As a preferred embodiment, obtaining the data block to be recycled according to the change information in the bitmap file includes:

[0091] S110: Obtaining a disk space reclamation period; wherein the disk space reclamation period indicates that the reclamation of the disk space is triggered when a preset number of bitmap files are accumulated.

[0092] S111: Determine whether to obtain a data block to be reclaimed according to the bitmap file based on the disk space reclaiming cycle; if so, proceed to step S112.

[0093] S112: Acquire change information of each data block in each bitmap file during a disk space recovery period.

[0094] S113: Obtain the data blocks to be recycled according to the change information of each data block in each bitmap file.

[0095] In the above embodiments, the specific process of obtaining the data blocks to be recycled according to the change information in the bitmap file is not limited and depends on the specific implementation. As a preferred embodiment, in this embodiment, the disk space recycling period is first obtained. The disk space recycling period represents that when a preset number of bitmap files are accumulated, the recycling of disk space is triggered.

[0096] It can be understood that considering reducing the impact of the disk space recycling process on the operation of the virtual machine, the disk space recycling period is set to adjust the frequency of disk space recycling. Specifically, in this embodiment, the disk recycling period can be set to a preset positive integer, and the numerical value represents that the recycling of disk space is triggered after accumulating a preset positive integer of bitmap files. For example, if the preset positive integer is 3, the recycling of disk space is triggered after accumulating 3 bitmap files. And the user can select one or more virtual machines to use this preset recycling period policy simultaneously. After obtaining the disk space recycling period, if the number of bitmap files meets the number of bitmap files in the disk space recycling period, the data blocks to be recycled are obtained according to the bitmap files.

[0097] Furthermore, the change information of each data block in each bitmap file within the disk space recycling period is obtained, that is, according to the multiple bitmaps exported by the virtual machine, they are compared in sequence to filter out the disk space data blocks that can be recycled. Specifically, the recycling of disk space is triggered according to the set disk space recycling period. If the set recycling frequency is n (n≥2), the recycling of space is triggered after generating n bitmap files bitmap1, bitmap2…bitmapn. Every two bits in the bitmap file represent the change situation of a data block, and use A i A i ' to represent the change situation of data block A in the i-th bitmap file. If it is judged whether the data block A marked in the m-th (m < n) bitmap can be recycled, it is necessary to traverse the situations of data block A in bitmapm, bitmapm+1…bitmapn in sequence and perform the following logical operations:

[0098]

[0099] It can be seen that in the above logical operation relationship formula, if A m A m ' is 11, then A m+1 A m+1 ' to A n A n ' are all 00. At this time, the operation result R m is true, indicating that the disk data of data block A marked in bitmap m is invalid and can be recycled. After traversing bitmap1, bitmap2…bitmapn-1 through this process, all recyclable data blocks are obtained.

[0100] For example, if the disk space reclamation cycle is 3, the resulting bitmap files are bitmap1, bitmap2, and bitmap3, and the change information in the bitmap file corresponding to data block A is AA', to determine whether data block A can be reclaimed, it is necessary to traverse data block A's status in bitmap1, bitmap2, and bitmap3. If the change information for data block A in bitmap1, bitmap2, and bitmap3 is 11, 00, and 00, respectively, the above relationship shows that the result is true, indicating that data block A can be reclaimed.

[0101] It should be noted that when the preset disk recycling cycle is set to 1, disk space recycling can be triggered after a bitmap file is generated. By traversing the bitmap, the data block marked as 11 indicates that the data is invalid and can be recycled. After all the data in the data block is erased and set to zero, the bitmap file can be deleted.

[0102] In this embodiment, a disk space recovery cycle is obtained; wherein the disk space recovery cycle indicates that the recovery of disk space is triggered when a preset number of bitmap files are accumulated; according to the disk space recovery cycle, it is determined whether to obtain the data blocks to be recovered according to the bitmap files; if so, the change information of each data block in each bitmap file within the disk space recovery cycle is obtained, and the data blocks to be recovered are obtained according to the change information of each data block in each bitmap file, thereby achieving the recovery of the data blocks to be recovered while reducing the impact of the disk space recovery process on the operation of the virtual machine.

[0103] Based on the above embodiment:

[0104] As a preferred embodiment, after the disk space is reclaimed, the following steps are further included:

[0105] The latest bitmap file in the disk space reclamation cycle is retained, and the other bitmap files in the disk space reclamation cycle are deleted.

[0106] It can be understood that in the above embodiment, the data in the data block to be recovered is obtained and then the data in the data block is erased. As a preferred embodiment, in this embodiment, after the disk space is recovered, that is, after the data in the data block to be recovered is erased, the latest bitmap file in the disk space recovery cycle is retained, and the other bitmap files in the disk space recovery cycle are deleted. Taking the disk space recovery cycle of 3 in the above embodiment and erasing the data in data block A as an example, after erasing the data in data block A to be recovered, the third bitmap file bitmap3 in the disk space recovery cycle is retained, and bitmap1 and bitmap2 are deleted. The above process can improve the recovery efficiency of the disk space. In the subsequent accumulation of bitmap space, only two more bitmap files need to be accumulated to recycle the disk space again.

[0107] In this embodiment, after the disk space is reclaimed, the latest bitmap file in the disk space reclaim cycle is retained and other bitmap files in the disk space reclaim cycle are deleted, so as to re-accumulate bitmap files, thereby improving the disk space reclaim efficiency.

[0108] Based on the above embodiment:

[0109] As a preferred embodiment, determining whether the preset condition is met includes:

[0110] Determine whether the monitoring change information reaches the preset time;

[0111] If so, proceed to the step of exporting the initial bitmap into which the change information is written to generate a bitmap file.

[0112] In the above embodiment, the preset conditions are not limited and are determined according to specific implementation conditions. As a preferred embodiment, in this embodiment, determining whether the preset conditions are met is to determine whether the monitoring change information has reached a preset time; if so, the step of exporting the initial bitmap written with the change information to generate a bitmap file is performed.

[0113] It's understandable that if CBT technology continuously monitors changes to data blocks on disk for too long, the resulting bitmap file will be large. This not only takes up storage space but also increases the complexity of subsequently retrieving the data blocks to be reclaimed based on the bitmap file. Therefore, a preset time for monitoring change information is set. When the preset time is reached, monitoring stops and the bitmap file is generated.

[0114] In this embodiment, it is determined whether the preset conditions are met, specifically whether the monitored change information reaches the preset time. If so, the initial bitmap written with the change information is exported to generate a bitmap file, thereby avoiding the bitmap file being too large and occupying too much storage space, and reducing the complexity of subsequent acquisition of the data blocks to be recovered.

[0115] Based on the above embodiment:

[0116] As a preferred embodiment, the change information includes a no-operation state, a data-writing state, a data-deleting state, and a data-modifying state.

[0117] It will be appreciated that, in the above embodiment, the recovery status of each data block is determined by the change information of each data block in the bitmap file. When the change information is 00, it indicates that the data block is in the no-operation state, and when the change information is 11, it indicates that the data block is in the data deletion state. These two types of change information can be used to determine the current state of the data block. To further determine the current state of the data block, the change information also includes a write state of 01, indicating that data is being written to the data block, and a modification state of 10, indicating that data in the data block is being modified. These two types of change information can clearly indicate the data writing status of each data block.

[0118] In this embodiment, the change information includes a no-operation status, a data-writing status, a data-deleting status, and a data-modifying status, thereby realizing the determination of the status of each data block to be recycled and the determination of the data-writing status.

[0119] In the above embodiments, a method for recovering virtual disk space is described in detail. This application also provides corresponding embodiments of a virtual disk space recovery device. It should be noted that this application describes the embodiments of the device from two perspectives: one is based on the functional modules, and the other is based on the hardware structure.

[0120] Figure 4 A schematic diagram of the structure of a virtual disk space recovery device provided in an embodiment of the present application.

[0121] like Figure 4 As shown, the virtual disk space recovery device includes:

[0122] The first acquisition module 10 is configured to acquire a bitmap file of the disk space of the virtual machine; wherein the bitmap file includes change information of each data block in the disk space.

[0123] The second acquisition module 11 is configured to acquire the data block to be recycled according to the change information in the bitmap file.

[0124] The recycling module 12 is used to erase data in the data blocks to be recycled, so as to recycle the disk space.

[0125] As a preferred embodiment, the first acquisition module includes:

[0126] The first generating module is used to generate an initial bitmap; wherein the initial bitmap does not contain change information of each data block in the disk space;

[0127] The monitoring module is used to monitor the change information of each data block in the disk space through CBT technology when the virtual machine is running, and write the change information into the initial bitmap;

[0128] The first judgment module is used to judge whether the preset conditions are met; if so, trigger the second generation module;

[0129] The second generating module is used to export the initial bitmap written with the change information to generate a bitmap file, so as to facilitate obtaining the bitmap file.

[0130] As a preferred embodiment, the first acquisition module further includes:

[0131] The third generating module is used to generate a new initial bitmap so as to continue monitoring the change information of each data block in the disk space.

[0132] As a preferred embodiment, the second acquisition module includes:

[0133] The third acquisition module is used to obtain a disk space recovery cycle; wherein the disk space recovery cycle indicates that the recovery of the disk space is triggered when a preset number of bitmap files are accumulated;

[0134] The second judgment module is used to judge whether to obtain the data block to be recovered according to the bitmap file according to the disk space recovery cycle; if so, trigger the fourth acquisition module;

[0135] The fourth acquisition module is used to obtain the change information of each data block in each bitmap file during the disk space recovery period;

[0136] The fifth acquisition module is used to acquire the data blocks to be recycled according to the change information of each data block in each bitmap file.

[0137] As a preferred embodiment, the present invention further comprises:

[0138] The bitmap processing module is used to retain the latest bitmap file in the disk space recovery cycle and delete other bitmap files in the disk space recovery cycle.

[0139] As a preferred embodiment, the first judgment module is used to judge whether the monitoring change information reaches a preset time; if so, trigger the second generation module.

[0140] As a preferred embodiment, the change information includes a no-operation state, a data-writing state, a data-deleting state, and a data-modifying state.

[0141] The virtual disk space recovery device provided in the present application includes a first acquisition module, a second acquisition module and a recovery module. By obtaining the bitmap file of the virtual machine's disk space; wherein the bitmap file contains the change information of each data block in the disk space; obtaining the data block to be recovered according to the change information in the bitmap file; erasing the data in the data block to be recovered, so as to recycle the disk space. It can be seen that the above scheme determines the data block to be recovered in the disk space by obtaining the bitmap file of the disk space, and recycles it. The scheme acts directly on the physical disk of the virtual machine and does not depend on the operating system of the virtual machine; when the virtual machine is in a shut down state or the virtual machine disk is in a mounted state, it can still be recovered normally, will not have a negative impact on the performance of the virtual machine, and has higher recovery efficiency.

[0142] Figure 5 This is a structural diagram of another virtual disk space recovery device provided in an embodiment of the present application. Figure 5 As shown, the virtual disk space recovery device includes:

[0143] Memory 20, for storing computer programs;

[0144] The processor 21 is configured to implement the steps of the method for reclaiming virtual disk space as described in the above embodiment when executing a computer program.

[0145] The virtual disk space recovery device provided in this embodiment may include but is not limited to a smart phone, a tablet computer, a laptop computer, or a desktop computer.

[0146] Among them, the processor 21 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 21 can be implemented in at least one hardware form of a digital signal processor (DSP), a field programmable gate array (FPGA), and a programmable logic array (PLA). The processor 21 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a central processing unit (CPU); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 21 may be integrated with a graphics processing unit (GPU), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 21 may also include an artificial intelligence (AI) processor, which is used to process computing operations related to machine learning.

[0147] The memory 20 may include one or more computer-readable storage media, which may be non-transitory. The memory 20 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In this embodiment, the memory 20 is at least used to store the following computer program 201, wherein, after the computer program is loaded and executed by the processor 21, it can implement the relevant steps of the virtual disk space recovery method disclosed in any of the aforementioned embodiments. In addition, the resources stored in the memory 20 may also include an operating system 202 and data 203, etc., and the storage method may be temporary storage or permanent storage. Among them, the operating system 202 may include Windows, Unix, Linux, etc. The data 203 may include but is not limited to data involved in the virtual disk space recovery method.

[0148] In some embodiments, the virtual disk space recovery device may further include a display screen 22 , an input / output interface 23 , a communication interface 24 , a power supply 25 , and a communication bus 26 .

[0149] Those skilled in the art will understand that Figure 5 The structure shown in the figure does not constitute a limitation on the virtual disk space recovery device, and may include more or fewer components than shown in the figure.

[0150] The virtual disk space recovery device provided in the present application includes a memory and a processor. The processor is used to implement the steps of the virtual disk space recovery method mentioned in the above embodiment when executing a computer program. By obtaining a bitmap file of the virtual machine's disk space; wherein the bitmap file contains change information of each data block in the disk space; obtaining the data block to be recovered according to the change information in the bitmap file; erasing the data in the data block to be recovered, so as to recycle the disk space. It can be seen that the above scheme determines the data block to be recovered in the disk space by obtaining the bitmap file of the disk space, and recycles it. The scheme acts directly on the physical disk of the virtual machine and does not depend on the operating system of the virtual machine; it can still be recovered normally when the virtual machine is in a shut down state or the virtual machine disk is in a mounted state, will not have a negative impact on the performance of the virtual machine, and has higher recovery efficiency.

[0151] Finally, the present application also provides an embodiment corresponding to a computer-readable storage medium. The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps described in the above method embodiment.

[0152] It is understandable that if the method in the above embodiment is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and executes all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0153] The computer-readable storage medium provided by the present application stores a computer program, and when the computer program is executed by the processor, the steps described in the above method embodiment are implemented. By obtaining a bitmap file of the virtual machine's disk space; wherein the bitmap file contains change information of each data block in the disk space; obtaining the data block to be recovered according to the change information in the bitmap file; erasing the data in the data block to be recovered, so as to recycle the disk space. It can be seen that the above scheme determines the data block to be recovered in the disk space by obtaining the bitmap file of the disk space, and recycles it. The scheme acts directly on the physical disk of the virtual machine and does not depend on the operating system of the virtual machine; when the virtual machine is in a shut down state or the virtual machine disk is in a mounted state, it can still be recycled normally, will not have a negative impact on the performance of the virtual machine, and has higher recycling efficiency.

[0154] In order to enable those skilled in the art to better understand the technical solution of this application, Figure 6 The above application is further described in detail. Figure 6 This is a flow chart of the virtual disk space recovery method provided in the embodiment of the present application in the application scenario. Figure 6 As shown, the method includes:

[0155] S30: Setting the initial bitmap and disk space recycling period.

[0156] S31: Monitor the change information of the disk space of the virtual machine.

[0157] S32: Write the change information into the initial bitmap to export the bitmap file.

[0158] S33: When the disk space recovery period is met, the disk space data block to be recovered is obtained according to the bitmap file.

[0159] S34: Erasing the data in the data block to be recovered.

[0160] This application scenario involves setting up an initial bitmap that contains no disk space change information to subsequently record changes. A disk space reclamation cycle is set, triggering disk space reclamation when a preset number of bitmap files are accumulated. The system continuously monitors virtual machine disk space changes, writes these changes to the initial bitmap, and exports the bitmap file. When the reclamation cycle is met, the system retrieves the disk space data blocks to be reclaimed based on the bitmap file and erases the data in the reclaimed blocks.

[0161] For example, an initial bitmap is set, in which the change information corresponding to each data block is 00. The disk space reclamation period is set to a preset value. CBT technology continuously monitors disk space change information and exports bitmap files when preset conditions are met. When the number of bitmap files reaches the preset value, data blocks to be reclaimed are obtained from all bitmap files. The data in these reclaimed blocks is then erased.

[0162] The above is a detailed introduction to a virtual disk space recovery method, device and medium provided by the present application. The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the various embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of this application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of this application.

[0163] It should also be noted that, in this specification, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variants thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or apparatus comprising the element.

Claims

1. A virtual disk space recovery method, characterized in that: include: Obtaining a bitmap file of a disk space of a virtual machine; wherein the bitmap file includes change information of each data block in the disk space; Acquire the data block to be recycled according to the change information in the bitmap file; Erasing data in the data block to be reclaimed to reclaim the disk space; The bitmap file of obtaining the disk space of the virtual machine includes: Generate an initial bitmap; wherein the initial bitmap does not contain the change information of each data block in the disk space; When the virtual machine is running, monitoring the change information of each data block in the disk space by using CBT technology, and writing the change information into the initial bitmap; Determine whether the preset conditions are met; If so, exporting the initial bitmap written with the change information to generate the bitmap file, so as to facilitate obtaining the bitmap file; After the initial bitmap written with the change information is exported to generate the bitmap file, the method further includes: generating a new initial bitmap to continue monitoring the change information of each data block in the disk space; The acquiring the data block to be recycled according to the change information in the bitmap file includes: Obtaining a disk space recycling cycle; wherein the disk space recycling cycle indicates that recycling of the disk space is triggered when a preset number of bitmap files are accumulated; Determining whether to obtain the data block to be recycled according to the bitmap file according to the disk space recycling cycle; If so, obtaining the change information of each data block in each bitmap file within the disk space recovery period; The data block to be recycled is obtained according to the change information of each data block in each bitmap file.

2. The virtual disk space recovery method according to claim 1, characterized in that: After the disk space is reclaimed, the method further includes: The latest bitmap file in the disk space reclamation cycle is retained, and the other bitmap files in the disk space reclamation cycle are deleted.

3. The virtual disk space recovery method according to claim 1, characterized in that: The determination of whether the preset condition is met includes: Determine whether the monitoring change information reaches a preset time; If so, proceed to the step of exporting the initial bitmap written with the change information to generate the bitmap file.

4. The virtual disk space recovery method according to any one of claims 1 to 3, characterized in that: The change information includes a no-operation state, a data-writing state, a data-deleting state, and a data-modifying state.

5. A virtual disk space recovery device, characterized in that: include: A first acquisition module is configured to acquire a bitmap file of a disk space of a virtual machine; wherein the bitmap file includes change information of each data block in the disk space; A second acquisition module, configured to acquire the data block to be recycled according to the change information in the bitmap file; A recycling module, configured to erase data in the data block to be recycled, so as to recycle the disk space; The first acquisition module includes: A first generating module is configured to generate an initial bitmap; wherein the initial bitmap does not include the change information of each data block in the disk space; A monitoring module, configured to monitor the change information of each data block in the disk space by using CBT technology when the virtual machine is running, and write the change information into the initial bitmap; The first judgment module is used to judge whether the preset conditions are met; if so, trigger the second generation module; A second generating module is configured to export the initial bitmap in which the change information is written to generate the bitmap file, so as to facilitate obtaining the bitmap file; The first acquisition module further includes: a third generating module, configured to generate a new initial bitmap, so as to continue monitoring the change information of each data block in the disk space; The second acquisition module includes: A third acquisition module is configured to acquire a disk space reclamation period, wherein the disk space reclamation period indicates that the reclamation of the disk space is triggered when a preset number of bitmap files are accumulated; A second judgment module is configured to judge whether to obtain the data block to be recovered according to the bitmap file based on the disk space recovery cycle; if so, trigger a fourth acquisition module; A fourth acquisition module is configured to acquire the change information of each data block in each bitmap file within the disk space recovery period; A fifth acquisition module is configured to acquire the data block to be recycled according to the change information of each data block in each bitmap file.

6. A virtual disk space recovery device, characterized in that: include: memory for storing computer programs; A processor is configured to implement the steps of the virtual disk space recovery method according to any one of claims 1 to 4 when executing the computer program.

7. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the virtual disk space recovery method according to any one of claims 1 to 4 are implemented.

Citation Information

Patent Citations

  • Data block release method and device

    CN104461780A

  • Method for realizing hyper-v virtual machine backup based on Bitmap and application thereof

    CN114020415A