A snapshot deletion method, system, device and medium

By directly acquiring and utilizing the storage device to copy and delete snapshot data blocks in the target device, the problem of slow traditional snapshot deletion is solved, achieving a more efficient snapshot deletion process and improving the robustness and performance of the virtual machine.

CN120122880BActive Publication Date: 2025-11-21NEW H3C CLOUD TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510189701.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-02-20
Publication Date
2025-11-21
Estimated Expiration
2045-02-20

AI Technical Summary

Technical Problem

Traditional snapshot deletion methods are slow when dealing with large amounts of snapshot data, making it difficult to meet the needs of rapid recovery, and can easily affect the performance of virtual machines.

Method used

By directly obtaining the source and destination logical block addressing addresses of the snapshot from the target device, and using the storage device to copy and delete data blocks, intermediate host processing is avoided, reducing the data transmission process.

Benefits of technology

This improves the speed of snapshot deletion, reduces the impact on virtual machine performance, and enhances the robustness and efficiency of the method.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120122880B_ABST
    Figure CN120122880B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of servers and discloses a snapshot deletion method, a snapshot deletion system, a snapshot deletion device and a medium, the method is executed by a target device, a target virtual machine is arranged in the target device, a first snapshot and a second snapshot of the target virtual machine are stored in a storage device of the target device, and the first snapshot is a parent snapshot of the second snapshot; the method comprises the following steps: when a target instruction for deleting the second snapshot is received, a source logical block addressing address of the second snapshot and a destination logical block addressing address of the first snapshot are acquired; the source logical block addressing address and the destination logical block addressing address are sent to the storage device, so that the storage device copies data blocks of the second snapshot to the destination logical block addressing address based on the source logical block addressing address, and then deletes the data blocks of the second snapshot. The above scheme reduces unnecessary data transmission processes and improves the snapshot deletion speed.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of servers, and particularly relates to a snapshot deletion method, system, device and medium. BACKGROUND

[0002] Under the background of wide application of virtualization technology, a virtual machine becomes an important carrier for data processing and application deployment. However, during running, data is vulnerable to software faults, misoperations and malicious attacks and other factors. Traditional backup means cannot meet the requirement of rapid recovery. Virtual machine disk snapshot technology can freeze the disk state and ensure data security and system stability. However, before deleting the virtual machine disk snapshot, the snapshot data needs to be merged into an image file, and then the snapshot is deleted.

[0003] In the related art, when deleting a snapshot, a host needs to first read snapshot data into the host memory, and then the host issues a write I / O (Input / Output) operation to write the snapshot data into an image file, so as to realize merging of the snapshot data and then deleting the snapshot. At this time, if the snapshot data is too much, it is easy to cause slow snapshot deletion. Therefore, there is an urgent need for an efficient snapshot deletion method. SUMMARY

[0004] Therefore, the present application provides a snapshot deletion method, which can improve the efficiency of snapshot deletion.

[0005] In a first aspect, the present application provides a snapshot deletion method, which is executed by a target device, the target device is provided with a target virtual machine, and a first snapshot and a second snapshot of the target virtual machine are stored in a storage device of the target device, the first snapshot being a parent snapshot of the second snapshot; the method comprises the following steps: when a target instruction of deleting the second snapshot is received, a source logical block addressing address of the second snapshot and a destination logical block addressing address of the first snapshot are acquired; the source logical block addressing address and the destination logical block addressing address are issued to the storage device, so that the storage device copies data blocks of the second snapshot to the destination logical block addressing address based on the source logical block addressing address, and then deletes the data blocks of the second snapshot.

[0006] In the embodiment of the present application, the virtual machine in the target device generates a first snapshot and a second snapshot when performing state saving, wherein the second snapshot is created on the basis of the first snapshot. When the target instruction of the second snapshot is received, the source logical block addressing address of the second snapshot and the destination logical block addressing address of the first snapshot are acquired first, and then the source logical block addressing address and the destination logical block addressing address are issued to the storage device, so that the storage device copies the data block of the second snapshot to the destination logical block addressing address and deletes the data block of the second snapshot after the copying, thereby completing the merging and deletion of the snapshot data. In the above scheme, after the target instruction of deleting the second snapshot is received, the source logical block addressing address of the second snapshot and the destination logical block addressing address of the first snapshot can be directly acquired to determine the starting address of the data block copying. Then, the source logical block addressing address and the destination logical block addressing address are issued to the storage device, so that the storage device can directly copy the data block of the second snapshot from the source logical block addressing address to the destination logical block addressing address. Compared with the process of reading the data block of the second snapshot from the source logical block addressing address by the host first, issuing an I / O operation, and writing the data block of the second snapshot to the destination logical block addressing address, the above process reduces unnecessary data transmission process, improves the speed of snapshot deletion, and deletes the data block of the second snapshot after the copying, thereby preventing the influence of directly deleting the data block of the second snapshot on the target device and improving the robustness of the method.

[0007] In an optional embodiment, the target device further runs a user state program and a kernel file system; when the target instruction of deleting the second snapshot is received, the source logical block addressing address of the second snapshot and the destination logical block addressing address of the first snapshot are acquired, including: when the user state program receives the target instruction and triggers the operation of deleting the second snapshot, the parameter information of the second snapshot and the parameter information of the first snapshot are issued to the kernel file system; the kernel file system parses the parameter information of the second snapshot and the parameter information of the first snapshot to acquire the source logical block addressing address of the second snapshot and the destination logical block addressing address of the first snapshot.

[0008] In the embodiment of the present application, the target device runs a user state program and a kernel file system, and the user state program issues the parameter information of the two snapshots to the kernel file system for processing when receiving the target instruction and triggering the operation of deleting the second snapshot. Compared with the mechanism without layering, the security of the target device can be improved.

[0009] In an optional embodiment, issuing the source logical block addressing address and the destination logical block addressing address to the storage device includes: the kernel file system issues a snapshot merging request to the storage device; the snapshot merging request is used to instruct the storage device to delete the data block of the second snapshot after copying the data block of the second snapshot to the destination logical block addressing address based on the source logical block addressing address.

