Snapshot data processing method and electronic device

CN122470440BActive Publication Date: 2026-09-11INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202610966198.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-06-30
Publication Date
2026-09-11
Estimated Expiration
2046-06-30

AI Technical Summary

Technical Problem

[0003]本发明提供了一种快照数据处理方法及电子设备,以至少解决相关技术中采用写时重定向方式生成源逻辑单元的多个代次的快照时存在的存储空间浪费的问题

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122470440B_ABST
    Figure CN122470440B_ABST
Patent Text Reader

Abstract

The application discloses a snapshot data processing method and electronic equipment, and relates to the technical field of storage. When data is written to a target logical address of a source logical unit, whether the data corresponding to the target logical address in two different generations of snapshots in multiple generations of snapshots is compared, and when the data is the same, only the mapping relationship and the corresponding physical space of the first generation of snapshots at the target logical address are retained, and the mapping relationship and the corresponding physical space of the second generation of snapshots at the target logical address are released or not occupied, so that repeated data across generations is only saved in one of the multiple generations of snapshots. When a read command is received, the second generation of snapshots can read correct data based on the first generation of snapshots or the source logical unit, thereby solving the technical problem of data space and metadata space waste caused by repeated writing of the same data in the multiple generations of snapshots, and achieving the technical effect of saving the data space and the metadata space occupied by the snapshots under the premise of ensuring the integrity of the snapshot data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of storage technology, and more particularly to a snapshot data processing method and electronic device. Background Technology

[0002] With the development of digital information technology, enterprises have an increasingly urgent need for data security, driving the rapid evolution of storage technology. Snapshot technology, as a data backup technology, has been widely used. Snapshots based on Redirect-on-write (ROW) technology support creating multiple generations of snapshots for the same source logical unit number (LUN). However, when multiple generations of snapshots exist for the same source logical unit, and the same data is repeatedly written to that source logical unit, it will result in multiple generations of snapshots backing up the same data, causing a waste of data space and metadata space. Summary of the Invention

[0003] This invention provides a snapshot data processing method and an electronic device to at least solve the problem of wasted storage space when generating multiple generations of snapshots of source logic units using write-time redirection in related technologies.

[0004] This invention provides a snapshot data processing method, comprising: In response to writing data to the target logical address of the source logical unit, compare whether the data corresponding to the target logical address is the same in two snapshots of different generations of the source logical unit. If the comparison results are the same, the mapping relationship of the first generation snapshot at the target logical address and the corresponding physical space are retained, and the mapping relationship of the second generation snapshot at the target logical address and the corresponding physical space are released or not occupied. In response to a read command on the target logical address of the second generation snapshot, the mapping relationship of the target logical address is read based on the first generation snapshot or the source logical unit, and the data of the target logical address is read according to the mapping relationship; The first generation snapshot and the second generation snapshot are snapshots from two different generations.

[0005] The present invention also provides an electronic device, comprising: a memory for storing a computer program; and a processor for implementing the steps of any of the snapshot data processing methods described above when executing the computer program.

[0006] Through this invention, when writing data to the target logical address of the source logical unit, the data corresponding to the target logical address of two different generations of snapshots in multiple generations are compared to see if they are the same. If they are the same, only the mapping relationship and corresponding physical space of the first generation snapshot at the target logical address are retained, while the mapping relationship and corresponding physical space of the second generation snapshot at the target logical address are released or not occupied. This ensures that duplicate data across generations is saved only once in multiple generations of snapshots. Furthermore, when the second generation snapshot receives a read command, it can read the correct data based on the first generation snapshot or the source logical unit, thereby eliminating redundant backups without losing data. Therefore, this invention can solve the technical problem of wasting data space and metadata space caused by repeatedly writing the same data in multi-generation snapshot scenarios, achieving the technical effect of saving the data space and metadata space occupied by snapshots while ensuring the integrity of snapshot data. Attached Figure Description

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

[0008] Figure 1 A schematic diagram of the initial state of snapshot activation and the corresponding bitmap; Figure 2 A diagram illustrating copy-on-write of data for a single snapshot and its corresponding bitmap; Figure 3 A configuration diagram for multiple generations of snapshots; Figure 4 A schematic diagram of copy-on-write of data for multiple generations of snapshots and the corresponding bitmaps; Figure 5 This is a configuration diagram for when there are three generations of snapshots; Figure 6 This is a diagram illustrating how repeatedly writing the same data in related technologies can lead to wasted space. Figure 7 An architecture diagram of a snapshot data processing system provided in an embodiment of the present invention; Figure 8 A flowchart of a first snapshot data processing method provided in an embodiment of the present invention; Figure 9 This is a schematic diagram illustrating a scenario of writing duplicate data according to an embodiment of the present invention; Figure 10 This is a schematic diagram of the mapping relationship and corresponding bitmap after removing redundant data, provided in an embodiment of the present invention. Figure 11A flowchart of a second snapshot data processing method provided in an embodiment of the present invention. Detailed Implementation

[0009] 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, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of the present invention.

[0010] It should be noted that, in the description of this invention, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. The terms "first," "second," etc., used in this invention are used to distinguish similar objects and are not used to describe a specific order or sequence.

[0011] To enable those skilled in the art to better understand the present invention, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0012] Here, we will first explain some key terms used in the embodiments of the present invention.

[0013] Source logical unit: refers to the logical storage unit that provides data reading and writing services to the outside world. The following explanation uses the source logical unit number (LUN) as an example, such as source logical unit (LUN A). The storage space of the source logical unit is divided into multiple logical addresses, which are referred to as L1, L2, and L3 in the following text to represent different logical addresses.

[0014] Physical location: refers to the actual location where data is stored on the physical storage medium. In the following text, P1, P2, P3, etc. are used to represent different physical locations.

[0015] Mapping relationship: This refers to the correspondence between logical addresses and physical locations. For example, the mapping relationship between L2 and P2 is denoted as L2P2, which is used to locate the actual physical location when reading data from a logical address. The mapping relationship is recorded by metadata, and the metadata itself also occupies storage space.

[0016] A snapshot is a consistent copy of the source data at a specific point in time. It is a fully usable copy of a specified dataset, containing a static image of the source data at that point in time. Snapshots enable near-zero backup window hot backups.

[0017] Multi-generation snapshots refer to multiple snapshots of the same source logic unit created sequentially at different points in time. For example, if a snapshot of source logic unit (LUN A) is created at the first time point to obtain the first snapshot (LUN B), and a snapshot is created at the second time point to obtain the second snapshot (LUN C), then the first snapshot (LUN B) and the second snapshot (LUN C) are two snapshots of the source logic unit (LUN A) from different generations. The generation created earlier is older, and the generation created later is newer.

[0018] Copy on Write (COW) and Redirect on Write (ROW) are two implementation mechanisms for snapshots. The solution in this embodiment of the invention can be applied to multi-generational snapshots created based on the Redirect on Write method.

[0019] Bitmap: This refers to an identifier table used to record whether each logical address in a snapshot has been backed up. Each logical address corresponds to an identifier bit in the bitmap. An initial identifier bit (e.g., 0) indicates that the logical address has not been written to and a snapshot copy has not yet been generated after the creation of this generation of snapshots; a set identifier bit (e.g., 1) indicates that the logical address has been written to and a snapshot copy has been generated after the creation of this generation of snapshots.

