Snapshot rollback method and device, electronic equipment and storage medium

By creating the first snapshot and the second snapshot during the snapshot rollback process and writing the data into the corresponding metadata structure, the problem that host data cannot be written simultaneously during the snapshot rollback process is solved, and the host data writing is implemented simultaneously, reducing the impact on host business.

CN120336088APending Publication Date: 2025-07-18INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510465532.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-14
Publication Date
2025-07-18

Smart Images

  • Figure CN120336088A_ABST
    Figure CN120336088A_ABST
Patent Text Reader

Abstract

The invention discloses a snapshot rollback method and device, electronic equipment and a storage medium, and relates to the technical field of data storage, the snapshot rollback method comprises the steps that in response to a received snapshot rollback request for a source volume, a first snapshot of the source volume is created, a snapshot identifier of the first snapshot is determined, and the snapshot rollback request comprises a snapshot identifier of a target snapshot; based on the snapshot identifier of the first snapshot, determining a snapshot identifier of a second snapshot of the source volume, the snapshot identifier of the second snapshot being obtained by adding one to the snapshot identifier of the first snapshot; and writing the data with the snapshot identifier of the target snapshot into the metadata structure of the first snapshot, and writing the host data into the metadata structure with the snapshot identifier of the second snapshot so as to complete snapshot rollback, thereby solving the problem that the host data cannot be written simultaneously in the snapshot rollback process in a related scheme, so that the snapshot rollback efficiency is improved. The method and the device solve the technical problem of influence on the host service due to the snapshot rollback, and achieve the technical effect of reducing the influence on the host service by writing the host data while the snapshot rollback is carried out.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of data storage, and particularly to a snapshot rollback method, apparatus, electronic device, and storage medium. Background Art

[0002] In related snapshot rollback solutions, only rollback data can be written during the rollback process, and host data cannot be written until the entire rollback process is completed. If the source volume contains a large amount of data, the rollback process will take a long time. Since host data cannot be written simultaneously during the rollback process, the long rollback process will extend the recovery time objective of host data writing, thereby affecting host services. Summary of the Invention

[0003] This application provides a snapshot rollback method, apparatus, electronic device, and storage medium to at least solve the problem in related technologies that host data cannot be written simultaneously during the rollback process, affecting host services.

[0004] This application provides a snapshot rollback method, including:

[0005] In response to receiving a snapshot rollback request for a source volume, creating a first snapshot of the source volume and determining the snapshot identifier of the first snapshot, where the snapshot rollback request includes the snapshot identifier of the target snapshot;

[0006] Based on the snapshot identifier of the first snapshot, determining the snapshot identifier of a second snapshot of the source volume, where the snapshot identifier of the second snapshot is obtained by adding one to the snapshot identifier of the first snapshot;

[0007] Writing data with the snapshot identifier of the target snapshot into the metadata structure of the first snapshot, and writing host data into the metadata structure with the snapshot identifier of the second snapshot to complete the snapshot rollback.

[0008] This application also provides a snapshot rollback apparatus, including:

[0009] A creation unit, configured to create a first snapshot of the source volume and determine the snapshot identifier of the first snapshot in response to receiving a snapshot rollback request for the source volume, where the snapshot rollback request includes the snapshot identifier of the target snapshot;

[0010] A determination unit, configured to determine the snapshot identifier of a second snapshot of the source volume based on the snapshot identifier of the first snapshot, where the snapshot identifier of the second snapshot is obtained by adding one to the snapshot identifier of the first snapshot;

[0011] A rollback unit, configured to write data with the snapshot identifier of the target snapshot into the metadata structure of the first snapshot, and write host data into the metadata structure with the snapshot identifier of the second snapshot to complete the snapshot rollback.

[0012] The present application also provides an electronic device, including: a memory for storing a computer program; a processor for implementing the steps of any of the above snapshot rollback methods when executing the computer program.

[0013] The present application also provides a computer-readable storage medium storing a computer program, wherein the computer program implements the steps of any of the above snapshot rollback methods when executed by a processor.

[0014] The present application also provides a computer program product including a computer program that implements the steps of any of the above snapshot rollback methods when executed by a processor.

[0015] Through the present application, in response to receiving a snapshot rollback request for a source volume, a first snapshot of the source volume is created and a snapshot identifier of the first snapshot is determined, and the snapshot rollback request includes a snapshot identifier of a target snapshot; based on the snapshot identifier of the first snapshot, a snapshot identifier of a second snapshot of the source volume is determined, and the snapshot identifier of the second snapshot is obtained by adding one to the snapshot identifier of the first snapshot; data with the snapshot identifier of the target snapshot is written into the metadata structure of the first snapshot, and host data is written into the metadata structure with the snapshot identifier of the second snapshot to complete the snapshot rollback, solving the technical problem in related solutions that host data writing cannot be performed simultaneously during the snapshot rollback process, affecting the host service, and achieving the technical effect of performing host data writing simultaneously during the snapshot rollback, thereby reducing the impact on the host service. Description of the Drawings

