This is a 35 U.S.C. 371 National Stage Patent Application of International Application No. PCT/CN2021/077594, filed Feb. 24, 2021, which claims priority to Chinese application 202010705961.8, filed Jul. 21, 2020, each of which is hereby incorporated by reference in its entirety.
The present disclosure relates to the field of storage technology, and in particular, to a data snapshot method and apparatus, a computer device, and a storage medium.
Snapshot is a common data protection technology of a distributed storage system. The essence of snapshot is a mirror image of data at a certain time point, which may be a copy of the data and may also be a reference of the data. In existing production applications, snapshot can back up and restore on-line data periodically. When a user performs a data deletion operation by mistake, data can be rolled back to a previous timing snapshot, thereby ensuring that a service can be normally performed. Therefore, the snapshot technology becomes more and more important in production applications, and among several processing stages of a snapshot process, data copying is the core of the snapshot technology.
Currently, there are mainly two manners for data copying after snapshot. A first manner for data copying after snapshot is Copy On Write (COW for short), and the principle thereof is: after data is snapshot, when writing-in is performed for the first time, the original data at a location requiring writing-in is read out and written into a snapshot storage location, and then new written data is written into the original storage location. The advantage of such a manner is that the reading performance after snapshot does not reduce, and the disadvantage is that the writing performance after snapshot will reduce more due to copying of data at writing location. A second manner for data copying after snapshot is Redirect On Write (ROW for short), and the principle thereof is: first writing of data subjected to snapshot is directly written to a new storage location, but an index of data at the writing location needs to point to the new storage location. The advantage of this technology is that the writing performance after snapshot does not reduce, and the disadvantage is that a large number of random writes after snapshot will cause the whole data reading performance to be reduced more. Hence, in the related art, there are disadvantages in both manners of data copying after snapshot by using COW or ROW, and therefore there is an urgent need for improvement.
In view of this, regarding the technical problems, it is necessary to provide a data snapshot method and apparatus, a computer device, and a storage medium, which take into account both data writing performance, and data reading performance after random writing.
According to one aspect of the present disclosure, a data snapshot method is provided, the method includes:
In an embodiment, the method further includes:
In an embodiment, the step of when the capacity of the to-be-written data is greater than or equal to the preset capacity, writing the to-be-written data into a snapshot volume in a Redirect On Write manner includes:
In an embodiment, the step of when the capacity of the to-be-written data is less than the preset capacity, writing the to-be-written data into a solid state drive in a Redirect On Write manner includes:
In an embodiment, the step of when a background write-back thread detects that there is data writing into the solid state drive, writing corresponding data in a source volume into the snapshot volume in a Copy On Write manner, and writing the to-be-written data in the solid state drive into the source volume includes:
In an embodiment, the preset capacity is 128KB.
In an embodiment, the source volume and the snapshot volume are both Hard Disk Drives.
According to another aspect of the present disclosure, a data snapshot apparatus is provided, the apparatus includes:
According to another aspect of the present disclosure, a computer device is further provided, including: at least one processor; and
According to another aspect of the present disclosure, a computer-readable storage medium is also provided, a computer program stored on the computer-readable storage medium, and having a computer program stored thereon, wherein the computer program is executed by a processor to implement the data snapshot method above.
In the data snapshot method and apparatus, computer device and storage medium, by comparing the capacity of to-be-written data after snapshot with a preset capacity, copying to-be-written data having a capacity equal to and exceeding the preset capacity after snapshot into a snapshot volume in a Redirect manner, copying to-be-written data having a capacity not exceeding the preset capacity after snapshot into a solid state drive in a Redirect manner, and writing data in a source volume into a snapshot volume in a Copy On Write manner, and writing to-be-written data in the solid state drive into the source volume, not only random writing performance of large blocks of data is ensured, but also reading performance of small blocks of data after random writing is ensured.
In order to describe the technical solutions in the embodiments of the present disclosure or in the related art more clearly, hereinafter, accompanying drawings requiring to be used for describing the embodiments or the related art are introduced briefly. Apparently, the accompanying drawings in the following description merely relate to some embodiments of the present disclosure, and for a person of ordinary skill in the art, other embodiments can also be derived from these accompanying drawings without involving any inventive effort.
In order to make the purposes, technical solutions, and advantages of the present disclosure clearer, hereinafter, the present disclosure will be further described in detail below with reference to the drawings and embodiments.
It should be noted that in the embodiments of the present disclosure, all expressions using “first” and “second” are used for distinguishing two entities having the same names but are different or different parameters. Hence, “first” and “second” are only used for convenience of expression, and should not be understood as limitations to embodiments of the present disclosure, and this will not be described one by one in subsequent embodiments.
In an embodiment, referring to
The snapshot volume refers to a snapshot data storage space, and the source volume refers to an original data storage space; and preferably, the snapshot volume and the source volume are both Hard Disk Drives (HHD).
In the data snapshot method, by comparing the capacity of to-be-written data after snapshot with a preset capacity, copying to-be-written data having a capacity equal to and exceeding the preset capacity after snapshot into a snapshot volume in a Redirect manner, copying to-be-written data having a capacity not exceeding the preset capacity after snapshot into a solid state drive in a Redirect manner, and writing data in a source volume into a snapshot volume in a Copy On Write manner, and writing to-be-written data in the solid state drive into the source volume, not only random writing performance of large blocks of data is ensured, but also reading performance of small blocks of data after random writing is ensured.
Preferably, in order to facilitate subsequent storage of writing data having a capacity smaller than a preset capacity after snapshot, on the basis of the described embodiments, the method of the embodiments of the present disclosure further comprises the following step:
In another embodiment, the step S200 specifically includes the following sub-steps:
In another embodiment, the step S300 specifically includes the following sub-steps:
Preferably, the step S400 specifically includes the following sub-steps:
Please refer to
Further, referring to
In another embodiment, referring to
In the data snapshot apparatus, by comparing the capacity of to-be-written data after snapshot with a preset capacity, copying to-be-written data having a capacity equal to and exceeding the preset capacity after snapshot in a Redirect manner, copying to-be-written data having a capacity not exceeding the preset capacity after snapshot into a solid state drive in a Redirect manner, and writing data in a source volume into a snapshot volume in a Copy On Write manner, and writing to-be-written data in the solid state drive into the source volume, not only random writing performance of large blocks of data is ensured, but also reading performance of small blocks of data after random writing is ensured.
For specific definitions of the data snapshot apparatus, reference can be made to the described definitions on the data snapshot method, and details are not repeated herein. All or some of the modules in the data snapshot apparatus may be implemented by software, hardware, or a combination thereof. The various modules may be embedded in or independent from a processor in a computer device in a hardware form, and may also be stored in a memory in the computer device in a software form, so that the processor invokes and executes operations corresponding to the various modules.
According to another aspect of the embodiments of the present disclosure, a computer device is provided. The computer device may be a server, and for an internal structural diagram thereof, please refer to
According to another aspect of the embodiments of the present disclosure, a computer-readable storage medium is provided. As shown in
A person of ordinary skill in the art would have been able to understand that all or a part of flow of the method according to the embodiments may be implemented by a computer program instructing relevant hardware. The computer program may be stored in a non-transitory computer-readable storage medium. When being executed, the computer program may comprise the flow of the embodiments of the method. Any references to memory, storage, database, or other media used in the embodiments provided in the embodiments of the present disclosure may comprise non-transitory and/or transitory memory. The non-transitory memory may include Read-Only Memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. The transitory memory may include Random Access Memory (RAM) or an external cache memory. By way of illustration but not limitation, RAM is available in a variety of forms, such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) Dynamic RAM (RDRAM), and Direct Rambus Dynamic RAM (DRDRAM), etc.
Various technical features of the embodiments can be combined in any way, and in order to make the description brief, all possible combinations of the technical features of the embodiments are not described. However, as long as the combination of these technical features is not contradictory, the technical features should be considered to fall within the scope disclosed in the description.
The embodiments as described above merely represent several embodiments of the present disclosure, and the illustration thereof is specific and detailed, but the specific and detailed illustration cannot be understood as limiting the patent scope of some embodiments of the present disclosure. It should be noted that for a person of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of some embodiments of the present disclosure, and all these modifications and improvements fall within the scope of protection of some embodiments of the present disclosure. Therefore, the patent scope of protection of the present disclosure shall be subject to the appended claims.
Number | Date | Country | Kind |
---|---|---|---|
202010705961.8 | Jul 2020 | CN | national |
Filing Document | Filing Date | Country | Kind |
---|---|---|---|
PCT/CN2021/077594 | 2/24/2021 | WO |
Publishing Document | Publishing Date | Country | Kind |
---|---|---|---|
WO2022/016863 | 1/27/2022 | WO | A |
Number | Name | Date | Kind |
---|---|---|---|
20040117572 | Welsh et al. | Jun 2004 | A1 |
Number | Date | Country |
---|---|---|
1658168 | Aug 2005 | CN |
102968381 | Mar 2013 | CN |
105302665 | Feb 2016 | CN |
108460045 | Aug 2018 | CN |
109213636 | Jan 2019 | CN |
109491605 | Mar 2019 | CN |
110781133 | Feb 2020 | CN |
111966531 | Nov 2020 | CN |
Entry |
---|
International Search report for application No. PCT/CN2021/077594 dated May 28, 2021. |
Chinese office action for application 202010705961.8 filed on Jul. 21, 2020. |
Number | Date | Country | |
---|---|---|---|
20230385155 A1 | Nov 2023 | US |