CN113468104A - Snapshot data structure, and related data processing method, device and system - Google Patents

Snapshot data structure, and related data processing method, device and system Download PDF

Info

Publication number
CN113468104A
CN113468104A CN202010242341.5A CN202010242341A CN113468104A CN 113468104 A CN113468104 A CN 113468104A CN 202010242341 A CN202010242341 A CN 202010242341A CN 113468104 A CN113468104 A CN 113468104A
Authority
CN
China
Prior art keywords
data block
inheritance
data
snapshot
snapshot version
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010242341.5A
Other languages
Chinese (zh)
Inventor
张军伟
刘振军
陈森
王利虎
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Alibaba Group Holding Ltd
Original Assignee
Alibaba Group Holding Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN202010242341.5A priority Critical patent/CN113468104A/en
Publication of CN113468104A publication Critical patent/CN113468104A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/11File system administration, e.g. details of archiving or snapshots
    • G06F16/128Details of file system snapshots on the file-level, e.g. snapshot creation, administration, deletion
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/18File system types
    • G06F16/1873Versioning file systems, temporal file systems, e.g. file system supporting different historic versions of files

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a data structure of a snapshot, a related data processing method, a related data processing device and a related data processing system, wherein the data structure of the snapshot comprises main data and metadata; the metadata comprises a data block identifier of the main data and a corresponding inheritance bitmap; each inheritance bit in the inheritance bitmap corresponds to a data block of the primary data, and each inheritance bit comprises an inheritance flag used for identifying whether the corresponding data block is shared with a previous snapshot version. By recording the inheritance marks of the corresponding data blocks in the inheritance bits of the inheritance bitmaps of the metadata, compared with the prior art, the method does not need to independently maintain the reference counts of the data blocks, thereby reducing the influence on the IO access performance of the system; and, the data read-write operation in the data processing process is convenient.

Description