[0016] The drawings are used to better understand the present solution and do not limit the present disclosure. Among them:

[0017] Figure 1 It is a schematic diagram of a snapshot time point provided by an embodiment of the present application;

[0018] Figure 2 It is a schematic diagram of a snapshot rollback provided by an embodiment of the present application;

[0019] Figure 3 It is a schematic flowchart of a snapshot rollback method provided by an embodiment of the present application;

[0020] Figure 4 It is a schematic diagram of a snapshot rollback provided by an embodiment of the present application;

[0021] Figure 5 It is a schematic diagram of a snapshot rollback provided by an embodiment of the present application;

[0022] Figure 6 It is a schematic structural diagram of a snapshot rollback device provided by an embodiment of the present application. Detailed Embodiments

[0023] The following will clearly and completely describe the technical solutions in the embodiments of the present application in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the protection scope of the present application.

[0024] It should be noted that in the description of the present application, the terms "include", "comprise" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or further includes elements inherent to such process, method, article or device. The terms "first", "second", etc. in the present application are used to distinguish similar objects, rather than to describe a specific order or sequence.

[0025] In order to enable those skilled in the art of this technology to better understand the solution of the present application, the following will further describe the present application in detail in conjunction with the accompanying drawings and specific implementation manners.

[0026] Combined with the specific application environment architecture or specific hardware architecture on which the execution of the snapshot rollback method depends, the specific application environment architecture or specific hardware architecture will be described herein.

[0027] The embodiments of the present application provide a snapshot rollback method, and the method will be described in detail in combination with the execution process of the snapshot rollback method.

[0028] Copy On Write (COW) means that when the data on the source volume changes, COW will first copy the old data block to a new location, and then allow the original data block to be modified.

[0029] Redirect On Write (ROW) means that when the data changes, the new data is directly written to a new location, and the metadata is updated to point to the new location. This method avoids additional data copying and improves the write performance.

[0030] TimePoint (TP) refers to the timestamp when the snapshot is created.

[0031] Input Output (IO) refers to the process of a computer system exchanging data with external devices.

[0032] Logical Block Address (LBA) represents the address of data at the logical level.

[0033] The Physical Block Address (PBA) represents the address where data is stored on the physical storage device of the hard disk.

[0034] The metadata structure is used to maintain the logical mapping relationship between the LBA and the PBA. When applying to read and write data, as long as the logical block address is given, the storage system can find the physical block address where the data is stored on the hard disk according to the metadata structure.

[0035] The Recovery Time Objective (RTO) refers to the time period from when a data disaster occurs until the information system or business function must resume operation after stopping.

[0036] For a storage system, data backup is an essential function. Volume snapshots are often considered an important means to achieve data backup. A volume snapshot refers to an immediate data backup of the source volume in the storage system at a specific point in time locally. If the data of the source volume is damaged due to misoperation or malicious destruction, such as data corruption caused by ransomware, it can be repaired by snapshot rollback. In practical applications, data analysis, data mining, etc. can be performed on the data of the snapshot volume without affecting the data and business of the source volume.

[0037] In related snapshot rollback schemes, for the thin volume architecture based on all-flash memory, when taking a snapshot of the source volume, ROW is usually used to optimize the snapshot operation. Compared with the previous COW method, after taking a snapshot of the source volume, when writing to the source volume, there is no need to copy data, and the data can be written directly. ROW provides higher efficiency and performance advantages. When writing IO, the system will mark a specific time point TP for the data written this time. TP is used to distinguish the data versions of different generations of snapshots, so that the data of each generation of snapshots can be distinguished and all snapshot data can be saved.

[0038] The specific process of reading and writing the data of the source volume is as follows: The initial SnapID of the source volume is 0. When creating a lossless snapshot of a source volume, newSnapID(TP) is determined as the sum of SnapID and 1. When there is a write IO again for a specified LBA, a new (SnapID = newSnapID) L->P metadata structure will be generated, so as to achieve write IO performance close to lossless. The logic is as Figure 1 shown. Figure 1It is a schematic diagram of a snapshot time point provided in a related solution. At time T0, the initial SnapID is 0, and the source volume has 4 LBAs, namely L0, L1, L2, and L3. In the figure, Snap0L0, Snap0 L1, Snap0 L2, and Snap0 L3 are the metadata structures of each LBA when SnapID is 0. At time T1, snapshot 0 is created, and its corresponding SnapID is 0. At time T2, when new data is written to L0 and L2, new metadata structures Snap1 L0 and Snap1 L2 are generated. At time T3, snapshot 1 is created, and its corresponding SnapID is 1. At time T4, when new data is written to L0 and L1, new metadata structures Snap2 L0 and Snap2 L1 are generated. Since the SnapID is always monotonically increasing, reading the IO of the source volume always reads the LBA with the largest SnapID to achieve near-lossless read IO performance. For example, at T4, if reading L0 of the source volume, it is necessary to read the data on the PBA corresponding to Snap2 L0; if reading L1 of the source volume, it is necessary to read the data on the PBA corresponding to Snap2 L1; if reading L2 of the source volume, it is necessary to read the data on the PBA corresponding to Snap1 L2; if reading L3 of the source volume, it is necessary to read the data on the PBA corresponding to Snap0L3.

