Working Principle
A snapshot works as a point-in-time copy of source data, and involves a source LUN, copy-on-write (COW) data space, and snapshot LUN. Snapshots are quick to generate with low requirements for storage space.
Concepts
Concept |
Description |
---|---|
Data organization |
The OceanStor storage systems use virtual storage technology. Each LUN is composed of both a meta volume and a data volume.
|
Source volume |
The storage of snapshot source data is represented as a source LUN. A source LUN consists of the following:
|
Snapshot volume |
A snapshot volume is a logical data copy generated after a snapshot is created for a source LUN. It is presented as a snapshot LUN to users. A snapshot LUN consists of the following:
NOTE:
If no data has ever been written to a snapshot LUN, the meta and data volumes are empty. |
COW |
COW technology saves a source LUN's original data to be changed. If snapshots are active, when an application server writes data to the source LUN, the storage system performs the following steps:
|
COW data space |
COW data space is dynamic storage allocated from the storage pool where the source LUN resides. This storage is used to store COW data following snapshot generation and activation. All snapshot LUNs of a source LUN share a single COW data space. COW data space consists of the following:
|
Mapping table |
Changes in source LUNs and snapshot LUNs are recorded here. Mapping tables are classified as shared or private. These perform the following functions:
|
Snapshot copy |
A snapshot copy is a saved snapshot, preserving it for future use if other snapshot data is later changed. |
Creating and Activating a Snapshot
Once a snapshot is created and activated, a data copy of the source LUN is generated. The storage system dynamically allocates COW data space from the storage pool where the source LUN resides, and generates a snapshot LUN. Because no data is written to snapshot or source LUNs, no data is recorded to the COW meta and data areas or to the snapshot meta and data volumes. Figure 1-1 shows the initial state of a snapshot after creation and generation.
Writing Data to a Source LUN
If an application server attempts to write data to the source LUN of an activated snapshot, the storage system performs the following:
- Uses the COW mechanism to copy COW data to the COW data space.
- Changes the mapping relationships in the mapping table.
- Writes new data to the source LUN.
Figure 1-2 shows the state of the snapshot after data is written to the source LUN.
A new write request for new data to a source LUN is processed as follows:
- The application server sends a write request to the source LUN after Time 1, with an attempt to change Data1 to DataX.
- The COW mechanism is triggered to copy Data1 to the COW data space.
- The mapping relationships are updated in the mapping table. The location of Data1 is changed to g0 in the COW data space.
- DataX is written into the source LUN.
In a snapshot period, COW is performed only once for data of each location. Following that, newly written data overwrites old data. For example, if the value of DataX is recorded as 1 in the mapping table, COW has been performed for DataX. For data write requests made in the future, the storage system will write data directly to the source LUN without copying DataX to COW data space.
If there are multiple data writes to the same location of the source LUN and new snapshots are generated, the shared mapping table records the data changes chronologically. For example, after DataX is written to the source LUN, a snapshot of the source LUN is created and activated. In this case, the process of writing data to the source LUN is shown in Figure 1-3.
A request for multiple data writes to the same location on the source LUN is processed as follows:
- The application server sends a write request to the source LUN after Time 2, with an attempt to change DataX to DataY.
- The COW mechanism is triggered to copy DataX to the COW data space.
- The mapping relationships are updated in the mapping table. The location of DataX is changed to g0 in the COW data space. The (g0, Time 2) location in the shared mapping table is marked as 1.
- DataY is written into the source LUN.
When the snapshot is read, the storage system compares the point in time of the shared mapping table (such as Time 2) with the time stamp of the COW data space to identify the data block of the snapshot.
Writing Data to a Snapshot LUN
Following snapshot activation, application servers are able to send read and write requests to the snapshot LUN. Write requests are directly processed by the snapshot LUN, and the private mapping table records the data location in the snapshot LUN. Figure 1-4 shows a snapshot state following a data write to its snapshot LUN.
A write request to a snapshot LUN is processed as follows:
- An application server sends a write request for Data a to the snapshot LUN after Time2.
- Data a is written directly to the snapshot LUN.
- The private mapping table records the storage location of Data a as g'0 of the snapshot LUN.
Reading Snapshot Data
When an application server attempts to read snapshot data, the storage system processes the read request as follows:
- The storage system searches the private mapping table for the data location in the snapshot LUN.
- If the data is in the snapshot LUN, the data is returned to the application server.
- If the snapshot LUN does not contain the data, the storage system searches the shared mapping table.
- The storage system searches the shared mapping table for the data location in the COW data space and source LUN.
- If the search result is 0, data is read from the source LUN.
- If the search result is 1, data is read from the COW data space.
- If the application server has written data into the snapshot LUN (Figure 1-4), the application server can read snapshot data. See Figure 1-5.
The process of reading snapshot data from the snapshot LUN is as follows:
- The application server sends a request to read snapshot data.
- The private mapping table locates the desired snapshot data.
- The application server reads the snapshot data. In Figure 1-5, this is Data a.
- If the application server has written data to the source LUN but not the snapshot LUN, the application server reads snapshot data from the source LUN or COW data space. See Figure 1-6.
The process of reading snapshot data from the source LUN is as follows:
- The application server sends a request to read snapshot data.
- The shared mapping table locates the desired snapshot data.
- The application server reads the snapshot data. In Figure 1-6, this is Data 0, Data 1, Data 2 and Data 3.
Snapshot Rollback Process
In addition to rapidly creating a point-in-time copy of source data, snapshots also provide a mechanism for rapid restoration of source LUN data. If data on a source LUN is altered unexpectedly, perform a snapshot rollback to restore data on the source LUN to its state at snapshot activation, which mitigates data loss. Figure 1-7 shows the snapshot rollback process.
After data is written to a snapshot, the snapshot no longer preserves the data state at the point of activation. To restore data on a source LUN to the data state at the point of activation, create a snapshot copy before writing data to a snapshot and use a snapshot copy to perform a rollback.