[0020] Fingerprint: A fingerprint is a characteristic value obtained by hashing a piece of data. If two pieces of data have the same fingerprint, they are considered to be the same.

[0021] Snapshot technology supports both creating multiple snapshots of a source logical unit and recreating snapshots from existing snapshots. This invention primarily addresses multi-generational snapshot scenarios where multiple snapshots are created sequentially for the same source logical unit. The following section, using a snapshot implementation based on write-time redirection, explains the origin of space waste caused by duplicate data in multi-generational snapshot scenarios.

[0022] Figure 1 This is a schematic diagram of the initial state for snapshot activation and the corresponding bitmap.

[0023] If a write-on-redirect snapshot technique is used, after creating and activating the first snapshot (LUN B) for the source logical unit (LUN A), the data in the first snapshot (LUN B) and the source logical unit (LUN A) will immediately appear identical. However, this doesn't mean a full data copy is actually completed. Instead, the snapshot's bitmap distinguishes which data locations have changed. When reading data from the first snapshot (LUN B), the bitmap is used to determine whether redirection to the source logical unit (LUN A) is necessary, thus ensuring that the data in the source logical unit (LUN A) and the first snapshot (LUN B) appear identical. The initial state of snapshot activation and the corresponding bitmap are shown below. Figure 1As shown, at this time, the logical addresses L1, L2, and L3 of the source logic unit (LUN A) are mapped to the physical locations P1, P2, and P3 respectively, and all the flag bits of the bitmap of the first snapshot (LUN B) are initially 0.

[0024] After activating a snapshot, when writing new data to the source logical unit (LUN A), the system first checks the bitmap to determine if it's the first write to that location. It's important to note that "first write" here refers to the first write to that location after the snapshot is created, not that there was no data at that location before. If it is the first write, the system first obtains the physical location corresponding to that logical address of the source logical unit (LUN A) before this write. Based on this physical location, it generates the corresponding mapping relationship for the first snapshot (LUN B), essentially completing a copy of the snapshot data at that location. Then, it updates the identifier bit of that location in the bitmap to show "copied." Next, it allocates a new physical location for the new data written to the source logical unit (LUN A) and updates the mapping relationship of the source logical unit (LUN A), thus achieving write-time redirection of snapshot data copying and write-time redirection of the source logical unit (LUN A).

[0025] Figure 2 A diagram illustrating copy-on-write of data for a single snapshot and its corresponding bitmap.

[0026] like Figure 2 As shown, when writing new data to the L2 position of the source logic unit (LUN A), the physical location P2 of the data is first obtained based on the L2 of the source logic unit (LUN A). The L2 of the first snapshot (LUN B) is then generated, and a mapping relationship between L2 and P2 is established. Then, the new data to be written to the source logic unit (LUN A) is stored in the idle physical location P4, and a mapping relationship between the L2 of the source logic unit (LUN A) and P4 is established. Simultaneously, the corresponding identifier position for L2 in the bitmap of the first snapshot (LUN B) is set to 1. Thus, when accessing data at the L2 position of the first snapshot (LUN B), the correct data can be read from the physical location P2 based on L2P2; when accessing data at the L2 position of the source logic unit (LUN A), the correct data can be read from the physical location P4 based on L2P4.

[0027] When a new snapshot (hereinafter referred to as the second snapshot (LUN C)) is created and activated using the source logical unit (LUN A), the second snapshot (LUN C) immediately has all the data of the source logical unit (LUN A) up to that moment. When writing new data to the source logical unit (LUNA), the bitmap of the second snapshot (LUN C) will be used to determine whether it is the first write at that position.

[0028] Figure 3 This is a configuration diagram for multiple generations of snapshots. For example... Figure 3As shown, the source logic unit (LUN A) created the first snapshot (LUN B) and the second snapshot (LUN C) in sequence.

[0029] Figure 4 A schematic diagram of copy-on-write of data for multiple generations of snapshots and the corresponding bitmaps.

[0030] When multiple generations of snapshots exist in the source logical unit (LUN A), when writing new data to the source logical unit (LUN A), only the data in the latest generation snapshot will be copied. For example... Figure 4 As shown, when writing data to L2 of the source logic unit (LUN A), the physical location P4 is first obtained based on L2 of the source logic unit (LUN A), L2 of the second snapshot (LUN C) is generated, and a mapping relationship between L2 and P4 is established. Then, the new data to be written to the source logic unit (LUN A) is stored in the idle physical location P5, and a mapping relationship between L2 and P5 of the source logic unit (LUN A) is established. When writing data to L3 of the source logic unit (LUN A), the physical location P3 is first obtained based on L3 of the source logic unit (LUN A), L3 of the second snapshot (LUN C) is generated, and a mapping relationship between L3 and P3 is established. Then, the new data to be written to the source logic unit (LUN A) is stored in the idle physical location P6, and a mapping relationship between L3 and P6 of the source logic unit (LUN A) is established.

[0031] To improve the backup efficiency of snapshots, when multiple generations of snapshots exist, data is not copied for all generations of snapshots. Instead, the dependencies between snapshots are used to ensure the correctness and integrity of the data in each generation of snapshots. Since the L3 location of the source logical unit (LUN A) was not written before the creation of the second snapshot (LUN C), the backup of the L3 location data of the first snapshot (LUNB) was not triggered. At this time, the first snapshot (LUN B) does not have an L3 mapping. After the creation of the second snapshot (LUN C), the L3 location of the source logical unit (LUN A) was written. The physical location of the L3 mapping of the source logical unit (LUN A) becomes P6. Therefore, the first snapshot (LUN B) cannot find the physical location P3 through itself or the L3 of the source logical unit (LUN A). It can only access the physical location P3 through the L3 mapping of the second snapshot (LUN C) created after the second snapshot (LUN C). Therefore, in a multi-generation snapshot configuration, the snapshots of older generations depend on the snapshots of newer generations. The complete backup data of the first snapshot (LUNB) can only be formed through L1P1 of the source logical unit (LUN A), L2P2 of the first snapshot (LUN B), and L3P3 of the second snapshot (LUN C).

[0032] Based on the above implementation of write-time redirection for multiple generations of snapshots, the following problems exist: when there are multiple snapshots of the same source logical unit, if the same data is repeatedly written to the source logical unit, it will result in multiple snapshots backing up the same data, causing a waste of data space and metadata space.

[0033] Figure 5 This is a configuration diagram for when there are three generations of snapshots; Figure 6 This is a diagram illustrating how repeatedly writing the same data in related technologies leads to wasted space.

[0034] like Figure 5 and Figure 6 As shown, creating the first snapshot (LUN B), the second snapshot (LUN C), and the third snapshot (LUN D) sequentially for the source logic unit (LUN A), and writing the same data to the same location after each creation, will result in the same data being saved multiple times. Figure 6 The data at physical locations P2, P4, and P5 are identical, and metadata space needs to be allocated to record the mapping relationship between these data locations, resulting in a double waste of data space and metadata space.