[0010] In the embodiments of the present application, the kernel file system issues a snapshot request to the storage device, which can improve efficiency and robustness compared with directly accessing the storage device.

[0011] In some optional embodiments, the parameter information of the second snapshot includes a source file offset address of the second snapshot and a data length of the second snapshot; the parameter information of the first snapshot includes a file offset address of the first snapshot; and the source logical block addressing address of the second snapshot and the destination logical block addressing address of the first snapshot are obtained by: obtaining a destination file offset address of the first snapshot, the source file offset address of the second snapshot and the data length of the second snapshot; and obtaining the destination logical block addressing address of the first snapshot according to the destination file offset address of the first snapshot and the data length of the second snapshot; and obtaining the source logical block addressing address of the second snapshot according to the source file offset address of the second snapshot.

[0012] In the embodiments of the present application, the destination file offset address, the source file offset address and the data length of the second snapshot are obtained to obtain the destination logical block addressing address of the first snapshot and the source logical block addressing address of the second snapshot. The destination logical block addressing address and the source logical block addressing address can be accurately positioned to ensure that the storage device can accurately copy the data block of the second snapshot from the source logical block addressing address to the destination logical block addressing address.

[0013] In an optional embodiment, the method further includes: determining a data block quantity of the second snapshot according to the data length of the second snapshot; issuing the data block quantity of the second snapshot to the storage device; and copying the data block of the second snapshot to the destination logical block addressing address based on the source logical block addressing address, including: copying data of the source logical block addressing address to the destination logical block addressing address according to the data block quantity.

[0014] In the embodiments of the present application, the data block quantity is determined according to the length of the second snapshot, and then the data block quantity is issued to the storage device, so that the storage device copies data of the source logical block addressing address to the destination logical block addressing address, thereby realizing the copying of the data block.

[0015] In an optional embodiment, the method further includes: obtaining a return result corresponding to the snapshot merging request; the return result is generated by the storage device after performing the operation of copying the data block of the second snapshot to the destination logical block addressing address according to the snapshot merging request; and instructing the storage device to delete the second snapshot in a case where the return result indicates that the data of the source logical block addressing address is successfully copied.

[0016] In the embodiment of the present application, the return result corresponding to the snapshot merging request is acquired, and the second snapshot is deleted in the case that the return result is data replication success. The occupation of the storage space by the second snapshot can be saved. In the case of data replication success, the second snapshot is deleted again, which can prevent the influence of the data block of the second snapshot directly deleted on the target device, and improve the robustness of the method.

[0017] In a second aspect, the present application provides a virtual machine snapshot system, which comprises a data processing unit and a storage device. The data processing unit is configured to acquire a source logical block addressing address of the second snapshot and a destination logical block addressing address of the first snapshot when receiving a target instruction of deleting the second snapshot. The data processing unit is configured to send the source logical block addressing address and the destination logical block addressing address to the storage device. The storage device is configured to delete the data block of the second snapshot after copying the data block of the second snapshot to the destination logical block addressing address based on the source logical block addressing address.

[0018] In an optional implementation, the data processing unit further runs a user state program and a kernel file system. The data processing unit is configured to send parameter information of the second snapshot and parameter information of the first snapshot to the kernel file system when the user state program receives the target instruction and triggers the operation of deleting the second snapshot. The kernel file system parses the parameter information of the second snapshot and the parameter information of the first snapshot to acquire the source logical block addressing address of the second snapshot and the destination logical block addressing address of the first snapshot.

[0019] In some optional implementations, the data processing unit is further configured to send a snapshot merging request to the storage device. The snapshot merging request is used to instruct the storage device to delete the data block of the second snapshot after copying the data block of the second snapshot to the destination logical block addressing address based on the source logical block addressing address.

[0020] In some optional implementations, the parameter information of the second snapshot comprises a source file offset address of the second snapshot and a data length of the second snapshot, and the parameter information of the first snapshot comprises a file offset address of the first snapshot. The data processing unit is further configured to acquire the destination file offset address of the first snapshot, the source file offset address of the second snapshot and the data length of the second snapshot, acquire the destination logical block addressing address of the first snapshot according to the destination file offset address of the first snapshot and the data length of the second snapshot, and acquire the source logical block addressing address of the second snapshot according to the source file offset address of the second snapshot.

[0021] In an optional implementation, the data processing unit is further configured to: determine the number of data blocks of the second snapshot according to the data length of the second snapshot; send the number of data blocks of the second snapshot to the storage device; and copy the data blocks of the second snapshot to the target logical block addressing address based on the source logical block addressing address, including: copying the data of the source logical block addressing address to the target logical block addressing address according to the number of data blocks.

[0022] In an optional implementation, the data processing unit is further configured to: obtain a return result corresponding to the snapshot merging request; the return result is generated after the storage device performs the operation of copying the data blocks of the second snapshot to the target logical block addressing address according to the snapshot merging request; and instruct the storage device to delete the second snapshot in a case where the return result indicates that the data of the source logical block addressing address is successfully copied.

[0023] In a third aspect, the present application provides a snapshot deletion device, the device is arranged in a target device, the target device is provided with a target virtual machine, and a storage device of the target device is stored with a first snapshot and a second snapshot of the target virtual machine, the first snapshot being a parent snapshot of the second snapshot; the device comprises: an address obtaining module, configured to obtain a source logical block addressing address of the second snapshot and a target logical block addressing address of the first snapshot when a target instruction of deleting the second snapshot is received; and an address sending module, configured to send the source logical block addressing address and the target logical block addressing address to the storage device, so that the storage device copies data blocks of the second snapshot to the target logical block addressing address based on the source logical block addressing address, and then deletes the data blocks of the second snapshot.