[0039] If the data in the source volume is damaged, it is necessary to roll back the snapshot, as Figure 2 shown Figure 2 It is a schematic diagram of snapshot rollback provided in a related solution. Specifically, at time T1, there are three snapshots, Snap0, Snap1, and Snap2. At this time, new IOs will be written into the metadata structure corresponding to Snap3. At time T2, if the snapshot to be rolled back is Snap1, that is, the corresponding SnapID is 1, for L0, it is detected that the snapshot data is Snap1 L0, and Snap1 L0 is used to overwrite and write to become Snap3 L0; for L1, it is detected that the snapshot data is Snap0 L1, and Snap0 L1 is used to replace Snap3L1; for L2, it is detected that the snapshot data is Snap1 L2, and Snap1 L2 is the latest data and does not require additional processing; for L3, it is detected that the snapshot data is Snap0L3, and Snap0 L3 is the latest data and does not require additional processing.

[0040] During the rollback process, it is impossible to read and write to the source volume simultaneously. The host write IO and the volume rollback write IO are mutually exclusive. That is, after writing to the source volume, it is no longer possible to perform overwrite writing for rollback on the source volume. Therefore, when rolling back the snapshot, reading and writing cannot be performed simultaneously, and the source volume cannot be made available in a timely manner. When the capacity of the source volume is very large, the rollback will take a long time. The inability to read and write to the volume means that the user's business is affected, extending the user's RTO and thus affecting the host business.

[0041] To solve the problems in related solutions, in response to receiving a snapshot rollback request for a source volume, this application creates a first snapshot of the source volume and determines the snapshot identifier of the first snapshot. The snapshot rollback request includes the snapshot identifier of the target snapshot. Based on the snapshot identifier of the first snapshot, determine the snapshot identifier of the second snapshot of the source volume, where the snapshot identifier of the second snapshot is obtained by adding one to the snapshot identifier of the first snapshot. Write the data with the snapshot identifier of the target snapshot into the metadata structure of the first snapshot, and write the host data into the metadata structure with the snapshot identifier of the second snapshot to complete the snapshot rollback, solving the technical problem in related solutions that during the snapshot rollback process, host data writing cannot be performed simultaneously, affecting the host service, and achieving the technical effect of performing host data writing simultaneously during snapshot rollback, thereby reducing the impact on the host service.

[0042] A snapshot rollback method provided by an embodiment of the present disclosure. The execution subject of this method can be a storage controller or a volume manager, and this method can be applied to a storage system or a database management system.

[0043] Figure 3 It is a schematic flowchart of a snapshot rollback method provided by an embodiment of the present disclosure.

[0044] As Figure 3 shown, this method includes the following steps:

[0045] Step 301, in response to receiving a snapshot rollback request for a source volume, create a first snapshot of the source volume and determine the snapshot identifier of the first snapshot. The snapshot rollback request includes the snapshot identifier of the target snapshot;

[0046] In some embodiments, a snapshot rollback request for a source volume is usually received when data is damaged or lost. Data damage is usually caused by misoperations (accidentally deleting files), hardware failures, malicious damage, or ransomware.

[0047] In some embodiments, the first snapshot of the source volume refers to the rollback snapshot, and the first snapshot is used to record the current data state of the source volume to ensure that no uncovered data is lost during the rollback process.

[0048] In some embodiments, each snapshot has a unique snapshot identifier, that is, SnapID. The snapshot identifier is used to distinguish different versions of snapshots. The snapshot identifier of the first snapshot is automatically generated by the system, usually incremented based on the current latest snapshot identifier. For example, if the current latest snapshot identifier is 2, then the snapshot identifier of the first snapshot is 3.

[0049] In some embodiments, the target snapshot refers to a previously created snapshot that saves the state of the source volume at a certain point in time. The snapshot identifier of the target snapshot is used to specify the time point to roll back to.

[0050] Step 302: Determine the snapshot identifier of the second snapshot of the source volume based on the snapshot identifier of the first snapshot. The snapshot identifier of the second snapshot is obtained by adding one to the snapshot identifier of the first snapshot.