Snapshot data structure, and related data processing method, device and system
Technical Field
The present invention relates to the field of snapshot technologies, and in particular, to a snapshot data structure, a related data processing method, an apparatus, and a system.
Background
A snapshot (snapshot) is a mirror image that preserves consistent data of a file system at a point in time. Different snapshot versions created for a file system at different points in time may form a chain of snapshot versions. The snapshot data can not be modified, the data consistency in the data backup process can be ensured, and when the application failure or file damage occurs to the storage equipment, the data can be quickly restored, and the data can be rolled back to restore the state of an available time point, so that the snapshot technology is widely used for data backup and restoration after abnormal failure.
In the prior art, a snapshot is usually implemented by two ways, i.e., Redirect On Write (ROW) and Copy On Write (COW). Referring to fig. 1, when data is written in a COW mode, a new data resource (referred to as a newly allocated data block in the embodiment of the present invention) is allocated to a snapshot version, the primary data of a snapshot is copied to the newly allocated data block as the primary data of the snapshot, then metadata of the snapshot version is modified, and finally, data in an original data block is modified by newly written data. Therefore, by adopting the COW mode, data modification needs to be carried out twice, the read-write data volume is large, and the Input/Output (IO) access performance of the system is seriously influenced. Referring to fig. 2, when data is written in the ROW manner, new data resources are allocated to the current writable snapshot version, and the newly written data is copied to the newly allocated data block, so that the data of the snapshot data block is kept from being modified. When data is written, only one-time data modification is needed, the read-write data volume is small, and the influence on the system IO access performance is small, so that the snapshot data processing is usually performed in an ROW mode in the prior art.
Snapshot data processing is performed in an ROW mode, data of one data block may be shared among multiple snapshot versions, that is, the data block number is recorded in metadata of the multiple snapshot versions. In order to efficiently determine whether data of a data block is shared by multiple snapshot versions, so as to keep data of a read-only snapshot version unmodified when writing data, and not release shared data when deleting a snapshot version, in the prior art, a block reference count table is usually used to record whether data of a data block corresponding to a data block number is shared by multiple snapshot versions. But this method requires maintenance of the block number reference table. If the block number reference table is maintained in the internal memory, not only is the overhead of the internal memory increased, but also after the system is restarted, the block number reference table can be constructed and completed only by traversing all metadata in the snapshot version chain, so that the IO access performance of the system can be influenced. If the data persistence mode is adopted, and the external memory maintains the block number reference table, each time the reference count of the corresponding data block in the block number reference table is updated, inefficient Input/Output (IO) operations of the external memory are required, and therefore, the IO access performance of the system is also affected.
Disclosure of Invention
In view of the above, the present invention has been made to provide a data structure of a snapshot, a related data processing method and apparatus and system that overcome the above problems or at least partially solve the above problems.
As a first aspect of the embodiments of the present invention, an embodiment of the present invention provides a data structure of a snapshot, including main data and metadata;
the metadata comprises a data block identifier of the main data and a corresponding inheritance bitmap;
each inheritance bit in the inheritance bitmap corresponds to a data block of the primary data, and each inheritance bit comprises an inheritance flag used for identifying whether the corresponding data block is shared with a previous snapshot version.
As a second aspect of the embodiments of the present invention, an embodiment of the present invention provides a data processing method, including:
acquiring a data block identifier and an inheritance bitmap of main data in the metadata of the snapshot; each inheritance bit in the inheritance bitmap corresponds to a data block of the main data, and each inheritance bit comprises an inheritance flag used for identifying whether the corresponding data block is shared with a previous snapshot version;
according to the data block identification of the main data and the inheritance flag of the corresponding inheritance bit in the inheritance bitmap, at least one of the following processes is carried out: creating snapshots, writing data, reading data, deleting snapshot versions, and data migration of snapshots.
As a third aspect of the embodiments of the present invention, an embodiment of the present invention provides a snapshot creating method, including:
fixing main data and metadata of the current writable snapshot version as the latest read-only snapshot version;
and copying the metadata of the latest read-only snapshot version as the metadata of the new writable snapshot version, and modifying the inheritance flag of the corresponding inheritance bit in the inheritance bitmap of the new writable snapshot version.
As a fourth aspect of the embodiments of the present invention, an embodiment of the present invention provides a snapshot data writing method, including:
accessing metadata of the current writable snapshot version, and acquiring a data block identifier of data to be written and an inheritance mark of a corresponding inheritance bit;
if the inheritance mark of the inheritance bit is an invalid mark, writing the data to be written into the data block indicated by the data block mark;
if the inheritance flag of the inheritance bit is an effective identifier, allocating a new data block, writing the data to be written into the newly allocated data block, modifying the data block identifier in the metadata into the data block identifier of the newly allocated data block, and modifying the inheritance flag of the inheritance bit corresponding to the data block identifier of the newly allocated data block in the inheritance bitmap.
As a fifth aspect of the embodiments of the present invention, an embodiment of the present invention provides a snapshot deleting method, including:
acquiring a data block identifier in metadata of a snapshot version to be deleted and an inheritance mark of a corresponding inheritance bit in an inheritance bitmap;
if the inheritance mark of the inheritance bit of the snapshot version to be deleted is an effective mark, the data of the data block indicated by the corresponding data block mark is not released;
if the inheritance marks of the inheritance bits of the corresponding data blocks of the snapshot version to be deleted and the next snapshot version are invalid identifications, releasing the data of the data block indicated by the corresponding data block identification of the snapshot version to be deleted;
if the inheritance flag of the inheritance bit of the snapshot to be deleted is an invalid flag and the inheritance flag of the inheritance bit corresponding to the later snapshot version is an effective flag, the data of the data block indicated by the data block identifier of the snapshot version to be deleted is not released, and the inheritance flag of the inheritance bit corresponding to the later snapshot version is modified to be an invalid flag.
As a sixth aspect of the embodiments of the present invention, an embodiment of the present invention provides a snapshot data migration method, which is applied to a source end of snapshot migration, and includes:
when the snapshot to be migrated is the current writable snapshot version, determining that the target end does not have a corresponding data block for each data block, and sending the data of the data block of the current writable snapshot version and the inheritance bit of the corresponding data block in the metadata to the target end;
when the snapshot to be migrated is a read-only snapshot version, aiming at each data block, if the inheritance mark of the corresponding inheritance bit in the inheritance bitmap of the next snapshot version of the snapshot to be migrated is an invalid identifier, the inheritance bit of the corresponding data block in the data and metadata of the corresponding data block is sent to a target end; otherwise, sending a request for constructing the mapping relation between the corresponding data block identifier and the data block in the metadata to the target terminal.
As a seventh aspect of the embodiments of the present invention, an embodiment of the present invention provides a snapshot data migration method, applied to a target end of snapshot migration, including:
when receiving data of a source end, distributing a new data block, writing the received data into the newly distributed data block, and modifying the data block identifier in the metadata into the data block identifier of the newly distributed data block;
and when a request for constructing the mapping relation between the corresponding data block identification and the data block in the metadata is received, constructing the mapping relation between the data block identification of the metadata in the current snapshot version and the corresponding data block in the next snapshot version.
As an eighth aspect of the embodiments of the present invention, an embodiment of the present invention provides a snapshot creating apparatus, including:
the snapshot solidification module is used for fixing main data and metadata of the current writable snapshot version as the latest read-only snapshot version;
and the writable snapshot generating module is used for copying the metadata of the latest read-only snapshot version as the metadata of the new writable snapshot version and modifying the inheritance mark of the corresponding inheritance bit in the inheritance bitmap of the new writable snapshot version.
As a ninth aspect of the embodiments of the present invention, an embodiment of the present invention provides a snapshot data writing apparatus, including:
the first acquisition module is used for accessing the metadata of the current writable snapshot version and acquiring the data block identifier of the data to be written and the inheritance mark of the corresponding inheritance bit;
the data writing module is used for writing the data to be written into the data block indicated by the data block identifier if the inheritance flag of the inheritance bit is an invalid identifier; if the inheritance flag of the inheritance bit is an effective identifier, allocating a new data block, writing the data to be written into the newly allocated data block, modifying the data block identifier in the metadata into the data block identifier of the newly allocated data block, and modifying the inheritance flag of the inheritance bit corresponding to the data block identifier of the newly allocated data block in the inheritance bitmap.
As a tenth aspect of the embodiments of the present invention, an embodiment of the present invention provides a snapshot deleting apparatus, including:
the second acquisition module is used for acquiring the data block identifier in the metadata of the snapshot version to be deleted and the inheritance mark of the corresponding inheritance bit in the inheritance bitmap;
the deletion and modification module is used for not releasing the data of the data block indicated by the corresponding data block identifier when the inheritance flag of the inheritance bit of the snapshot version to be deleted is an effective identifier; when the inheritance marks of the inheritance bits of the corresponding data blocks of the snapshot version to be deleted and the next snapshot version are invalid identifications, releasing the data of the data block indicated by the corresponding data block identification of the snapshot version to be deleted; when the inheritance flag of the inheritance bit of the snapshot to be deleted is an invalid flag and the inheritance flag of the inheritance bit corresponding to the later snapshot version is an effective flag, the data of the data block indicated by the data block identifier of the snapshot version to be deleted is not released, and the inheritance flag of the inheritance bit corresponding to the later snapshot version is modified to be an invalid flag.
As an eleventh aspect of the embodiment of the present invention, an embodiment of the present invention provides a snapshot data migration apparatus, including:
the source end migration module is used for determining that the target end does not have a corresponding data block aiming at each data block when the snapshot to be migrated is the current writable snapshot version, and then sending the data of the data block of the current writable snapshot version and the inheritance bit of the corresponding data block in the metadata to the target end; when the snapshot to be migrated is a read-only snapshot version, aiming at each data block, if the inheritance mark of the corresponding inheritance bit in the inheritance bitmap of the next snapshot version of the snapshot to be migrated is an invalid identifier, the inheritance bit of the corresponding data block in the data and metadata of the corresponding data block is sent to a target end; otherwise, sending a request for constructing the mapping relation between the corresponding data block identifier and the data block in the metadata to the target end;
the target end migration module is used for distributing a new data block when receiving the data of the source end, writing the received data into the newly distributed data block, and modifying the data block identifier in the metadata into the data block identifier of the newly distributed data block; and when a request for constructing the mapping relation between the corresponding data block identification and the data block in the metadata is received, constructing the mapping relation between the data block identification of the metadata in the current snapshot version and the corresponding data block in the next snapshot version.
As a twelfth aspect of the embodiments of the present invention, an embodiment of the present invention provides a snapshot system, including:
at least one client, at least one data resource store, and at least one server connected to the at least one data resource store;
the client is used for sending at least one of a snapshot creation request, a data writing request, a data reading request, a snapshot version deleting request and a data migration request to the server;
the server is used for executing snapshot creation, data writing, data reading, snapshot version deletion or data migration according to a request sent by the client;
and the data resource storage is used for storing the data resources of each snapshot version in the snapshot version chain.
As a thirteenth aspect of the embodiments of the present invention, an embodiment of the present invention provides a computer-readable storage medium, on which computer instructions are stored, where the instructions, when executed by a processor, can implement at least one of the snapshot processing method, the snapshot creation method, the snapshot data writing method, the snapshot deletion method, and the snapshot deletion method as described above.
The technical scheme provided by the embodiment of the invention has the beneficial effects that at least:
according to the snapshot data structure, the related data processing method, the device and the system, the inheritance flag of the corresponding data block is recorded in the inheritance bit of the inheritance bitmap of the metadata, whether the corresponding data block is shared with the previous snapshot version or not is identified through the inheritance flag of the inheritance bit, and compared with a mode that a block reference counting table is adopted to record reference counting of the data block in the prior art, the reference counting of the data block is not required to be independently maintained, so that the influence on the IO access performance of the system is reduced; and moreover, whether the data of the data block of the current fast and good version is modified or not can be determined by inheriting the inheriting mark of the inheriting bit in the bitmap, and data reading and writing operations in the data processing process are facilitated.
Additional features and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. The objectives and other advantages of the invention will be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.
The technical solution of the present invention is further described in detail by the accompanying drawings and embodiments.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this specification, illustrate embodiments of the invention and together with the description serve to explain the principles of the invention and not to limit the invention. In the drawings:
fig. 1 is a schematic diagram illustrating a principle of processing snapshot data writing in a COW mode in the prior art;
FIG. 2 is a schematic diagram illustrating a prior art method for processing snapshot data writing in a ROW manner;
fig. 3 is a schematic structural diagram of a data snapshot system according to an embodiment of the present invention;
fig. 4 is a flowchart illustrating a method for creating a snapshot according to an embodiment of the present invention;
fig. 5 is a schematic diagram illustrating an implementation principle of the method for creating a snapshot shown in fig. 4 according to an embodiment of the present invention;
fig. 6 is a flowchart illustrating a method for writing snapshot data according to an embodiment of the present invention;
fig. 7 is a schematic diagram illustrating an implementation principle of the method for writing snapshot data shown in fig. 6 according to an embodiment of the present invention;
fig. 8 is a flowchart illustrating a method for reading snapshot data according to an embodiment of the present invention;
fig. 9 is a flowchart illustrating a method for deleting a snapshot according to an embodiment of the present invention;
fig. 10 is a schematic diagram illustrating an implementation principle of the method for deleting the snapshot shown in fig. 9 according to an embodiment of the present invention;
FIG. 11 is a flowchart illustrating a method for data migration of a snapshot according to an embodiment of the present invention;
fig. 12 is a flowchart illustrating a specific implementation of a method for data migration of a snapshot shown in fig. 9 according to an embodiment of the present invention;
fig. 13 is a schematic structural diagram of a snapshot creation apparatus according to an embodiment of the present invention;
fig. 14 is a schematic structural diagram of a snapshot data writing apparatus according to an embodiment of the present invention;
fig. 15 is a schematic structural diagram of a snapshot deleting apparatus according to an embodiment of the present invention;
fig. 16 is a schematic structural diagram of a snapshot data migration apparatus according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
In order to solve the problems that in the prior art, a block reference count table is adopted to record whether data of a data block corresponding to a data block number is shared by a plurality of snapshot versions, the cost of occupying an internal memory or the IO access efficiency of an external memory is low, and the IO access performance of a system is influenced, embodiments of the invention provide a data structure, a data processing method, a related method, a device and a system of a data snapshot, wherein the inheritance marks of the corresponding data blocks are recorded in inheritance bits of an inheritance bitmap of metadata, and the inheritance marks of the inheritance bits are used to identify whether the corresponding data blocks are shared with a previous snapshot version, so that when data is carried out on the snapshot in an ROW mode, the reference count of the data blocks is not required to be maintained independently, and the influence on the IO access performance of the system is reduced; and moreover, whether the data of the data block of the current fast and good version is modified or not can be determined by inheriting the inheriting mark of the inheriting bit in the bitmap, and data reading and writing operations in the data processing process are facilitated. The technical solutions provided by the embodiments of the present invention are described below by specific examples.
The embodiment of the invention provides a data structure of a snapshot, which comprises main data and metadata;
the metadata comprises a data block identifier of the main data and a corresponding inheritance bitmap;
each inheritance bit in the inheritance bitmap corresponds to a data block of the primary data, and each inheritance bit comprises an inheritance flag used for identifying whether the corresponding data block is shared with a previous snapshot version.
If the inheritance flag of the inheritance bit of the inheritance bitmap is an effective identifier, the inheritance bit indicates that the data block corresponding to the inheritance bit is a data block shared by the current snapshot version and the previous snapshot version in the snapshot version chain; and if the inheritance flag of the inheritance bit of the inheritance bitmap is an invalid identifier, indicating that the data block corresponding to the inheritance bit is a newly allocated data block in the current snapshot version.
In a specific embodiment, the value of the inheritance flag for identifying the inheritance bit as the valid identifier may be "1", and the value of the inheritance flag for identifying the inheritance bit as the invalid identifier may be "0", and certainly, the value of the inheritance flag for identifying the inheritance bit as the valid identifier and the value of the invalid identifier may be reversed, and in order to facilitate the description of the embodiment of the present invention, in the following embodiments, the value of the inheritance flag for identifying the inheritance bit as the valid identifier is "1", and the value of the inheritance flag for identifying the inheritance bit as the invalid identifier is "0".
In the process of processing snapshot data, for example, in data writing, in order to keep the data of a snapshot version from being modified, in the current writable snapshot version, a redirection operation is performed when writing a data block referenced by multiple snapshot versions, and in order to ensure that the data still referenced by other snapshot versions is not deleted in the process of releasing the data of the data block when deleting the snapshot version, it is necessary to efficiently determine whether a data block is referenced by multiple different snapshot versions. Based on this, the embodiment of the present invention provides the data structure of the snapshot, so as to be applied to the data processing method of the snapshot.
It should be noted that, in the embodiment of the present invention, the main data includes main data before the snapshot is created and snapshot data after the snapshot is created, and the metadata is data describing the main data. And representing the mapping relation between the increment of the main data in the snapshot version and the main data through the metadata, wherein the data block identification of the main data indicates the data block stored by the data in the main data. One or more data blocks may be included in the main data, and the granularity of each data block may be determined, either as large-granularity data, e.g., 128KB, 1MB data blocks, or as small-granularity data, e.g., 4KB data blocks. In an embodiment of the present invention, the snapshot version is a snapshot of a consistent data image representing a certain point in time.
The data structure of the snapshot provided by the embodiment of the invention can be applied to a file system server, a database server and the like for data processing, and is described by a specific description of the snapshot system as follows:
an embodiment of the present invention provides a snapshot system, shown in fig. 3, including:
at least one client 1, at least one data resource store 2, and at least one server 3 connected to the at least one data resource store 2;
the client 1 is configured to send at least one of a request for creating a snapshot, a request for writing data, a request for reading data, a request for deleting a snapshot version, and a request for migrating data to the server 3;
the server 3 is used for executing snapshot creation, data writing, data reading, snapshot version deletion or data migration according to a request sent by the client 1;
the data resource storage 3 is used for storing the data resources of the snapshot versions in the snapshot version chain.
The client may be a computer device in the prior art, such as a desktop computer, a notebook computer, a tablet computer, and the like, which is not limited in the embodiment of the present invention.
And the server executes a corresponding data processing process when receiving a data processing request of the client. The embodiment of the invention provides a data processing method, which comprises the following steps:
acquiring a data block identifier and an inheritance bitmap of main data in the metadata of the snapshot; according to the data block identification of the main data and the inheritance flag of the corresponding inheritance bit in the inheritance bitmap, at least one of the following processes is carried out: creating snapshots, writing data, reading data, deleting snapshot versions, and data migration of snapshots.
In the data processing method, as shown in fig. 4, when the server receives a snapshot creation request sent by the client, the step of executing the snapshot creation method includes:
s101: fixing main data and metadata of the current writable snapshot version as the latest read-only snapshot version;
s102: copying the metadata of the latest read-only snapshot version as the metadata of the new writable snapshot version, and modifying the inheritance mark of the corresponding inheritance bit in the inheritance bitmap of the new writable snapshot version;
each inheritance bit in the inheritance bitmap corresponds to a data block of the primary data, and each inheritance bit comprises an inheritance flag used for identifying whether the corresponding data block is shared with a previous snapshot version.
In the embodiment of the present invention, when creating the snapshot, because the latest read-only snapshot version and the new writable snapshot version share the same data block, the inheritance flag of the inheritance bit in the inheritance bitmap of the new writable snapshot version should be modified to identify each data block of the writable snapshot version as the data block inherited from the latest read-only snapshot version.
Referring to fig. 5, taking creating snapshot snap103 as an example, assuming that metadata of an original current writable snapshot version RW includes data block identifiers X and Y, and data blocks indicated by two data blocks X and Y are exclusive data blocks of the current writable snapshot version RW, that is, values of inheritance flags of inheritance bits corresponding to the data block identifiers X and Y are both "0", when creating a snapshot, fixing main data and metadata of the original current writable snapshot version RW as a latest read-only snapshot version, that is, snapshot snap103, copying metadata of snapshot snap103 as metadata of a new writable snapshot version, and modifying values of inheritance bits corresponding to the data blocks X and Y to be "1" in a copying process. When the snapshot is created, the data in each data block in the original current writable snapshot version does not need to be copied, and the data volume of the metadata in the snapshot is very small, so that the creation time of the snapshot is short, and the efficiency of creating the snapshot is improved.
In the data processing method, as shown in fig. 6, when the server receives a data writing request sent by the client, the step of executing the data writing method includes:
s201: accessing metadata of the current writable snapshot version, and acquiring a data block identifier of data to be written and an inheritance mark of a corresponding inheritance bit;
s202: judging whether the inheritance flag of the inheritance bit is an invalid flag, if so, executing step S203, otherwise, executing step S204:
s203: writing the data to be written into the data block indicated by the data block identifier;
s204: and allocating a new data block, writing the data to be written into the new allocated data block, modifying the data block identifier in the metadata into the data block identifier of the new allocated data block, and modifying the inheritance mark of the inheritance bit corresponding to the data block identifier of the new allocated data block in the inheritance bitmap.
Referring to fig. 7, assuming that no data modification is performed after the current writable snapshot version is the metadata of the copied snapshot snap103, at this time, if new data is to be written into the data block indicated by the data block identifier X in the metadata, at this time, because the value of the inheritance bit corresponding to the data block identifier X is "1", it indicates that the data block indicated by the data block identifier X inherits from the previous snapshot snap103, in order to not modify the data in the snapshot snap103, a new data block needs to be allocated to the current writable snapshot version, assuming that the data block identifier allocated to the newly allocated data block in the metadata is Z, then a redirect-on-write operation should be performed, the data is written into the newly allocated data block, and the original data block identifier X is replaced by the data block identifier Z in the metadata, and the value of the inheritance bit corresponding to the data block identifier Z is modified to "0"; if a data block (corresponding to the data block identifier Z) is already pre-allocated in the current writable snapshot version before data writing is performed, at this time, the value of the inheritance bit corresponding to the data block identifier Z is "0", then the data can be directly written into the allocated data block.
In the data processing method, as shown in fig. 8, when the server receives a data reading request sent by the client, the step of executing data reading includes:
s301: acquiring a data block identifier of data to be read from metadata of a current accessed snapshot version;
s302: and reading data from the data block indicated by the data block identification.
In the data processing method provided by the embodiment of the invention, because the data in the data block indicated by the data block identifier in the metadata is the data occupied by the data block alone, the inheritance flag of the inheritance bit corresponding to the data block identifier does not need to be acquired, and the prior snapshot version does not need to be traced back, so that the data reading process is simpler and faster.
In the data processing method, as shown in fig. 9, when the server receives a request for deleting a snapshot version sent by the client, the step of executing the method for deleting the snapshot version includes:
s401: acquiring a data block identifier in metadata of a snapshot version to be deleted and an inheritance mark of a corresponding inheritance bit in an inheritance bitmap;
s402: judging whether the inheritance flag of the inheritance bit of the snapshot version to be deleted is a valid identifier, if so, executing the step S403, otherwise, executing the step S404:
s403: not releasing the data of the data block indicated by the corresponding data block identification;
s404: judging whether the inheritance flag of the corresponding inheritance bit of the next snapshot version to be deleted is a valid identifier, if so, executing the step S405, otherwise, executing the step S406:
s405: the data of the data block indicated by the data block identifier of the snapshot version to be deleted is not released, and the inheritance mark of the corresponding inheritance bit in the inheritance bitmap of the next snapshot version is modified to be an invalid identifier;
s406: and releasing the data of the data block indicated by the corresponding data block identifier of the snapshot version to be deleted.
In the embodiment of the invention, when the snapshot is deleted, the storage resource (hereinafter referred to as data resource) of the data exclusive to the snapshot version to be deleted needs to be released, and in order to not influence the IO access performance of the system as much as possible, the data resource can be asynchronously released in the background.
In a specific embodiment, the snapshot resource release is performed according to the following steps:
acquiring a data block identifier in metadata of a snapshot version to be deleted and an inheritance mark of a corresponding inheritance bit in an inheritance bitmap;
the inheritance flag of the inheritance bit corresponding to the data block identifier is '1', which indicates that the data block indicated by the data block identifier in the snapshot version to be deleted is a data block shared by the current snapshot version and the previous snapshot version in the snapshot version chain, and in order to ensure that the data in the previous snapshot version is not modified, the data resource of the data block cannot be released;
the inheritance flag of the inheritance bit corresponding to the data block identifier is '0', which indicates that the data block indicated by the data block identifier is a newly allocated data block in the current snapshot version, and further, the inheritance flag of the inheritance bit corresponding to the data block identifier and the inheritance bit in the metadata of the next snapshot version are acquired;
if the inheritance flag of the inheritance bit corresponding to the next snapshot version is '0', the inheritance flag indicates that the data block corresponding to the inheritance bit is a newly allocated data block in the next snapshot version, namely, the corresponding data block in the snapshot version to be deleted is an exclusive data block in the snapshot version to be deleted, so that the data resource of the data block in the snapshot version to be deleted needs to be released;
if the inheritance flag of the inheritance bit corresponding to the next snapshot version is "1", it indicates that the data block indicated by the data block identifier in the snapshot version to be deleted is a data block shared by the current snapshot version and the next snapshot version, and in order to ensure that the data in the next snapshot version is not modified, the data resource of the data block cannot be released, but the inheritance flag of the inheritance bit corresponding to the data block in the next snapshot version should be modified to "0".
Referring to fig. 10, taking a snapshot version to be deleted as snapshot sanp103 as an example, data block identifiers A, X and Y and an inheritance flag of an inheritance bit corresponding to each data block identifier are obtained from metadata of snapshot sanp 103; for the data block identifier a, the value of the inheritance flag of the inheritance bit of the data block identifier a is "1" to indicate that the data block indicated by the data block identifier a is snapshot sanp103 shared and referenced from snapshot sanp102, and in order to ensure that data in the previous snapshot version is not modified, and therefore, the data resource of the data block cannot be released, only the representation and the inheritance bit of the corresponding data block in the metadata need to be cleared; for the data block identifier X, the value of the inheritance flag of the inheritance bit thereof is "0", and the value of the inheritance flag of the inheritance bit of the corresponding position in the metadata in the snapshot snap104 is also "0", that is, the data block identifier Z is newly allocated in the snapshot snap104, it can be seen that the data block indicates that the data block indicated by X has undergone data modification in the snap104, that is, the data block indicated by the data block identifier X is an exclusive data block in the snap103, and therefore, the data resource of the data block indicated by the data block identifier X needs to be released; while for data block Y, the inheritance flag of its inheritance bit is "1", which means that the data block indicated by data block id Y is referenced from snapshot sanp103 as shared by snapshot sanp104, in order to ensure that the data in snapshot snap104 is not modified, the data resource of the data block indicated by data block id Y cannot be released, but the inheritance flag of the corresponding inheritance bit of the data block indicated by data block id Y in snapshot snap104 should be modified to "0".
In the data processing method, as shown in fig. 11, when the server receives a data migration request sent by the client, the method for executing data migration includes:
s501: when the snapshot to be migrated is the current writable snapshot version, determining that the target end does not have a corresponding data block for each data block, and sending the data of the data block of the current writable snapshot version and the inheritance bit of the corresponding data block in the metadata to the target end;
s502: when the snapshot to be migrated is the read-only snapshot version, for each data block, determining whether an inheritance flag of a corresponding inheritance bit in an inheritance bitmap of a snapshot version next to the snapshot to be migrated is an invalid identifier, if so, executing a step S503, otherwise, executing a step S504:
s503: sending the inheritance bits of the corresponding data blocks in the data and metadata corresponding to the data blocks to a target end;
s504: sending a request for constructing a mapping relation between corresponding data block identifications and data blocks in metadata to a target end;
s505: the target terminal distributes a new data block according to the data received from the source terminal, writes the received data into the newly distributed data block, and modifies the data block identifier in the metadata into the data block identifier of the newly distributed data block;
s506: and the target terminal constructs the mapping relation between the data block identification of the metadata in the current snapshot version and the corresponding data block of the next snapshot version according to the received request for constructing the mapping relation between the corresponding data block identification and the data block in the metadata.
In a specific embodiment, in step S506, when the target constructs a mapping relationship between a data block identifier of metadata in the current snapshot version and a corresponding data block of the next snapshot version according to the received request for constructing a mapping relationship between a corresponding data block identifier and a data block in the metadata, the specific implementation process includes:
if the snapshot to be migrated is a read-only snapshot version before the current writable snapshot version and the inheritance flag of the inheritance bit of the data block of the current writable snapshot version at the target end is invalid data, sending a request for retransmitting data to the source end, allocating a new data block, writing the data of the data block of the snapshot to be migrated which is received again into the newly allocated data block, and modifying the data block identifier in the metadata into the data block identifier of the newly allocated data block; otherwise, establishing a mapping relation between the data block identification of the metadata in the current snapshot version and the corresponding data block of the next snapshot version.
In the embodiment of the present invention, because a file system in a common application scenario in the prior art usually has three identical copies, and each copy maintains one identical snapshot task, the states of snapshot data of the three copies are identical under normal conditions, and a certain copy fails during program operation, a new snapshot system needs to be quickly established by a new node, and the establishment of the snapshot system corresponding to the copy can be completed in a data migration manner.
In the embodiment of the invention, when the snapshot to be migrated is the current writable snapshot version, before data migration, whether the corresponding data block exists at the target end is judged, if so, the target end is indicated to have performed data modification operation, and the data migration step of the corresponding data block of the current writable snapshot version is not executed.
In the data migration process, the target end may simultaneously perform IO operations on data to modify the data of the target end, so that in the data migration process, it is required to first determine whether the target end has data of the current writable snapshot version, if the current writable snapshot version of the target end has no data, the data of the current writable snapshot version of the source end is migrated to the target end, and the inheritance flag of the inheritance bit of the corresponding data block in the metadata of the modified target end is the same as that of the source end. If the target end already has data of the current writable snapshot version, the inheritance flag of the inheritance bit corresponding to the data block in the current writable snapshot version of the target end needs to be judged to determine whether data writing occurs during data migration, and if the inheritance flag of the inheritance bit corresponding to the data block is '0', the target end is indicated to be subjected to data modification, so that in order to prevent the newly written data from being covered by old data, the data of the data block corresponding to the source end does not need to be migrated to the target end under the condition; if the inheritance flag of the inheritance bit of the corresponding data block is "1", it indicates that the data of the data block in the current writable version of the source end has been successfully migrated, and the overwriting of the data does not need to be repeated, because a network retransmission phenomenon may occur during the data migration process, and therefore, when it is determined that the data has been successfully migrated, the data migration does not need to be repeatedly requested.
For the read-only snapshot version in the snapshot version chain of the source end, because the data of the read-only snapshot is solidified, the data modification cannot occur in the data migration process, so that the data migration can be performed according to the inheritance flag of the inheritance bit of the corresponding data block in the next snapshot version, if the inheritance flag of the inheritance bit of the corresponding data block in the next snapshot version is '0', the data in the data block of the source end is migrated to the target end, and if the inheritance flag of the inheritance bit of the corresponding data block in the next snapshot version is '1', the two snapshot versions share the data referring to the data block, so that the mapping relation between the data block identifier and the data block in the metadata can be directly established in the read-only snapshot version of the target end; however, for the previous read-only snapshot version of the current writable version, since data in the current writable snapshot version of the target end may be modified during the data migration process, if the value of the inheritance flag of the inheritance bit corresponding to the data block of the current writable snapshot version of the source end is "1", and the target end receives a request for constructing a data sharing relationship between the previous read-only snapshot version and the current writable snapshot version, it is further required to determine whether the target end has modified the data of the corresponding data block in the current writable snapshot version, and if the value of the inheritance flag of the corresponding data block of the current writable snapshot version of the target end is still "1", it indicates that no data modification has occurred at the target end, so that the data sharing relationship between the previous read-only snapshot version and the current writable snapshot version can be safely constructed, modifying the inheritance mark of the inheritance bit of the corresponding data block in the metadata to be the same as the source end; otherwise, it indicates that data modification has occurred in the current writable snapshot version of the target end, and a data sharing relationship between the previous read-only snapshot version and the current writable snapshot version cannot be established, so that the source end needs to retransmit the data of the corresponding data block and transmit the data of the corresponding data block to the target end.
In the prior art, after the current writable snapshot version updates data and reallocates a new data block, the reference count of the data block in the block reference count table needs to be maintained. In a snapshot migration scenario, if a current writable snapshot version updates data and a block reference count table is not constructed yet, a certain problem will be caused. Such as: after the data of the data block of the current writable snapshot version is migrated to the target, the current writable snapshot version of the target can accept data modification operation, and then, when the data of the data block of the source is shared with the previous read-only snapshot version, the data of the data block corresponding to the current writable snapshot version only needs to be shared with the previous read-only snapshot version at the target. By the data migration method provided by the embodiment of the invention, when the data of the previous read-only snapshot version of the current writable snapshot version is migrated, whether the data of the corresponding data block of the current writable snapshot version is modified or not can be determined by judging the inheritance flag of the inheritance bit in the metadata of the current writable snapshot version of the target end, so that the problem that the data of the previous read-only snapshot version of the current writable snapshot version is inconsistent with the source end due to the fact that the block reference count table is not constructed yet when the data is updated is avoided.
As a specific implementation manner of the embodiment of the present invention, when performing data migration of a snapshot, the following steps may be performed:
and migrating the RW snapshot of the current writable snapshot version, wherein when the data of the snapshot is migrated, the inherited bits in the inherited bitmap of the source end and the target end in the migration process need to be kept consistent.
Specifically, it may be determined whether the target side already has a data block of the current writable snapshot version, and if yes, the data of the data block of the current writable snapshot version does not need to be migrated. At this time, if the value of the inheritance flag of the inheritance bit is "0", it indicates that data modification has been performed at the target end, and therefore, if data migration is performed again, old data is overwritten with new data; if the value of the inheritance flag of the inheritance bit is "1", it indicates that data migration has been completed at the target end, and therefore, it is not necessary to perform repeated data migration to overwrite the migrated data. If the target end does not have the data block, distributing a new data block at the target end, migrating the data of the data block of the source end to the newly distributed data block of the target end, and modifying the metadata of the target end to ensure that the inheritance mark of the corresponding inheritance bit of the newly distributed data block of the target end is the same as that of the source end.
Next, a read-only snapshot version that is prior to the current writable snapshot version is migrated.
When data of a snapshot is migrated, firstly, acquiring an inheritance flag of an inheritance bit of a corresponding data block of a current writable snapshot version at a source end, if the inheritance flag of the inheritance bit is '0', indicating that the current writable snapshot version at the source end has data modification on the corresponding data block, so that a sharing relation between a previous read-only snapshot and the data block of the current writable snapshot version cannot be directly established at a target end, at the moment, sending read-only snapshot data of the data block of the previous snapshot version at the source end to the target end, distributing a new data block at the target end, writing the received read-only snapshot data into a newly distributed data block, and modifying the inheritance flag of the inheritance bit of the newly distributed data block in source data to be identical to that of the source end;
if the value of the inheritance flag of the inheritance bit is '1', it indicates that the current writable snapshot version and the previous read-only snapshot version of the source end share the data referencing the same data block, under the condition that the data migration of the current writable snapshot version is completed, only a request for constructing the data sharing relationship between the previous read-only snapshot version and the current writable snapshot version needs to be sent to the target end, and when the target end receives the request for constructing the data sharing relationship between the previous read-only snapshot version and the current writable snapshot version, judging whether the value of the inheritance flag inherited to the corresponding data block of the current writable snapshot version of the target end is still 1, if so, indicating that no data modification occurs at the target end, therefore, the data sharing relation between the previous read-only snapshot version and the current writable snapshot version can be safely constructed, and the inheritance mark of the inheritance bit of the corresponding data block in the metadata is modified to be the same as the source end; otherwise, it indicates that data modification has occurred in the current writable snapshot version of the target end, and a data sharing relationship between the previous read-only snapshot version and the current writable snapshot version cannot be established, so that the source end is required to retransmit data of the corresponding data block.
And finally, migrating other read-only snapshot versions except the previous read-only snapshot version.
When the snapshot data is migrated, firstly, acquiring an inheritance flag of an inheritance bit of a corresponding data block of a read-only snapshot version next to the read-only snapshot version to be migrated at a source end, and if the inheritance flag of the inheritance bit is '0', indicating that the data block corresponding to the read-only snapshot version next to the source end is modified in data at the source end, so that a sharing relation between the read-only snapshot to be migrated and the data block of the read-only snapshot version next to the source end cannot be directly established at a target end, at the moment, data of the data block of the read-only snapshot version to be migrated at the source end needs to be sent to the target end, a new data block is allocated at the target end, the received read-only snapshot data is written into the newly allocated data block, and the inheritance flag of the inheritance bit of the newly allocated data block in the source data is modified to be the same as that of the source end;
if the value of the inheritance flag of the inheritance bit is '1', the fact that the read-only snapshot version at the back of the source end and the read-only snapshot version to be migrated share the data which refers to the same data block is shown, under the condition that the data migration of the latter read-only snapshot version is completed, only a request for constructing the data sharing relationship between the to-be-migrated read-only snapshot version and the latter read-only snapshot version needs to be sent to the target end, after the target end receives the request for constructing the data sharing relationship between the to-be-migrated read-only snapshot version and the latter read-only snapshot version, because the data in the latter read-only snapshot version is already fixed, no modification is possible, therefore, the data sharing relation between the read-only snapshot version and the next read-only snapshot version can be safely constructed, and the inheritance mark of the inheritance bit of the corresponding data block in the metadata of the migrated read-only snapshot version is modified to be the same as the source end.
As a specific implementation manner of the embodiment of the present invention, referring to fig. 12, it is assumed that a file system includes A, B, C snapshot tasks of three copies, and when a snapshot subsystem of a copy B fails to cause data loss, a snapshot of the copy B needs to be reconstructed, and if a snapshot of the copy a is migrated to the copy B to reconstruct snapshot data of the copy B, a snapshot subsystem of the copy a is a source end, and a snapshot subsystem of the copy B is a target end.
Firstly, migrating data of a data block (this data block is also referred to as a data block Z) indicated by a data block identifier Z of a currently writable version of a copy a to a target end, and because an IO request may also be received in the copy B during snapshot data migration to write new data, it is necessary to first determine whether a corresponding data block is already in the copy B, if no, indicating that the copy B has not yet written new data, then allocating a new data block Z ' to copy data in the data block of the copy a to a newly allocated data block Z ' of the copy B, and if a corresponding data block Z ' already exists before data migration, then the data in the data block Z does not need to be migrated.
Then, the data of the data block in the snapshot snap104 is migrated to the copy B, because the inheritance flag of the corresponding inheritance bit of the data block Z in the current writable snapshot version of the copy a is "1", the copy a sends a request for constructing a data sharing relationship between the snapshot snap104 and the current writable snapshot version to the target end, after the copy B receives the request, it needs to be determined whether the inheritance flag of the inheritance bit corresponding to the data block Z ' in the current writable version of the copy B is valid data, and if the inheritance flag of the inheritance bit corresponding to the data block Z ' is "1", it indicates that the data in the data block Z ' of the target end is not modified, so that the data sharing relationship of the data block Z ' can be established in the metadata of the snapshot snap104, that is, the data block identifier Z ' is set in the metadata, and the inheritance flag of the inheritance bit is set to "0".
And finally, carrying out data migration on the snapshot snap103 and the snapshot snap102, wherein in the data migration, only the inheritance flag of the inheritance bit of the corresponding data block in the corresponding next read-only snapshot version in the copy A needs to be judged. Specifically, it may be that, because the inheritance flag of the inheritance bit of the corresponding data block Z in the snapshot snap104 is "0", the data of the data block Z in the snapshot snap104 is different from the data of the data block X in the snapshot snap103, the data of the data block X in the snapshot snap103 in copy a needs to be migrated into copy B, and because the inheritance flag of the inheritance bit of the corresponding data block X in the snapshot snap103 is "1", the data of the data block X in the snapshot snap103 is shared with the snapshot snap102, so that only a request for building the data sharing relationship of the data block X needs to be sent to copy B, the sharing relationship of the data block X ' of the snapshot snap103 is built in the metadata in the snapshot snap102 in copy B, that is to say, the data block identification X ' is set in the metadata and the inheritance flag of the inheritance bit corresponding to the data block identification X ' is set to be the same as the inheritance flag of the data block identification X corresponding to the snapshot snap102 in copy a, i.e., set to "0".
Based on the description of the steps of the data migration method executed in the data processing method, an embodiment of the present invention further provides a snapshot data migration method, which is applied to a source end of snapshot migration to execute the steps S501 to S504. The embodiment of the invention also provides a data migration method of the snapshot, which is applied to a target end of the snapshot migration to execute the steps S505 and S506. For the above snapshot migration method applied to the source and target ends of snapshot migration, reference may be specifically made to detailed description of steps of a method for executing data migration in the data processing method, and details are not described here again.
Based on the same inventive concept, embodiments of the present invention further provide a snapshot creating apparatus, an apparatus for writing data in a snapshot, an apparatus for reading data in a snapshot, an apparatus for deleting a snapshot version in a snapshot, and a computer-readable storage medium, where the principles of the problems solved by these apparatuses and computer-readable storage media are similar to the related data processing methods, so that the implementation of the apparatuses and computer-readable storage media can refer to the implementation of the foregoing methods, and repeated parts are not described again.
An embodiment of the present invention provides a snapshot creating apparatus, as shown in fig. 13, including:
the snapshot solidifying module 101 is configured to fix main data and metadata of a current writable snapshot version as a latest read-only snapshot version;
and the writable snapshot generating module 102 is configured to copy the metadata of the latest read-only snapshot version as the metadata of the new writable snapshot version, and modify an inheritance flag of a corresponding inheritance bit in an inheritance bitmap of the new writable snapshot version.
An embodiment of the present invention provides a snapshot data writing apparatus, as shown in fig. 14, including:
a first obtaining module 201, configured to access metadata of a current writable snapshot version, and obtain a data block identifier of data to be written and an inheritance flag of a corresponding inheritance bit;
a data writing module 202, configured to write data to be written into the data block indicated by the data block identifier if the inheritance flag of the inheritance bit is an invalid identifier; if the inheritance flag of the inheritance bit is an effective identifier, allocating a new data block, writing the data to be written into the newly allocated data block, modifying the data block identifier in the metadata into the data block identifier of the newly allocated data block, and modifying the inheritance flag of the inheritance bit corresponding to the data block identifier of the newly allocated data block in the inheritance bitmap.
An embodiment of the present invention provides a snapshot deleting apparatus, as shown in fig. 15, including:
a second obtaining module 301, configured to obtain a data block identifier in metadata of the snapshot version to be deleted and an inheritance flag of a corresponding inheritance bit in an inheritance bitmap;
the deleting and modifying module 302 is configured to, when the inheritance flag of the inheritance bit of the snapshot version to be deleted is the valid identifier, not release the data of the data block indicated by the corresponding data block identifier; when the inheritance marks of the inheritance bits of the corresponding data blocks of the snapshot version to be deleted and the next snapshot version are invalid identifications, releasing the data of the data block indicated by the corresponding data block identification of the snapshot version to be deleted; when the inheritance flag of the inheritance bit of the snapshot to be deleted is an invalid flag and the inheritance flag of the inheritance bit corresponding to the later snapshot version is an effective flag, the data of the data block indicated by the data block identifier of the snapshot version to be deleted is not released, and the inheritance flag of the inheritance bit corresponding to the later snapshot version is modified to be an invalid flag.
An embodiment of the present invention provides a snapshot data migration apparatus, as shown in fig. 16, including:
a source migration module 401, configured to, when the snapshot to be migrated is the current writable snapshot version, determine, for each data block, that no corresponding data block exists at the target end, and send the data of the data block of the current writable snapshot version and the inheritance bit of the corresponding data block in the metadata to the target end; when the snapshot to be migrated is a read-only snapshot version, aiming at each data block, if the inheritance mark of the corresponding inheritance bit in the inheritance bitmap of the next snapshot version of the snapshot to be migrated is an invalid identifier, the inheritance bit of the corresponding data block in the data and metadata of the corresponding data block is sent to a target end; otherwise, sending a request for constructing the mapping relation between the corresponding data block identifier and the data block in the metadata to the target end;
a target migration module 402, configured to allocate a new data block when receiving data from the source, write the received data into the newly allocated data block, and modify a data block identifier in the metadata to be a data block identifier of the newly allocated data block; and when a request for constructing the mapping relation between the corresponding data block identification and the data block in the metadata is received, constructing the mapping relation between the data block identification of the metadata in the current snapshot version and the corresponding data block in the next snapshot version.
In an embodiment, the source migration module is further configured to determine whether the target has a corresponding data block, and if so, not send data of the data block.
In an embodiment, the target migration module is specifically configured to, if the snapshot to be migrated is a read-only snapshot version before the current writable snapshot version and a request for constructing a mapping relationship between a corresponding data block identifier in the metadata and a data block is received, establish a mapping relationship between the data block identifier of the metadata in the current snapshot version and the corresponding data block in the current writable snapshot version if an inheritance flag of an inheritance bit of the corresponding data block in the current writable snapshot version is valid data; if the inheritance flag of the inheritance bit of the data block of the current writable snapshot version is invalid data, sending a data retransmission request to the source end, distributing a new data block, writing the data of the data block of the newly received snapshot to be migrated into the newly distributed data block, and modifying the data block identifier in the metadata into the data block identifier of the newly distributed data block;
and if the snapshot to be migrated is a read-only snapshot version and is not a read-only snapshot version before the current writable snapshot version, when a request for constructing the mapping relationship between the corresponding data block identifier and the data block in the metadata is received, establishing the mapping relationship between the data block identifier of the metadata in the current snapshot version and the corresponding data block in the next snapshot version.
Embodiments of the present invention provide a computer-readable storage medium, on which computer instructions are stored, where the instructions, when executed by a processor, can implement at least one of the above-mentioned data processing method, snapshot creating method, snapshot data writing method, snapshot deleting method, and data migration method of a snapshot.
According to the data structure of the snapshot, the related data processing method, the device and the system, the inheritance flag of the corresponding data block is recorded in the inheritance bit of the inheritance bitmap of the metadata, whether the corresponding data block is shared with the previous snapshot version or not is identified through the inheritance flag of the inheritance bit, and compared with a mode that a block reference counting table is adopted to record reference counting of the data block in the prior art, the reference counting of the data block does not need to be maintained independently, so that the influence on the IO access performance of the system is reduced; and moreover, whether the data of the data block of the current fast and good version is modified or not can be determined by inheriting the inheriting mark of the inheriting bit in the bitmap, and data reading and writing operations in the data processing process are facilitated.
Unless specifically stated otherwise, terms such as processing, computing, calculating, determining, displaying, or the like, may refer to an action and/or process of one or more processing or computing systems or similar devices that manipulates and transforms data represented as physical (e.g., electronic) quantities within the processing system's registers and memories into other data similarly represented as physical quantities within the processing system's memories, registers or other such information storage, transmission or display devices. Information and signals may be represented using any of a variety of different technologies and techniques. For example, data, instructions, commands, information, signals, bits, symbols, and chips that may be referenced throughout the above description may be represented by voltages, currents, electromagnetic waves, magnetic fields or particles, optical fields or particles, or any combination thereof.
It should be understood that the specific order or hierarchy of steps in the processes disclosed is an example of exemplary approaches. Based upon design preferences, it is understood that the specific order or hierarchy of steps in the processes may be rearranged without departing from the scope of the present disclosure. The accompanying method claims present elements of the various steps in a sample order, and are not intended to be limited to the specific order or hierarchy presented.
In the foregoing detailed description, various features are grouped together in a single embodiment for the purpose of streamlining the disclosure. This method of disclosure is not to be interpreted as reflecting an intention that the claimed embodiments of the subject matter require more features than are expressly recited in each claim. Rather, as the following claims reflect, invention lies in less than all features of a single disclosed embodiment. Thus, the following claims are hereby expressly incorporated into the detailed description, with each claim standing on its own as a separate preferred embodiment of the invention.
Those of skill would further appreciate that the various illustrative logical blocks, modules, circuits, and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both. To clearly illustrate this interchangeability of hardware and software, various illustrative components, blocks, modules, circuits, and steps have been described above generally in terms of their functionality. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the overall system. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present disclosure.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in RAM memory, flash memory, ROM memory, EPROM memory, EEPROM memory, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor such the processor can read information from, and write information to, the storage medium. Of course, the storage medium may also be integral to the processor. The processor and the storage medium may reside in an ASIC. The ASIC may reside in a user terminal. Of course, the processor and the storage medium may reside as discrete components in a user terminal.
For a software implementation, the techniques described herein may be implemented with modules (e.g., procedures, functions, and so on) that perform the functions described herein. The software codes may be stored in memory units and executed by processors. The memory unit may be implemented within the processor or external to the processor, in which case it can be communicatively coupled to the processor via various means as is known in the art.
What has been described above includes examples of one or more embodiments. It is, of course, not possible to describe every conceivable combination of components or methodologies for purposes of describing the aforementioned embodiments, but one of ordinary skill in the art may recognize that many further combinations and permutations of various embodiments are possible. Accordingly, the embodiments described herein are intended to embrace all such alterations, modifications and variations that fall within the scope of the appended claims. Furthermore, to the extent that the term "includes" is used in either the detailed description or the claims, such term is intended to be inclusive in a manner similar to the term "comprising" as "comprising" is interpreted when employed as a transitional word in a claim. Furthermore, the term "or" as used in any one of the claims and the specification is intended to mean a "non-exclusive or".