[0035] To address the storage space waste problem that occurs when generating multiple generations of snapshots of a source logical unit using write-time redirection in related technologies, this invention provides a snapshot data processing scheme. When writing data to the target logical address of the source logical unit, the scheme compares whether the data corresponding to two different generations of snapshots at that target logical address is the same. If they are the same, only the mapping relationship and corresponding physical space of the first generation snapshot at that target logical address are retained, while the mapping relationship and corresponding physical space of the second generation snapshot at that target logical address are released or not occupied. This ensures that duplicate data across generations is saved only once across multiple generations of snapshots. Furthermore, when the second generation snapshot receives a read command, it can read the correct data based on the first generation snapshot or the source logical unit, thereby eliminating redundant backups without data loss. Therefore, this solution addresses the technical problem of wasted data space and metadata space caused by repeatedly writing the same data in multi-generation snapshot scenarios, achieving the technical effect of saving data space and metadata space occupied by snapshots while ensuring the integrity of snapshot data.

[0036] Figure 7 This is an architecture diagram of a snapshot data processing system provided in an embodiment of the present invention.

[0037] The specific application environment architecture or specific hardware architecture on which the execution of the snapshot data processing method depends is described here.

[0038] The snapshot data processing method provided in this embodiment of the invention can be based on Figure 7The snapshot data processing system implementation is shown below. Figure 7 As shown, the snapshot data processing system includes a host and a storage device. The host connects to the storage device via a network and sends data read / write commands and snapshot creation commands to the storage device.

[0039] The storage device includes a processor, memory, storage medium, and a snapshot management module and a data redundancy removal module implemented by the processor executing programs in memory. The processor executes the snapshot processing program stored in memory to complete the snapshot data processing method provided in this embodiment of the invention. The memory stores the snapshot processing program and intermediate data during the processing. The storage medium stores the source logic units and the actual data of each generation of snapshots, such as a disk array composed of hard disks or solid-state drives.

[0040] The snapshot management module maintains the bitmaps of each generation of snapshots and the metadata mapping between logical addresses and physical locations, as well as the dependencies between multiple generations of snapshots. The data redundancy removal module compares the data at the same logical address from different generations of snapshots when writing data to the source logical unit. If they are identical, it releases the mapping relationship of the removed snapshot and its corresponding physical space, thus reclaiming the data space and metadata space. It should be noted that the above module division is for ease of description; in actual implementation, these functions can be implemented by the same processor executing the corresponding program. This invention does not limit the specific module division method.

[0041] The embodiments of the present invention provide a snapshot data processing method. The method is described in detail below in conjunction with the execution flow of the snapshot data processing method.

[0042] Figure 8 This is a flowchart of a snapshot data processing method provided in an embodiment of the present invention.

[0043] like Figure 8 As shown, the snapshot data processing method provided in this embodiment of the invention may include S801~S803.

[0044] S801: In response to writing data to the target logical address of the source logical unit, compare whether the data corresponding to the target logical address is the same in two snapshots of different generations of the source logical unit.

[0045] In practice, the source logical unit has created multiple generations of snapshots. The target logical address refers to the logical address to which this write command will write. Two snapshots of different generations refer to any two snapshots of different generations among the multiple generation snapshots mentioned above. The comparison object is the data corresponding to the target logical address in these two different generation snapshots, that is, comparing whether the data stored in the physical locations pointed to by the target logical address is the same. The comparison can be performed asynchronously either during the process of writing data to the source logical unit and establishing the mapping relationship for the corresponding generation snapshot, or after the process of writing data to the source logical unit and establishing the mapping relationship for the corresponding generation snapshot is completed.

[0046] S802: If the comparison results are the same, the mapping relationship of the first generation snapshot in the target logical address and the corresponding physical space are retained, and the mapping relationship of the second generation snapshot in the target logical address and the corresponding physical space are released or not occupied.

[0047] The first-generation snapshot and the second-generation snapshot are snapshots from two different generations.

[0048] In practical implementation, when the comparison result of S801 is the same, it indicates that the two snapshots of different generations store duplicate data at the target logical address, and there is no need to retain a copy of each. At this time, the mapping relationship and corresponding physical space of one of them (defined as the first generation snapshot in this embodiment of the invention) at the target logical address are retained, while the mapping relationship and corresponding physical space of the other (defined as the second generation snapshot in this embodiment of the invention) at the target logical address are released or are not occupied in the first place.

[0049] "Release" refers to deleting the mapping relationship of the second-generation snapshot at the target logical address and reclaiming the corresponding physical space for cases where the snapshot has already been established; "Do not occupy" refers to not establishing a mapping relationship for the target logical address or allocating the corresponding physical space for cases where the snapshot has not yet been established. The former corresponds to retaining the newer generation and releasing the older generation, while the latter corresponds to retaining the older generation and not writing to the newer generation. The specific implementation will be described in the following embodiments.

[0050] S803: In response to a read command on the target logical address of the second-generation snapshot, read the mapping relationship of the target logical address based on the first-generation snapshot or the source logical unit, and read the data of the target logical address according to the mapping relationship.

[0051] In practice, because the mapping relationship of the second-generation snapshot to the target logical address has been released or not established, when reading the target logical address data of the second-generation snapshot, the mapping relationship cannot be directly obtained from the second-generation snapshot itself. Instead, based on the dependency relationship between multiple generations of snapshots, the mapping relationship of the target logical address is read from the first-generation snapshot with the retained mapping relationship or the source logical unit, and then the data of the target logical address is read according to the mapping relationship. In this way, the second-generation snapshot with the removed mapping relationship can still read the correct data, ensuring the integrity of the snapshot data.

[0052] Among them, the first-generation snapshot and the second-generation snapshot are two snapshots of different generations mentioned above. That is, the side whose mapping relationship is preserved is called the first-generation snapshot, and the side whose mapping relationship is released or not occupied is called the second-generation snapshot.

[0053] The snapshot data processing method provided in this embodiment of the invention may further include: if the comparison results are different, retaining the mapping relationship of the two snapshots of different generations in the target logical address and the corresponding physical space.

[0054] Specifically, if the comparison result of S801 is different, it means that the data stored in the target logical address of the two snapshots from different generations is not duplicated, and both need to save their respective data. In this case, the mapping relationship of the two snapshots from different generations in the target logical address and the corresponding physical space are retained, without being released, and the reading of their respective data is not affected.

[0055] The snapshot data processing method provided in this invention compares the data corresponding to two different generations of snapshots at the target logical address when writing data to the target logical address of the source logical unit. If they are the same, only the mapping relationship and corresponding physical space of the first generation snapshot at the target logical address are retained, while the mapping relationship and corresponding physical space of the second generation snapshot at the target logical address are released or not occupied. This ensures that duplicate data across generations is saved only once in multiple generations of snapshots. Furthermore, when the second generation snapshot receives a read command, it can read the correct data based on the first generation snapshot or the source logical unit, thereby eliminating redundant backups without losing data. Therefore, it can solve the technical problem of wasting data space and metadata space caused by repeatedly writing the same data in multi-generation snapshot scenarios, achieving the technical effect of saving data space and metadata space occupied by snapshots while ensuring the integrity of snapshot data.

[0056] Based on the above embodiments, the present invention further describes the comparison process in S801.

[0057] In some optional embodiments of the present invention, comparing whether the data corresponding to the target logical address of two different generation snapshots in multiple generations of the source logic unit in S801 is the same may include: obtaining fingerprints of the data corresponding to the target logical address of the two different generation snapshots respectively, and determining whether the data is the same based on whether the two fingerprints are the same.