[0051] In some embodiments, after the first snapshot is created, the system needs to process the read and write operations of the host. Therefore, the system generates a new snapshot identifier based on the snapshot identifier of the first snapshot to store the newly written data.

[0052] Step 303: Write the data with the snapshot identifier of the target snapshot into the metadata structure of the first snapshot, and write the host data into the metadata structure with the snapshot identifier of the second snapshot to complete the snapshot rollback.

[0053] In some embodiments, the data with the snapshot identifier of the target snapshot refers to the data to be rolled back.

[0054] In some embodiments, if the snapshot identifier of the target snapshot is 1, the snapshot identifier of the first snapshot SnapID is 3, and the SnapID of the second snapshot is 4, then write the data in the snapshot with SnapID 1 into the metadata structure with SnapID 3, and write the newly written data of the host into the metadata structure with SnapID 4.

[0055] In some embodiments, by writing the data with the snapshot identifier of the target snapshot into the metadata structure of the first snapshot, and writing the host data into the metadata structure with the snapshot identifier of the second snapshot, the host can continue to perform write operations during the snapshot rollback without waiting for the entire rollback process to complete, thereby ensuring business continuity and minimizing the impact on users.

[0056] Through the present application, in response to receiving a snapshot rollback request for a source volume, create a first snapshot of the source volume and determine the snapshot identifier of the first snapshot. The snapshot rollback request includes the snapshot identifier of the target snapshot; based on the snapshot identifier of the first snapshot, determine the snapshot identifier of the second snapshot of the source volume. The snapshot identifier of the second snapshot is obtained by adding one to the snapshot identifier of the first snapshot; write the data with the snapshot identifier of the target snapshot into the metadata structure of the first snapshot, and write the host data into the metadata structure with the snapshot identifier of the second snapshot to complete the snapshot rollback, solving the technical problem in the related solutions that during the snapshot rollback process, host data writing cannot be performed simultaneously, affecting the host business, and achieving the technical effect of performing host data writing simultaneously during the snapshot rollback, thereby reducing the impact on the host business.

[0057] In some embodiments, during snapshot rollback, the system needs to restore the source volume to the state of the target snapshot while allowing the host to continue with new read and write operations. To prevent the inability to distinguish between host IOs before and after rollback and to avoid conflicts between newly written data and the rollback process, it is necessary to temporarily control the host read and write requests first.

[0058] In some embodiments, in response to receiving a snapshot rollback request for the source volume, creating a first snapshot of the source volume and determining the snapshot identifier of the first snapshot includes:

[0059] In response to receiving a snapshot rollback request for the source volume, silencing the first read and write input / output requests for the source volume, where the first read and write input / output requests are read and write input / output requests after the timestamp corresponding to the snapshot rollback request;

[0060] In some embodiments, silencing the first read and write input / output requests for the source volume means pausing or delaying the read and write operations for a specific period of time, and the goal of silencing is to handle those read and write requests that occur after the timestamp corresponding to the snapshot rollback request.

[0061] In some embodiments, during the silencing period, these requests will be put into a queue for subsequent processing. Silencing usually only lasts for a very short time. Once the rollback process enters a stable state, the system will immediately resume processing these requests.

[0062] In some embodiments, by silencing the first read and write input / output requests for the source volume, the consistency of data before and after rollback can be ensured.

[0063] In response to the completion of the second read and write input / output request for the source volume, creating a first snapshot of the source volume and determining the snapshot identifier of the first snapshot, where the second read and write input / output request is a read and write input / output request before the timestamp corresponding to the snapshot rollback request.

[0064] In some embodiments, the second read and write input / output request may include an unfinished write operation or a request to attempt to read historical data.

[0065] In some embodiments, by creating a first snapshot of the source volume and determining the snapshot identifier of the first snapshot in response to the completion of the second read and write input / output request for the source volume, it is possible to ensure that the snapshot rollback operation is based on a consistent and stable data state, which can not only improve the reliability and accuracy of snapshot rollback but also reduce the impact on host services.

[0066] In some embodiments, after creating a first snapshot of the source volume and determining the snapshot identifier of the first snapshot in response to the completion of the second read and write input / output request for the source volume, the snapshot rollback method further includes:

[0067] Resume the first read / write input / output request for the source volume.

[0068] In some embodiments, after resuming the first read / write input / output request for the source volume, the host is in an available state at any time, that is, the host can perform write operations on the source volume at any time and can continue with the first read / write input / output request that was previously silenced.

[0069] In some embodiments, the snapshot rollback method further includes:

[0070] In response to the logical block address not having a corresponding metadata structure in the metadata structure with the snapshot identifier of the target snapshot, obtain the snapshot identifier of the third snapshot, where the snapshot identifier of the third snapshot is less than the snapshot identifier of the target snapshot;

[0071] In some embodiments, the logical block address not having a corresponding metadata structure in the metadata structure with the snapshot identifier of the target snapshot means that no new data was written to the logical block address at the time point corresponding to the snapshot identifier of the target snapshot, as described above Figure 1 In the above, when L1 had no new data written when SnapID was 1, it was necessary to find the data in the snapshots before that time point, such as when the SnapID of the third snapshot was 0.

[0072] Write the data with the snapshot identifier of the third snapshot into the metadata structure with the snapshot identifier of the first snapshot.

[0073] In some embodiments, the data with the snapshot identifier of the third snapshot refers to the data in the physical block address corresponding to L1 with SnapID 0.

[0074] In some embodiments, after the snapshot rollback is completed, the system needs to clean up the metadata structure of the first snapshot to ensure that only those metadata structures that have not been overwritten or updated are retained, which can avoid unnecessary storage overhead and improve the efficiency of subsequent data reading.

[0075] In some embodiments, after writing the data with the snapshot identifier of the target snapshot into the metadata structure of the first snapshot and writing the host data into the metadata structure with the snapshot identifier of the second snapshot to complete the snapshot rollback, the snapshot rollback method further includes:

[0076] Obtain multiple logical block addresses included in the metadata structure of the first snapshot;

[0077] In some embodiments, in different snapshot volumes, the data corresponding to the same logical block address may be the same or different. Among them, the data corresponding to the same logical block address being the same indicates that the data has not been modified, and the data corresponding to the same logical block address being different indicates that the data has been updated. The number of logical block addresses in this application is not limited.

[0078] In response to finding the first logical block address among multiple logical block addresses in the metadata structure with the snapshot identifier of the second snapshot, delete the metadata structure corresponding to the first logical block address in the first snapshot;

[0079] In some embodiments, the first logical block address is used to indicate data that has been rollback-written and overwritten by the host. In this case, only the data overwritten by the host needs to be retained.

[0080] In some embodiments, by responding to finding the first logical block address among multiple logical block addresses in the metadata structure with the snapshot identifier of the second snapshot and deleting the metadata structure corresponding to the first logical block address in the first snapshot, storage space can be freed up to avoid saving redundant metadata structures.

[0081] In response to not finding the second logical block address among multiple logical block addresses in the metadata structure with the snapshot identifier of the second snapshot, retain the metadata structure corresponding to the second logical block address in the first snapshot.

[0082] In some embodiments, the second logical block address is used to indicate data that has not been overwritten by new writes from the host. These data blocks are still valid historical data and may be accessed or used.

[0083] In some embodiments, the snapshot rollback method further includes:

[0084] In response to receiving a host data read request, obtain the rollback identifier of the first snapshot;

[0085] In some embodiments, the rollback identifier of the first snapshot is determined when the first snapshot is created.

[0086] Based on the rollback identifier of the first snapshot, determine the data read by the host.

[0087] In some embodiments, when receiving a host data read request, it is necessary to first check the LBA involved in the request and the status of the current source volume, and determine the data to be read based on the LBA involved in the request and the status of the current source volume.

[0088] In some embodiments, determining the data read by the host based on the rollback identifier of the first snapshot includes:

[0089] Based on the rollback identifier of the first snapshot, determine whether the source volume is in a rollback state;

[0090] In some embodiments, if the rollback identifier of the first snapshot is true, it indicates that the source volume is in a rollback state; if the rollback identifier of the first snapshot is false, it indicates that the source volume is in a non-rollback state.

[0091] In some embodiments, if the source volume is in a rollback state, it is necessary to determine whether the source volume has been overwritten with data by the host.

[0092] If the source volume is in a rollback state, determine the first physical block address corresponding to the third logical block address from the metadata structure of the first snapshot, and determine the data read from the first physical block address as the data read by the host.

[0093] In some embodiments, the third logical block address refers to the logical block address corresponding to the data that has been overwritten by the host after rollback writing. At this time, the data read by the host is the data overwritten by the host.

[0094] If the source volume is not in a rollback state, determine the second physical block address corresponding to the fourth logical block address from the metadata structure of the second snapshot, and determine the data read from the second physical block address as the data read by the host.

[0095] In some embodiments, the fourth logical block address refers to the logical block address corresponding to the data that has only been rollback written. At this time, the data read by the host is the data rollback written.

[0096] In some embodiments, by dynamically judging the state of the source volume based on the rollback flag of the first snapshot and reading data from the correct snapshot, consistent and efficient data access can be provided at different stages of snapshot rollback, improving the reliability and performance of the system.