[0024] In a fourth aspect, the present application provides a computer readable storage medium, the computer readable storage medium is stored with computer instructions, and the computer instructions are used to make a computer execute the snapshot deletion method of the first aspect or any implementation thereof. BRIEF DESCRIPTION OF DRAWINGS

[0025] In order to more clearly illustrate the specific embodiments of the present application or the technical solutions in the prior art, the drawings needed in the specific embodiments or the prior art description will be briefly introduced as follows. Obviously, the drawings in the following description are some embodiments of the present application, and other drawings can also be obtained by those skilled in the art without creative labor.

[0026] Figure 1 is a structural schematic diagram of a target device according to an embodiment of the present application;

[0027] Figure 2 is a flow schematic diagram of a snapshot deletion method according to an embodiment of the present application;

[0028] Figure 3This is a flowchart illustrating another snapshot deletion method according to an embodiment of the present invention;

[0029] Figure 4 This is a flowchart illustrating another snapshot deletion method according to an embodiment of the present invention;

[0030] Figure 5 This is a flowchart illustrating another snapshot deletion method according to an embodiment of the present invention;

[0031] Figure 6 This is a structural block diagram of a virtual machine snapshot system according to an embodiment of the present invention;

[0032] Figure 7 This is a structural block diagram of a snapshot deletion device according to an embodiment of the present invention;

[0033] Figure 8 This is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. Detailed Implementation

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

[0035] Figure 1 This is a schematic diagram of the structure of a target device to which the snapshot deletion method provided in this application embodiment is applicable. For example... Figure 1 The target device shown can be a computer cluster consisting of multiple computer devices, performing an Xcopy Commit operation. This computer cluster can deploy multiple VMs (Virtual Machines), and these VMs can be deployed on one or more hosts within the computer cluster. The VMs will back up their own state, generating a base snapshot and a snap1 snapshot, where the base snapshot is the parent snapshot of the snap1 snapshot.

[0036] After creating the base snapshot and the snap1 snapshot, an access request can be sent to a SAN Storage (Storage Area Network Storage) to store the base snapshot and the snap1 snapshot in the SAN Storage. The access request needs to pass through a host, and then a Kernel (kernel) of the host drive is used to realize communication with the SAN Storage. In a specific implementation, the base snapshot and the snap1 snapshot are in a format of qcow2 (QEMU Copy-on-Write2, QEMU write-on-copy generation 2) and are stored in the SAN Storage.

[0037] When the snap1 snapshot is deleted, the snapshot data that needs to be saved in the snap1 snapshot and the storage locations of the snap1 snapshot and the base snapshot in the SAN Storage need to be confirmed. Then, the virtual machine sends a target instruction to the SAN Storage to drive the SAN Storage to execute an xcopy (extended copy) command, that is, a copy offload, to copy the snapshot data that needs to be saved in the snap1 snapshot from the storage location of the snap1 snapshot to the storage location of the base snapshot. Then, the snap1 snapshot is deleted.

[0038] The embodiment of the present application offloads the snapshot deletion data merging operation of the virtual machine to the storage device for execution, which can greatly improve the speed and performance of snapshot deletion compared with a large number of read and write operations sent by the host through the SAN Storage, and reduces the CPU (Central Processing Unit, central processor) overhead, network resources and traffic on the SAN Storage on the host, and reduces the performance impact on the virtual machine.

[0039] According to the embodiment of the present application, a snapshot deletion method embodiment is also provided to further illustrate how the embodiment of the present application realizes the data merging operation when the virtual machine snapshot is deleted. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0040] In the embodiment of the present application, a snapshot deletion method is provided, which is executed by a target device, the target device is provided with a target virtual machine, and a storage device of the target device stores a first snapshot and a second snapshot of the target virtual machine, the first snapshot being a parent snapshot of the second snapshot. Figure 2 is a flowchart of the snapshot deletion method according to the embodiment of the present application, like Figure 2As shown, the flow includes the following steps:

[0041] In step S201, when a target instruction to delete the second snapshot is received, the source logical block addressing address of the second snapshot and the destination logical block addressing address of the first snapshot are acquired.

[0042] A target virtual machine is arranged in a target device, and when the target virtual machine in the target device is running, in order to improve the robustness of the target virtual machine, the state of the target virtual machine at a specific time point is recorded through a virtual machine snapshot technology. After the state of the target virtual machine at a first time point is recorded to generate a first snapshot, the state of the target virtual machine at a second time point is recorded, and a second snapshot is generated on the basis of the first snapshot. Using the cascaded snapshot mode to record the state of the target virtual machine can improve the storage resource utilization rate of the target device.

[0043] When the target instruction to delete the second snapshot is received, the data blocks in the second snapshot need to be merged into the parent snapshot of the second snapshot to protect data integrity and avoid the data of the second snapshot on which the child snapshot of the second snapshot depends from being inaccessible.

[0044] The source logical block addressing address of the second snapshot and the destination logical block addressing address of the first snapshot can be determined according to the positions of the first snapshot and the second snapshot in a storage device. The storage device includes a storage array, a disk, and the like.

[0045] In step S202, the source logical block addressing address and the destination logical block addressing address are issued to the storage device, so that the storage device copies the data blocks of the second snapshot to the destination logical block addressing address on the basis of the source logical block addressing address, and then deletes the data blocks of the second snapshot.

[0046] After the source logical block addressing address and the destination logical block addressing address are acquired, target information including the source logical block addressing address and the destination logical block addressing address can be generated according to a communication protocol between the target virtual machine and the storage device. Then, the target information is issued to the storage device according to the communication protocol.

[0047] After the storage device receives the target information, the source logical block addressing address and the destination logical block addressing address are parsed. Then, the data blocks of the second snapshot are read from the original logical block addressing address, so that the data blocks of the second snapshot are directly copied and written into the destination logical block addressing address without passing through a data processor, to complete the copying of the data blocks of the second snapshot.

[0048] After the data blocks of the second snapshot are copied, the data blocks of the second snapshot are deleted. The deletion can include logical deletion and physical deletion.