[0058] In practical implementation, when comparing whether the data at the target logical address of two snapshots from different generations is the same, hash operations are performed on these two data sets to obtain their respective fingerprints, and then the two fingerprints are compared for similarity. If the two fingerprints are the same, the two data sets are considered identical; if the two fingerprints are different, the two data sets are considered different. For example, fingerprints are calculated for the data in the physical location pointed to by L3 of the first snapshot (LUNB) and the data in the physical location pointed to by L3 of the second snapshot (LUN C), and comparing the two fingerprints determines whether the data at the two locations is the same. By using fingerprint comparison, it is not necessary to read and compare two complete data sets byte by byte; only two shorter feature values ​​need to be compared to determine whether the data is the same, reducing the comparison overhead and improving the efficiency of duplicate data identification.

[0059] In some optional embodiments of the present invention, comparing whether the data corresponding to the target logical address of two different generation snapshots in the multiple generation snapshots of the source logic unit is the same in S801 may include: taking the generation snapshot corresponding to the data written this time as the starting point, querying the adjacent older generations step by step according to the dependency relationship between the multiple generation snapshots; determining the most recent generation snapshot that has a mapping relationship in the target logical address and the generation snapshot corresponding to the starting point as two different generation snapshots.

[0060] In practice, the data write operation triggers the establishment of a target logical address mapping for the corresponding generation snapshot, using this generation snapshot as the starting point. Since not every generation snapshot in a multi-generation snapshot scenario has a mapping relationship for every logical address, the process starts from the starting point and queries the adjacent older generations level by level according to the dependencies between multiple generations of snapshots to find the first generation snapshot with a mapping relationship to the target logical address. This nearest older generation snapshot with a mapping relationship to the target logical address, along with the generation snapshot corresponding to the starting point, is identified as the two different generation snapshots that need to be compared. If no generation snapshot with a mapping relationship to the target logical address is found even after querying up to the first generation snapshot, it means there is no comparable previous generation mapping, and redundancy removal is not performed.

[0061] The embodiments of the present invention query and locate the oldest generation snapshot that has a mapping relationship with the target logical address by following the dependency relationship step by step. This makes it possible to find the previous generation snapshot with the relevant mapping for comparison each time a write operation is performed, avoiding the need to compare all generation snapshots one by one and reducing unnecessary comparison operations.

[0062] In some optional embodiments of the present invention, comparing whether the data corresponding to the target logical address of two different generations of snapshots of multiple generations of the source logical unit is the same in S801 may include: determining whether the target logical address is the first write after the generation snapshot is created based on the bitmap of the generation snapshot corresponding to this write; if it is the first write, then perform the comparison; if it is not the first write, then do not perform the comparison.

[0063] In practice, the flag bit corresponding to the target logical address is read based on the bitmap of the corresponding generation snapshot. If the flag bit is the initial value, it means that no data has been written to the target logical address since the generation snapshot was created. This write is the first write to the target logical address since the generation snapshot was created. In this case, this write will trigger the generation snapshot to generate a snapshot copy at the target logical address, and thus a comparison is performed. If the flag bit has been set, it means that data has been written to the target logical address and a snapshot copy has been generated since the generation snapshot was created. This write will not trigger the generation of a new snapshot copy, and thus no comparison is performed.

[0064] This invention avoids repeated comparisons for the same location in the same generation of snapshots by performing the comparison only when the target logical address is first written after the snapshot generation is created, i.e. when the snapshot copy is actually triggered. This reduces unnecessary comparison overhead.

[0065] In some optional embodiments of the present invention, comparing whether the data corresponding to the target logical address of two different generations of snapshots in multiple generations of the source logic unit in S801 is the same may include: when multiple consecutive small data blocks are written, aggregating the multiple consecutive small data blocks into one data block, and performing a comparison on the aggregated data block.

[0066] In other words, when multiple consecutive small data blocks are written, these consecutive small data blocks can be aggregated into a larger data block before fingerprint comparison, thereby reducing the number of fingerprint calculations and comparisons and improving comparison efficiency.

[0067] Based on the above embodiments, in the snapshot data processing method provided by the embodiments of the present invention, the method for removing redundancy can be to retain the newer generation snapshot and release the older generation snapshot. That is, the first generation snapshot is the newer generation snapshot among two different generation snapshots, and the second generation snapshot is the older generation snapshot among two different generation snapshots. Releasing or not occupying the mapping relationship and corresponding physical space of the second generation snapshot at the target logical address in S802 can include: after determining that the first generation snapshot has a mapping relationship and corresponding physical space at the target logical address, deleting the established mapping relationship of the second generation snapshot at the target logical address and reclaiming its corresponding physical space. Reading the mapping relationship of the target logical address based on the first generation snapshot or the source logical unit in S803 can include: reading the mapping relationship of the target logical address corresponding to the second generation snapshot based on the first generation snapshot.

[0068] Figure 9 This is a schematic diagram illustrating a scenario of writing duplicate data according to an embodiment of the present invention; Figure 10 This is a schematic diagram of the mapping relationship and corresponding bitmap after removing redundant data, provided in an embodiment of the present invention.

[0069] In specific implementations, embodiments of the present invention retain snapshots of more recent generations and release snapshots of older generations. For example... Figure 9 and Figure 10 As shown, the source logical unit (LUN A) creates the first snapshot (LUN B) and the second snapshot (LUN C) sequentially. After the second snapshot (LUN C) is created and activated, when data is written to the L3 of the source logical unit (LUN A), an L3 mapping relationship for the newer generation of the second snapshot (LUN C) is generated. For example, it points to the physical location P5, and the L3 mapping relationship of the source logical unit (LUN A) changes from the original physical location to point to the newly allocated physical location P6.

[0070] When generating the L3 mapping relationship for the second snapshot (LUN C), the previous generation snapshot can be queried step by step according to the dependency relationship between multiple generations of snapshots, starting from the generation snapshot corresponding to the data written this time. In this example, the previous generation is the first snapshot (LUN B) of the older generation. The system checks whether a mapping relationship exists in the L3 of the first snapshot (LUN B). If it exists, it means that data was also written to the L3 position after the first snapshot (LUN B) was activated. Then, fingerprint comparison is used to verify whether the data in the physical location P3 pointed to by the L3 of the first snapshot (LUN B) is the same as the data in the physical location P5 pointed to by the L3 of the second snapshot (LUN C).

[0071] If the two sets of data are identical, after determining that the newer generation's second snapshot (LUN C) (i.e., the first generation snapshot) already has the L3 mapping relationship L3P5 and the corresponding physical space P5, delete the L3 mapping relationship L3P3 already established in the older generation's first snapshot (LUN B) (i.e., the second generation snapshot), and reclaim the physical space occupied by physical location P3, retaining only the L3 mapping relationship L3P5 of the second snapshot (LUN C). The mapping relationship after removing redundant data is as follows: Figure 10 As shown, L1, L2, and L3 of the source logic unit (LUN A) point to P1, P4, and P6 respectively. The first snapshot (LUN B) retains L2P2, and the second snapshot (LUN C) retains L2P4 and L3P5. The first snapshot (LUN B) no longer occupies physical space separately in L3.