[0097] In some embodiments, as Figure 4 shown Figure 4A schematic diagram of snapshot rollback provided by an embodiment of this application. At time T1, there are three snapshots, Snap0, Snap1, and Snap2. At time T2, assume the target snapshot (the snapshot to be rolled back) is Snap1, and the corresponding SnapID is 1. Create the first snapshot, which is the rollback snapshot, and the SnapID corresponding to the rollback snapshot is 3. The snapshot identifier of the second snapshot is the latest SnapID plus one, which is 4. Set the rollback flag Restoring to true, and the rollback SnapID RestoringSnapID to 1. At time T3, after the rollback is completed, for L0, it is detected that the snapshot data is Snap1 L0, and Snap1 L0 is overwritten and written into Snap3 L0. If the host writes data, it is directly written into Snap4 L0. When the host reads data, it is detected whether Snap4 L0 exists. If it exists, it means the host has overwritten and written, and Snap4 L0 is directly read; if it does not exist, when it is detected that it is in the rollback state, the snapshot data Snap1 L0 is directly read. For L1, it is detected that the snapshot data is Snap0 L1, and Snap0 L1 is overwritten and written into Snap3 L1; if the host writes data, it is also directly written into Snap4 L1. When the host reads data, it also first detects whether Snap4 L1 exists to determine whether to read Snap4 L1 or the snapshot data Snap0 L1; for L2, it is detected that the snapshot data is Snap0 L2, and Snap0 L2 is directly written into Snap3 L2; for L3, it is detected that the snapshot data is Snap0 L3, and Snap0 L3 is directly written into Snap3 L3.

[0098] In some embodiments, as Figure 5 shown, Figure 5 A schematic diagram of snapshot rollback provided by an embodiment of this application. After the snapshot rollback is completed, the first snapshot (SnapID is 3) is deleted, and after deletion, the system will automatically recycle the deleted data in the garbage collection manner. For L0, it is detected that Snap3 L0 is not the latest data, and Snap3 L0 is recycled and deleted; for L1, it is detected that Snap3 L1 is not the latest data, and Snap3 L1 is recycled and deleted; for L2, it is detected that Snap3 L2 is the latest data, and Snap3 L2 is not deleted first. If the host writes later, Snap3 L2 will be recycled and deleted; for L2, it is detected that Snap3 L3 is the latest data, and Snap3 L3 is also not deleted first.

[0099] Through this application, in response to receiving a snapshot rollback request for a source volume, a first snapshot of the source volume is created and the snapshot identifier of the first snapshot is determined. The snapshot rollback request includes the snapshot identifier of a target snapshot. Based on the snapshot identifier of the first snapshot, the snapshot identifier of a second snapshot of the source volume is determined. The snapshot identifier of the second snapshot is obtained by incrementing the snapshot identifier of the first snapshot by one. Data with the snapshot identifier of the target snapshot is written into the metadata structure of the first snapshot, and host data is written into the metadata structure with the snapshot identifier of the second snapshot to complete the snapshot rollback. This solves the technical problem in related solutions that during the snapshot rollback process, host data writing cannot be performed simultaneously, affecting host services, and achieves the technical effect of performing host data writing simultaneously during snapshot rollback, thereby reducing the impact on host services.

[0100] Through the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by means of software plus a necessary general hardware platform. Of course, it can also be implemented by hardware, but in many cases the former is a better implementation.

[0101] An embodiment of this application also provides a snapshot rollback device 600. Figure 6 It is a schematic structural diagram of a snapshot rollback device provided by an embodiment of the present disclosure, as Figure 6 shown, including:

[0102] A creation unit 601, configured to create a first snapshot of a source volume and determine the snapshot identifier of the first snapshot in response to receiving a snapshot rollback request for the source volume. The snapshot rollback request includes the snapshot identifier of a target snapshot.

[0103] A determination unit 602, configured to determine the snapshot identifier of a second snapshot of the source volume based on the snapshot identifier of the first snapshot. The snapshot identifier of the second snapshot is obtained by incrementing the snapshot identifier of the first snapshot by one.

[0104] A rollback unit 603, configured to write data with the snapshot identifier of the target snapshot into the metadata structure of the first snapshot, and write host data into the metadata structure with the snapshot identifier of the second snapshot to complete the snapshot rollback.

[0105] By creating a first snapshot of the source volume and determining the snapshot identifier of the first snapshot in response to receiving a snapshot rollback request for the source volume, where the snapshot rollback request includes the snapshot identifier of the target snapshot; determining the snapshot identifier of a second snapshot of the source volume based on the snapshot identifier of the first snapshot, where the snapshot identifier of the second snapshot is obtained by incrementing the snapshot identifier of the first snapshot by one; writing data with the snapshot identifier of the target snapshot into the metadata structure of the first snapshot, and writing host data into the metadata structure with the snapshot identifier of the second snapshot to complete the snapshot rollback, the technical problem in related solutions that host data writing cannot be performed simultaneously during snapshot rollback, affecting host services, is solved, and the technical effect of performing host data writing simultaneously during snapshot rollback, thereby reducing the impact on host services, is achieved.

