Data storage method, device, storage system, program product and storage medium

By centrally temporarily storing metadata in the cache device and storing metadata in a tree data structure, the problem of resource waste and loss caused by frequent metadata writing in the cache device is solved, and the efficiency of data flushing is improved.

CN118377443BActive Publication Date: 2024-09-17SHANDONG YUNHAI GUOCHUANG CLOUD COMPUTING EQUIP IND INNOVATION CENT CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410843560.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-27
Publication Date
2024-09-17
Estimated Expiration
2044-06-27

AI Technical Summary

Technical Problem

Cache devices waste thread resources and accelerate loss due to frequent metadata writing operations, affecting data flushing efficiency.

Method used

Record the metadata of the cached data in the designated storage. When the preset trigger conditions are met, store it as a tree node in the cache device, and flush the dirty cache data to the back-end storage device when appropriate, using tree data Structure to reduce write times and thread waste.

Benefits of technology

It reduces the number of writes to the cache device, reduces thread waste, slows down device wear, and improves data flushing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118377443B
    Figure CN118377443B
Patent Text Reader

Abstract

The present invention discloses a data storage method, device, storage system, program product and storage medium, which belongs to the field of data storage, is used to manage cached data and its metadata in a storage system, and solves the technical problem of how to reduce the waste of metadata storage on threads and the loss of cache devices. The present invention can record the metadata of cached data in a designated memory, and when a preset trigger condition is met, the metadata recorded in the designated memory is used as a tree node in a preset metadata tree and stored in the cache device, so that the dirty cached data in the cache device can be flushed to the back-end storage device according to the tree node stored in the cache device. Since the metadata is centrally stored and stored in the cache device in a tree data structure, the number of writes to the cache device is reduced, thread waste is reduced, and the loss of the cache device is slowed down, and the orderly organization of metadata can improve the efficiency of data flushing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data storage, and in particular to a data storage method, device, storage system, program product and storage medium. Background Art

[0002] Caching technology refers to storing part of the data of the back-end storage device through the cache device. Since the data reading and writing speed of the cache device is higher than that of the back-end storage device, the data access speed can be improved by accessing the cache device. When the data to be written sent by the host is written to the cache device as cache data, metadata of the cache data written this time will also be generated. Since the amount of metadata of the cache data is usually small and data write requests are more frequent, writing the metadata of the cache data to the cache device in real time will generate frequent data write actions, which not only wastes thread resources, but also accelerates the loss of the cache device.

[0003] Therefore, how to provide a solution to the above technical problems is a problem that those skilled in the art need to solve at present. Summary of the invention

[0004] The purpose of the present invention is to provide a data storage method, device, storage system, program product and storage medium, which can record the metadata of cache data in a designated memory, and when a preset trigger condition is met, the metadata recorded in the designated memory is used as a tree node in a preset metadata tree and stored in the cache device, so that according to the tree node stored in the cache device, the dirty cache data in the cache device can be flushed to the back-end storage device. Since the metadata is centrally stored and stored in the cache device in a tree data structure, the number of writes to the cache device is reduced, thread waste is reduced and the loss of the cache device is slowed down, and the orderly organization of metadata can improve the efficiency of data flushing.

[0005] In order to solve the above technical problems, the present invention provides a data storage method, which is applied to a processor, comprising:

[0006] In response to a data write request from the host, write the to-be-written data of the data write request as cache data into the cache device;

[0007] Recording metadata of the cached data in a designated storage;

[0008] When a preset trigger condition is met, the metadata currently recorded in the designated storage is stored in the cache device as a tree node in a preset metadata tree;

[0009] In response to the data flush instruction, according to the tree nodes stored in the cache device, the cache data corresponding to the tree nodes in the preset metadata tree that are in a dirty state are flushed to the back-end storage device, wherein the dirty state means that the cache data corresponding to the tree nodes are not flushed to the back-end storage device;

[0010] The state of the tree node corresponding to the cache data flushed to the backend storage device is set to a clean state, wherein the clean state means that the cache data corresponding to the tree node has been flushed to the backend storage device.

[0011] On the other hand, in response to a data write request from the host, writing the to-be-written data of the data write request as cache data into the cache device includes:

[0012] In response to a data write request from the host, write the to-be-written data of the data write request as cache data into an idle cache data storage area in the cache device in a first preset order, wherein the first preset order is an order from small to large logical addresses;

[0013] The metadata currently recorded in the designated storage is stored in the cache device as a tree node in a preset metadata tree, including:

[0014] The metadata currently recorded in the designated storage is stored as a tree node in a preset metadata tree in a tree node storage area with remaining space in the cache device;

[0015] The data storage method further comprises:

[0016] In the initialization stage of the cache device, a storage space of a preset capacity of the cache device is used as a super block according to a first preset order, a storage space of a preset capacity after the super block is used as a tree node storage area according to the first preset order, and a storage space after the tree node storage area with the largest current logical address is used as a cache data storage area;

[0017] The super block is used to store the binding relationship between the cache device and the backend storage device, the block capacity, and the cache write-back policy;

[0018] If there is no remaining space in the tree node storage area with the largest logical address in the cache device, then the free storage space of the cache device with a preset capacity is used as a new tree node storage area according to a first preset order.

[0019] On the other hand, storing the metadata currently recorded in the designated storage as a tree node in a preset metadata tree in the cache device includes:

[0020] Determine the metadata of the currently designated storage device that respectively corresponds to the data write request;

[0021] For any metadata currently recorded in the designated storage, the metadata is used as a tree node in a preset metadata tree, and the parent-child node identifiers of the tree node are determined, wherein the parent-child node identifiers include a parent node identifier and a child node identifier;

[0022] The generated tree nodes and their parent and child node identifiers are stored in the cache device.

[0023] On the other hand, the data storage method further comprises:

[0024] In response to the metadata tree display instruction, obtaining each tree node and its parent and child node identifiers in the cache device;

[0025] Constructing a topological diagram of the preset metadata tree according to each parent-child node identifier;

[0026] Hanging each tree node in the cache device at a corresponding position in the topology map;

[0027] The display is controlled to display the topology diagram.

[0028] On the other hand, in response to a data write request from the host, writing the to-be-written data of the data write request as cache data into the cache device includes:

[0029] In response to a data write request from the host, determining a write-back policy of the storage system, wherein the write-back policy refers to: a method of writing the to-be-written data of the data write request into a back-end storage device of the storage system;

[0030] Determining whether the write-back strategy requires writing the data to be written into the cache device;

[0031] If necessary, the data to be written of the data write request is written into the cache device as cache data.

[0032] On the other hand, determining whether the write-back strategy requires writing the to-be-written data into the cache device includes:

[0033] Determining whether the write-back strategy is a write-latency strategy or a write-through strategy;

[0034] If yes, it is determined that the write-back strategy requires writing the to-be-written data into the cache device;

[0035] If not, it is determined that the write-back policy does not require writing the to-be-written data into the cache device.

[0036] On the other hand, in response to a data write request from the host, determining a write-back policy of the storage system includes:

[0037] In response to a data write request from a host, determining whether a cache device exists in the storage system;

[0038] If so, determine the write-back policy of the storage system;

[0039] The data storage method further comprises:

[0040] If there is no cache device in the storage system, the data to be written in the data write request is written to the backend storage device of the storage system.

[0041] On the other hand, the designated memory is a non-volatile memory;

[0042] The data storage method further comprises:

[0043] After power-on, determining whether metadata exists in the designated memory;

[0044] If so, storing the metadata currently recorded in the designated storage device as a tree node in a preset metadata tree in the cache device;

[0045] After storing the metadata currently recorded in the designated storage as a tree node in a preset metadata tree in the cache device, the data storage method further includes:

[0046] The metadata stored in the cache device in the designated memory is deleted.

[0047] On the other hand, the preset trigger conditions include:

[0048] The amount of metadata in the designated memory reaches a preset threshold or there is a trigger instruction generated every preset trigger period.

[0049] On the other hand, in response to the data flush instruction, according to the tree nodes stored in the cache device, flushing the cache data corresponding to the tree nodes in the preset metadata tree in a dirty state to the backend storage device includes:

[0050] In response to a data flush instruction, determining a tree node in the preset metadata tree that is in a dirty state;

[0051] Add the tree nodes in dirty state to the write-back list;

[0052] The cache data corresponding to each tree node in the write-back list is flushed to the back-end storage device in the order of the logical addresses in the back-end storage device from small to large.

[0053] In another aspect, the cache device comprises a solid state drive;

[0054] The back-end storage device includes an independent redundant disk array constructed based on a mechanical hard disk group.

[0055] On the other hand, in response to the data flush instruction, before flushing the cache data corresponding to the tree nodes in the preset metadata tree in a dirty state to the backend storage device according to the tree nodes stored in the cache device, the data storage method further includes:

[0056] Determine the proportion of cache data in a dirty state in the cache device relative to the capacity of the cache device;

[0057] If the capacity ratio is greater than a first preset ratio, a data refresh instruction is generated;

[0058] Receive data refresh instructions through the human-computer interaction device.

[0059] On the other hand, in response to the data flush instruction, according to the tree nodes stored in the cache device, flushing the cache data corresponding to the tree nodes in the preset metadata tree in a dirty state to the backend storage device includes:

[0060] In response to the data flush instruction, determining a proportion of cache data in a dirty state in the cache device relative to a real-time capacity of the cache device;

[0061] According to a first preset corresponding relationship between the capacity ratio and the number of threads, determining the number of threads corresponding to the real-time capacity ratio as the target number of threads;

[0062] Through target thread number threads, cache data corresponding to tree nodes in a dirty state in the preset metadata tree is flushed to a backend storage device according to the tree nodes stored in the cache device.

[0063] On the other hand, the first preset corresponding relationship includes:

[0064] If the capacity ratio is greater than the second preset ratio and less than the third preset ratio, the capacity ratio is positively correlated with the number of threads;

[0065] If the capacity ratio is greater than the third preset ratio, the number of threads is the preset maximum number of threads.

[0066] On the other hand, in response to the data flush instruction, after determining the proportion of cache data in a dirty state in the cache device relative to the real-time capacity of the cache device, the data storage method further includes:

[0067] According to a second preset correspondence between the capacity share and the ratio, taking the ratio corresponding to the real-time capacity share as the target ratio;

[0068] The write-back strategy of the target ratio of data write requests of the storage system is set as a bypass write strategy.

[0069] On the other hand, the second preset corresponding relationship includes:

[0070] If the capacity ratio is greater than the third preset ratio and less than the fourth preset ratio, the capacity ratio is positively correlated with the proportion;

[0071] If the capacity ratio is greater than the fourth preset ratio, the ratio is the preset maximum ratio.

[0072] In order to solve the above technical problems, the present invention further provides a data storage device, comprising:

[0073] Memory for storing computer programs;

[0074] A processor is used to implement the steps of the data storage method as described above when executing the computer program.

[0075] In order to solve the above technical problem, the present invention also provides a storage system, including the data storage device as described above.

[0076] In order to solve the above technical problem, the present invention further provides a computer program product, including a computer program / instruction, which implements the steps of the data storage method described above when executed by a processor.

[0077] In order to solve the above technical problem, the present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the data storage method described above are implemented.