[0072] When it is necessary to access the L3 location data of the first snapshot (LUN B) of an older generation, since the L3 mapping relationship of the first snapshot (LUN B) has been deleted, the L3 mapping relationship corresponding to the first snapshot (LUN B) will be read based on the dependency relationship between multiple generations of snapshots, based on the second snapshot (LUN C) of the newer generation (i.e. the first generation snapshot). That is, the mapping relationship L3P5 is read from the L3 location of the second snapshot (LUNC), and then the correct data is read from the physical location P5 accordingly.

[0073] The snapshot data processing method provided in this invention adopts a redundancy removal approach that retains the newer generation snapshot and releases the older generation snapshot. When the older generation snapshot and the newer generation snapshot store duplicate data at the same logical address, the mapping relationship established by the older generation snapshot is deleted and its physical space is reclaimed, retaining only the mapping relationship and physical space of the newer generation snapshot, thus saving metadata space and data space. Furthermore, since the redundancy removal operation can be performed asynchronously after the write is completed, it has little impact on write performance. It only needs to look up the newer generation snapshot one more step based on the dependency relationship when reading the older generation snapshot, which also has a small impact on read performance.

[0074] In this embodiment of the invention, multiple generations of snapshots can be snapshots created based on write-time redirection. The steps for establishing the mapping relationship of the target logical address corresponding to the first generation snapshot and the corresponding physical space can include: obtaining the first physical location corresponding to the target logical address before this write; establishing the mapping relationship between the target logical address and the first physical location of the first generation snapshot; allocating a second physical location for the data written this time; and updating the mapping relationship of the target logical address of the source logical unit to point to the second physical location.

[0075] In specific implementation, the multiple generational snapshots in this embodiment are snapshots created based on the write-time redirection method. The mapping relationship of the first generational snapshot (i.e., the newer generational snapshot) to the target logical address and the establishment process of the corresponding physical space are as follows: First, obtain the first physical location corresponding to the target logical address before this write; then establish the mapping relationship between the target logical address of the first generational snapshot and the first physical location, which is equivalent to assigning the data before this write to the first generational snapshot; then allocate a second physical location for the new data written this time, and update the mapping relationship of the target logical address of the source logical unit to point to the second physical location. Figure 9 For example, when writing data to L3 of the source logical unit (LUN A), the target logical address L3 corresponds to the first physical location P5 before this write. First, establish the mapping relationship L3P5 between L3 and P5 of the second snapshot (LUN C), then allocate the second physical location P6 for the new data, and update the L3 mapping relationship of the source logical unit (LUN A) to L3P6.

[0076] The snapshot data processing method provided in this embodiment of the invention may further include: when deleting the mapping relationship established at the target logical address in the second-generation snapshot, resetting the backup identifier bit corresponding to the target logical address in the bitmap of the second-generation snapshot.

[0077] In practice, when deleting the mapping relationship of an older generation snapshot (i.e., the second generation snapshot) where an established mapping relationship has been established for the target logical address, the backup flag bit corresponding to the target logical address in the second generation snapshot bitmap is simultaneously reset to its initial value. Figure 10 For example, when deleting the L3 mapping relationship of the first snapshot (LUN B), the flag bit corresponding to L3 in the bitmap of the first snapshot (LUN B) is reset from 1 to 0, so that the bitmap state is consistent with the actual mapping relationship. In this way, the backup status recorded in the bitmap accurately reflects whether the generation of snapshots still retains an independent mapping relationship at this logical address.

[0078] In this embodiment of the invention, deleting the mapping relationship established at the target logical address in the second-generation snapshot and reclaiming its corresponding physical space is performed asynchronously with writing data to the target logical address of the source logical unit.

[0079] In practice, the redundancy removal operation—deleting the mapping relationship established at the target logical address of the older generation snapshot and reclaiming the corresponding physical space—is executed asynchronously with the operation of writing data to the target logical address of the source logical unit. In other words, once the data writing operation is complete, a completion message is sent to the host. The deletion of the mapping relationship and the redundancy removal operation of reclaiming the physical space are performed separately outside the writing process, without occupying the response time of the write command.

[0080] Furthermore, deleting the established mapping relationship of the second-generation snapshot at the target logical address and reclaiming its corresponding physical space may include: adding the physical space to be reclaimed to a delayed reclamation queue, and performing physical erasure on the physical space in the delayed reclamation queue when the storage device is idle.

[0081] In practice, when reclaiming the physical space corresponding to the second-generation snapshot, the physical space to be reclaimed can be added to a delayed reclamation queue, and physical erasure is not performed immediately. Physical erasure is then performed on the physical space in the delayed reclamation queue when the storage device is idle, completing the actual reclamation of the physical space. Whether the storage device is idle can be determined based on whether the input / output load is below a set level. For example, when the number of read / write requests per unit time is lower than a set value, the storage device is considered idle. This set value can be determined by technicians based on the processing capacity of the storage device.

[0082] In this embodiment of the invention, reading the mapping relationship of the target logical address based on the first-generation snapshot may include: responding to a read command on the target logical address of the second-generation snapshot, querying the index information corresponding to the source logical unit, determining the first-generation snapshot among multiple generations of snapshots; and reading the mapping relationship of the target logical address based on the first-generation snapshot.

[0083] In practical implementation, index information can be maintained for the source logical unit. This index information records the generational snapshots where the mapping relationship is still preserved for each logical address. When a read command is received for the target logical address of the second generational snapshot (i.e., an older generational snapshot), the index information corresponding to the source logical unit is queried to directly determine the first generational snapshot among multiple generational snapshots that retains the mapping relationship for the target logical address. Then, the mapping relationship of the target logical address is read based on the first generational snapshot, without having to traverse each generational snapshot level by level along the dependency relationship. Figure 10 For example, when reading the L3 data of the first snapshot (LUN B), the second snapshot (LUN C) that retains the L3 mapping relationship is directly determined through the index information, and then L3P5 is read from the second snapshot (LUN C).

[0084] By maintaining a generation index for each logical address that still retains the mapping relationship, when reading an older generation snapshot where the mapping relationship has been removed, the generation snapshot that retains the mapping relationship can be directly located, avoiding traversing along the dependency relationship level by level, thus improving read performance and compensating for the read performance loss caused by redundancy removal.

[0085] Furthermore, the snapshot data processing method provided in this embodiment of the invention also includes: recording logical addresses that have been accessed more than a set number of times in multiple generations of snapshots, pre-storing the mapping relationship located by the logical address through the dependency relationship into a cache; and after reading the data of the logical address, storing the reading result into a cache, and returning the reading result from the cache the next time the logical address is read.

[0086] Specifically, it can record which logical addresses are frequently accessed, pre-cache the mapping relationships of these frequently accessed logical addresses through dependency relationships, and cache the read results so that the same logical address can be retrieved directly from the cache the next time it is read. The number of times can be set by technical personnel based on cache capacity and business access characteristics, for example, set to 5 times per unit time.

[0087] Furthermore, the snapshot data processing method provided in this embodiment of the invention further includes: on the basis of maintaining a generation index that still retains the mapping relationship for each logical address, for older generation snapshots that have no mapping dependency relationship with previous and subsequent generation snapshots, if no deletion snapshot command is received for the older generation snapshot, the older generation snapshot is removed from the snapshot version dependency relationship without being deleted; when it is necessary to read the data of the older generation snapshot, the required mapping relationship is found from the previous snapshot version of the older generation snapshot.