[0106] Further, in a possible implementation manner of the embodiments of the present disclosure, the creating unit 601 is configured to:

[0107] In response to receiving a snapshot rollback request for the source volume, silence the first read / write input / output request for the source volume, where the first read / write input / output request is a read / write input / output request after the time stamp corresponding to the snapshot rollback request;

[0108] In response to the completion of the second read / write input / output request for the source volume, create a first snapshot of the source volume and determine the snapshot identifier of the first snapshot, where the second read / write input / output request is a read / write input / output request before the time stamp corresponding to the snapshot rollback request.

[0109] Further, in a possible implementation manner of the embodiments of the present disclosure, the snapshot rollback device 600 further includes a recovery unit, and the recovery unit is configured to:

[0110] Recover the first read / write input / output request for the source volume.

[0111] Further, in a possible implementation manner of the embodiments of the present disclosure, the snapshot rollback device 600 further includes a writing unit, and the writing unit is configured to:

[0112] In response to the logical block address having no corresponding metadata structure in the metadata structure with the snapshot identifier of the target snapshot, obtain the snapshot identifier of a third snapshot, where the snapshot identifier of the third snapshot is less than the snapshot identifier of the target snapshot;

[0113] Write the data with the snapshot identifier of the third snapshot into the metadata structure with the snapshot identifier of the first snapshot.

[0114] Further, in a possible implementation manner of the embodiments of the present disclosure, the snapshot rollback device 600 further includes a deletion unit, and the deletion unit is configured to:

[0115] Obtain the multiple logical block addresses included in the metadata structure of the first snapshot;

[0116] In response to finding a first logical block address among a plurality of logical block addresses in a metadata structure with a snapshot identifier of a second snapshot, delete the metadata structure corresponding to the first logical block address in the first snapshot;

[0117] In response to not finding a second logical block address among a plurality of logical block addresses in a metadata structure with a snapshot identifier of a second snapshot, retain the metadata structure corresponding to the second logical block address in the first snapshot.

[0118] Further, in a possible implementation manner of an embodiment of the present disclosure, the snapshot rollback device 600 further includes a data determination unit, and the data determination unit is configured to:

[0119] In response to receiving a host data reading request, obtain a rollback identifier of the first snapshot;

[0120] Based on the rollback identifier of the first snapshot, determine the host data to be read.

[0121] Further, in a possible implementation manner of an embodiment of the present disclosure, the data determination unit is further configured to:

[0122] Based on the rollback identifier of the first snapshot, determine whether the source volume is in a rollback state;

[0123] If the source volume is in a rollback state, determine a first physical block address corresponding to a third logical block address from the metadata structure of the first snapshot, and determine the data read from the first physical block address as the host data to be read;

[0124] If the source volume is not in a rollback state, determine a second physical block address corresponding to a fourth logical block address from the metadata structure of the second snapshot, and determine the data read from the second physical block address as the host data to be read.

[0125] For the description of the features in the embodiments corresponding to the snapshot rollback device, reference may be made to the relevant description of the embodiments corresponding to the snapshot rollback method, which will not be elaborated here one by one.

[0126] An embodiment of the present application further provides an electronic device, including a memory and a processor. A computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the embodiments of the above snapshot rollback method.

[0127] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored. The computer program is configured to execute the steps in any one of the embodiments of the above snapshot rollback method when running.

[0128] In an exemplary embodiment, the above computer-readable storage medium may include, but is not limited to: various media that can store computer programs, such as USB flash drives, read-only memory (ROM), random access memory (RAM), mobile hard disks, magnetic disks, or optical discs.

[0129] An embodiment of the present application also provides a computer program product. The above computer program product includes a computer program, and when the computer program is executed by a processor, it implements the steps in any of the above-described snapshot rollback method embodiments.

[0130] An embodiment of the present application also provides another computer program product, including a non-volatile computer-readable storage medium. The non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it implements the steps in any of the above-described snapshot rollback method embodiments.

[0131] Those skilled in the art can further realize that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. To clearly illustrate the interchangeability of hardware and software, the components and steps of each example have been generally described according to their functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Skilled professionals can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present application.

[0132] The above has introduced in detail a snapshot rollback method, device, electronic device, and storage medium provided by the present application. Specific examples are used herein to elaborate on the principles and implementation manners of the present application. The description of the above embodiments is only used to help understand the method and its core idea of the present application. It should be noted that for those of ordinary skill in the art in the technical field, without departing from the principle of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the protection scope of the claims of the present application.