Claims (23)

1. A data structure of a snapshot, comprising primary data and metadata;
the metadata comprises a data block identifier of the main data and a corresponding inheritance bitmap;
each inheritance bit in the inheritance bitmap corresponds to a data block of the primary data, and each inheritance bit comprises an inheritance flag used for identifying whether the corresponding data block is shared with a previous snapshot version.
2. The data structure of the snapshot according to claim 1, wherein if the inheritance flag of the inheritance bit is a valid flag, it indicates that the data block corresponding to the inheritance bit is a data block shared by the current snapshot version and the previous snapshot version in the snapshot version chain;
and if the inheritance flag of the inheritance bit is an invalid identifier, indicating that the data block corresponding to the inheritance bit is a newly allocated data block in the current snapshot version.
3. A method of data processing, comprising:
acquiring a data block identifier and an inheritance bitmap of main data in the metadata of the snapshot; each inheritance bit in the inheritance bitmap corresponds to a data block of the main data, and each inheritance bit comprises an inheritance flag used for identifying whether the corresponding data block is shared with a previous snapshot version;
according to the data block identification of the main data and the inheritance flag of the corresponding inheritance bit in the inheritance bitmap, at least one of the following processes is carried out: creating snapshots, writing data, reading data, deleting snapshot versions, and data migration of snapshots.
4. The data processing method of claim 3, the creating a snapshot comprising:
fixing main data and metadata of the current writable snapshot version as the latest read-only snapshot version;
and copying the metadata of the latest read-only snapshot version as the metadata of the new writable snapshot version, and modifying the inheritance flag of the corresponding inheritance bit in the inheritance bitmap of the new writable snapshot version.
5. The data processing method of claim 3, the writing data comprising:
accessing metadata of the current writable snapshot version, and acquiring a data block identifier of data to be written and an inheritance mark of a corresponding inheritance bit;
if the inheritance mark of the inheritance bit is an invalid mark, writing the data to be written into the data block indicated by the data block mark;
if the inheritance flag of the inheritance bit is an effective identifier, allocating a new data block, writing the data to be written into the newly allocated data block, modifying the data block identifier in the metadata into the data block identifier of the newly allocated data block, and modifying the inheritance flag of the inheritance bit corresponding to the data block identifier of the newly allocated data block in the inheritance bitmap.
6. The data processing method of claim 3, the reading data, comprising:
acquiring a data block identifier of data to be read from metadata of a current accessed snapshot version;
and reading data from the data block indicated by the data block identification.
7. The data processing method of claim 3, the deleting the snapshot version, comprising:
acquiring a data block identifier in metadata of a snapshot version to be deleted and an inheritance mark of a corresponding inheritance bit in an inheritance bitmap;
if the inheritance mark of the inheritance bit of the snapshot version to be deleted is an effective mark, the data of the data block indicated by the corresponding data block mark is not released;
if the inheritance marks of the corresponding inheritance bits of the snapshot version to be deleted and the next snapshot version are invalid identifications, releasing the data of the data block indicated by the corresponding data block identification of the snapshot version to be deleted;
if the inheritance flag of the inheritance bit of the snapshot to be deleted is an invalid flag and the inheritance flag of the inheritance bit corresponding to the later snapshot version is an effective flag, the data of the data block indicated by the data block identifier of the snapshot version to be deleted is not released, and the inheritance flag of the inheritance bit corresponding to the later snapshot version is modified to be an invalid flag.
8. The data processing method of claim 3, the data migration of the snapshot comprising:
when the snapshot to be migrated is the current writable snapshot version, determining that the target end does not have a corresponding data block for each data block, and sending the data of the data block of the current writable snapshot version and the inheritance bit of the corresponding data block in the metadata to the target end;
when the snapshot to be migrated is a read-only snapshot version, aiming at each data block, if the inheritance mark of the corresponding inheritance bit in the inheritance bitmap of the next snapshot version of the snapshot to be migrated is an invalid identifier, the inheritance bit of the corresponding data block in the data and metadata of the corresponding data block is sent to a target end; otherwise, sending a request for constructing the mapping relation between the corresponding data block identifier and the data block in the metadata to the target end;
the target terminal distributes a new data block according to the data received from the source terminal, writes the received data into the newly distributed data block, and modifies the data block identifier in the metadata into the data block identifier of the newly distributed data block;
and the target terminal constructs the mapping relation between the data block identification of the metadata in the current snapshot version and the corresponding data block of the next snapshot version according to the received request for constructing the mapping relation between the corresponding data block identification and the data block in the metadata.
9. The method of claim 8, wherein the constructing, by the target, the mapping relationship between the data block identifier of the metadata in the current snapshot version and the corresponding data block of the next snapshot version according to the received request for constructing the mapping relationship between the corresponding data block identifier and the data block in the metadata comprises:
if the snapshot to be migrated is a read-only snapshot version before the current writable snapshot version and the inheritance flag of the inheritance bit of the data block of the current writable snapshot version at the target end is invalid data, sending a request for retransmitting data to the source end, allocating a new data block, writing the data of the data block of the snapshot to be migrated which is received again into the newly allocated data block, and modifying the data block identifier in the metadata into the data block identifier of the newly allocated data block; otherwise, establishing a mapping relation between the data block identification of the metadata in the current snapshot version and the corresponding data block of the next snapshot version.
10. The method of claim 8, wherein when the snapshot to be migrated is the current writable snapshot version, before performing the data migration, further comprising:
and judging whether the target end has a corresponding data block, if so, not executing the data migration step of the corresponding data block of the current writable snapshot version.
11. A snapshot creation method, comprising:
fixing main data and metadata of the current writable snapshot version as the latest read-only snapshot version;
and copying the metadata of the latest read-only snapshot version as the metadata of the new writable snapshot version, and modifying the inheritance flag of the corresponding inheritance bit in the inheritance bitmap of the new writable snapshot version.
12. A snapshot data writing method comprises the following steps:
accessing metadata of the current writable snapshot version, and acquiring a data block identifier of data to be written and an inheritance mark of a corresponding inheritance bit;
if the inheritance mark of the inheritance bit is an invalid mark, writing the data to be written into the data block indicated by the data block mark;
if the inheritance flag of the inheritance bit is an effective identifier, allocating a new data block, writing the data to be written into the newly allocated data block, modifying the data block identifier in the metadata into the data block identifier of the newly allocated data block, and modifying the inheritance flag of the inheritance bit corresponding to the data block identifier of the newly allocated data block in the inheritance bitmap.
13. A snapshot deletion method, comprising:
acquiring a data block identifier in metadata of a snapshot version to be deleted and an inheritance mark of a corresponding inheritance bit in an inheritance bitmap;
if the inheritance mark of the inheritance bit of the snapshot version to be deleted is an effective mark, the data of the data block indicated by the corresponding data block mark is not released;
if the inheritance marks of the inheritance bits of the corresponding data blocks of the snapshot version to be deleted and the next snapshot version are invalid identifications, releasing the data of the data block indicated by the corresponding data block identification of the snapshot version to be deleted;
if the inheritance flag of the inheritance bit of the snapshot to be deleted is an invalid flag and the inheritance flag of the inheritance bit corresponding to the later snapshot version is an effective flag, the data of the data block indicated by the data block identifier of the snapshot version to be deleted is not released, and the inheritance flag of the inheritance bit corresponding to the later snapshot version is modified to be an invalid flag.
14. A data migration method of a snapshot is applied to a source end of snapshot migration and comprises the following steps:
when the snapshot to be migrated is the current writable snapshot version, determining that the target end does not have a corresponding data block for each data block, and sending the data of the data block of the current writable snapshot version and the inheritance bit of the corresponding data block in the metadata to the target end;
when the snapshot to be migrated is a read-only snapshot version, aiming at each data block, if the inheritance mark of the corresponding inheritance bit in the inheritance bitmap of the next snapshot version of the snapshot to be migrated is an invalid identifier, the inheritance bit of the corresponding data block in the data and metadata of the corresponding data block is sent to a target end; otherwise, sending a request for constructing the mapping relation between the corresponding data block identifier and the data block in the metadata to the target terminal.
15. The method of claim 14, wherein when the snapshot to be migrated is the current writable snapshot version, before performing the data migration, further comprising:
and judging whether the target end has a corresponding data block, if so, not sending the data of the data block.
16. A data migration method of a snapshot is applied to a target end of snapshot migration and comprises the following steps:
when receiving data of a source end, distributing a new data block, writing the received data into the newly distributed data block, and modifying the data block identifier in the metadata into the data block identifier of the newly distributed data block;
and when a request for constructing the mapping relation between the corresponding data block identification and the data block in the metadata is received, constructing the mapping relation between the data block identification of the metadata in the current snapshot version and the corresponding data block in the next snapshot version.
17. The method of claim 16, wherein upon receiving a request to construct a mapping between corresponding data block identifications in the metadata and data blocks, constructing a mapping between data block identifications in the metadata in a current snapshot version and corresponding data blocks in a subsequent snapshot version comprises:
if the snapshot to be migrated is a read-only snapshot version before the current writable snapshot version and a request for constructing the mapping relationship between the corresponding data block identifier and the data block in the metadata is received, if the inheritance flag of the inheritance bit of the corresponding data block of the current writable snapshot version is valid data, establishing the mapping relationship between the data block identifier of the metadata in the current snapshot version and the corresponding data block of the current writable snapshot version; if the inheritance flag of the inheritance bit of the data block of the current writable snapshot version is invalid data, sending a data retransmission request to the source end, distributing a new data block, writing the data of the data block of the newly received snapshot to be migrated into the newly distributed data block, and modifying the data block identifier in the metadata into the data block identifier of the newly distributed data block;
and if the snapshot to be migrated is a read-only snapshot version and is not a read-only snapshot version before the current writable snapshot version, when a request for constructing the mapping relationship between the corresponding data block identifier and the data block in the metadata is received, establishing the mapping relationship between the data block identifier of the metadata in the current snapshot version and the corresponding data block in the next snapshot version.
18. A snapshot creation apparatus comprising:
the snapshot solidification module is used for fixing main data and metadata of the current writable snapshot version as the latest read-only snapshot version;
and the writable snapshot generating module is used for copying the metadata of the latest read-only snapshot version as the metadata of the new writable snapshot version and modifying the inheritance mark of the corresponding inheritance bit in the inheritance bitmap of the new writable snapshot version.
19. A snapshot data writing apparatus comprising:
the first acquisition module is used for accessing the metadata of the current writable snapshot version and acquiring the data block identifier of the data to be written and the inheritance mark of the corresponding inheritance bit;
the data writing module is used for writing the data to be written into the data block indicated by the data block identifier if the inheritance flag of the inheritance bit is an invalid identifier; if the inheritance flag of the inheritance bit is an effective identifier, allocating a new data block, writing the data to be written into the newly allocated data block, modifying the data block identifier in the metadata into the data block identifier of the newly allocated data block, and modifying the inheritance flag of the inheritance bit corresponding to the data block identifier of the newly allocated data block in the inheritance bitmap.
20. A snapshot deletion apparatus comprising:
the second acquisition module is used for acquiring the data block identifier in the metadata of the snapshot version to be deleted and the inheritance mark of the corresponding inheritance bit in the inheritance bitmap;
the deletion and modification module is used for not releasing the data of the data block indicated by the corresponding data block identifier when the inheritance flag of the inheritance bit of the snapshot version to be deleted is an effective identifier; when the inheritance marks of the inheritance bits of the corresponding data blocks of the snapshot version to be deleted and the next snapshot version are invalid identifications, releasing the data of the data block indicated by the corresponding data block identification of the snapshot version to be deleted; when the inheritance flag of the inheritance bit of the snapshot to be deleted is an invalid flag and the inheritance flag of the inheritance bit corresponding to the later snapshot version is an effective flag, the data of the data block indicated by the data block identifier of the snapshot version to be deleted is not released, and the inheritance flag of the inheritance bit corresponding to the later snapshot version is modified to be an invalid flag.
21. A data migration apparatus for snapshots, comprising:
the source end migration module is used for determining that the target end does not have a corresponding data block aiming at each data block when the snapshot to be migrated is the current writable snapshot version, and then sending the data of the data block of the current writable snapshot version and the inheritance bit of the corresponding data block in the metadata to the target end; when the snapshot to be migrated is a read-only snapshot version, aiming at each data block, if the inheritance mark of the corresponding inheritance bit in the inheritance bitmap of the next snapshot version of the snapshot to be migrated is an invalid identifier, the inheritance bit of the corresponding data block in the data and metadata of the corresponding data block is sent to a target end; otherwise, sending a request for constructing the mapping relation between the corresponding data block identifier and the data block in the metadata to the target end;
the target end migration module is used for distributing a new data block when receiving the data of the source end, writing the received data into the newly distributed data block, and modifying the data block identifier in the metadata into the data block identifier of the newly distributed data block; and when a request for constructing the mapping relation between the corresponding data block identification and the data block in the metadata is received, constructing the mapping relation between the data block identification of the metadata in the current snapshot version and the corresponding data block in the next snapshot version.
22. A snapshot system, comprising:
at least one client, at least one data resource store, and at least one server connected to the at least one data resource store;
the client is used for sending at least one of a snapshot creation request, a data writing request, a data reading request, a snapshot version deleting request and a data migration request to the server;
the server is used for executing snapshot creation, data writing, data reading, snapshot version deletion or data migration according to a request sent by the client;
and the data resource storage is used for storing the data resources of each snapshot version in the snapshot version chain.
23. A computer-readable storage medium having stored thereon computer instructions, wherein the instructions, when executed by a processor, are capable of implementing at least one of the snapshot processing method of any one of claims 3-10, the snapshot creation method of claim 11, the snapshot data writing method of claim 12, the snapshot deletion method of claim 13, and the snapshot deletion method of any one of claims 14-17.
CN202010242341.5A 2020-03-31 2020-03-31 Snapshot data structure, and related data processing method, device and system Pending CN113468104A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010242341.5A CN113468104A (en) 2020-03-31 2020-03-31 Snapshot data structure, and related data processing method, device and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010242341.5A CN113468104A (en) 2020-03-31 2020-03-31 Snapshot data structure, and related data processing method, device and system