[0088] In other words, for older generation snapshots that have no mapping dependency with previous or subsequent generation snapshots, the older generation snapshot can be removed from the snapshot version dependency relationship without the user issuing a delete snapshot command, but the snapshot itself is not deleted; after removal, if data needs to be read from the older generation snapshot, the required mapping relationship can be found from its previous snapshot version.

[0089] Figure 11 A flowchart of a second snapshot data processing method provided in an embodiment of the present invention.

[0090] By retaining newer snapshots and releasing older snapshots, the overall flow of the snapshot data processing method provided in this embodiment of the invention can be as follows: Figure 11As shown: When writing data to the target logical address Lx of snapshot n, it is determined whether a previous generation snapshot exists. If no previous generation snapshot exists, space saving cannot be performed, and the process ends. If a previous generation snapshot exists, it is determined whether there is a mapping relationship between the previous generation snapshot and Lx. If there is no mapping relationship between the previous generation snapshot and Lx, the process continues to traverse backwards until the first generation snapshot is reached. If there is a mapping relationship between the previous generation snapshot and Lx, the data of snapshot n and the previous generation snapshot in Lx are compared. If the two data are the same, the corresponding flag bit of Lx in the bitmap of the previous generation snapshot (snapshot n minus 1) is reset, and the metadata and data space of the previous generation snapshot (snapshot n minus 1) are released. If the two data are different, each generation snapshot is retained, and the process ends.

[0091] Based on the above embodiments, in the snapshot data processing method provided by the embodiments of the present invention, the method of removing redundancy can also be to retain the older generation snapshot and not write the newer generation snapshot. That is, the first generation snapshot is the older generation snapshot among two different generation snapshots, and the second generation snapshot is the newer generation snapshot among two different generation snapshots. Releasing or not occupying the mapping relationship and corresponding physical space of the second generation snapshot at the target logical address in S802 can include: if the data written to the target logical address of the source logical unit is the same as the existing data at the target logical address, not performing the write operation and redirection of the source logical unit, and not establishing the mapping relationship and corresponding physical space of the target logical address for the second generation snapshot, and reporting the completion of the write operation. Reading the mapping relationship of the target logical address based on the first generation snapshot or the source logical unit in S803 can include: reading the mapping relationship of the target logical address corresponding to the second generation snapshot based on the source logical unit.

[0092] In this implementation, the older generation snapshot is retained, while the newer generation snapshot is not written. When writing data to the target logical address of the source logical unit, the data to be written is first compared with the existing data at the target logical address (e.g., the fingerprint comparison method described in the above embodiment). If the data to be written is the same as the existing data at the target logical address, it indicates that the data being written is duplicate data. Therefore, the write operation is not performed, no write-time redirection is performed on the source logical unit, and no mapping relationship for the target logical address and the corresponding physical space is established for the newer generation snapshot (i.e., the second generation snapshot). The write is directly reported to the host as complete. Since the older generation snapshot (i.e., the first generation snapshot) and the target logical address mapping relationship of the source logical unit remain unchanged, duplicate data is still only saved once.

[0093] When it is necessary to read the target logical address data of a newer generation snapshot (i.e., the second generation snapshot), since no mapping relationship has been established for the target logical address of the second generation snapshot, the mapping relationship of the target logical address corresponding to the second generation snapshot will be read based on the dependency relationship according to the source logical unit, and then the correct data will be read accordingly. In other words, because the duplicate data was not written and the target logical address mapping relationship of the source logical unit has not changed, the correct data can be read from the second generation snapshot through the source logical unit.

[0094] Compared with the above embodiment of retaining new and deleting old, the retaining old and deleting new in this embodiment intercepts duplicate data during the writing process. Duplicate data is never written from the beginning, so there is no need for subsequent deletion mapping relationship and physical space reclamation operations. Furthermore, since the target logical address mapping relationship of the source logical unit is not changed, the mapping relationship can be obtained through the source logical unit when reading the newer generation snapshot, so there is no impact on the reading performance.

[0095] In this embodiment of the invention, multiple generational snapshots can also be snapshots created based on write-time redirection. Specifically, the steps for establishing the mapping relationship of the target logical address and the corresponding physical space for the first generational snapshot may include: obtaining existing data in the physical location corresponding to the target logical address before the current write operation; comparing the data to be written with the existing data; if they are the same, not allocating a new physical location for the data to be written, nor updating the mapping relationship of the target logical address of the source logical unit, i.e., not performing write-time redirection for the source logical unit, and not establishing the mapping relationship of the target logical address and the corresponding physical space for the newer generational snapshot, and reporting the write completion to the host. In this way, the target logical address of the source logical unit still points to the original physical location, and when the newer generational snapshot reads the target logical address, it can read the data in the original physical location based on the source logical unit.

[0096] Taking a source logical unit (LUN A), an older generation first snapshot (LUN B), and a newer generation second snapshot (LUNC) as an example, when writing data to the L3 level of the source logical unit (LUN A) after activating the second snapshot (LUN C), the existing data in the physical location corresponding to the L3 level of the source logical unit (LUN A) before the write is performed is first read and compared with the data to be written. If they are the same, no new physical location is allocated for the data, the L3 mapping relationship of the source logical unit (LUN A) remains unchanged, and no L3 mapping relationship is established for the second snapshot (LUN C). A write completion message is then sent. When reading the L3 data of the second snapshot (LUN C), the correct data can be read based on the L3 mapping relationship of the source logical unit (LUN A).

[0097] Based on the above embodiments, before comparing whether the data corresponding to the target logical address of two different generations of snapshots of the source logical unit is the same in response to writing data to the target logical address in S801, the snapshot data processing method provided by the present invention may further include: determining whether the remaining storage space of the storage device is less than a preset threshold; if so, then performing the comparison whether the data corresponding to the target logical address of two different generations of snapshots of the source logical unit is the same in response to writing data to the target logical address; if not, then not performing the comparison whether the data corresponding to the target logical address of two different generations of snapshots of the source logical unit is the same in response to writing data to the target logical address, and retaining the mapping relationship of the second generation snapshot at the target logical address and the corresponding physical space.

[0098] In practice, before performing the comparison, it is first determined whether the remaining storage space of the storage device is less than a preset threshold. If the remaining storage space is less than the preset threshold, it means that the storage space is already relatively tight. In this case, the comparison is performed and redundancy is removed in the manner described above to save space. If the remaining storage space is not less than the preset threshold, it means that the storage space is still relatively abundant. In this case, the comparison is not performed, and the mapping relationship of the second-generation snapshot in the target logical address and the corresponding physical space are retained, thereby sacrificing read performance by preserving redundant data.

[0099] The preset threshold can be set proportionally to the total capacity of the storage device, for example, 20% of the total capacity; or it can be set to a fixed capacity value, such as 100GB. When the total capacity of the storage device is 1TB and the preset threshold is 20% of the total capacity, the preset threshold is 200GB. When the remaining storage space is less than 200GB, comparison and redundancy removal are performed. The specific value of the preset threshold can be determined by technicians based on the capacity of the storage device and the read performance requirements of the business; this embodiment of the invention does not limit this.

[0100] Based on the above embodiments, the snapshot data processing method provided by the present invention may further include: in response to a snapshot creation command, determining whether there is a logical address in the source logical unit corresponding to multiple duplicate data; if so, first performing a redundancy removal operation on the duplicate data corresponding to the logical address, and then executing the snapshot creation command.