Claims

1. A snapshot rollback method, characterized in that, Including: In response to receiving a snapshot rollback request for a source volume, creating a first snapshot of the source volume and determining a snapshot identifier of the first snapshot, where the snapshot rollback request includes a snapshot identifier of a target snapshot; Based on the snapshot identifier of the first snapshot, determining a snapshot identifier of a second snapshot of the source volume, where the snapshot identifier of the second snapshot is obtained by adding one to the snapshot identifier of the first snapshot; Writing data with the snapshot identifier of the target snapshot into a metadata structure of the first snapshot, and writing host data into a metadata structure with the snapshot identifier of the second snapshot to complete the snapshot rollback.

2. The snapshot rollback method according to claim 1, wherein The step of "In response to receiving a snapshot rollback request for a source volume, creating a first snapshot of the source volume and determining a snapshot identifier of the first snapshot" includes: In response to receiving a snapshot rollback request for a source volume, silencing a first read / write input / output request for the source volume, where the first read / write input / output request is a read / write input / output request after the timestamp corresponding to the snapshot rollback request; In response to completion of a second read / write input / output request for the source volume, creating a first snapshot of the source volume and determining a snapshot identifier of the first snapshot, where the second read / write input / output request is a read / write input / output request before the timestamp corresponding to the snapshot rollback request.

3. The snapshot rollback method according to claim 2, wherein After the step of "In response to completion of a second read / write input / output request for a source volume, creating a first snapshot of the source volume and determining a snapshot identifier of the first snapshot", the method further includes: Restoring the first read / write input / output request for the source volume.

4. The snapshot rollback method according to claim 1, wherein The method further includes: In response to a logical block address having no corresponding metadata structure in the metadata structure with the snapshot identifier of the target snapshot, obtaining a snapshot identifier of a third snapshot, where the snapshot identifier of the third snapshot is less than the snapshot identifier of the target snapshot; Writing data with the snapshot identifier of the third snapshot into the metadata structure with the snapshot identifier of the first snapshot.

5. The snapshot rollback method according to claim 1, wherein After the step of "Writing data with the snapshot identifier of the target snapshot into a metadata structure of the first snapshot, and writing host data into a metadata structure with the snapshot identifier of the second snapshot to complete the snapshot rollback", the method further includes: Obtaining a plurality of logical block addresses included in the metadata structure of the first snapshot; In response to finding a first logical block address among the plurality of logical block addresses in the metadata structure with the snapshot identifier of the second snapshot, deleting the metadata structure corresponding to the first logical block address in the first snapshot; In response to not finding a second logical block address among the plurality of logical block addresses in the metadata structure with the snapshot identifier of the second snapshot, retaining the metadata structure corresponding to the second logical block address in the first snapshot.

6. The snapshot rollback method according to claim 1, wherein The method further includes: In response to receiving a host data read request, obtaining a rollback identifier of the first snapshot; Based on the rollback identifier of the first snapshot, determining the host read data.

7. The snapshot rollback method according to claim 6, characterized in that, The step of "Based on the rollback identifier of the first snapshot, determining the host read data" includes: Based on the rollback identifier of the first snapshot, determining whether the source volume is in a rollback state; If the source volume is in a rollback state, determine the first physical block address corresponding to the third logical block address from the metadata structure of the first snapshot, and determine the data read from the first physical block address as the data read by the host; If the source volume is not in a rollback state, determine the second physical block address corresponding to the fourth logical block address from the metadata structure of the second snapshot, and determine the data read from the second physical block address as the data read by the host.

8. A snapshot rollback device, characterized in that Comprising: A creation unit, configured to create a first snapshot of the source volume and determine a snapshot identifier of the first snapshot in response to receiving a snapshot rollback request for the source volume, where the snapshot rollback request includes a snapshot identifier of a target snapshot; A determination unit, configured to determine a snapshot identifier of a second snapshot of the source volume based on the snapshot identifier of the first snapshot, where the snapshot identifier of the second snapshot is obtained by adding one to the snapshot identifier of the first snapshot; A rollback unit, configured to write data with the snapshot identifier of the target snapshot into the metadata structure of the first snapshot, and write host data into the metadata structure with the snapshot identifier of the second snapshot to complete snapshot rollback.

9. An electronic device, characterized in that, Comprising: A memory, configured to store a computer program; A processor, configured to implement the steps of the snapshot rollback method according to any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium, characterized in that, A computer program is stored in the computer-readable storage medium, where the computer program implements the steps of the snapshot rollback method according to any one of claims 1 to 7 when executed by a processor.

Citation Information

Cited By

  • System snapshot storage method and device, electronic equipment and storage medium

    CN121301287A