[0049] The logical deletion can mark the data block of the second snapshot, modify the index information in the system, and write the modified data into the storage device to determine the consistency of the data. After marking the data block of the second snapshot for deletion, the physical deletion can be performed at a suitable time of the system, such as garbage collection when the system is idle.

[0050] The physical deletion can first remove the application information of the data block of the second snapshot in the system, perform an overwrite write on the data block using a specific pattern, and then release the storage device space corresponding to the data block.

[0051] The snapshot deletion method provided in the embodiment can generate the first snapshot and the second snapshot when the virtual machine in the target device performs state saving, wherein the second snapshot is created based on the first snapshot. When the target instruction of the second snapshot is received, the source logical block addressing address of the second snapshot and the destination logical block addressing address of the first snapshot are first obtained, and then the source logical block addressing address and the destination logical block addressing address are issued to the storage device, so that the storage device copies the data block of the second snapshot to the destination logical block addressing address and deletes the data block of the second snapshot after the copying, thereby completing the merging and deletion of the snapshot data. The above scheme can directly obtain the source logical block addressing address of the second snapshot and the destination logical block addressing address of the first snapshot after receiving the target instruction of deleting the second snapshot, so as to determine the starting address of the data block copying. Then, the source logical block addressing address and the destination logical block addressing address are issued to the storage device, so that the storage device directly copies the data block of the second snapshot from the source logical block addressing address to the destination logical block addressing address. Compared with reading the data block of the second snapshot from the source logical block addressing address by the host first, issuing an I / O operation, and writing the data block of the second snapshot to the destination logical block addressing address, the above scheme reduces unnecessary data transmission process, improves the speed of snapshot deletion, and deletes the data block of the second snapshot after copying, which can prevent the influence of directly deleting the data block of the second snapshot on the target device and improve the robustness of the method.

[0052] In the embodiment, a snapshot deletion method is provided. The method is executed by a target device. The target device is provided with a target virtual machine. A storage device of the target device stores a first snapshot and a second snapshot of the target virtual machine. The first snapshot is a parent snapshot of the second snapshot, Figure 3 The flowchart of the snapshot deletion method according to the embodiment of the present application is shown in Figure 3 The flowchart of the snapshot deletion method according to the embodiment of the present application is shown in

[0053] In step S301, when receiving a target instruction for deleting the second snapshot, the source logical block addressing address of the second snapshot and the destination logical block addressing address of the first snapshot are obtained.

[0054] Specifically, the target device also runs a user mode program and a kernel file program. The step S301 includes:

[0055] In step S3011, when the user mode program receives the target instruction and triggers the operation of deleting the second snapshot, the parameter information of the second snapshot and the parameter information of the first snapshot are sent to the kernel file system.

[0056] The user mode program receives the target instruction of deleting the second snapshot, triggers the operation of deleting the second snapshot, reads the parameter information of the second snapshot and the parameter information of the first snapshot, and then triggers the kernel file system call by calling the related function. After receiving the call, the kernel file system calls the related function of the kernel file system to perform the write operation, so that the kernel file system receives the parameter information of the second snapshot and the parameter information of the first snapshot.

[0057] In step S3012, the kernel file system parses the parameter information of the second snapshot and the parameter information of the first snapshot to obtain the source logical block addressing address of the second snapshot and the destination logical block addressing address of the first snapshot.

[0058] After reading the parameter information of the second snapshot and the parameter information of the first snapshot written by the user mode program, the kernel file system parses the parameter information to obtain the data length and the offset of the first snapshot and the second snapshot, calculates the corresponding logical block number, maps the logical block number to the physical block number according to the preset mapping mechanism in the kernel file system, and determines the source logical block addressing address of the second snapshot and the destination logical block addressing address of the first snapshot.

[0059] In some optional embodiments, the parameter information of the second snapshot includes the source file offset address of the second snapshot and the data length of the second snapshot, and the parameter information of the first snapshot includes the file offset address of the first snapshot. The step S3012 includes:

[0060] In step a1, the destination file offset address of the first snapshot, the source file offset address of the second snapshot and the length of the second snapshot are obtained.

[0061] Specifically, in the embodiment of the present application, the destination file offset address of the first snapshot, the source file offset address of the second snapshot and the length of the second snapshot can be obtained by a command line tool or the like.

[0062] In step a2, the destination logical block addressing address of the first snapshot is mapped according to the destination file offset address of the first snapshot and the length of the second snapshot.

[0063] Specifically, in the embodiments of the present application, the storage format of the first snapshot can be determined first, and then the mapping relationship between the physical address and the logical address of the first snapshot is determined according to the storage format. Then, the destination logical block addressing address of the first snapshot is obtained according to the mapping relationship and the length of the second snapshot.

[0064] In step a3, the source logical block addressing address of the second snapshot is obtained according to the source file offset address of the second snapshot.

[0065] The storage format of the second snapshot can be determined, and then the mapping relationship between the physical address and the logical address of the second snapshot is determined according to the storage format. Then, the destination logical block addressing address of the second snapshot is obtained according to the mapping relationship.

[0066] In actual application, the storage format of the snapshot is different, and the mapping relationship between the physical address and the logical address is also different. When the storage format of the snapshot is qcow2 format, the mapping relationship between the logical address and the physical address of the snapshot can be obtained by using the debugging mode.

[0067] In step S302, the source logical block addressing address and the destination logical block addressing address are sent to the storage device, so that the storage device copies the data block of the second snapshot to the destination logical block addressing address based on the source logical block addressing address, and then deletes the data block of the second snapshot.

[0068] Specifically, the kernel file system sends a snapshot merging request to the storage device; the snapshot merging request is used to instruct the storage device to copy the data block of the second snapshot to the destination logical block addressing address based on the source logical block addressing address, and then delete the data block of the second snapshot.