[0101] In practice, when a snapshot creation command is received for a source logical unit, it is first determined whether there are logical addresses corresponding to multiple duplicate data in the existing multiple generations of snapshots of the source logical unit. If such logical addresses exist, the aforementioned deduplication operation is first performed on the duplicate data corresponding to these logical addresses to release the duplicate mapping relationships and physical space, and then the snapshot creation command is executed; if not, the snapshot creation command is executed directly.

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

[0103] Embodiments of the present invention also provide a snapshot data processing apparatus, which may include: a comparison module, configured to compare whether the data corresponding to the target logical address of two snapshots of different generations of the source logical unit is the same in response to writing data to the target logical address of the source logical unit; a space reclamation module, configured to retain the mapping relationship of the first generation snapshot at the target logical address and the corresponding physical space if the comparison results are the same, and release or not occupy the mapping relationship of the second generation snapshot at the target logical address and the corresponding physical space; and a snapshot management module, configured to read the mapping relationship of the target logical address based on the first generation snapshot or the source logical unit in response to a read command on the target logical address of the second generation snapshot, and read the data of the target logical address according to the mapping relationship; wherein the first generation snapshot and the second generation snapshot are two snapshots of different generations.

[0104] In this embodiment of the invention, the first-generation snapshot can be the newer snapshot among two different generations, and the second-generation snapshot can be the older snapshot among two different generations. The space reclamation module releases or does not occupy the mapping relationship of the second-generation snapshot at the target logical address and the corresponding physical space, which may include: after determining that the first-generation snapshot has a mapping relationship at the target logical address and the corresponding physical space, deleting the established mapping relationship of the second-generation snapshot at the target logical address and reclaiming its corresponding physical space; the snapshot management module reads the mapping relationship of the target logical address based on the first-generation snapshot or the source logical unit, which may include: reading the mapping relationship of the target logical address corresponding to the second-generation snapshot based on the first-generation snapshot.

[0105] In this embodiment of the invention, multiple generations of snapshots can be snapshots created based on write-time redirection. The snapshot management module's steps of executing the mapping relationship of the target logical address corresponding to the first generation snapshot and the establishment of the corresponding physical space may include: obtaining the first physical location corresponding to the target logical address before this write; establishing the mapping relationship between the target logical address and the first physical location of the first generation snapshot; allocating a second physical location for the data written this time, and updating the mapping relationship of the target logical address of the source logical unit to point to the second physical location.

[0106] In this embodiment of the invention, the snapshot management module can also be used to reset the backup flag bit corresponding to the target logical address in the bitmap of the second-generation snapshot when deleting the mapping relationship established at the target logical address of the second-generation snapshot.

[0107] In this embodiment of the invention, deleting the mapping relationship established at the target logical address in the second-generation snapshot and reclaiming its corresponding physical space can be performed asynchronously with writing data to the target logical address of the source logical unit.

[0108] In this embodiment of the invention, the space reclamation module deletes the mapping relationship established at the target logical address of the second-generation snapshot and reclaims its corresponding physical space, which may include: adding the physical space to be reclaimed to a delayed reclamation queue, and performing physical erasure on the physical space in the delayed reclamation queue when the storage device is idle.

[0109] In this embodiment of the invention, the snapshot management module reads the mapping relationship of the target logical address based on the first-generation snapshot, which may include: responding to a read command on the target logical address of the second-generation snapshot, querying the index information corresponding to the source logical unit, determining the first-generation snapshot among multiple generations of snapshots; and reading the mapping relationship of the target logical address based on the first-generation snapshot.

[0110] In this embodiment of the invention, the first-generation snapshot can be the older of two different-generation snapshots, and the second-generation snapshot can be the newer of two different-generation snapshots. The space reclamation module releases or does not occupy the mapping relationship of the second-generation snapshot at the target logical address and the corresponding physical space, which may include: if the data written to the target logical address of the source logical unit is the same as the existing data at the target logical address, not performing the writing and redirection of the source logical unit, and not establishing the mapping relationship of the target logical address and the corresponding physical space for the second-generation snapshot, and reporting the completion of the writing; the snapshot management module reads the mapping relationship of the target logical address based on the first-generation snapshot or the source logical unit, including: reading the mapping relationship of the target logical address corresponding to the second-generation snapshot based on the source logical unit.

[0111] In this embodiment of the invention, the comparison module compares whether the data corresponding to the target logical address of two snapshots of different generations in multiple generations of the source logic unit are the same. This may include: obtaining fingerprints of the data corresponding to the target logical address of the two snapshots of different generations respectively, and determining whether the data are the same based on whether the two fingerprints are the same.

[0112] In this embodiment of the invention, the comparison module compares whether the data corresponding to the target logical address of two snapshots of different generations in the multiple generations of the source logical unit are the same. This can include: taking the snapshot of the generation corresponding to the data written this time as the starting point, querying the adjacent older generations step by step according to the dependency relationship between the snapshots of multiple generations; determining the most recent snapshot of the generation that has a mapping relationship with the target logical address and the snapshot of the generation corresponding to the starting point as two snapshots of different generations.

[0113] In this embodiment of the invention, the comparison module compares whether the data corresponding to the target logical address is the same in two snapshots of different generations among multiple generations of the source logical unit. This may include: determining whether the target logical address is the first write after the generation snapshot is created based on the bitmap of the current write; if it is the first write, then the comparison is performed; if it is not the first write, then the comparison is not performed.

[0114] In this embodiment of the invention, the space reclamation module can also be used to retain the mapping relationship of the two snapshots of different generations in the target logical address and the corresponding physical space if the comparison results are different.

[0115] The snapshot data processing apparatus provided in this embodiment of the invention may further include: a storage space monitoring module, configured to determine whether the remaining storage space of the storage device is less than a preset threshold before comparing whether the data corresponding to the target logical address of two snapshots of different generations of the source logical unit is the same in response to writing data to the target logical address of the source logical unit; if so, trigger the comparison module to perform the comparison of whether the data corresponding to the target logical address of two snapshots of different generations of the source logical unit is the same in response to writing data to the target logical address of the source logical unit; if not, do not trigger the comparison module to perform the comparison of whether the data corresponding to the target logical address of two snapshots of different generations of the source logical unit is the same in response to writing data to the target logical address of the source logical unit, and retain the mapping relationship of the second generation snapshot at the target logical address and the corresponding physical space.

[0116] In this embodiment of the invention, the space reclamation module can also be used to respond to the snapshot creation command by determining whether there is a logical address in the source logical unit that corresponds to multiple duplicate data; if so, the duplicate data corresponding to the logical address is first deredundant, and then the snapshot creation command is executed.

[0117] For a description of the features in the embodiment corresponding to the snapshot data processing device, please refer to the relevant description in the embodiment corresponding to the snapshot data processing method, which will not be repeated here.

[0118] Embodiments of the present invention also provide an electronic device, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the above-described snapshot data processing method embodiments.

[0119] Embodiments of the present invention also provide a computer-readable storage medium storing a computer program configured to execute the steps in any of the above-described snapshot data processing method embodiments at runtime.

[0120] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.

[0121] Embodiments of the present invention also provide a computer program product, which includes a computer program that, when executed by a processor, implements the steps in any of the above-described snapshot data processing method embodiments.