Publications (1)

Publication Number Publication Date
CN113468104A true CN113468104A (en) 2021-10-01

Family

ID=77865295

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010242341.5A Pending CN113468104A (en) 2020-03-31 2020-03-31 Snapshot data structure, and related data processing method, device and system

Country Status (1)

Country Link
CN (1) CN113468104A (en)

Similar Documents

Publication Publication Date Title
US9176853B2 (en) Managing copy-on-writes to snapshots
JP4809040B2 (en) Storage apparatus and snapshot restore method
US8417907B2 (en) Synchronizing snapshot volumes across hosts
US6950915B2 (en) Data storage subsystem
US8112600B2 (en) Creating a snapshot based on a marker transferred from a first storage system to a second storage system
US7343449B2 (en) Storage subsystem and storage system
CN106776147B (en) Differential data backup method and differential data backup device
CN106126374B (en) Method for writing data, method for reading data and device
US10620871B1 (en) Storage scheme for a distributed storage system
CN106357703B (en) Cluster switching method and device
CN109918352B (en) Memory system and method of storing data
US20200104054A1 (en) Methods, apparatuses, system and computer program products for managing storage units
CN111198845A (en) Data migration method, readable storage medium and computing device
CN111966531B (en) Data snapshot method and device, computer equipment and storage medium
US9003129B1 (en) Techniques for inter-storage-processor cache communication using tokens
US10620872B2 (en) Replicating data in a data storage system
CN113468104A (en) Snapshot data structure, and related data processing method, device and system
CN116225314A (en) Data writing method, device, computer equipment and storage medium
CN113468105A (en) Data structure of data snapshot, related data processing method, device and system
JP2005215940A (en) Storage system, server apparatus, and preceding copy data preparation method
CN115827322A (en) Cloud storage data full-scale disaster recovery method and system
US10678453B2 (en) Method and device for checking false sharing in data block deletion using a mapping pointer and weight bits
CN115729463A (en) Data migration method, system and related device
US8281096B1 (en) Systems and methods for creating snapshots
CN114327248A (en) Storage node, storage device and network chip

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40063925

Country of ref document: HK