[0069] The kernel file system generates and sends a corresponding storage device command to the storage device according to the type of the storage device after obtaining the source logical block addressing address of the second snapshot and the destination logical block addressing address of the first snapshot. The storage device executes corresponding operations according to the command content after receiving the storage device command, that is, copies the data block of the second snapshot to the destination logical block addressing address, and then deletes the data block of the second snapshot.

[0070] In some optional embodiments, the above step S302 includes:

[0071] In step S3021, the number of data blocks of the second snapshot is determined according to the data length of the second snapshot.

[0072] The data length of the second snapshot can be obtained through the metadata in the storage device.

[0073] The data block size of the second snapshot can be determined according to actual conditions, and then the length of the second snapshot is divided by the data block size of the second snapshot to obtain the data block quantity of the second snapshot.

[0074] In a possible implementation of the embodiment of the present application, the second snapshot only includes data changed compared with the first snapshot, and the data block quantity of the second snapshot is the change block quantity of the second snapshot. The change record of the first snapshot can be combined to only count the number of newly added or changed blocks in the second snapshot.

[0075] In step S3022, the data block quantity of the second snapshot is sent to the storage device.

[0076] The data block quantity of the second snapshot is sent to the storage device according to the communication protocol, so that the storage device copies the data of the corresponding data block quantity to the destination logical block addressing address, which can avoid omission of data block copying of the second snapshot and data block copying error.

[0077] In step S3023, the data of the source logical block addressing address is copied to the destination logical block addressing address according to the data block quantity.

[0078] After obtaining the data block quantity of the second snapshot, the storage device selects a corresponding copying tool according to the system environment of the target virtual machine in the target device. The data block quantity of the target data block is read from the source logical block addressing address and written into the destination logical block addressing address.

[0079] In a possible implementation of the embodiment of the present application, before data copying, the data copying is planned according to the data block quantity to determine how to perform data copying in batches. In the case of a small data block quantity, all data can be copied at one time; in the case of a large data block quantity, the data blocks can be copied in batches according to the target interval, so as to avoid depletion of system resources and cause data copying failure.

[0080] In some optional embodiments, step S302 further includes:

[0081] In step S3024, a return result corresponding to the snapshot merging request is obtained. The return result is generated after the storage device performs the operation of copying the data block of the second snapshot to the destination logical block addressing address according to the snapshot merging request.

[0082] After the storage device copies the data block of the second snapshot to the destination logical block addressing address according to the snapshot merging request based on the source logical block addressing address, a return result is generated.

[0083] In a possible implementation of the embodiment of the present application, the return result can be expressed in the form of code. In the case of a data copy failure of the source logical block addressing address, the storage device can generate an error code according to the reason for the failure. The user can process the error code according to the error code. Each error code corresponds to a specific type of error, which facilitates the system to quickly identify and process errors. For example, "1001" represents a network failure; "1002" represents insufficient storage space, and the like.

[0084] In the case of a successful data copy of the return result representing the source logical block addressing address, the storage device is instructed to delete the second snapshot in step S3025.

[0085] In the case of a successful data copy of the return result representing the source logical block addressing address, the storage device is instructed to delete the second snapshot. The integrity of the data can be ensured.

[0086] In the case of the existence of a snapshot of the second snapshot in the storage device, after the deletion of the second snapshot, the cascade link of the snapshot of the second snapshot is adjusted to be connected to the first snapshot, so as to prevent the third snapshot from being unable to be used due to the failure to access the data.

[0087] Please refer to Figure 4 , Figure 4 is a flowchart of a snapshot deletion method according to the embodiment of the present application. As shown in Figure 4 , the LBA (Logical Block Addressing) address and size of the snapshot data copy source disk and the destination disk are obtained, and then the EXTENDED COPY SCSI (Extended Copy in Small Computer System Interface) command is assembled based on the obtained information, and the command is sent to the CDB (Command Descriptor Block). The xcopy request is initiated by the host to the storage device, and the snapshot data is copied from the LBA address of the source disk to the LBA address of the destination disk. After the copy is completed, the return result is generated and sent to the host. In the case of a data copy failure, the return result is an error code of a copy failure (fail); in the case of a successful data copy, the return result is a copy success (success).

[0088] In a possible implementation of the embodiment of the present application, as shown in Figure 5 , the snapshot deletion is executed in the qemu (Quick Emulator) program in the user space (Host user space), and the snapshot data merging operation flow is initiated by the qemu.

[0089] When starting the snapshot merge operation (Start Delete snapshot), the user-mode qemu module needs to first issue an xcopy ioctl (Input / Output Control) system call to the kernel space (Host kernelspace) to execute xcopy. The xcopy ioctl system call parameters include the logical offset and size of the snapshot data copy source file and destination file data block.

[0090] In an actual application, the xcopy ioctl system call parameters are defined as follows:

[0091] struct fs_xcopy_parameter{

[0092] int src_fd, dst_fd; / * Source file and destination file fd (File Descriptor) * /

[0093] uint64_t src_offset; / * Source file offset * /

[0094] uint64_t dst_offset; / * Destination file offset * /

[0095] uint64_t len; / * Copy length * /

[0096] };

[0097] After receiving the xcopy ioctl system call parameters, the kernel space uses the kernel file system fs_ioctl (filesystem Input / Output Control) to parse the xcopy iotcl system call parameters, and then maps the logical offset address of the source file and the destination file into the physical storage LBA address (Get Mapping disk LBA) according to the logical offset address through the index file system extent.

[0098] In one practical application, the kernel uses the vfs_ioctl (Virtual File System Input / Output Control) function to receive the xcopy ioctl request from the user space, and according to the specific file system type, calls the fs_ioctl function implemented by the corresponding file system. For example, when processing the ioctl operation of the OCFS2 (Oracle Cluster File System 2) file system, the vfs_ioctl calls the ocfs2_ioctl (Oracle Cluster File System 2 Input / Output Control) to complete the actual processing work.