[0078] Beneficial effects: The present invention provides a data storage method. Considering that (1) metadata of cached data is temporarily stored in a centralized manner, the metadata can be stored in batches in a cache device. (2) a tree data structure can organize a large amount of metadata in an orderly manner, the metadata of cached data can be recorded in a designated memory. When a preset trigger condition is met, the metadata recorded in the designated memory is stored in the cache device as a tree node in a preset metadata tree. Thus, dirty cached data in the cache device can be flushed to a back-end storage device according to the tree node stored in the cache device. Since the metadata is temporarily stored in a centralized manner and stored in the cache device in a tree data structure, the number of writes to the cache device is reduced, thread waste is reduced, and the loss of the cache device is slowed down. In addition, the orderly organization of metadata can improve the efficiency of data flushing.

[0079] The present invention also provides a data storage device, a storage system, a computer program product and a computer-readable storage medium, which have the same beneficial effects as the above data storage method. BRIEF DESCRIPTION OF THE DRAWINGS

[0080] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the relevant technologies and the drawings required for use in the embodiments are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0081] Figure 1 A schematic diagram of a data storage method provided by the present invention;

[0082] Figure 2 A schematic diagram of a flow chart of another data storage method provided by the present invention;

[0083] Figure 3 A schematic diagram of the structure of a space allocation scheme for a cache device provided by the present invention;

[0084] Figure 4 A schematic diagram of a flow chart of another data storage method provided by the present invention;

[0085] Figure 5 A structural schematic diagram of a data storage device provided by the present invention;

[0086] Figure 6 A schematic diagram of the structure of a computer-readable storage medium provided by the present invention. DETAILED DESCRIPTION

[0087] The core of the present invention is to provide a data storage method, device, storage system, program product and storage medium, which can record the metadata of cache data in a designated memory, and when a preset trigger condition is met, the metadata recorded in the designated memory is used as a tree node in a preset metadata tree and stored in the cache device, so that the dirty cache data in the cache device can be flushed to the back-end storage device according to the tree node stored in the cache device. Since the metadata is centrally stored and stored in the cache device in a tree data structure, the number of writes to the cache device is reduced, thread waste is reduced and the loss of the cache device is slowed down, and the orderly organization of metadata can improve the efficiency of data flushing.

[0088] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0089] Please refer to Figure 1 , Figure 1A schematic flow chart of a data storage method provided by the present invention, wherein the data storage method is applied to a processor and comprises:

[0090] S101: In response to a data write request from a host, write the to-be-written data of the data write request as cache data into a cache device;

[0091] Specifically, taking into account the technical problems in the above background technology, and considering that the metadata of the cached data is temporarily stored in a centralized manner, the metadata can be stored in batches in the cache device. Therefore, in an embodiment of the present invention, the metadata of the cached data is temporarily stored in a designated memory, and the metadata stored in the designated memory is uniformly stored in the cache device at a certain time. Since the cached data usually comes from the data write request of the host, in this step, the data to be written of the data write request can be responded to the data write request of the host, and the cache device is written with the data to be written of the data write request as cache data. At the same time, the need for "processing metadata" is generated, that is, the processing action of the metadata in the subsequent steps.

[0092] The data write request is also a write request in an IO (Input / Output) request sent by the host.

[0093] S102: Recording metadata of cached data in a designated storage;

[0094] Specifically, based on the foregoing description, in order to centrally store metadata in the cache device, the metadata of the cached data can be recorded in a designated memory in an embodiment of the present invention. It is worth mentioning that the metadata in this step may refer to the metadata corresponding to the data to be written of a single data write request, that is, when the data to be written of each data write request is written to the cache device as cache data, the metadata of the cached data can be recorded in the designated memory.

[0095] The designated storage device here cannot be a cache device, otherwise the effect of "centrally storing metadata in the cache device" will not be achieved.

[0096] S103: When a preset trigger condition is met, the metadata recorded in the current designated storage is stored in the cache device as a tree node in a preset metadata tree;

