Disclosure of Invention
Therefore, the invention aims to overcome the defects that the snapshot technology adopted by the existing snapshot product is single and has no universality, thereby providing a snapshot system capable of simultaneously supporting two snapshot technologies, namely COW and ROW.
In order to achieve the above object, the present invention provides a snapshot system, which includes a device management toolset, a snapshot implementation module, and a physical device; the snapshot realization module comprises a snapshot mechanism layer used for data searching and time point management and a physical resource management layer used for allocation and recovery management of the physical equipment, wherein the snapshot mechanism layer comprises at least one snapshot group, and different snapshot groups can adopt different snapshot technologies; the physical resource management layer comprises metadata equipment and data equipment corresponding to the snapshot group.
In the above technical solution, the snapshot technology adopted in the snapshot group is a copy-on-write technology or a redirect-on-write technology.
In the above technical solution, the metadata device stores metadata, where the metadata is used to indicate an increment of data and a storage location of data in a snapshot version of the snapshot group on the data device; the metadata is recorded in the form of a bitmap or mapping table.
In the above technical solution, the bitmaps are divided into multiple levels, where a value of a bit in a previous bitmap is 1, which is used to indicate that a bit with a value of 1 exists in a corresponding next bitmap, and if the value of the bit is 0, the bit with a value of 1 does not exist in the corresponding next bitmap; on the bitmap at the lowest level, the value of a certain bit is 1, which is used to indicate that the data on the corresponding data block changes, and if the value is 0, the data on the corresponding data block does not change.
In the above technical solution, all snapshot groups use the same memory structure, and have four pointers: including r0, r1 pointers for the physical device that needs to be accessed for a corresponding read operation and w0, w1 pointers for the physical device that needs to be accessed for a corresponding write operation.
In the above technical solution, the snapshot group has corresponding snapshot devices at a certain time point, and the snapshot devices at each time point are organized by adopting a chain structure.
The invention also provides a using method of the snapshot system, which comprises the following steps:
step 1), a user issues a snapshot creating command through the equipment management toolset, and determines which snapshot technology is selected to create a snapshot in the command;
step 2), the snapshot mechanism layer in the snapshot realization module creates a snapshot according to the snapshot technology selected in the step 1);
and 3) performing relevant operation on the snapshot according to the requirement of a user, wherein the operation comprises reading, writing and deleting of the snapshot.
In the above technical solution, in the step 2), the creating a snapshot further includes the following steps:
step 2-1-1), creating a source device, and enabling all snapshot relation pointers of the source device to point to the physical device of the source device;
step 2-1-2), creating snapshots at subsequent time points, and inserting the created snapshots in a snapshot set linked list.
In the above technical solution, if a copy-on-write technique is used when creating a snapshot, when inserting the created snapshot into a snapshot set linked list, the w0 pointer of the source device points to the newly created snapshot device, the r0 pointer of the newly created snapshot device points to the source device, and if there is still a snapshot device with an earlier time point in the snapshot set linked list, the r0 pointer of the snapshot device with an earlier time point and the closest time point to the newly created snapshot device than the newly created snapshot device points to the newly created snapshot device.
In the above technical solution, if a redirection-while-writing technique is used when creating a snapshot, when inserting the created snapshot into a snapshot set linked list, the r0 pointer of the source device points to a newly created snapshot device, and the r0 pointer of the newly created snapshot device points to a snapshot device with an earlier time point and a closest time; if no snapshot device with an earlier time point exists in the snapshot set linked list, the r0 pointer of the newly created snapshot device points to a zero device.
In the above technical solution, in the step 3), the reading of the data in the snapshot includes reading of data in the source device and reading of data in the snapshot device.
In the above technical solution, the reading of the data in the source device further includes the following steps:
step 3-1-1), inquiring corresponding bits in the bitmap according to the address of the data to be read, if the value of the bit is 1, directly reading the bit locally, returning the read data value, and if the value of the bit is 0, executing the next step;
and 3-1-2) judging whether the data in the source equipment has a corresponding snapshot or not, if not, returning all-zero data, if so, forwarding a data reading request according to a snapshot set linked list, and completing the data reading process by reading the snapshot data.
In the above technical solution, when determining whether the data in the source device has the corresponding snapshot, if the r0 pointer in the source device points to the physical device, the snapshot does not exist; if the r0 pointer in the source device points to a logical device, then a snapshot exists.
In the above technical solution, when the snapshot is created by using a copy-on-write technique, step 3) further includes the following steps, which are used to read data of the snapshot:
step 3-2-1), determining the physical equipment for storing data according to the value of the bitmap, traversing from the tail part of the snapshot set linked list to the front part in the determination process, and if the physical equipment is in a certain snapshot SkThe value of bitmap on is 1, then the snapshot S is before itk-1If the bitmap value is 0, the data reading request is forwarded to the previous snapshot along the snapshot set linked list until the snapshot with the bitmap value of 1 is found;
step 3-2-2), if the snapshot with the bitmap value of 1 is not found in the snapshots of the snapshot set linked list, reading a data request to the source device, if the bitmap value of the source device is 1, reading data on the data device of the snapshot adjacent to the source device, otherwise, reading the data on the data device of the source device;
when the snapshot is created by adopting a redirection-on-write technology, the step 3) further comprises the following steps of:
firstly, determining physical equipment for storing data according to the value of a bitmap, and then reading the data from the physical equipment for storing the data; when determining the physical device for storing data, it traverses from the tail of the snapshot set linked list to the front, if it is at a certain snapshot SkIf the bitmap value is 1, reading the bitmap value on local data equipment and returning corresponding data, if the bitmap value is 0, judging whether the current snapshot is the oldest snapshot in the snapshot set linked list, namely whether the current snapshot is the snapshot at the tail end of the snapshot linked list, if so, returning all 0, otherwise, forwarding the read data request to the previous snapshot in the snapshot linked list.
In the above technical solution, if the data writing operation is completed in the snapshot, the step 3) further includes the following steps:
firstly, determining physical equipment for storing data according to the value of a bitmap; and then writing data in the determined physical device.
In the above technical solution, when the snapshot is created by using a copy-on-write technique, step 3) further includes the following steps, which are used to write snapshot data:
judging the bitmap value, and if the bitmap value is 1, directly writing the bitmap value into the physical equipment of the source; if the bitmap value is 0, the copy-on-write operation is completed and then written into the physical device of the source.
In the above technical solution, when the snapshot is created by using a redirection-on-write technique, step 3) further includes the following steps, which are used to write snapshot data:
judging the bitmap value, and if the bitmap value is 1, directly writing the bitmap value into the physical equipment of the source; and if the bitmap value is 0, merging the data of the data blocks and then writing the merged data into the physical equipment of the source.
In the above technical solution, in the step 3), when the snapshot adopts a copy-on-write technology, only the snapshot with the earliest time point can be deleted in the process of deleting the snapshot.
In the above technical solution, in the step 3), when the snapshot adopts a redirection-while-write technique, the data triggered by the snapshot deletion is merged before the snapshot to be deleted is deleted.
In the above technical solution, the data merging includes the following steps:
step 3-3-1), sequentially reading the corresponding bit of each data block in the bitmap in the snapshot device S2; wherein S2 is the neighboring snapshot device of the snapshot device S1 to delete;
step 3-3-2), combining the bitmap bit in the snapshot device S2 with the corresponding bitmap bit of the snapshot device S1, four situations can be obtained:
S2 S1
a、0 0
b、0 1
c、1 0
d、1 1
when the bitmap bit of S2 is 1, it indicates that new data has been written, so that only the data block with bitmap bit 1 of S2 needs to be copied back to the data device of S1 during data merging;
step 3-3-3), executing data back-shifting operation, and copying the data in the data device of S2 to the data device of S1;
step 3-3-4), after the data return is finished, setting the corresponding bit of the bitmap of S2 as 0;
step 3-3-5), if all data blocks are processed, ending the data merging operation, otherwise, executing step 3-3-1 again), and continuing to process the next data block.
The invention has the advantages that:
1. the universal snapshot system can simultaneously support two snapshot technologies of COW and ROW, and a user can flexibly select according to actual requirements to provide optimal support for different applications.
2. The invention provides writable snapshot support while supporting COW and ROW read-only snapshot devices, and expands the application of snapshot technology in new fields of service deployment, electronic classrooms and the like.
3. The invention adopts a chain type equipment organization structure, at a specific time point, data only needs to be stored on the data equipment and does not increase along with the increase of the number of snapshots, and in a COW mode of a star type structure, the use of storage resources linearly increases along with the increase of the number of the snapshot equipment, so that the invention can effectively save storage space
4. The invention adopts the chain type equipment organization structure and the metadata equipment and data equipment separation structure, and has good expansibility on performance and capacity.
5. The invention adopts independent equipment to store metadata, does not reserve space on data equipment, avoids the defect of overlarge or undersize reserved space, and has no limitation of system scale by the capacity of a metadata reserved area.
6. The invention adopts the independent equipment to store the metadata, so that the operation on the metadata can not cause the jitter of the magnetic head accessed by the data equipment, and the performance of user data access is not influenced.
7. The invention adopts a three-level bitmap memory structure when storing the metadata, provides the swap-in and swap-out operation of a third-level bitmap, and occupies less memory resources while keeping the high efficiency of the metadata operation.
8. The invention adopts chain organization, only involves two data devices when reading and writing data, and the performance is not reduced along with the increase of the number of snapshots.
Detailed Description
The snapshot system of the present invention is described below with reference to the accompanying drawings and the detailed description.
Before the present invention is explained in detail, the definitions of partial terms related to the present invention will be explained:
a logic device: the equipment created by the snapshot system of the invention is called as logic equipment and is divided into snapshot equipment and source equipment.
Physical equipment: the underlying devices used by the logical devices, the devices used to store data, are referred to as physical devices.
The metadata device: the physical device in which the metadata is stored is called a metadata device.
A data device: physical devices for storing user data are called data devices
Zero equipment: is a virtual device which returns zero data when reading.
Data block: the minimum granularity of access for an I/O request is typically 4K bytes.
Snapshot group: a source device and a group of snapshot devices derived from the source device
Having described the above vocabulary of the present invention which is subject to confusion, the general snapshot system of the present invention and the corresponding methods involved in the system are described below.
The general snapshot system of the present invention is a device-level snapshot system that can support both copy-on-write (COW) snapshot technology and redirect-on-write (ROW) snapshot technology. As shown in fig. 2, a complete general snapshot system includes a device management toolset, a snapshot implementation module, and a physical device. The equipment management tool set is positioned at the top of the general snapshot system and is an interactive interface between the system and a user, the snapshot realization module is positioned at the next layer of the equipment management tool set and belongs to a core module of the system and is used for realizing various operations on snapshots, and the physical equipment is the bottom layer of the general snapshot system and is used for storing various data related to the snapshots. The composition and function of each will be further described below.
The device management toolset is composed of a group of user programs and provides management functions for creating/deleting/modifying snapshot devices. When the general snapshot system of the invention creates the snapshot, it needs to select which snapshot technology is used to create the snapshot, and this selection process is also implemented by the device management toolset. The specific implementation of the device management toolset has similarity to the implementation of the corresponding functional module of the snapshot system in the prior art, and therefore, a repetitive description is not made in the present invention.
The snapshot implementation module is a main part of the general snapshot system. Logically, the method can be divided into two layers: a snapshot mechanism layer and a physical resource management layer. The snapshot mechanism layer provides the relation between snapshot devices for data searching and time point management. The physical resource management layer provides allocation and reclamation management of the underlying physical space. The composition and function of the snapshot mechanism layer and the physical resource management layer are described below.
The snapshot mechanism layer contains a plurality of snapshot groups, and the snapshot technology adopted in one snapshot group is the same, while different snapshot technologies can be used in different snapshot groups. That is, in the present invention, one snapshot group can only select one of the COW snapshot implementation techniques and the ROW snapshot implementation techniques, but the snapshot implementation techniques between different snapshot groups are not necessarily the same.
In a snapshot group, a plurality of snapshot devices are distinguished according to time points, and all the snapshot devices are organized in an incremental mode and a serial mode. The relationship between the source device and the snapshot device in a snapshot group is depicted in fig. 3 and 4. Fig. 3 shows a relationship between a source device and a snapshot device in the COW snapshot implementation technique. Fig. 4 shows the relationship between the source device and the snapshot device in the ROW snapshot implementation technique. In the ROW device group, the inter-device dependencies are sequentially pointed to the earliest created snapshot device by the source device, and in the COW device group, the opposite is true, and the dependencies are pointed to the source device by the earliest created snapshot device.
Although the snapshot group may adopt the COW technology or the ROW technology in the above snapshot group, in order to simplify the design, two different technologies, i.e., COW and ROW, are integrated in the implementation, and the present invention adopts a general memory structure with four pointers. In fig. 6, a general memory structure with four pointers is illustrated, where the r0 and r1 pointers correspond to physical devices that need to be accessed during a read operation, and the w0 and w1 pointers correspond to physical devices that need to be accessed during a write operation.
The snapshots provided by the universal snapshot system of the present invention may be classified by type as read-only and writable snapshots. In general, snapshots are read-only, a source device and read-only snapshots created at different times form a chain structure, the source device is at the head of a chain, and serves as a root node, and the snapshot device with the earliest time is at the tail of the chain. Each snapshot device records incremental data that changes at adjacent snapshot points in time, providing different versions of data at multiple points in time on the source volume for a data version management application. Under some specific applications, the system also provides a writable snapshot, and a completely new snapshot device is created for the read-only snapshot to obtain a writable copy of the read-only snapshot, so that the writing of the read-only snapshot is realized. After the writable snapshot is created for the read-only snapshot, the original read-only snapshot is still visible to the outside, and the writable snapshot created for the read-only snapshot is represented as a brand-new snapshot device which is equivalent to a new source device to the outside. A read-only snapshot may be created over the writable snapshot, with the writable snapshot also forming a chain with its read-only snapshot. The write operation to the writable snapshot is directly written into the new snapshot device.
When the writable snapshot is read, data is firstly searched in a chain where the writable snapshot is located, and if the data cannot be searched, the data is forwarded to the read-only snapshot on which the writable snapshot depends for reading. As shown in fig. 3 and 4, g0 is a snapshot group, in which snapshot apparatuses snap5 are made writable snapshots to generate snap5 'snapshot apparatuses, and snap 5' is continued to make read-only snapshots to form a g2 snapshot group. Snapshot group g2 is connected to snapshot group g0 by its parent pointer of writable device snap 5'. Similarly, the snap 5' 2 in the snapshot group g2 is made into a writable snapshot, and finally a g3 snapshot group is formed. When data in snap5 ' 1 equipment in g2 group is read, firstly, search is carried out in g2 group, if the chain head equipment snap5 ' is found, the search is continued in g0 group through parent pointer of snap5 '. Until the desired data is found.
The physical resource management layer provides management of the physical devices used by the logical devices, including opening, closing, adding, deleting, and checking for legitimacy of the physical devices, among others. In a snapshot group, both the source device and the snapshot device may be referred to as logical devices, and one logical device corresponds to two physical devices at a physical resource layer, as shown in fig. 1, where one physical device is a metadata device and the other is a data device.
On the metadata device, metadata identifying management and use of physical resources such as physical devices is stored. Specifically, the metadata is used to indicate the increment of the data and the storage location of the data in the snapshot version on the data device, and reflects the data mapping relationship of the snapshot version at a certain time point. For each data block (Chunk) in the data device, there is a corresponding entry in the metadata table of the metadata device for recording whether the data block has been modified and the storage location of the data block. In one metadata item must be included: time, data location, data modification status, etc. The metadata may take the form of a bitmap (bitmap), a mapping table, or any other form of record. In this embodiment, the metadata is recorded in a bitmap manner. During specific recording, each logical device has a bitmap, each bit in the bitmap represents an address range of the size of a data block, the whole bitmap covers the logical space of the snapshot device, and the positioning operation of user data is performed through the value of the corresponding bit in the bitmap.
The bitmap for recording the metadata is stored in the metadata equipment, and the bitmap can be divided into a plurality of levels in consideration of the storage space and the access efficiency of the metadata, and the divided bitmap structure is closely related to the size of a data block in the data equipment. In the present embodiment, the data block size is set to 4096 bytes, and as shown in fig. 5, the bitmap uses the following three-level structure: each bit in the first level bitmap represents a logical space of 4T size, occupying 4 kbytes (1 page), each bit in the second level bitmap represents a 128M address space, and each bit in the third level bitmap represents a 4k address space. The first level bitmap is resident in the memory, and the second level and the third level adopt a swap-in swap-out mechanism to ensure that the metadata occupies smaller space. The relationship between the three level bitmaps is: if a certain bit of the first level bitmap is 1, the corresponding secondary bitmap has 1, and similarly, if 1 exists in the secondary bitmap, the corresponding tertiary bitmap has 1. Bitmap traversal time can be reduced by a three-level bitmap structure.
In the general snapshot system of the present invention, when data changes between logical devices, the change is reflected using metadata, that is, the metadata has a function of indicating data increments. When representing the increment between snapshots at two different time points, the metadata recorded in a bitmap mode has the following specific meanings:
bitmap value 1: indicating that there is a write between the time points of the two snapshots;
bitmap value is 0: indicating that there were no write operations between the time points of the two snapshots.
Reading of data in the logical device can be achieved through the metadata. However, in the general snapshot system of the present invention, the snapshot implementation technique adopted in the snapshot group may be a COW snapshot implementation technique or a ROW snapshot implementation technique. Therefore, the metadata recorded in the bitmap mode has respective specific meanings in the two snapshot realization technologies, and when the metadata is used for reading the data, the internal semantics of the metadata are different. The different internal semantics involved here are related in detail when creating and deleting snapshots and reading snapshot data by using the general snapshot system of the present invention, and will be described in detail below.
After the above description of the structure of the general snapshot system of the present invention, the method for using the general snapshot system of the present invention is further described, which includes the following steps:
step 1, a user issues a snapshot creating command through the equipment management toolset, and determines which snapshot technology is selected to create a snapshot in the command;
step 2, the snapshot mechanism layer in the snapshot realization module creates a snapshot according to the snapshot technology selected in the step 1;
step 3, reading data in the snapshot according to the requirements of the user;
step 4, according to the requirement of the user, completing the operation of writing data in the snapshot;
and 5, deleting the snapshot according to the requirement of the user.
In the above steps, the snapshot creation, snapshot data reading, snapshot data writing, and snapshot deletion may be different due to different snapshot technologies, and are respectively described below.
As shown in fig. 7, in the process of creating a ROW-like snapshot, when only the source device exists, the physical device used by the source device is the physical device 1, and after the snapshot is created, the physical device 2 assigned to the snapshot device is handed over to the source device for use, and the physical device 1 used by the source device is handed over to the snapshot device for use.
In the ROW mode, since the metadata device is exchanged with the data device when the snapshot is created, 1 in the bitmap has a one-to-one correspondence with the incremental data on the data device. When snapshot data at a certain time point is accessed, the values in the bitmap thereof mean as follows:
bitmap value 1: data representing the data block corresponding to the corresponding bit is deposited on the data device of the snapshot.
Bitmap value is 0: data representing the data block corresponding to the respective bit is not on the data device of the snapshot.
As shown in fig. 8, the bitmap of the ROW corresponds to the data position one to one, where the bitmap is 1, which indicates that the data is on the device, and a value of 0 requires a backward search. For example, in fig. 8, to read the a data of state 6, it must be looked back to the s1 time point to determine the data location.
As shown in fig. 6, in the COW mode creating process, only the metadata device is exchanged, and the data device does not exchange. The dependency relationship between the logical devices of the device group is different from the ROW mode. For example, the source device corresponds to physical device 1, after creating the snapshot, the source device still corresponds to physical device 1, and snapshot s1 corresponds to physical device 2.
In COW mode, a write that occurs after a snapshot is created will cause a COW process to copy data into the snapshot. Thus, a1 of the metadata of the snapshot device cannot indicate that data is deposited on the data device of the snapshot until the COW is not performed, and at this time, a1 only indicates that a COW operation is generated on the corresponding data block at that time. With reference to fig. 6, the data position determination method in the COW mode is described as follows:
when reading the snapshot S1, reading the bitmap of the snapshot S2 at a later time point, and if the value of the bitmap is 1, indicating that the data of the corresponding data block is stored in the data device of the snapshot S1; if the bitmap value is 0, the snapshot at the later time point along the chain continues to be searched, if the snapshot S is encounteredkIf the bitmap value of (1) indicates that the data of the corresponding data block is stored in the snapshot Sk-1On the data device of (1); if the source equipment is encountered in the searching process and the bitmap value of the source equipment is 1, indicating that the data of the data block is stored on the data equipment of the adjacent snapshot of the source equipment; if the bitmap value of the source device is 0, the data representing the data block is stored on the source data device.
As shown in fig. 9, state 1 is that the s1 snapshot device was created after the source written four ABCD blocks, at which time s1 holds the bitmap of the source in state s0, and the bitmap of the source is cleared. In state 2, blocks 1, 3 are written, which triggers a COW operation to copy data from the source device to the s1 snapshot device. The bitmap of the source is set in the corresponding position, and the bitmap of the snapshot is not changed. In state 4, write the 2, 3 blocks of the source, at which point a COW operation is triggered, copying the data from the source device to the s2 snapshot device, and so on. When reading the s1 point-in-time data, a look-ahead is required, such as reading D data at state 6, and then a look-ahead is required to the s3 device to finally determine the location of the data.
When the metadata is stored in the physical device, the metadata and the data can be stored on the same physical medium together to realize mixed storage, and can also be stored on an independent physical device and isolated from the physical medium where the data is located. In the embodiment, in consideration of the efficiency and the scalability, a scheme of separating the metadata devices is finally adopted.
After the basic composition of the general snapshot system of the present invention is explained, the processes of creating a snapshot, deleting a snapshot, reading data, migrating data, etc. by the snapshot system are explained.
Fig. 6 and fig. 7 are corresponding descriptions of a snapshot creation process, where fig. 6 is a process of creating a snapshot using a COW snapshot implementation technique, and fig. 7 is a process of creating a snapshot using a ROW snapshot implementation technique.
In fig. 6, there are four snapshot relationship pointers in both the snapshot device and the source device, which point to the physical devices whose read-write operations need to access, and record the dependency relationships between snapshots and the source device. The creation process of the snapshot in the COW mode is as follows: firstly, creating a source device, and pointing all snapshot relation pointers of the source device to physical devices of the source device when creating, wherein only the source device is in a snapshot linked list at the moment; then, a first snapshot is created at the next time point, in the process of inserting the snapshots into a snapshot linked list, a pointer w0 of a modified source device points to the snapshot, a pointer r0 of the snapshot points to the source, and if the created snapshot is a read-only snapshot, devices w0 and w1 of the snapshot need to be modified into null pointers; when a second snapshot is created for the source device, and the snapshot device 2 is inserted into the linked list, the pointer w0 of the modified source device points to the snapshot device 2, the pointer r0 of the snapshot device 2 points to the source, and the pointer r0 of the snapshot device 1 points to the snapshot device 2, and if the snapshot is a read-only snapshot, the pointers w0 and w1 of the snapshot device 2 also need to be modified to be null pointers. Through the process, the dependency relationship among the snapshot devices at different time points is established.
FIG. 7 is similar to the snapshot creation process of FIG. 6, except that it differs when four pointers point. In the ROW mode, the r0 pointer of the source device points to the snapshot device, and the snapshot device does not point back to the source device. When there are multiple snapshot devices, the snapshot chain of the ROW is from the snapshot at the latest time point to the snapshot at the oldest time point in turn, as shown in fig. 7, s1 is the earliest created snapshot device whose time point is the oldest, and s2 is the latest created snapshot whose time point is the newest. The snapshot chain is pointed to s2 and s1 devices by the source device in turn, which is the reverse of the COW mode.
When reading data in the general snapshot system, the reading of data in the source device and the reading of data in the snapshot device can be divided.
When reading data in a source device, no matter in a COW mode or a ROW mode, the flow of reading the data is the same, and the method comprises the following steps:
step A1, inquiring a corresponding bit in a bitmap according to the address of the data to be read, if the value of the bit is 1, directly reading the bit locally, returning the read data value, and if the value of the bit is 0, executing the next step;
step A2, judging whether the data in the source device has a corresponding snapshot, the judging algorithm is: if the r0 pointer points to a physical device, then there is no snapshot; if it is a logical device, a snapshot exists. If the snapshot does not exist, returning all-zero data, if the snapshot exists, forwarding the read data request according to the snapshot chain, and entering a read flow of the snapshot data.
In the process of reading snapshot data, there is a significant difference in reading according to different snapshot implementation techniques, which will be described below.
In the COW mode, the process of reading snapshot data is as follows:
step B1, determining the physical device for storing data according to the value of the bitmap; the judgment algorithm is as follows: traverse from the tail of the snapshot linked list, if at a certain snapshot SkThe value of bitmap on is 1, then the snapshot S is before itk-1If the bitmap value is 0, the data reading request is forwarded to the previous snapshot along the snapshot linked list until the snapshot with the bitmap value of 1 is found;
step B2, finding no snapshot with bitmap value 1 in the snapshots of the snapshot linked list, and reading the data request to the source device, if the bitmap value of the source device is 1, reading the data on the data device of the snapshot adjacent to the source device, otherwise, reading the data on the data device of the source device. The specific implementation of this step can be seen from the above description of fig. 9.
In the ROW mode, the process of reading snapshot data is as follows:
and determining the physical equipment where the data is stored according to the value of the bitmap, and then reading the data from the physical equipment where the data is stored. In the ROW mode, the judgment algorithm for determining the data storage position is as follows: traversing from the tail part of the snapshot linked list to the front part if the snapshot is in a certain snapshot SkIf the bitmap value is 1, reading the bitmap from the local data equipment and returning corresponding data, and if the bitmap value is 0, judging whether the current snapshot is available or notAnd the current snapshot is the oldest snapshot in the snapshot linked list, namely whether the current snapshot is the snapshot at the tail end of the snapshot linked list, if so, all 0 is returned, otherwise, the read data request is forwarded to the previous snapshot in the snapshot linked list. The specific implementation of this step can be seen from the above description of fig. 8.
In the process of writing data to the source, there is a difference in writing data according to different snapshot implementation techniques, which will be described below.
In the COW mode, the flow of writing data is as follows:
a1, determining the physical device for storing data according to the value of the bitmap;
step a2, writing data according to the physical device determined in step a 1.
The specific implementation method comprises the following steps: if the bitmap value is 1, directly writing into the physical equipment of the source; and if the bitmap value is 0, writing the COW operation into the physical equipment of the source after the COW operation is finished.
In the ROW mode, the flow of writing data is as follows:
step b1, determining the physical device for storing data according to the value of the bitmap;
step b2, writing data according to the physical device determined in step b 1.
The specific implementation method comprises the following steps: if the bitmap value is 1, directly writing into the physical equipment of the source; and if the bitmap value is 0, merging the data of the data blocks and then writing the merged data into the physical equipment of the source.
Similarly, in the general snapshot system, there is a difference in the deletion of the snapshot due to the difference in the snapshot technology, and the deletion process of the snapshot is described in the following cases.
In the COW mode, when there are multiple time snapshots, in order to simplify design and implementation, we stipulate that only the oldest time snapshot can be deleted, and data migration operation is avoided.
In the ROW mode, there is a need to delete a newly created snapshot, and as can be seen from the relationship in fig. 7, snapshots at different time points have a dependency relationship, and data at the same time point may be distributed on different physical devices, so that data needs to be merged. Taking fig. 7 as an example, a data merging method triggered when the snapshot device is deleted will be described.
In fig. 7, S1 and S2 are snapshot devices at two time points that are immediately adjacent to each other, and it is assumed that the snapshot device S1 is to be deleted, and a specific data merging process includes:
step 10, sequentially reading the corresponding bit of each data block in the bitmap in the snapshot device S2;
step 20, combining the bitmap bit in the snapshot device S2 with the corresponding bitmap bit of the snapshot device S1, can obtain four situations:
S2 S1
a、0 0
b、0 1
c、1 0
d、1 1
when the bitmap bit of S2 is 1, it indicates that new data has been written, so that only the data block with bitmap bit 1 of S2 needs to be copied back to the data device of S1 during data merging, no matter what value the bitmap bit of S1 is. This copying process is referred to as a data move-back operation.
And step 30, executing a data back shift operation, and copying the data in the data device of the S2 to the data device of the S1.
Step 40, after the migration is finished, setting the corresponding bit of the bitmap of S2 as 0;
step 50, if all the data blocks are processed, executing the next step; otherwise, step 10 is executed again, and the next data block is processed continuously.
And step 60, locking the two logical devices, simultaneously changing the values of the bitmap and the r1 pointer, and exchanging the physical devices of the two logical devices.
And step 70, releasing resources such as the memory and the physical equipment occupied by the deleted equipment.
Finally, it should be noted that the above embodiments are only used for illustrating the technical solutions of the present invention and are not limited. Although the present invention has been described in detail with reference to the embodiments, it will be understood by those skilled in the art that various changes may be made and equivalents may be substituted without departing from the spirit and scope of the invention as defined in the appended claims.