[0099] Assemble and issue the xcopy command (Issue xcopy command). Among them, the command format of the EXTENDED COPY SCSI needs to be determined first, then assembled according to the format to obtain the xcopy command, and then the command is sent to the SAN Storage. In one practical application, the command is sent to the storage device (Storage), that is, the SAN Storage, by calling the kernel function blk_execute_rq.

[0100] In one practical application, the parameters of the SCSI (Small Computer System Interface) command are defined as follows:

[0101] struct scsi_extended_copy{

[0102] int sg_fd, uint8_t list_id,

[0103] uint8_t*src_desc, int src_desc_len,

[0104] uint8_t*dst_desc, int dst_desc_len,

[0105] int seg_desc_type, int64_t num_blk,

[0106] uint64_t src_lba, uint64_t dst_lba / * LBA address of the source disk and the destination disk* /

[0107] };

[0108] After receiving the xcopy command, the SAN storage performs data offload copy and returns the xcopy request execution result to the host.

[0109] In some optional embodiments, the host judges whether the data merging has an exception according to the returned result of the xcopy request, and if there is an exception, performs exception processing.

[0110] By Figure 4 With Figure 5 the logic and code examples shown, that is, by using the standard EXTENDED COPY SCSI, the virtual machine deletion snapshot data merging is copied to the storage device, and the data movement is performed by the storage device, so that each step provided in the embodiments of the present application can be implemented. The host CPU, network and other resources can be greatly reduced, and the user hardware cost is reduced. At the same time, the impact on the normal I / O performance of the virtual machine and the delay jitter influence in the deletion snapshot process are greatly reduced, and the robustness and stability of the virtual machine are greatly improved.

[0111] The snapshot deletion method provided in the embodiments receives a target instruction for deleting a second snapshot, obtains a destination logical block addressing address of a first snapshot and a source logical block addressing address of the second snapshot by obtaining a destination file offset address, a source file offset address and a length of the second snapshot. The destination logical block addressing address and the source logical block addressing address can be accurately positioned to ensure that the storage device can accurately copy the data block of the second snapshot from the source logical block addressing address to the destination logical block addressing address. The start address of the data block copying is determined; and the source logical block addressing address and the destination logical block addressing address are sent to the storage device, so that the storage device can directly copy the data block of the second snapshot from the source logical block addressing address to the destination logical block addressing address. Compared with reading the data block of the second snapshot from the source logical block addressing address by the host first, and then sending an I / O operation to write the data block of the second snapshot to the destination logical block addressing address, the unnecessary data transmission process is reduced, and the snapshot deletion speed is improved.

[0112] In the embodiments, a virtual machine snapshot system is also provided, as shown in Figure 6 The system includes a data processing unit and a storage device; the data processing unit is configured to obtain a source logical block addressing address of a second snapshot and a destination logical block addressing address of a first snapshot when a target instruction for deleting the second snapshot is received;

[0113] The data processing unit is configured to send the source logical block addressing address and the destination logical block addressing address to the storage device.

[0114] The storage device is configured to delete the data block of the second snapshot after copying the data block of the second snapshot to the destination logical block addressing address based on the source logical block addressing address.

[0115] In some optional embodiments, the data processing unit further runs a user mode program and a kernel file system; and the data processing unit is configured to: when the user mode program receives the target instruction and triggers the operation of deleting the second snapshot, send the parameter information of the second snapshot and the parameter information of the first snapshot to the kernel file system; and the kernel file system is configured to: parse the parameter information of the second snapshot and the parameter information of the first snapshot to obtain the source logical block addressing address of the second snapshot and the destination logical block addressing address of the first snapshot.

[0116] In some optional embodiments, the data processing unit is further configured to: send, by the kernel file system, a snapshot merge request to the storage device; and the snapshot merge request is configured to instruct the storage device to delete the data block of the second snapshot after copying the data block of the second snapshot to the destination logical block addressing address based on the source logical block addressing address.

[0117] In some optional embodiments, the parameter information of the second snapshot includes a source file offset address of the second snapshot and a data length of the second snapshot; and the parameter information of the first snapshot includes a file offset address of the first snapshot; and the data processing unit is further configured to: obtain a destination file offset address of the first snapshot, the source file offset address of the second snapshot, and the data length of the second snapshot; obtain the destination logical block addressing address of the first snapshot according to the destination file offset address of the first snapshot and the data length of the second snapshot; and obtain the source logical block addressing address of the second snapshot according to the source file offset address of the second snapshot.

[0118] In some optional embodiments, the data processing unit is further configured to: determine a data block quantity of the second snapshot according to the data length of the second snapshot; send the data block quantity of the second snapshot to the storage device; and copy the data block of the second snapshot to the destination logical block addressing address based on the source logical block addressing address, including: copying the data of the source logical block addressing address to the destination logical block addressing address according to the data block quantity.

[0119] In some optional embodiments, the data processing unit is further configured to: obtain a return result corresponding to the snapshot merge request; the return result is generated by the storage device after performing the operation of copying the data block of the second snapshot to the destination logical block addressing address according to the snapshot merge request; and instruct the storage device to delete the second snapshot in a case where the return result indicates that the data of the source logical block addressing address is successfully copied.

[0120] A snapshot deletion apparatus is also provided in the embodiments, which is configured to implement the above-described embodiments and preferred embodiments, and details of which have been described above. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the apparatus described in the following embodiments is preferably implemented in software, implementation in hardware, or a combination of software and hardware, is also possible and contemplated.

[0121] The embodiments provide a snapshot deletion apparatus, which is configured to be arranged in a target device, the target device being arranged with a target virtual machine, and a storage device of the target device being arranged to store a first snapshot and a second snapshot of the target virtual machine, the first snapshot being a parent snapshot of the second snapshot. The apparatus, as shown in Figure 7

[0122] The address obtaining module 701 is configured to, when receiving a target instruction of deleting the second snapshot, obtain a source logical block addressing address of the second snapshot and a destination logical block addressing address of the first snapshot.