[0097] Specifically, to better illustrate the embodiments of the present invention, please refer to Figure 2 , Figure 2 A flow chart of another data storage method provided by the present invention, in Figure 2 In the process, the metadata of the data to be written of each data write request can be stored in the designated storage in the form of a "write log", and the metadata of the data to be written of each data write request is stored as a write log (such as Figure 2Therefore, a write log can actually be directly used as a tree node in the preset metadata tree. Therefore, the processor can periodically insert the write log (that is, the tree node) in the specified memory into the metadata tree in the memory, and then write the newly generated tree node of the metadata tree to the cache device.

[0098] Of course, writing into a log can be understood as a log form. In addition to the log form, metadata can also be recorded in other forms, which is not limited in the embodiment of the present invention.

[0099] Specifically, in order to achieve batch writing of metadata into the cache device, the embodiments of the present invention can flexibly set appropriate preset trigger conditions, so that when the preset trigger conditions are met, the metadata recorded in the current designated storage is stored in the cache device. Considering that data write requests are relatively frequent, resulting in a huge amount of metadata, in order to organize a large amount of metadata in a more systematic way, and the tree data structure can organize a large amount of metadata in an orderly manner, therefore, in the embodiments of the present invention, when the preset trigger conditions are met, the metadata recorded in the current designated storage can be stored in the cache device as a tree node in the preset metadata tree.

[0100] The preset metadata tree may be of various specific types, such as tree (b+tree), etc., which is not limited in the embodiment of the present invention.

[0101] S104: In response to the data flush instruction, according to the tree nodes stored in the cache device, the cache data corresponding to the tree nodes in the preset metadata tree that are in a dirty state are flushed to the backend storage device, wherein the dirty state means that the cache data corresponding to the tree nodes are not flushed to the backend storage device;

[0102] Specifically, considering that the amount of cached data in the cache device will continue to increase, and these cached data will eventually be written to the back-end storage device, the embodiments of the present invention can respond to the data flush instruction and flush the cached data corresponding to the tree nodes in the preset metadata tree that are in a dirty state to the back-end storage device according to the tree nodes stored in the cache device.

[0103] Among them, since the tree node is the metadata of the cached data in the cache device, the metadata usually includes the mapping relationship between the logical address of the cached data in the cache device and the logical address in the back-end storage device. Therefore, in an embodiment of the present invention, the cached data can be flushed to the back-end storage device according to the tree node stored in the cache device.

[0104] Of course, in addition to the "mapping relationship between the logical address of the cache data in the cache device and the logical address in the backend storage device", the metadata of the cache data may also include the capacity of the cache data, etc., which is not limited in the embodiment of the present invention.

[0105] S105: Setting the state of the tree node corresponding to the cache data flushed to the backend storage device to a clean state, wherein the clean state means that the cache data corresponding to the tree node has been flushed to the backend storage device.

[0106] Specifically, in order to correctly maintain the status of each cached data, after processing S104, in this step, the status of the tree node corresponding to the cached data flushed to the back-end storage device can be set to a clean state, so that the status of the cached data corresponding to each data write request can be more conveniently maintained through the status of the tree node.

[0107] The present invention provides a data storage method. Considering that (1) metadata of cached data is temporarily stored in a centralized manner, the metadata can be stored in batches in a cache device. (2) a tree data structure can organize a large amount of metadata in an orderly manner, the metadata of cached data can be recorded in a designated memory. When a preset trigger condition is met, the metadata recorded in the designated memory is stored in the cache device as a tree node in a preset metadata tree. Thus, dirty cached data in the cache device can be flushed to a back-end storage device according to the tree node stored in the cache device. Since the metadata is temporarily stored in a centralized manner and stored in the cache device in a tree data structure, the number of writes to the cache device is reduced, thread waste is reduced, and the loss of the cache device is slowed down. In addition, the orderly organization of metadata can improve the efficiency of data flushing.

[0108] Based on the above embodiments:

[0109] As an optional embodiment, in response to a data write request from a host, writing the to-be-written data of the data write request as cache data into a cache device includes:

[0110] In response to a data write request from the host, write the to-be-written data of the data write request as cache data into an idle cache data storage area in the cache device in a first preset order, wherein the first preset order is an order from small to large logical addresses;

[0111] Storing the metadata recorded in the current designated storage as a tree node in a preset metadata tree in the cache device includes:

[0112] The metadata recorded in the currently designated storage device is stored as a tree node in a preset metadata tree in a tree node storage area with remaining space in the cache device;

[0113] The data storage method also includes:

[0114] In the initialization stage of the cache device, a storage space of a preset capacity of the cache device is used as a super block according to a first preset order, a storage space of a preset capacity after the super block is used as a tree node storage area according to the first preset order, and a storage space after the tree node storage area with the largest current logical address is used as a cache data storage area;

[0115] The super block is used to store the binding relationship between the cache device and the backend storage device, the block capacity, and the cache write-back policy;

[0116] If there is no remaining space in the tree node storage area with the largest logical address in the cache device, then the free storage space of the cache device with a preset capacity is used as a new tree node storage area according to the first preset order.

[0117] Specifically, to better illustrate the embodiments of the present invention, please refer to Figure 3 , Figure 3 A schematic diagram of a space allocation scheme for a cache device provided by the present invention. In order to more reasonably and accurately utilize the storage space of the cache device, in an embodiment of the present invention, during the initialization phase of the cache device, the storage space of the cache device with a preset capacity can be allocated as a super block (i.e. Figure 3 The super block is used to store some basic parameters of the storage device, which may include the binding relationship between the cache device and the back-end storage device, the block capacity, and the cache write-back policy. Then, the storage space of the preset capacity after the super block is used as the tree node storage area (i.e. Figure 3 The first rectangular block containing a circle after the super block shown in the figure can have a preset capacity that can be set independently, for example, it can be a block size, such as 512Kb, and the storage space after the tree node storage area with the largest current logical address is used as a cache data storage area (that is, Figure 3 That is, in the initial exchange stage, the cache device includes a super block, a tree node storage area and a cache data storage area. When the data to be written needs to be stored in the cache device as cache data in response to a data write request, it will be written to the cache data storage area according to the first preset order, and the corresponding metadata will also be written to the tree node storage area in batches at a scheduled time.

[0118] Specifically, when the tree node storage area is full, a new tree node storage area (for example, the storage area can be stored in the first predetermined order) can be generated starting from the location of the current cache data storage area of ​​the cache device that is free and has the smallest storage address. Figure 3The tree node storage area below the super block in the cache device is the second tree node storage area in total), and the storage space after the newly generated tree node storage area is used as the cache data storage area (that is, the storage space after the second tree node storage area). In this way, the cache device storage space is divided and utilized cyclically.

[0119] Of course, in addition to this specific space allocation scheme, the space allocation scheme of the cache device may also be of other types, which is not limited in the embodiment of the present invention.

[0120] As an optional embodiment, storing the metadata recorded in the current designated storage as a tree node in a preset metadata tree in the cache device includes:

[0121] Determine the metadata recorded in the current designated storage device that respectively correspond to the data write request;

[0122] For any metadata recorded in the currently designated storage, the metadata is used as a tree node in a preset metadata tree, and the parent-child node identifiers of the tree node are determined, wherein the parent-child node identifiers include a parent node identifier and a child node identifier;

[0123] The generated tree nodes and their parent and child node identifiers are stored in a cache device.

[0124] Specifically, in order to more conveniently manage data write requests and their corresponding cache data metadata, the metadata of the data to be written of a single data write request can be recorded as a copy in a designated memory, and when generating a tree node, one copy of the metadata can be used as a tree node, which can easily reduce the error probability.

[0125] When metadata is recorded in a designated storage in the form of a log, a copy of metadata in the designated storage may be represented by a write-once log. Figure 2 A rectangular box represents a write log. Figure 2 The diagram in the middle includes a total of 8 writes to the log.

[0126] Specifically, the parent and child node identifiers of the tree nodes may be stored in the cache device at the same time, so as to facilitate finding the parent and child nodes of each tree node to form the entire preset metadata tree.

[0127] As an optional embodiment, the data storage method further includes:

[0128] In response to the metadata tree display instruction, obtaining each tree node and its parent and child node identifiers in the cache device;

[0129] Construct a topological diagram of a preset metadata tree according to the identifiers of each parent and child node;

[0130] Hang each tree node in the cache device at the corresponding position in the topology map;

[0131] Control the display to show the topology diagram.

[0132] Specifically, considering that in some cases users have the need to know the overall structure of the preset metadata tree and the information of each tree node, the embodiments of the present invention can respond to the metadata tree display instruction, obtain the identification of each tree node and its parent and child node in the cache device, and then construct a topological map of the preset metadata tree according to each parent and child node identification and hang each tree node in the cache device at the corresponding position in the topological map, and finally control the display to display the topological map, thereby supporting users to quickly and conveniently learn about the overall structure of the preset metadata tree and the information of each tree node.

[0133] The metadata tree display instruction may be generated in various ways, for example, in real time through a human-computer interaction device, or at a scheduled time, etc., which is not limited in the embodiment of the present invention.

[0134] As an optional embodiment, in response to a data write request from a host, writing the to-be-written data of the data write request as cache data into a cache device includes:

[0135] In response to a data write request from the host, determining a write-back policy of the storage system, wherein the write-back policy refers to: a method of writing the to-be-written data of the data write request into a back-end storage device of the storage system;

[0136] Determine whether the write-back policy requires writing the data to be written into the cache device;

[0137] If necessary, the data to be written of the data write request is written into the cache device as cache data.

[0138] Specifically, in order to better illustrate the embodiments of the present invention, please refer to Figure 4 , Figure 4A flow chart of another data storage method provided by the present invention, after receiving a data write request from a host and in the case where it is determined that there is a cache device in the storage system, different processing can be performed according to the write-back strategy, specifically including: when the write-back strategy is a bypass write strategy (write bypass), the data to be written can be written to the back-end storage device; when the write-back strategy is a delayed write strategy (write back), the cached data can be written to the cache device first, and the replacement data of the cached data can be written to the designated memory, and the cached data can be flushed to the back-end storage device at a suitable time later; when the write-back strategy is a write-through strategy (write back), the actions of "writing the data to be written to the back-end storage device" and "writing the cached data to the cache device" can be executed simultaneously, and the metadata of the cached data can be written to the designated memory; no matter which write-back strategy is executed, a response can be returned to the host after the action is completed.

[0139] Specifically, in order to more quickly write cache data to a storage device, an embodiment of the present invention can determine whether the write-back strategy requires writing the data to be written to the cache device. If necessary, the data to be written of the data write request is written to the cache device as cache data.

[0140] As an optional embodiment, determining whether the write-back policy requires writing the to-be-written data into the cache device includes:

[0141] Determine whether the write-back strategy is a delayed write strategy or a write-through strategy;

[0142] If yes, it is determined that the write-back policy requires writing the data to be written into the cache device;

[0143] If not, it is determined that the write-back policy does not require writing the data to be written into the cache device.

[0144] Specifically, since among the three write-back strategies, the lagging write strategy or the through write strategy requires the data to be written to the cache device, the embodiment of the present invention can quickly determine whether the write-back strategy requires the data to be written to the cache device by determining whether the write-back strategy belongs to the lagging write strategy or the through write strategy.

[0145] As an optional embodiment, in response to a data write request from a host, determining a write-back policy of the storage system includes:

[0146] In response to a data write request from a host, determining whether a cache device exists in the storage system;

[0147] If so, determine the write-back policy of the storage system;

[0148] The data storage method also includes:

[0149] If there is no cache device in the storage system, the data to be written in the data write request is written to the backend storage device of the storage system.

[0150] Specifically, considering that there is no cache mechanism at all in some storage systems, in order to improve the applicability of the data storage method in the embodiment of the present invention, the embodiment of the present invention can respond to the data write request of the host, first determine whether there is a cache device in the storage system, and if there is a cache device, continue to determine the write-back policy of the storage system, and when there is no cache device in the storage system, write the data to be written of the data write request to the back-end storage device of the storage system.

[0151] As an optional embodiment, the designated memory is a non-volatile memory;

[0152] The data storage method also includes:

[0153] After power-on, determine whether metadata exists in the specified memory;

[0154] If it exists, the metadata recorded in the currently designated storage is stored in the cache device as a tree node in a preset metadata tree;

[0155] After storing the metadata recorded in the current designated storage as a tree node in a preset metadata tree in the cache device, the data storage method further includes:

[0156] Deletes the metadata stored in the cache device in the specified storage.

[0157] Specifically, considering the unexpected situation of sudden power outage in the storage system, in order to prevent the loss of metadata temporarily stored in the designated memory, the designated memory in the embodiment of the present invention can adopt a non-volatile memory, and considering that the processor is in the process of storing the metadata in the designated memory as a tree node in the cache device (not yet completed), a sudden power outage will affect the normal transfer of metadata. Therefore, in order to transfer metadata in a timely and accurate manner, in the embodiment of the present invention, after power-on, it can be determined whether there is metadata in the designated memory. If so, the metadata currently recorded in the designated memory is stored in the cache device as a tree node in the preset metadata tree, and the metadata in the designated memory that has been stored in the cache device is deleted.

[0158] The non-volatile memory may be of various types, such as NVRAM (Non-Volatile Random Access Memory), etc., which is not limited in the embodiment of the present invention.

[0159] As an optional embodiment, the preset trigger condition includes:

[0160] The amount of metadata in the specified memory reaches a preset threshold or there is a trigger instruction generated every preset trigger period.

[0161] Specifically, considering that the frequency of writing metadata in the specified memory is difficult to predict, one of the two methods can be flexibly selected as the preset trigger condition, that is, the preset trigger condition can be "the amount of metadata in the specified memory reaches a preset threshold" or "there is a trigger instruction generated every preset trigger period."

[0162] The preset trigger period may be independently set, for example, may be 1 hour, etc., and the embodiment of the present invention does not limit this.

[0163] As an optional embodiment, in response to the data flush instruction, according to the tree nodes stored in the cache device, flushing the cache data corresponding to the tree nodes in the preset metadata tree in a dirty state to the backend storage device includes:

[0164] In response to the data flush instruction, determining a tree node in a preset metadata tree that is in a dirty state;

[0165] Add the tree nodes in dirty state to the write-back list;

[0166] The cache data corresponding to each tree node in the write-back list is flushed to the back-end storage device in the order of the logical address in the back-end storage device from small to large.

[0167] Specifically, considering that the capacity of the cache device is limited, when there is too much cached data, the dirty cached data needs to be flushed. Therefore, in an embodiment of the present invention, in response to a data flush instruction, the tree nodes in the preset metadata tree that are in a dirty state can be determined, and then the tree nodes in the dirty state are added to the write-back list. Finally, the cached data corresponding to each tree node in the write-back list are flushed to the back-end storage device in the order of the logical address in the back-end storage device from small to large. The cached data can be flushed accurately and without omission according to the granularity of the tree node, and the cached data can be flushed in the order of the logical address in the back-end storage device from small to large, which can increase the rate at which the cached data is placed on the disk, thereby improving work efficiency.

[0168] Among them, the preset metadata tree of the tree data structure can arrange the "logical addresses of each metadata in the back-end storage device from small to large" when generating each tree node. Therefore, in the cache data disk stage, the dirty tree nodes sorted according to the "logical addresses in the back-end storage device from small to large" can be quickly obtained according to the sorting method of the tree nodes in the preset metadata tree, in the form of a write-back list, which is conducive to further improving the efficiency of data disk placement.

[0169] As an optional embodiment, the cache device includes a solid state drive;

[0170] The back-end storage device includes an independent redundant disk array built on a mechanical hard disk group.

[0171] Specifically, the combination of a solid-state drive and an "independent redundant disk array built on a mechanical hard disk group" helps balance costs and data storage efficiency.

[0172] Of course, in addition to this combination, the cache device and the backend storage device may also be combined in other forms, which is not limited in the embodiment of the present invention.

[0173] As an optional embodiment, in response to the data flush instruction, before flushing cache data corresponding to the tree nodes in the preset metadata tree that are in a dirty state to the backend storage device according to the tree nodes stored in the cache device, the data storage method further includes:

[0174] Determine the proportion of cache data in a dirty state in the cache device relative to the capacity of the cache device;

[0175] If the capacity ratio is greater than the first preset ratio, a data refresh instruction is generated;

[0176] Receive data refresh instructions through the human-computer interaction device.

[0177] Specifically, considering that the space of the cache device is limited and the user may have the need to actively control the cache data to be written to the disk, two methods of triggering data flushing are provided in the embodiment of the present invention. The first method is: determining the proportion of cache data in a dirty state in the cache device relative to the capacity of the cache device, and if the capacity proportion is greater than a first preset ratio, a data flush instruction is generated. The second method allows the user to actively control the cache data to be written to the disk by generating a data flush instruction. Therefore, in the embodiment of the present invention, the data flush instruction can be received through the human-computer interaction device.

[0178] The first preset ratio may be independently set, for example, may be 10%, etc., and the embodiment of the present invention does not limit this.

[0179] As an optional embodiment, in response to the data flush instruction, according to the tree nodes stored in the cache device, flushing the cache data corresponding to the tree nodes in the preset metadata tree in a dirty state to the backend storage device includes:

[0180] In response to the data flush instruction, determining a proportion of cache data in a dirty state in the cache device relative to a real-time capacity of the cache device;

[0181] According to a first preset corresponding relationship between the capacity ratio and the number of threads, determining the number of threads corresponding to the real-time capacity ratio as the target number of threads;

[0182] Through the target number of threads, according to the tree nodes stored in the cache device, the cache data corresponding to the tree nodes in the preset metadata tree that are in a dirty state are flushed to the back-end storage device.

[0183] Specifically, considering that the higher the proportion of cache data in a dirty state in the cache device relative to the real-time capacity of the cache device is, the higher the risk of the cache device being full is, in order to reduce this risk, in an embodiment of the present invention, when the above-mentioned real-time capacity proportion is higher, more threads are used to write cache data to the disk, thereby avoiding this risk. Therefore, in an embodiment of the present invention, in response to a data flush instruction, the proportion of cache data in a dirty state in the cache device relative to the real-time capacity of the cache device can be determined, and according to a first preset corresponding relationship between the capacity proportion and the number of threads, the number of threads corresponding to the real-time capacity proportion is determined as the target number of threads, and finally, through the target number of threads, according to the tree nodes stored in the cache device, the cache data corresponding to the tree nodes in the preset metadata tree in a dirty state is flushed to the back-end storage device.

[0184] As an optional embodiment, the first preset corresponding relationship includes:

[0185] If the capacity ratio is greater than the second preset ratio and less than the third preset ratio, the capacity ratio is positively correlated with the number of threads;

[0186] If the capacity ratio is greater than the third preset ratio, the number of threads is the preset maximum number of threads.

[0187] Specifically, the first preset corresponding relationship in the embodiment of the present invention has the advantages of simplicity and high efficiency.

[0188] Of course, in addition to this specific form, the first preset corresponding relationship may also be in many other forms, which is not limited in the embodiment of the present invention.

[0189] Among them, the second preset ratio to the third preset ratio can all be set independently, for example, the second preset ratio can be 10%, the third preset ratio can be 40%, etc., and the embodiment of the present invention is not limited here.

[0190] As an optional embodiment, in response to the data flush instruction, after determining the proportion of cache data in a dirty state in the cache device relative to the real-time capacity of the cache device, the data storage method further includes:

[0191] According to a second preset correspondence between the capacity share and the ratio, taking the ratio corresponding to the real-time capacity share as the target ratio;

[0192] The write-back policy of the target ratio of data write requests of the storage system is set to a bypass write policy.

[0193] Specifically, in order to further avoid the risk of the cache device being full, considering that the rate of cache data written to the cache device can be adjusted by adjusting the proportion of data write requests with the "write back strategy as the bypass write strategy", a second preset corresponding relationship can be set in the embodiment of the present invention, and according to the second preset corresponding relationship between the capacity ratio and the ratio, the proportion corresponding to the real-time capacity ratio can be used as the target ratio, and the write back strategy of the data write request of the target ratio of the storage system can be set to the bypass write strategy.

[0194] Among them, in the second preset corresponding relationship, there may be a positive correlation between the capacity share and the ratio, that is, when the capacity share is higher, the corresponding ratio should be higher, which may be a linear relationship, etc., and the embodiment of the present invention is not limited here.

[0195] As an optional embodiment, the second preset corresponding relationship includes:

[0196] If the capacity ratio is greater than the third preset ratio and less than the fourth preset ratio, the capacity ratio is positively correlated with the proportion;

[0197] If the capacity ratio is greater than the fourth preset ratio, the ratio is the preset maximum ratio.

[0198] Specifically, the second preset corresponding relationship in the embodiment of the present invention is concise in form and clear in logic. Through the second preset corresponding relationship in the embodiment of the present invention, the write-back strategy of the target ratio of data write requests of the storage system can be efficiently and accurately set to the bypass write strategy.

[0199] Of course, in addition to this specific form, the second preset corresponding relationship may also be in other forms, which is not limited in the embodiment of the present invention.

[0200] Among them, the fourth preset ratio can be set independently, for example, it can be 70%, etc., and the embodiment of the present invention is not limited here.

[0201] Please refer to Figure 5 , Figure 5 A structural schematic diagram of a data storage device provided by the present invention, the data storage device comprises:

[0202] A memory 51, used for storing computer programs;

[0203] The processor 52 is used to implement the steps of the data storage method in the above embodiment when executing the computer program.

[0204] For an introduction to the data storage device provided in the embodiment of the present invention, please refer to the aforementioned embodiment of the data storage method, and the embodiment of the present invention will not be described in detail here.

[0205] The present invention also provides a storage system, comprising the data storage device as described in the above embodiment.

[0206] For an introduction to the storage system provided by the embodiment of the present invention, please refer to the aforementioned embodiment of the data storage method, and the embodiment of the present invention will not be described in detail here.

[0207] The present invention also provides a computer program product, comprising a computer program / instruction, which implements the steps of the data storage method in the above embodiment when executed by a processor.

[0208] For an introduction to the computer program product provided by the embodiment of the present invention, please refer to the aforementioned embodiment of the data storage method, and the embodiment of the present invention will not be described in detail here.

[0209] Please refer to Figure 6 , Figure 6 This is a schematic diagram of the structure of a computer-readable storage medium provided by the present invention. A computer program 62 is stored on the computer-readable storage medium 61. When the computer program 62 is executed by a processor, the steps of the data storage method in the aforementioned embodiment are implemented.

[0210] For an introduction to the computer-readable storage medium provided in an embodiment of the present invention, please refer to the aforementioned embodiment of the data storage method, and the embodiment of the present invention will not be described in detail here.

[0211] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same and similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description. It should also be noted that in this specification, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is any such actual relationship or order between these entities or operations. Moreover, the term "include", "comprise" or any other variant thereof is intended to cover non-exclusive inclusion, so that the process, method, article or equipment including a series of elements includes not only those elements, but also includes other elements that are not explicitly listed, or also includes elements inherent to such process, method, article or equipment. In the absence of more restrictions, the elements defined by the sentence "including one..." do not exclude the existence of other identical elements in the process, method, article or equipment including the element.

[0212] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A data storage method, characterized in that: Applicable to processors, including: In response to a data write request from the host, write the to-be-written data of the data write request as cache data into the cache device; Recording metadata of the cached data in a designated storage; When a preset trigger condition is met, the metadata currently recorded in the designated storage is stored in the cache device as a tree node in a preset metadata tree; In response to the data flush instruction, according to the tree nodes stored in the cache device, the cache data corresponding to the tree nodes in the preset metadata tree that are in a dirty state are flushed to the back-end storage device, wherein the dirty state means that the cache data corresponding to the tree nodes are not flushed to the back-end storage device; The state of the tree node corresponding to the cache data flushed to the backend storage device is set to a clean state, wherein the clean state means that the cache data corresponding to the tree node has been flushed to the backend storage device.

2. The data storage method according to claim 1, characterized in that: In response to a data write request from a host, writing the to-be-written data of the data write request as cache data into a cache device comprises: In response to a data write request from the host, write the to-be-written data of the data write request as cache data into an idle cache data storage area in the cache device in a first preset order, wherein the first preset order is an order from small to large logical addresses; The metadata currently recorded in the designated storage is stored in the cache device as a tree node in a preset metadata tree, including: The metadata currently recorded in the designated storage is stored as a tree node in a preset metadata tree in a tree node storage area with remaining space in the cache device; The data storage method further comprises: In the initialization stage of the cache device, a storage space of a preset capacity of the cache device is used as a super block according to a first preset order, a storage space of a preset capacity after the super block is used as a tree node storage area according to the first preset order, and a storage space after the tree node storage area with the largest current logical address is used as a cache data storage area; The super block is used to store the binding relationship between the cache device and the backend storage device, the block capacity, and the cache write-back policy; If there is no remaining space in the tree node storage area with the largest logical address in the cache device, then the free storage space of the cache device with a preset capacity is used as a new tree node storage area according to a first preset order.

3. The data storage method according to claim 2, characterized in that: The metadata currently recorded in the designated storage is stored in the cache device as a tree node in a preset metadata tree, including: Determine the metadata of the currently designated storage device that respectively corresponds to the data write request; For any metadata currently recorded in the designated storage, the metadata is used as a tree node in a preset metadata tree, and the parent-child node identifiers of the tree node are determined, wherein the parent-child node identifiers include a parent node identifier and a child node identifier; The generated tree nodes and their parent and child node identifiers are stored in the cache device.

4. The data storage method according to claim 3, characterized in that: The data storage method further comprises: In response to the metadata tree display instruction, obtaining each tree node and its parent and child node identifiers in the cache device; Constructing a topological diagram of the preset metadata tree according to each parent-child node identifier; Hanging each tree node in the cache device at a corresponding position in the topology map; The display is controlled to display the topology diagram.

5. The data storage method according to claim 1, characterized in that: In response to a data write request from a host, writing the to-be-written data of the data write request as cache data into a cache device comprises: In response to a data write request from the host, determining a write-back policy of the storage system, wherein the write-back policy refers to: a method of writing the to-be-written data of the data write request into a back-end storage device of the storage system; Determining whether the write-back strategy requires writing the data to be written into the cache device; If necessary, the data to be written of the data write request is written into the cache device as cache data.

6. The data storage method according to claim 5, characterized in that: Determining whether the write-back strategy requires writing the to-be-written data into the cache device includes: Determining whether the write-back strategy is a write-latency strategy or a write-through strategy; If yes, it is determined that the write-back strategy requires writing the to-be-written data into the cache device; If not, it is determined that the write-back policy does not require writing the to-be-written data into the cache device.

7. The data storage method according to claim 5, characterized in that: In response to a data write request from a host, determining a write-back policy of the storage system includes: In response to a data write request from a host, determining whether a cache device exists in the storage system; If so, determine the write-back policy of the storage system; The data storage method further comprises: If there is no cache device in the storage system, the data to be written in the data write request is written to the backend storage device of the storage system.

8. The data storage method according to claim 1, characterized in that: The designated memory is a non-volatile memory; The data storage method further comprises: After power-on, determining whether metadata exists in the designated memory; If so, storing the metadata currently recorded in the designated storage device as a tree node in a preset metadata tree in the cache device; After storing the metadata currently recorded in the designated storage as a tree node in a preset metadata tree in the cache device, the data storage method further includes: The metadata stored in the cache device in the designated memory is deleted.

9. The data storage method according to claim 8, characterized in that: The preset trigger conditions include: The amount of metadata in the designated memory reaches a preset threshold or there is a trigger instruction generated every preset trigger period.

10. The data storage method according to claim 1, characterized in that: In response to the data flush instruction, according to the tree nodes stored in the cache device, flushing the cache data corresponding to the tree nodes in the preset metadata tree in a dirty state to the backend storage device includes: In response to a data flush instruction, determining a tree node in the preset metadata tree that is in a dirty state; Add the tree nodes in dirty state to the write-back list; The cache data corresponding to each tree node in the write-back list is flushed to the back-end storage device in the order of the logical addresses in the back-end storage device from small to large.

11. The data storage method according to claim 1, characterized in that: The cache device includes a solid state drive; The back-end storage device includes an independent redundant disk array constructed based on a mechanical hard disk group.

12. The data storage method according to claim 1, characterized in that: In response to the data flush instruction, before flushing cache data corresponding to the tree nodes in the preset metadata tree that are in a dirty state to the backend storage device according to the tree nodes stored in the cache device, the data storage method further includes: Determine the proportion of cache data in a dirty state in the cache device relative to the capacity of the cache device; If the capacity ratio is greater than a first preset ratio, a data refresh instruction is generated; Receive data refresh instructions through the human-computer interaction device.

13. The data storage method according to any one of claims 1 to 12, characterized in that: In response to the data flush instruction, according to the tree nodes stored in the cache device, flushing the cache data corresponding to the tree nodes in the preset metadata tree in a dirty state to the backend storage device includes: In response to the data flush instruction, determining a proportion of cache data in a dirty state in the cache device relative to a real-time capacity of the cache device; According to a first preset corresponding relationship between the capacity ratio and the number of threads, determining the number of threads corresponding to the real-time capacity ratio as the target number of threads; Through target thread number threads, cache data corresponding to tree nodes in a dirty state in the preset metadata tree is flushed to a backend storage device according to the tree nodes stored in the cache device.

14. The data storage method according to claim 13, characterized in that: The first preset corresponding relationship includes: If the capacity ratio is greater than the second preset ratio and less than the third preset ratio, the capacity ratio is positively correlated with the number of threads; If the capacity ratio is greater than the third preset ratio, the number of threads is the preset maximum number of threads.

15. The data storage method according to claim 13, characterized in that: In response to the data flush instruction, after determining the proportion of dirty cache data in the cache device relative to the real-time capacity of the cache device, the data storage method further includes: According to a second preset correspondence between the capacity share and the ratio, taking the ratio corresponding to the real-time capacity share as the target ratio; The write-back policy of the target ratio of data write requests of the host is set to a bypass write policy.

16. The data storage method according to claim 15, characterized in that: The second preset corresponding relationship includes: If the capacity ratio is greater than the third preset ratio and less than the fourth preset ratio, the capacity ratio is positively correlated with the proportion; If the capacity ratio is greater than the fourth preset ratio, the ratio is the preset maximum ratio.

17. A data storage device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the data storage method according to any one of claims 1 to 16 when executing the computer program.

18. A storage system, characterized in that: Comprising the data storage device of claim 17.

19. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the data storage method according to any one of claims 1 to 16 are implemented.

20. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the data storage method according to any one of claims 1 to 16 are implemented.