[0122] Embodiments of the present invention also provide another computer program product, including a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps in any of the above-described snapshot data processing method embodiments.

[0123] Any of the components, modules, units, parts, methods, and operations described herein can be implemented using software, firmware, hardware (e.g., fixed logic circuitry), manual processing, or any combination thereof. Alternatively or additionally, any functionality described herein can be performed at least in part by one or more hardware logic components, such as, but not limited to, a central processing unit (CPU), a field-programmable gate array (FPGA), an application-specific integrated circuit (ASIC), an application-specific standard product (ASSP), a system-on-a-chip (SoC), a complex programmable logic device (CPLD), a microprocessor (MCU), etc. The terms "system," "computing device," or "apparatus" as used herein encompass various means, devices, and machines for processing data, including, for example, one or more programmable processors, computers, SoCs, or combinations thereof. The apparatus may also include code that creates an execution environment for the computer program in question, such as code constituting processor firmware, a protocol stack, a database management system, an operating system, a cross-platform runtime environment, a virtual machine, or one or more combinations thereof. The aforementioned computer program (also known as a program, software, software application, app, script, or code) can be written in any form of programming language, including compiled or interpreted languages, declarative or procedural languages, and can be deployed in any form, including as a standalone program or as a module, component, subroutine, object, or other unit suitable for a computing environment.

[0124] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.

[0125] The snapshot data processing method and electronic device provided by the present invention have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only intended to help understand the method and core ideas of the present invention. It should be noted that those skilled in the art can make several improvements and modifications to the present invention without departing from the principles of the present invention, and these improvements and modifications also fall within the protection scope of the present invention.

Claims

1. A snapshot data processing method, characterized in that, include: In response to writing data to the target logical address of the source logical unit, the system compares whether the data corresponding to the target logical address is the same in two snapshots of different generations of the source logical unit; wherein, the snapshots of multiple generations are snapshots created based on write-time redirection; comparing whether the data corresponding to the target logical address is the same in two snapshots of different generations of the source logical unit includes: starting from the snapshot of the generation corresponding to the data being written, querying the adjacent older generations level by level according to the dependency relationship between the snapshots of multiple generations; determining the most recent snapshot of the generation that has a mapping relationship with the target logical address, and the snapshot of the generation corresponding to the starting point as the two snapshots of different generations; If the comparison results are the same, the mapping relationship of the first generation snapshot to the target logical address and the corresponding physical space are retained, and the mapping relationship of the second generation snapshot to the target logical address and the corresponding physical space are released; wherein, the first generation snapshot is the newer snapshot of the two different generations, and the second generation snapshot is the older snapshot of the two different generations; releasing the mapping relationship of the second generation snapshot to the target logical address and the corresponding physical space includes: after determining that the first generation snapshot has the mapping relationship and corresponding physical space of the target logical address, deleting the established mapping relationship of the second generation snapshot to the target logical address and reclaiming its corresponding physical space; Index information is maintained for the source logical unit, and the index information records the generational snapshots in which the mapping relationship is still retained for each logical address; In response to a read command for the target logical address of the second generation snapshot, the index information corresponding to the source logical unit is queried to determine the first generation snapshot among the multiple generation snapshots; the mapping relationship of the target logical address is read based on the first generation snapshot, and the data of the target logical address is read according to the mapping relationship.

2. The snapshot data processing method according to claim 1, characterized in that, The mapping relationship of the target logical address corresponding to the first generation snapshot and the steps for establishing the corresponding physical space include: Obtain the first physical location of the target logical address before this write operation; Establish a mapping relationship between the target logical address of the first generation snapshot and the first physical location; Assign a second physical location to the data being written, and update the mapping relationship of the target logical address of the source logical unit to point to the second physical location.

3. The snapshot data processing method according to claim 1, characterized in that, Also includes: When deleting the established mapping relationship of the second-generation snapshot to the target logical address, the backup flag bit corresponding to the target logical address in the bitmap of the second-generation snapshot is reset.

4. The snapshot data processing method according to claim 1, characterized in that, Deleting the mapping relationship established at the target logical address by the second-generation snapshot and reclaiming its corresponding physical space is performed asynchronously with writing data to the target logical address of the source logical unit.

5. The snapshot data processing method according to claim 4, characterized in that, Delete the mapping relationship established by the second-generation snapshot at the target logical address and reclaim its corresponding physical space, including: The physical space to be reclaimed is added to the delayed reclamation queue, and physical erasure is performed on the physical space in the delayed reclamation queue when the storage device is idle.

6. The snapshot data processing method according to claim 1, characterized in that, The first generation snapshot is the snapshot of the older generation among the two different generation snapshots, and the second generation snapshot is the snapshot of the newer generation among the two different generation snapshots. Releasing or not occupying the mapping relationship of the second-generation snapshot at the target logical address and the corresponding physical space includes: If the data written to the target logical address of the source logical unit is the same as the existing data at the target logical address, no writing or redirection of the source logical unit is performed, and no mapping relationship and corresponding physical space of the target logical address are established for the second generation snapshot, and the writing is reported as complete. Based on the mapping relationship of reading the target logical address from the first-generation snapshot or the source logical unit, the following is included: The mapping relationship of the target logical address corresponding to the second-generation snapshot is read based on the source logical unit.

7. The snapshot data processing method according to claim 1, characterized in that, Comparing whether the data corresponding to the target logical address is the same in snapshots of multiple generations of the source logical unit from two different generations includes: The fingerprints of the data corresponding to the target logical address of the two snapshots of different generations are obtained respectively, and the data is determined to be the same based on whether the two fingerprints are the same.

8. The snapshot data processing method according to claim 1, characterized in that, Comparing whether the data corresponding to the target logical address is the same in snapshots of multiple generations of the source logical unit from two different generations includes: Based on the bitmap of the generation snapshot corresponding to this write, determine whether the target logical address is the first write after the generation snapshot is created; If this is the first write, then perform a comparison; If this is not the first time the data has been written, no comparison will be performed.

9. The snapshot data processing method according to claim 1, characterized in that, Also includes: If the comparison results are different, the mapping relationship between the two snapshots of different generations at the target logical address and their corresponding physical space are retained.

10. The snapshot data processing method according to claim 1, characterized in that, Before comparing whether the data corresponding to the target logical address is the same in two snapshots of different generations of the source logical unit in response to writing data to the target logical address, the method further includes: Determine whether the remaining storage space on the storage device is less than a preset threshold; If so, then in response to writing data to the target logical address of the source logical unit, compare whether the data corresponding to the target logical address of two snapshots of different generations in the multiple generations of the source logical unit is the same. If not, then the response of writing data to the target logical address of the source logical unit is not executed. The data corresponding to the target logical address of two different generations of snapshots of the source logical unit are compared to see if they are the same. The mapping relationship of the second generation snapshot at the target logical address and the corresponding physical space are retained.

11. The snapshot data processing method according to claim 1, characterized in that, Also includes: In response to the snapshot creation command, determine whether there is a logical address in the source logical unit that corresponds to multiple duplicate data; If it exists, first perform a redundancy removal operation on the duplicate data corresponding to the logical address, and then execute the snapshot creation command.

12. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the steps of the snapshot data processing method as described in any one of claims 1 to 11.

Citation Information

Patent Citations

  • Snapshot volume creation method and device, electronic equipment and storage medium

    CN116820327A