[0123] The address issuing module 702 is configured to issue the source logical block addressing address and the destination logical block addressing address to the storage device, so that the storage device, based on the source logical block addressing address, copies data blocks of the second snapshot to the destination logical block addressing address, and then deletes the data blocks of the second snapshot.

[0124] In some optional embodiments, the target device is further arranged to run a user mode program and a kernel file system, and the address obtaining module 701 comprises:

[0125] The issuing unit is configured to, when the user mode program receives the target instruction and triggers the operation of deleting the second snapshot, issue parameter information of the second snapshot and parameter information of the first snapshot to the kernel file system.

[0126] The parsing unit is configured to parse, by the kernel file system, the parameter information of the second snapshot and the parameter information of the first snapshot, to obtain the source logical block addressing address of the second snapshot and the destination logical block addressing address of the first snapshot.

[0127] In some optional embodiments, the address issuing module 702 comprises:

[0128] The executing unit is configured to issue, by the kernel file system, a snapshot merging request to the storage device, the snapshot merging request being configured to instruct the storage device, based on the source logical block addressing address, to copy the data blocks of the second snapshot to the destination logical block addressing address, and then delete the data blocks of the second snapshot.

[0129] In some optional embodiments, the parameter information of the second snapshot comprises a source file offset address of the second snapshot and a data length of the second snapshot, the parameter information of the first snapshot comprises a file offset address of the first snapshot, and the address obtaining module 701 comprises:​

[0130] a parameter acquisition unit, configured to acquire a destination file offset address of the first snapshot, a source file offset address of the second snapshot, and a data length of the second snapshot;

[0131] a first addressing address acquisition unit, configured to acquire a destination logical block addressing address of the first snapshot according to the destination file offset address of the first snapshot and the data length of the second snapshot;

[0132] a second addressing address acquisition unit, configured to acquire a source logical block addressing address of the second snapshot according to the source file offset address of the second snapshot.

[0133] In some optional embodiments, the snapshot deletion apparatus comprises a data block quantity acquisition module, configured to acquire a data block quantity, comprising:

[0134] a data block quantity determination unit, configured to determine the data block quantity of the second snapshot according to the data length of the second snapshot.

[0135] a data block quantity delivery unit, configured to deliver the data block quantity of the second snapshot to the storage device.

[0136] a copying unit, configured to copy data of the source logical block addressing address to the destination logical block addressing address according to the data block quantity.

[0137] In some optional embodiments, the snapshot deletion apparatus further comprises:

[0138] a return result acquisition module, configured to acquire a return result corresponding to the snapshot merging request; the return result is generated by the storage device after performing the operation of copying the data block of the second snapshot to the destination logical block addressing address according to the snapshot merging request.

[0139] a deletion module, configured to instruct the storage device to delete the second snapshot in a case where the return result indicates that the data of the source logical block addressing address is successfully copied.

[0140] Further function descriptions of the above-mentioned various modules and units are the same as those of the above-mentioned corresponding embodiments, and will not be described here again.

[0141] The snapshot deletion apparatus in the embodiment is presented in the form of a functional unit. The unit herein refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and a memory executing one or more software or fixed programs, and / or other devices that can provide the above-mentioned functions.

[0142] The embodiment of the present application further provides a computer device with the above-mentioned Figure 7 snapshot deletion apparatus.

[0143] Please see Figure 8 , Figure 8 This is a schematic diagram of the structure of a computer device provided in an optional embodiment of the present invention, such as... Figure 8 As shown, the computer device includes one or more processors 10, memory 20, and interfaces for connecting the components, including high-speed interfaces and low-speed interfaces. The components communicate with each other via different buses and can be mounted on a common motherboard or otherwise installed as needed. The processors can process instructions executed within the computer device, including instructions stored in or on memory to display graphical information of a GUI on external input / output devices (such as display devices coupled to the interfaces). In some alternative implementations, multiple processors and / or multiple buses can be used with multiple memories and multiple memory modules, if desired. Similarly, multiple computer devices can be connected, each providing some of the necessary operations (e.g., as a server array, a group of blade servers, or a multiprocessor system). Figure 8 Take a processor 10 as an example.

[0144] Processor 10 may be a central processing unit, a network processor, or a combination thereof. Processor 10 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The programmable logic device may be a complex programmable logic device (CAMP), a field-programmable gate array (FPGA), a general-purpose array logic (GPA), or any combination thereof.

[0145] The memory 20 stores instructions executable by at least one processor 10 to cause at least one processor 10 to perform the method shown in the above embodiments.

[0146] The memory 20 may include a program storage area and a data storage area. The program storage area may store the operating system and applications required for at least one function; the data storage area may store data created based on the use of the computer device. Furthermore, the memory 20 may include high-speed random access memory and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some alternative embodiments, the memory 20 may optionally include memory remotely located relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.

[0147] The memory 20 may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as flash memory, hard disk or solid-state drive; the memory 20 may also include a combination of the above types of memory.

[0148] The computer device also includes an input device 30 and an output device 40. The processor 10, the memory 20, the input device 30 and the output device 40 can be connected by a bus or other means, Figure 8 The bus connection is taken as an example.

[0149] The input device 30 can receive inputted digital or character information, and generate key signal input related to user settings and function control of the computer device, such as touch screen, keypad, mouse, trackpad, touchpad, pointing stick, one or more mouse buttons, trackball, joystick, etc. The output device 40 can include display device, auxiliary lighting device (such as LED), and tactile feedback device (such as vibration motor), etc. The display device includes but is not limited to liquid crystal display, light emitting diode, display and plasma display. In some optional embodiments, the display device can be a touch screen.

