A data storage method, system, device, and storage medium
By copying write I/O and determining dirty data during caching policy switching, directly writing to the RAID group and updating the dirty data, the data loss problem during WRITE-THROUGH switching is solved, thus achieving data storage integrity and consistency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHANDONG YUNHAI GUOCHUANG CLOUD COMPUTING EQUIP IND INNOVATION CENT CO LTD
- Filing Date
- 2022-09-27
- Publication Date
- 2026-04-24
AI Technical Summary
When the caching policy is switched from WRITE-BACK to WRITE-THROUGH, new IO cannot be directly stored in the cache, resulting in data loss during abnormal writing to the RAID group storage medium, and the data in the cache is permanently lost after it expires.
When switching caching strategies, copy the write I/O and check if there is any unexpired dirty data. Write one copy of the write I/O to the RAID group and update the dirty data with the other copy. Ensure that the dirty data in the cache is invalidated only after the write I/O is successful to avoid permanent data loss.
During the caching strategy switching process, ensure that the new IO is successfully written to the RAID group before invalidating the dirty data in the cache, avoid permanent data loss, and improve the integrity and consistency of data storage.
Smart Images

Figure CN115629705B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of storage, and more specifically to a data storage method, system, device, and storage medium. Background Technology
[0002] In the storage field, caching is an important component that can greatly improve storage performance and reduce IO latency. When the caching strategy is changed from WRITE-BACK to WRITE-THROUGH, ensuring the integrity and consistency of stored data becomes the top priority.
[0003] Under the WRITE-BACK policy, the cache stores a large amount of dirty cache data. If the caching policy is switched from WRITE-BACK to WRITE-THROUGH, new I / O from the host can no longer be stored in the cache. It needs to bypass the cache and be stored on the storage media of the RAID group in order to respond to the host. The current approach is to make a copy of the new I / O in the cache component, one copy passing through the cache and one copy not passing through the cache.
[0004] New I / O operations that have been cached will attempt to find a match in the cache. If there is a partial or full match, the cached data will be invalidated, and resources will be released and reclaimed. If there is a miss, no action will be taken. If an error occurs while writing uncached data to the RAID group storage media, the storage will fail. Conversely, if cached I / O data finds a match, it will invalidate any dirty data stored in the cache. In such a scenario, the I / O data in the cache has been modified, but the RAID group storage media does not contain the client's new I / O data. The client's cached I / O data will be permanently lost after invalidation, resulting in irreparable damage. Summary of the Invention
[0005] In view of this, in order to overcome at least one aspect of the above-mentioned problems, embodiments of the present invention propose a data storage method, comprising the following steps:
[0006] In response to receiving a write I / O, obtain the current caching strategy;
[0007] In response to the current caching strategy being the first caching strategy, determine whether there is any undeniable dirty data in the current cache;
[0008] In response to the presence of unexpired dirty data, the write IO is copied to obtain two write IOs and it is determined whether the write IO hits unexpired dirty data;
[0009] In response to a hit on the non-expired dirty data, one write IO is written directly to the RAID, and the other write IO updates the hit non-expired dirty data;
[0010] In response to a successful write IO to the RAID, invalidate the dirty data that was not yet invalidated.
[0011] In some embodiments, it also includes:
[0012] In response to a write IO failure to write to the RAID, the cache is notified of the non-invalid dirty data hit.
[0013] In some embodiments, it also includes:
[0014] In response to the absence of non-expired dirty data, the write IO is directly written to the RAID.
[0015] In some embodiments, it also includes:
[0016] In response to a miss on the non-expired dirty data, one write IO is written directly to the RAID, and the other write IO is discarded;
[0017] In response to one of the write IOs failing to write to the RAID, a data write failure is reported.
[0018] Based on the same inventive concept, according to another aspect of the present invention, embodiments of the present invention also provide a data storage system, comprising:
[0019] The receiving module is configured to retrieve the current caching strategy in response to receiving a write I / O.
[0020] The judgment module is configured to respond to the current caching strategy as the first caching strategy and determine whether there is any undeniable dirty data in the current cache.
[0021] The copy module is configured to, in response to the presence of unexpired dirty data, copy the write IO to obtain two write IOs and determine whether the write IO hits unexpired dirty data;
[0022] The first write module is configured to, in response to a hit of the non-expired dirty data, directly write one write IO to the RAID and update the hit non-expired dirty data with another write IO.
[0023] The failure module is configured to fail the non-failed dirty data in response to a successful write IO to the RAID.
[0024] In some embodiments, a notification module is also included, configured as follows:
[0025] In response to a write IO failure to write to the RAID, the cache is notified of the non-invalid dirty data hit.
[0026] In some embodiments, a second writing module is further included, configured as follows:
[0027] In response to the absence of non-expired dirty data, the write IO is directly written to the RAID.
[0028] In some embodiments, the first writing module is further configured to:
[0029] In response to a miss on the non-expired dirty data, one write IO is written directly to the RAID, and the other write IO is discarded;
[0030] In response to one of the write IOs failing to write to the RAID, a data write failure is reported.
[0031] Based on the same inventive concept, according to another aspect of the present invention, embodiments of the present invention also provide a computer device, comprising:
[0032] At least one processor; and
[0033] A memory storing a computer program executable on the processor, characterized in that the processor performs the following steps when executing the program:
[0034] In response to receiving a write I / O, obtain the current caching strategy;
[0035] In response to the current caching strategy being the first caching strategy, determine whether there is any undeniable dirty data in the current cache;
[0036] In response to the presence of unexpired dirty data, the write IO is copied to obtain two write IOs and it is determined whether the write IO hits unexpired dirty data;
[0037] In response to a hit on the non-expired dirty data, one write IO is written directly to the RAID, and the other write IO updates the hit non-expired dirty data;
[0038] In response to a successful write IO to the RAID, invalidate the dirty data that was not yet invalidated.
[0039] In some embodiments, it also includes:
[0040] In response to a write IO failure to write to the RAID, the cache is notified of the non-invalid dirty data hit.
[0041] In some embodiments, it also includes:
[0042] In response to the absence of non-expired dirty data, the write IO is directly written to the RAID.
[0043] In some embodiments, it also includes:
[0044] In response to a miss on the non-expired dirty data, one write IO is written directly to the RAID, and the other write IO is discarded;
[0045] In response to one of the write IOs failing to write to the RAID, a data write failure is reported.
[0046] Based on the same inventive concept, according to another aspect of the present invention, embodiments of the present invention also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the following steps:
[0047] In response to receiving a write I / O, obtain the current caching strategy;
[0048] In response to the current caching strategy being the first caching strategy, determine whether there is any undeniable dirty data in the current cache;
[0049] In response to the presence of unexpired dirty data, the write IO is copied to obtain two write IOs and it is determined whether the write IO hits unexpired dirty data;
[0050] In response to a hit on the non-expired dirty data, one write IO is written directly to the RAID, and the other write IO updates the hit non-expired dirty data;
[0051] In response to a successful write IO to the RAID, invalidate the dirty data that was not yet invalidated.
[0052] In some embodiments, it also includes:
[0053] In response to a write IO failure to write to the RAID, the cache is notified of the non-invalid dirty data hit.
[0054] In some embodiments, it also includes:
[0055] In response to the absence of non-expired dirty data, the write IO is directly written to the RAID.
[0056] In some embodiments, it also includes:
[0057] In response to a miss on the non-expired dirty data, one write IO is written directly to the RAID, and the other write IO is discarded;
[0058] In response to one of the write IOs failing to write to the RAID, a data write failure is reported.
[0059] The present invention has one of the following beneficial technical effects: When the caching strategy proposed in this invention is switched from WRITE-BACK to WRITE-THROUGH, the caching component of the IO stack copies one IO, one IO is cached, and the other IO is directly written to the storage medium of the RAID group without being cached. If the data that is not cached is not invalidated, the new IO is guaranteed to be successfully written to the storage medium of the RAID group before the cache is invalidated. If the new IO is not successfully written to the storage medium of the RAID group, the dirty data in the cache is not invalidated, so that permanent data loss will not occur. Attached Figure Description
[0060] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other embodiments can be obtained based on these drawings without creative effort.
[0061] Figure 1 A flowchart illustrating a data storage method provided in an embodiment of the present invention;
[0062] Figure 2 A schematic diagram of the data storage system provided for an embodiment of the present invention;
[0063] Figure 3 A schematic diagram of the structure of a computer device provided for an embodiment of the present invention;
[0064] Figure 4 A schematic diagram of the structure of a computer-readable storage medium provided for an embodiment of the present invention. Detailed Implementation
[0065] To make the objectives, technical solutions, and advantages of the present invention clearer, the embodiments of the present invention will be further described in detail below with reference to specific examples and the accompanying drawings.
[0066] It should be noted that all uses of "first" and "second" in the embodiments of the present invention are for the purpose of distinguishing two entities or parameters with the same name but different names. It is clear that "first" and "second" are only for the convenience of expression and should not be construed as limiting the embodiments of the present invention. Subsequent embodiments will not explain this in detail.
[0067] In embodiments of this invention, WB, short for WRITE-BACK, is a caching strategy. Specifically, when a write I / O event arrives in the cache, if cache resources are sufficient, the write I / O data is stored in the cache, and a successful write response is immediately sent to the host. The write I / O data stored in the cache is asynchronously written to the storage medium of the RAID group when certain conditions are met. If cache resources are insufficient, the write I / O data is written to the storage medium of the RAID group before a response is sent to the host. Similarly, when a read event arrives in the cache, if the read I / O operation is a full cache hit, the hit data is retrieved from the cache, and a successful read response is immediately sent to the host. If the read I / O operation is a partial cache hit, the hit data is retrieved from the cache, and the missing data is retrieved from the storage medium of the RAID group before a response is sent to the host. If the read I / O operation is a complete cache miss, all data is retrieved from the storage medium of the RAID group before a response is sent to the host. This technique can improve I / O performance and significantly reduce I / O latency.
[0068] WT, short for WRITE-THROUGH, is a caching strategy (first caching strategy). For write I / O events, the host is responded to after the write I / O data is written to the storage medium of the RAID group; for read I / O events, the host is responded to after the data is read from the storage medium of the RAID group.
[0069] A RAID array is a group of many independent hard drives combined into a large-capacity disk array. It leverages the synergistic effect of individual disks to improve the overall performance of the disk system. This technology divides data into many segments and stores them on different hard drives.
[0070] Dirty data refers to IO data stored in the cache that has not yet been written to the storage media of the RAID group.
[0071] According to one aspect of the present invention, embodiments of the present invention provide a data storage method, such as... Figure 1 As shown, it may include the following steps:
[0072] S1, in response to receiving a write IO, obtain the current caching strategy;
[0073] S2, in response to the current caching strategy being the first caching strategy, determines whether there is any unexpired dirty data in the current cache;
[0074] S3, in response to the presence of unexpired dirty data, copy the write IO to obtain two write IOs and determine whether the write IO hits the unexpired dirty data;
[0075] S4, in response to the hit of the non-expired dirty data, one write IO is written directly to the RAID, and the other write IO updates the hit non-expired dirty data;
[0076] S5, in response to a successful write IO to the RAID, invalidates the dirty data that was not yet invalidated.
[0077] The proposed solution, when switching the caching strategy from WRITE-BACK to WRITE-THROUGH, copies an IO to the caching component of the IO stack. One copy of the IO is cached, while the other copy is directly written to the storage medium of the RAID group without being cached. Before the data that is not cached is invalidated, the new IO is successfully written to the storage medium of the RAID group, and then the dirty data in the cache is invalidated. If the new IO is not successfully written to the storage medium of the RAID group, the dirty data in the cache is not invalidated, thus preventing permanent data loss.
[0078] In some embodiments, it also includes:
[0079] In response to a write IO failure to write to the RAID, the cache is notified of the non-invalid dirty data hit.
[0080] In some embodiments, it also includes:
[0081] In response to the absence of non-expired dirty data, the write IO is directly written to the RAID.
[0082] In some embodiments, it also includes:
[0083] In response to a miss on the non-expired dirty data, one write IO is written directly to the RAID, and the other write IO is discarded;
[0084] In response to one of the write IOs failing to write to the RAID, a data write failure is reported.
[0085] Specifically, upon receiving a new I / O, a copy is made in the I / O stack's cache component. This copy is then cached. If the address in the I / O operation matches dirty data in the cache, the dirty data is updated directly. The other I / O operation is written directly to the RAID group's storage medium without going through the cache. When a new I / O operation successfully writes to the RAID group's storage medium, the cache component is notified that the matched data can be invalidated. When a new I / O operation fails to write to the RAID group's storage medium, the cache component is notified that the matched data cannot be invalidated.
[0086] The proposed solution, when switching the caching strategy from WRITE-BACK to WRITE-THROUGH, copies an IO to the caching component of the IO stack. One copy of the IO is cached, while the other copy is directly written to the storage medium of the RAID group without being cached. Before the data that is not cached is invalidated, the new IO is successfully written to the storage medium of the RAID group, and then the dirty data in the cache is invalidated. If the new IO is not successfully written to the storage medium of the RAID group, the dirty data in the cache is not invalidated, thus preventing permanent data loss.
[0087] Based on the same inventive concept, according to another aspect of the present invention, embodiments of the present invention also provide a data storage system 400, such as... Figure 2 As shown, it includes:
[0088] The receiving module 401 is configured to obtain the current caching strategy in response to receiving a write IO;
[0089] The judgment module 402 is configured to respond to the current caching strategy as the first caching strategy and determine whether there is any undeniable dirty data in the current cache.
[0090] The copy module 403 is configured to, in response to the existence of unexpired dirty data, copy the write IO to obtain two write IOs and determine whether the write IO hits unexpired dirty data;
[0091] The first write module 404 is configured to, in response to a hit of the non-expired dirty data, directly write one write IO to the RAID and update the hit non-expired dirty data with another write IO.
[0092] The failure module is configured to fail the non-failed dirty data in response to a successful write IO to the RAID.
[0093] In some embodiments, a notification module is also included, configured as follows:
[0094] In response to a write IO failure to write to the RAID, the cache is notified of the non-invalid dirty data hit.
[0095] In some embodiments, a second writing module is further included, configured as follows:
[0096] In response to the absence of non-expired dirty data, the write IO is directly written to the RAID.
[0097] In some embodiments, the first writing module 404 is further configured to:
[0098] In response to a miss on the non-expired dirty data, one write IO is written directly to the RAID, and the other write IO is discarded;
[0099] In response to one of the write IOs failing to write to the RAID, a data write failure is reported.
[0100] The proposed solution, when switching the caching strategy from WRITE-BACK to WRITE-THROUGH, copies an IO to the caching component of the IO stack. One copy of the IO is cached, while the other copy is directly written to the storage medium of the RAID group without being cached. Before the data that is not cached is invalidated, the new IO is successfully written to the storage medium of the RAID group, and then the dirty data in the cache is invalidated. If the new IO is not successfully written to the storage medium of the RAID group, the dirty data in the cache is not invalidated, thus preventing permanent data loss.
[0101] Based on the same inventive concept, according to another aspect of the present invention, such as Figure 3 As shown, embodiments of the present invention also provide a computer device 501, comprising:
[0102] At least one processor 520; and
[0103] Memory 510 stores a computer program 511 that can run on a processor. When the processor 520 executes the program, it performs the following steps:
[0104] S1, in response to receiving a write IO, obtain the current caching strategy;
[0105] S2, in response to the current caching strategy being the first caching strategy, determines whether there is any unexpired dirty data in the current cache;
[0106] S3, in response to the presence of unexpired dirty data, copy the write IO to obtain two write IOs and determine whether the write IO hits the unexpired dirty data;
[0107] S4, in response to the hit of the non-expired dirty data, one write IO is written directly to the RAID, and the other write IO updates the hit non-expired dirty data;
[0108] S5, in response to a successful write IO to the RAID, invalidates the dirty data that was not yet invalidated.
[0109] In some embodiments, it also includes:
[0110] In response to a write IO failure to write to the RAID, the cache is notified of the non-invalid dirty data hit.
[0111] In some embodiments, it also includes:
[0112] In response to the absence of non-expired dirty data, the write IO is directly written to the RAID.
[0113] In some embodiments, it also includes:
[0114] In response to a miss on the non-expired dirty data, one write IO is written directly to the RAID, and the other write IO is discarded;
[0115] In response to one of the write IOs failing to write to the RAID, a data write failure is reported.
[0116] The proposed solution, when switching the caching strategy from WRITE-BACK to WRITE-THROUGH, copies an IO to the caching component of the IO stack. One copy of the IO is cached, while the other copy is directly written to the storage medium of the RAID group without being cached. Before the data that is not cached is invalidated, the new IO is successfully written to the storage medium of the RAID group, and then the dirty data in the cache is invalidated. If the new IO is not successfully written to the storage medium of the RAID group, the dirty data in the cache is not invalidated, thus preventing permanent data loss.
[0117] Based on the same inventive concept, according to another aspect of the present invention, such as Figure 4 As shown, embodiments of the present invention also provide a computer-readable storage medium 601, which stores a computer program 610. When the computer program 610 is executed by a processor, it performs the following steps:
[0118] S1, in response to receiving a write IO, obtain the current caching strategy;
[0119] S2, in response to the current caching strategy being the first caching strategy, determines whether there is any unexpired dirty data in the current cache;
[0120] S3, in response to the presence of unexpired dirty data, copy the write IO to obtain two write IOs and determine whether the write IO hits the unexpired dirty data;
[0121] S4, in response to the hit of the non-expired dirty data, one write IO is written directly to the RAID, and the other write IO updates the hit non-expired dirty data;
[0122] S5, in response to a successful write IO to the RAID, invalidates the dirty data that was not yet invalidated.
[0123] In some embodiments, it also includes:
[0124] In response to a write IO failure to write to the RAID, the cache is notified of the non-invalid dirty data hit.
[0125] In some embodiments, it also includes:
[0126] In response to the absence of non-expired dirty data, the write IO is directly written to the RAID.
[0127] In some embodiments, it also includes:
[0128] In response to a miss on the non-expired dirty data, one write IO is written directly to the RAID, and the other write IO is discarded;
[0129] In response to one of the write IOs failing to write to the RAID, a data write failure is reported.
[0130] The proposed solution, when switching the caching strategy from WRITE-BACK to WRITE-THROUGH, copies an IO to the caching component of the IO stack. One copy of the IO is cached, while the other copy is directly written to the storage medium of the RAID group without being cached. Before the data that is not cached is invalidated, the new IO is successfully written to the storage medium of the RAID group, and then the dirty data in the cache is invalidated. If the new IO is not successfully written to the storage medium of the RAID group, the dirty data in the cache is not invalidated, thus preventing permanent data loss.
[0131] Finally, it should be noted that those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods.
[0132] Furthermore, it should be understood that the computer-readable storage medium (e.g., memory) described herein may be volatile memory or non-volatile memory, or may include both volatile memory and non-volatile memory.
[0133] Those skilled in the art will also understand that the various exemplary logic blocks, modules, circuits, and algorithm steps described in conjunction with the disclosure herein can be implemented as electronic hardware, computer software, or a combination of both. To clearly illustrate this interchangeability between hardware and software, the functionality of various illustrative components, blocks, modules, circuits, and steps has been generally described. Whether this functionality is implemented as software or as hardware depends on the specific application and the design constraints imposed on the system as a whole. Those skilled in the art can implement the functionality in various ways for each specific application, but such implementation decisions should not be construed as departing from the scope of the embodiments disclosed herein.
[0134] The above are exemplary embodiments disclosed in this invention. However, it should be noted that various changes and modifications can be made without departing from the scope of the embodiments of this invention as defined by the claims. The functions, steps, and / or actions of the methods according to the disclosed embodiments described herein do not need to be performed in any particular order. Furthermore, although the elements disclosed in the embodiments of this invention may be described or claimed individually, they may be understood as multiple unless explicitly limited to a singular number.
[0135] It should be understood that, as used herein, the singular form “a” is intended to include the plural form as well, unless the context clearly supports an exception. It should also be understood that, as used herein, “and / or” refers to any and all possible combinations of one or more of the associated listed items.
[0136] The embodiment numbers disclosed in the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0137] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.
[0138] Those skilled in the art should understand that the discussion of any of the above embodiments is merely exemplary and is not intended to imply that the scope of the invention (including the claims) is limited to these examples. Within the framework of the invention, technical features of the above embodiments or different embodiments can be combined, and many other variations of different aspects of the invention exist, which are not provided in the details for the sake of brevity. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the invention should be included within the protection scope of the invention.
Claims
1. A data storage method, characterized in that, Includes the following steps: In response to receiving a write I / O, obtain the current caching strategy; In response to the current caching strategy being the first caching strategy, determine whether there is any undeniable dirty data in the current cache; In response to the presence of unexpired dirty data, the write IO is copied to obtain two write IOs and it is determined whether the write IO hits unexpired dirty data; In response to a hit on the non-expired dirty data, one write IO is written directly to the RAID, and the other write IO updates the hit non-expired dirty data; In response to a successful write IO to the RAID, invalidate the dirty data that was not invalidated. In response to a miss on the non-expired dirty data, one write IO is written directly to the RAID, and the other write IO is discarded; In response to one of the write IOs failing to write to the RAID, a data write failure is reported.
2. The method as described in claim 1, characterized in that, Also includes: In response to a write IO failure to write to the RAID, the cache is notified of the non-invalid dirty data hit.
3. The method as described in claim 1, characterized in that, Also includes: In response to the absence of non-expired dirty data, the write IO is directly written to the RAID.
4. A data storage system, characterized in that, include: The receiving module is configured to retrieve the current caching strategy in response to receiving a write I / O. The judgment module is configured to respond to the current caching strategy as the first caching strategy and determine whether there is any undeniable dirty data in the current cache. The copy module is configured to, in response to the presence of unexpired dirty data, copy the write IO to obtain two write IOs and determine whether the write IO hits unexpired dirty data; The first write module is configured to, in response to a hit of the non-expired dirty data, directly write one write IO to the RAID and update the hit non-expired dirty data with another write IO. The failure module is configured to fail the non-failed dirty data in response to a successful write IO to the RAID. The first write module is also configured as follows: In response to a miss on the non-expired dirty data, one write IO is written directly to the RAID, and the other write IO is discarded; In response to one of the write IOs failing to write to the RAID, a data write failure is reported.
5. The system as described in claim 4, characterized in that, It also includes a notification module, configured as follows: In response to a write IO failure to write to the RAID, the cache is notified of the non-invalid dirty data hit.
6. The system as described in claim 4, characterized in that, It also includes a second write module, configured as follows: In response to the absence of non-expired dirty data, the write IO is directly written to the RAID.
7. A computer device, comprising: At least one processor; as well as A memory storing a computer program executable on the processor, characterized in that the processor executes the program by performing the steps of the method as described in any one of claims 1-3.
8. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it performs the steps of the method as described in any one of claims 1-3.
Citation Information
Patent Citations
Dual buffer solid state drive
US20170177276A1