[0150] The embodiments of the present application also provide a computer readable storage medium, the method according to the embodiments of the present application can be implemented in hardware, firmware, or recorded in a storage medium, or stored in a remote storage medium or a non-transitory machine readable storage medium and downloaded to a local storage medium through network and stored in the local storage medium, so that the method described herein can be processed by such software on a storage medium using a general purpose computer, a special purpose processor or programmable or special hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only memory, a random access memory, a flash memory, a hard disk or a solid state disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that the computer, processor, microprocessor controller or programmable hardware includes a storage component that can store or receive software or computer code, when the software or computer code is accessed and executed by the computer, processor or hardware, the method shown in the above embodiments is implemented.

[0151] Part of the present application can be applied as a computer program product, for example, computer program instructions, when executed by a computer, the operation of the computer can invoke or provide the method and / or technical solutions according to the present application. Those skilled in the art should understand that the form of computer program instructions in computer readable medium includes but is not limited to source file, executable file, installation package file, etc., and accordingly, the way of computer program instructions executed by computer includes but is not limited to: the computer directly executes the instructions, or the computer compiles the instructions and then executes the corresponding compiled program, or the computer reads and executes the instructions, or the computer reads and installs the instructions and then executes the corresponding installed program. Here, the computer readable medium can be any available computer readable storage medium or communication medium accessible to the computer.

[0152] While embodiments of the present application have been described in conjunction with the appended drawings, various modifications and changes are possible within the spirit and scope of the present application, and such modifications and changes are intended to fall within the scope of the appended claims.

Claims

1. A snapshot deletion method characterized by, The method is executed by a target device, a target virtual machine is arranged in the target device, a first snapshot and a second snapshot of the target virtual machine are stored in a storage device of the target device, and the first snapshot is a parent snapshot of the second snapshot; the method comprises: When a target instruction of deleting the second snapshot is received, a source logical block addressing address of the second snapshot and a destination logical block addressing address of the first snapshot are acquired; The source logical block addressing address and the destination logical block addressing address are sent to the storage device, so that the storage device copies data blocks of the second snapshot to the destination logical block addressing address based on the source logical block addressing address, and then deletes the data blocks of the second snapshot.

2. The method of claim 1, wherein, The target device also runs a user state program and a kernel file system; When the target instruction of deleting the second snapshot is received, the source logical block addressing address of the second snapshot and the destination logical block addressing address of the first snapshot are acquired, which comprises: When the user state program receives the target instruction and triggers the operation of deleting the second snapshot, parameter information of the second snapshot and parameter information of the first snapshot are sent to the kernel file system; The kernel file system parses the parameter information of the second snapshot and the parameter information of the first snapshot to acquire the source logical block addressing address of the second snapshot and the destination logical block addressing address of the first snapshot.

3. The method of claim 2, wherein, The source logical block addressing address and the destination logical block addressing address are sent to the storage device, which comprises: The kernel file system sends a snapshot merging request to the storage device; the snapshot merging request is used to instruct the storage device to copy data blocks of the second snapshot to the destination logical block addressing address based on the source logical block addressing address, and then delete the data blocks of the second snapshot.

4. The method of claim 2, wherein, The parameter information of the second snapshot comprises a source file offset address of the second snapshot and a data length of the second snapshot; and the parameter information of the first snapshot comprises a file offset address of the first snapshot; The source logical block addressing address of the second snapshot and the destination logical block addressing address of the first snapshot are acquired, which comprises: A destination file offset address of the first snapshot, a source file offset address of the second snapshot and a data length of the second snapshot are acquired; The destination logical block addressing address of the first snapshot is acquired according to the destination file offset address of the first snapshot and the data length of the second snapshot; The source logical block addressing address of the second snapshot is acquired according to the source file offset address of the second snapshot.

5. The method of claim 4, wherein, The method further comprises: The number of data blocks of the second snapshot is determined according to the data length of the second snapshot; The number of data blocks of the second snapshot is sent to the storage device; The data of the source logical block addressing address is copied to the destination logical block addressing address according to the number of data blocks. The method further comprises:

6. The method of claim 3, wherein, ​ obtaining a return result corresponding to the snapshot merge request; the return result is generated after the storage device performs an operation of copying a data block of the second snapshot to the target logical block addressing address according to the snapshot merge request; in a case where the return result indicates that the data copying of the source logical block addressing address is successful, instructing the storage device to delete the second snapshot.

7. A virtual machine snapshot system, characterized by, The system comprises a data processing unit and a storage device. The data processing unit is configured to, when receiving a target instruction of deleting a second snapshot, obtain a source logical block addressing address of the second snapshot and a target logical block addressing address of a first snapshot. The data processing unit is configured to send the source logical block addressing address and the target logical block addressing address to the storage device. The storage device is configured to, after copying a data block of the second snapshot to the target logical block addressing address based on the source logical block addressing address, delete the data block of the second snapshot.

8. The system of claim 7, wherein, The data processing unit further runs a user mode program and a kernel file system; The data processing unit is configured to: When the user mode program receives a target instruction and triggers an operation of deleting a second snapshot, send parameter information of the second snapshot and parameter information of a first snapshot to the kernel file system. The kernel file system parses the parameter information of the second snapshot and the parameter information of the first snapshot to obtain a source logical block addressing address of the second snapshot and a target logical block addressing address of the first snapshot.

9. A snapshot deletion apparatus characterized by comprising: The device is arranged in a target device, the target device is provided with a target virtual machine, and a storage device of the target device stores a first snapshot and a second snapshot of the target virtual machine, the first snapshot being a parent snapshot of the second snapshot; the device comprises: An address obtaining module is configured to, when receiving a target instruction of deleting a second snapshot, obtain a source logical block addressing address of the second snapshot and a target logical block addressing address of a first snapshot. An address sending module is configured to send the source logical block addressing address and the target logical block addressing address to the storage device, so that the storage device deletes a data block of the second snapshot after copying the data block of the second snapshot to the target logical block addressing address based on the source logical block addressing address.

10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer instructions, and the computer instructions are used to make a computer execute the snapshot deletion method in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Method for implementing data storage snapshot based on solid state disk, and solid state disk

    CN102591790A

  • Virtual machine online snapshot generating and deleting method

    CN104375877A