Data storage method and device
By dividing the high-speed buffer into three areas in the UFS device and determining the storage area according to the data response level of the IO request, the performance degradation problem caused by insufficient SLC cache in Turbo Write technology is solved and more efficient data writing performance is achieved. .
Patent Information
- Application Number
- CN202411422853.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-12
- Publication Date
- 2025-01-21
AI Technical Summary
When prior art When utilizing Turbo Write technology, SLC cache may be insufficient to store high bandwidth data, resulting in degradation in storage device performance in high bandwidth scenarios.
By dividing the high-speed buffer into three areas in the UFS device, and determining the storage area according to the data response level of the IO request, a more refined distribution of written data is achieved, thereby better utilizing the high-speed writing performance of the SLC cache.
It effectively improves the writing performance of storage devices in high-bandwidth scenarios, ensures reasonable utilization of SLC cache, and avoids performance degradation.
Smart Images

Figure CN119336265A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of data storage, and more specifically, to a data storage method and device. Background Art
[0002] During the running process, the application needs to frequently read data from the storage device and / or write data to the storage device. Figure 1A and Figure 1B An example of data read and write speed during the operation of a certain game application and an example of data read and write speed during the operation of a certain shopping application are shown.
[0003] Reference Figure 1A and Figure 1B ,The game application wrote a large amount of data of about 15G to the storage device in 25 minutes, and the shopping ,application read and wrote a small amount of data in 10 minutes.
[0004] It can be seen that the read and write behaviors of different applications vary greatly and the read and write speed of each application varies with time and user behavior. The write speed of applications spans a wide range (eg, 2MB / s to 800MB / s).
[0005] In order to improve the write performance of the storage device, Turbo Write (TW) technology can be used. TW technology first writes data to a fast storage device (e.g., Single Level Cell (SLC) flash memory) used as a cache of the storage device, and then migrates all data in the fast storage device to a slow storage device of the storage device when the storage device is dormant.
[0006] Figure 2 A diagram showing an example of reading and writing data based on the TW technology.
[0007] Reference Figure 2 , all data of the Android system and applications are first written to the SLC cache (i.e., SLC area) of the Universal Flash Storage (UFS) device, and then the data in the SLC cache is flushed to the multi-layer cell (e.g., Trinary-Level Cell (TLC) / Quad-Level Cell (QLC)) area when the UFS device is dormant. Most of the data is read from the TLC / QLC area. Since the data has not yet been migrated to the TLC / QLC area when it is read shortly after being written, a small amount of data will be read from the SLC cache.
[0008] Since most applications do not require high bandwidth when writing data, if the data of these applications is written to the SLC cache by adopting TW technology, the SLC cache may not have enough space to store data that requires high bandwidth writing, which will cause performance degradation in high-bandwidth scenarios.
[0009] Therefore, there is an urgent need for a data storage method that can more reasonably utilize the SLC cache to improve the data writing performance of the storage device. Summary of the invention
[0010] The object of the present invention is to provide a data storage method and device to at least solve the above-mentioned problems in the related art, or not to solve any of the above-mentioned problems.
[0011] According to an exemplary embodiment of the present invention, on one hand, a data storage method is provided, the method comprising: in response to receiving an input / output (IO) request, determining a data response level of the IO request, determining a storage area in a UFS device for storing data to be written corresponding to the IO request according to the data response level; and writing the data to be written into the determined storage area, wherein the UFS device comprises a high-speed buffer and a regular storage area, wherein the high-speed buffer comprises a first area, a second area, and a third area, wherein data stored in the first area is flushed into the regular storage area based on a first preset rule, data stored in the second area is flushed into the regular storage area based on a second preset rule, and data stored in the third area is not flushed into the regular storage area, wherein a data read and write speed of the high-speed buffer is greater than a read and write speed of the regular storage area, wherein the first area, the second area, the third area and the regular storage area correspond to different data response levels, respectively.
[0012] According to an embodiment of the present disclosure, data in three areas included in the cache are flushed into or not flushed into the regular storage area according to different rules, which can achieve more refined diversion of data written into the cache, thereby better utilizing the high-speed write performance of the cache.
[0013] Optionally, the step of determining the data response level includes: determining the data response level based on at least one of the type of process corresponding to the IO request, the type of the IO request, and input and output operations per second (IOPS) of the process, wherein the type of the process indicates one of a foreground process, a background process, and a core process, and the type of the IO request indicates one of a read operation request, a write operation request, or a read-write operation request.
[0014] According to an embodiment of the present disclosure, at least one of the type of process corresponding to the IO request, the type of the IO request, and the IOPS of the process can reflect the urgency of the write response required for the data to be written. Therefore, an embodiment of the present disclosure can more accurately determine the data response level of the IO request (or the data to be written).
[0015] Optionally, the step of determining the data response level includes: when a first condition is met, determining the data response level as the first level, wherein the first condition indicates that the process is a foreground process and the IO request is a write operation request; when a second condition is met, determining the data response level as the second level, wherein the second condition indicates that the process is a foreground process, the IO request is a read-write operation request, and the ratio of the IOPS of the process to the maximum IOPS of the conventional storage area is greater than a first threshold; when a third condition is met, determining the data response level as the third level, wherein the third condition indicates that the process is a core process and the ratio of the IOPS of the process to the maximum IOPS of the conventional storage area is greater than a first threshold; and when the first condition, the second condition and the third condition are not met, determining the data response level as the zeroth level, wherein the conventional storage area, the first area, the second area and the third area correspond to the zeroth level, the first level, the second level and the third level, respectively.
[0016] Optionally, the first preset rule indicates that when the UFS device enters sleep mode, the data in the first area is flushed into the regular storage area, and the second preset rule indicates that when the process changes from a foreground process to a background process, the data in the first area is flushed into the regular storage area.
[0017] Optionally, the method may also include: determining whether the remaining available storage space of the second area and / or the third area is less than a second threshold; when the remaining available storage space is less than the second threshold, determining whether the proportion of invalid data in the third area to the data stored in the third area is greater than a third threshold, allocating another area in the cache as a new third area based on the result of determining whether the proportion of invalid data in the third area to the data stored in the third area is greater than the third threshold, migrating valid data in the third area to another area, deleting data in the third area, and migrating at least part of the high-frequency read data in the conventional storage area to the other area.
[0018] Optionally, the step of allocating another area includes: when the proportion of invalid data in the third area to the data stored in the third area is greater than a third threshold, allocating another area in the buffer memory having the same storage capacity as the storage capacity of the third area as a new third area; and / or, when the proportion of invalid data in the third area to the data stored in the third area is not greater than a third threshold, allocating another area in the buffer memory having a storage capacity larger than the storage capacity of the third area as a new third area.
[0019] Optionally, the method may also include: when the remaining available storage space in the second area and / or the third area is less than a second threshold, migrating the data in the second area to the conventional storage area and deleting the data in the second area; and / or determining whether the proportion of invalid data in the second area to the data stored in the second area is greater than a fourth threshold, and when the proportion of invalid data in the second area to the data stored in the second area is not greater than the fourth threshold, expanding the storage capacity of the second area.
[0020] Optionally, the high-speed buffer is a single-layer cell flash memory, and the conventional storage area is a multi-layer cell flash memory.
[0021] According to another aspect of an exemplary embodiment of the present invention, a data storage device is provided, comprising: a first determining unit configured to determine a data response level of an input / output (IO) request in response to receiving an IO request; a second determining unit configured to determine a storage area in a UFS device for storing data to be written corresponding to the IO request according to the data response level; and a writing unit configured to write the data to be written into the determined storage area, wherein the UFS device comprises a cache memory and a regular storage area, wherein the cache memory comprises a first area, a second area, and a third area, wherein data stored in the first area is flushed into the regular storage area based on a first preset rule, data stored in the second area is flushed into the regular storage area based on a second preset rule, and data stored in the third area is not flushed into the regular storage area, wherein a data read and write speed of the cache memory is greater than a read and write speed of the regular storage area, wherein the first area, the second area, the third area and the regular storage area correspond to different data response levels, respectively.
[0022] Optionally, the first determination unit is configured to determine the data response level based on at least one of a type of process corresponding to the IO request, a type of the IO request, and input / output operations per second (IOPS) of the process, wherein the type of the process indicates one of a foreground process, a background process, and a core process, and the type of the IO request indicates one of a read operation request, a write operation request, or a read-write operation request.
[0023] Optionally, the first determination unit is configured to: when a first condition is met, determine the data response level as the first level, wherein the first condition indicates that the process is a foreground process and the IO request is a write operation request; when a second condition is met, determine the data response level as the second level, wherein the second condition indicates that the process is a foreground process, the IO request is a read-write operation request, and the ratio of the IOPS of the process to the maximum IOPS of the conventional storage area is greater than a first threshold; when a third condition is met, determine the data response level as the third level, wherein the third condition indicates that the process is a core process and the ratio of the IOPS of the process to the maximum IOPS of the conventional storage area is greater than a first threshold; and when the first condition, the second condition and the third condition are not met, determine the data response level as the zeroth level, wherein the conventional storage area, the first area, the second area and the third area correspond to the zeroth level, the first level, the second level and the third level, respectively.
[0024] Optionally, the first preset rule indicates that when the UFS device enters sleep mode, the data in the first area is flushed into the regular storage area, and the second preset rule indicates that when the process changes from a foreground process to a background process, the data in the first area is flushed into the regular storage area.
[0025] Optionally, the data storage device also includes: a first invalid data management unit, configured to: determine whether the remaining available storage space in the second area and / or the third area is less than a second threshold; when the remaining available storage space is less than the second threshold, determine whether the proportion of invalid data in the third area to the data stored in the third area is greater than a third threshold; based on the result of determining whether the proportion of invalid data in the third area to the data stored in the third area is greater than the third threshold, allocate another area in the cache as a new third area, migrate valid data in the third area to another area, delete data in the third area, and migrate at least part of the high-frequency read data in the conventional storage area to the other area.
[0026] Optionally, the first invalid data management unit is configured to: when the proportion of invalid data in the third area to the data stored in the third area is greater than a third threshold, allocate another area in the buffer memory having the same storage capacity as the storage capacity of the third area as a new third area; and / or, when the proportion of invalid data in the third area to the data stored in the third area is not greater than a third threshold, allocate another area in the buffer memory having a storage capacity larger than the storage capacity of the third area as a new third area.
[0027] Optionally, the data storage device may also include: a second invalid data management unit, configured to migrate the data in the second area to the regular storage area and delete the data in the second area when the remaining available storage space in the second area and / or the third area is less than a second threshold; and / or determine whether the proportion of invalid data in the second area to the data stored in the second area is greater than a fourth threshold, and when the proportion of invalid data in the second area to the data stored in the second area is not greater than the fourth threshold, expand the storage capacity of the second area.
[0028] Optionally, the high-speed buffer is a single-layer cell flash memory, and the conventional storage area is a multi-layer cell flash memory.
[0029] According to another aspect of an embodiment of the present disclosure, a computer-readable storage medium storing a computer program is provided, wherein when the computer program is executed by a processor, the processor is enabled to implement the data storage method as described herein. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] The above and other objects and features of the present invention will become more apparent from the following description in conjunction with the accompanying drawings which exemplarily illustrate embodiments, in which:
[0031] Figure 1A and Figure 1B An example of data read and write speed during operation of a game application and an example of data read and write speed during operation of a shopping application are shown;
[0032] Figure 2 A diagram showing an example of reading and writing data based on the TW technology;
[0033] Figure 3 A diagram showing an example of writing data based on the TW technology in the related art;
[0034] Figure 4 A schematic diagram showing a data storage method according to an embodiment of the present disclosure is shown;
[0035] Figure 5 A flow chart of a data storage method according to an embodiment of the present disclosure is shown;
[0036] Figure 6 An overall architecture diagram of an example of a data reading method according to an embodiment of the present disclosure is shown;
[0037] Figure 7 A diagram showing an example of a fixed stream manager;
[0038] Figure 8 An example of the correspondence between the type of process and the oom_adj score is shown;
[0039] Fig. 9 An example flow chart of cleaning invalid data according to an embodiment of the present disclosure is shown;
[0040] Fig.10 is a block diagram showing a structure of a data storage device according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0041] Hereinafter, various embodiments of the present disclosure are described with reference to the accompanying drawings, wherein the same reference numerals are used to represent the same or similar elements, features and structures. However, it is not intended that the present disclosure be limited to specific embodiments by the various embodiments described herein, and it is intended that: the present disclosure covers all modifications, equivalents and / or substitutes of the present disclosure, as long as they are within the scope of the attached claims and their equivalents. The terms and words used in the following specification and claims are not limited to their dictionary meanings, but are only used to enable a clear and consistent understanding of the present disclosure. Therefore, it should be apparent to those skilled in the art that the following description of various embodiments of the present disclosure is provided for illustrative purposes only, and not for the purpose of limiting the present disclosure defined by the attached claims and their equivalents.
[0042] It should be understood that the singular includes the plural unless the context clearly indicates otherwise.The terms "include", "comprising" and "having" used herein indicate the presence of disclosed functions, operations or elements, but do not exclude other functions, operations or elements.
[0043] For example, the expression "A or B" or "at least one of A and / or B" may indicate A and B, A or B. For example, the expression "A or B" or "at least one of A and / or B" may indicate (1) A, (2) B, or (3) both A and B.
[0044] In various embodiments of the present disclosure, it is intended that when a component (e.g., a first component) is referred to as being "coupled" or "connected" to another component (e.g., a second component) or being "coupled" or "connected" to another component (e.g., the second component), the component may be directly connected to the other component or may be connected through another component (e.g., a third component). In contrast, when a component (e.g., a first component) is referred to as being "directly coupled" or "directly connected" to another component (e.g., the second component) or being directly coupled to or directly connected to another component (e.g., the second component), there is no other component (e.g., the third component) between the component and the other component.
[0045] The expression "configured to" used in describing various embodiments of the present disclosure may be used interchangeably with expressions such as "suitable for", "having the ability to", "designed to", "suitable for", "manufactured to", and "capable of", for example, depending on the circumstances. The term "configured to" may not necessarily indicate that it is "specially designed to" in terms of hardware. On the contrary, the expression "a device configured to..." in some cases may indicate that the device and another device or part "can..." For example, the expression "a processor configured to perform A, B, and C" may indicate a dedicated processor (e.g., an embedded processor) for performing the corresponding operations or a general-purpose processor (e.g., a central processing unit CPU or an application processor (AP)) for performing the corresponding operations by executing at least one software program stored in a memory device.
[0046] The terms used herein are to describe certain embodiments of the present disclosure, but are not intended to limit the scope of other embodiments. Unless otherwise noted herein, all terms used herein (including technical or scientific terms) may have the same meaning as those generally understood by those skilled in the art. Typically, the terms defined in the dictionary should be considered to have the same meaning as the contextual meaning in the relevant field, and, unless clearly defined herein, should not be understood differently or understood to have an overly formal meaning. In any case, the terms defined in the present disclosure are not intended to be interpreted as excluding embodiments of the present disclosure. Figure 3 A diagram showing an example of writing data based on the TW technique in the related art.
[0047] Reference Figure 3 ,After the application low-speed data is written to the SLC cache, when high-speed data needs to be written, the SLC cache does not have sufficient storage space to store the high-speed data, resulting in a decrease in data writing performance.
[0048] As understood by those skilled in the art, low-speed data indicates data having a low reading and / or writing speed or data requiring low-speed reading and / or writing, and high-speed data indicates data having a high reading and / or writing speed or data requiring high-speed reading and / or writing.
[0049] Figure 4 A schematic diagram of a data storage method according to an embodiment of the present disclosure is shown.
[0050] Reference Figure 4 , the SLC buffer can be divided into a pinning area and a flushing area, and only the data in the flushing area is flushed into the TLC / QLC area when the UFS is in a dormant state. This ensures that the data written to the pinning area can always be read at high speed, and the SLC buffer has sufficient storage space by flushing the data in the flushing area into the TLC / QLC area.
[0051] Figure 5 A flow chart of a data storage method according to an embodiment of the present disclosure is shown.
[0052] Reference Figure 5 In step S501, in response to receiving an IO request, a data response level of the IO request is determined.
[0053] As those skilled in the art understand, a high data response level indicates that the IO request requires a higher data reading and / or writing speed. For example, a high data response level for a certain IO request indicates that the data corresponding to the IO request needs to be read quickly and / or the data corresponding to the IO request needs to be written quickly.
[0054] In step S502, a storage area in the UFS for storing the to-be-written data corresponding to the IO request is determined according to the data response level. Different storage areas of the UFS device correspond to different data response levels, and the corresponding relationship can be determined in advance.
[0055] In step S503, the data to be written is written into a determined storage area, wherein the UFS device includes a high-speed buffer and a regular storage area, wherein the high-speed buffer includes a first area, a second area and a third area, wherein the data stored in the first area is flushed into the regular storage area based on a first preset rule, the data stored in the second area is flushed into the regular storage area based on a second preset rule, and the data stored in the third area is not flushed into the regular storage area, wherein the data reading and writing speed of the high-speed buffer is greater than the reading and writing speed of the regular storage area, wherein the first area, the second area, the third area and the regular storage area respectively correspond to different data response levels.
[0056] As an example, the first preset rule indicates that when the UFS enters the sleep mode, the data in the first area is flushed into the regular storage area, and the second preset rule indicates that when the process changes from a foreground process to a background process, the data in the first area is flushed into the regular storage area.
[0057] Hereinafter, the first area, the second area, and the third area may be referred to as a normal TW area (Normal TW area, NTA), a temporary pinning area (Temporary Pinning Area, TPA), and a permanent pinning area (Durable Pinning Area, DPA), respectively.
[0058] As an example, the normal storage area may be a multi-level cell flash memory area, and the high-speed buffer area may be a SLC flash memory area.
[0059] In this article, the SLC area, SLC flash area, and SLC buffer in this article have the same meaning and can be used interchangeably.
[0060] As an example, a conventional storage region (or a multi-level cell flash memory region) may be a TLC / QLC region.
[0061] Figure 6 An overall architecture diagram of an example of a data reading method according to an embodiment of the present disclosure is shown.
[0062] Reference Figure 6 , a storage area in the UFS device for storing write data corresponding to the IO request can be determined through the fixed stream manager.
[0063] As an example, the fixed stream manager may determine a data response level of an IO request, and determine a storage area in the UFS device for storing the to-be-written data corresponding to the IO request according to the determined data response level.
[0064] As an example, the fixed stream manager may determine a data response level of an IO request based on information related to the IO request.
[0065] As an example, the fixed stream manager may determine the data response level of the IO request based on the priority of the data to be written and / or the writing speed required for the data to be written.
[0066] As an example, the fixed stream manager can divide the data to be written into core system streams, high priority streams, real-time write streams, and non-accelerated streams based on the priority of the data to be written and / or the write speed required for the data to be written or the data response level of the IO request, wherein the core system stream permanently requires a high read / write speed, the high priority stream temporarily requires a high read / write speed, the real-time write stream only requires a high write speed, and the non-accelerated stream requires a regular write speed.
[0067] As an example, a core system stream, a high priority stream, a real-time write stream, and a non-accelerated stream may be written to the third area, the second area, the first area, and the regular storage area, respectively.
[0068] Figure 7 A diagram showing an example of a fixed stream manager.
[0069] Reference Figure 7 The fixed stream manager may include a process identifier, a read / write (R / W) mode identifier, an input / output operations per second (IOPS) identifier, and a stream allocator.
[0070] Those skilled in the art should understand that the fixed stream manager may include other modules and the modules included therein may be split or combined.
[0071] As an example, step S501 may include: determining the data response level based on at least one of the type of process corresponding to the IO request, the type of the IO request, and the IOPS of the process, wherein the type of the process indicates one of a foreground process, a background process, and a core process, and the type of the IO request indicates one of a read operation request, a write operation request, or a read-write operation request.
[0072] As an example, step S501 may include: when a first condition is met, determining the data response level as the first level, wherein the first condition indicates that the process is a foreground process and the IO request is a write operation request; when a second condition is met, determining the data response level as the second level, wherein the second condition indicates that the process is a foreground process, the IO request is a read-write operation request, and the ratio of the IOPS of the process to the maximum IOPS of the conventional storage area is greater than a first threshold; when a third condition is met, determining the data response level as the third level, wherein the third condition indicates that the process is a core process and the ratio of the IOPS of the process to the maximum IOPS of the conventional storage area is greater than a first threshold; and when the first condition, the second condition and the third condition are not met, determining the data response level as the zeroth level, wherein the conventional storage area, the first area, the second area and the third area correspond to the zeroth level, the first level, the second level and the third level, respectively.
[0073] As an example, the process identifier may be used to identify the type of process corresponding to the IO request and mark the data to be written. For example, when it is determined that the process is a system process or a core process, the data to be written may be marked as corresponding to the core process.
[0074] As an example, the type of a process may be determined based on an Out of Memory Adjustment (oom_adj) score of the process.
[0075] Figure 8 An example of the correspondence between the type of process and the oom_adj score is shown.
[0076] Reference Figure 8 , the process type label of the core process λ Label marked as 10000, foreground process λ 01000, the label of the background process λ is 00000.
[0077] As an example, the read / write operation type corresponding to the IO request may be determined by a R / W pattern identifier.
[0078] As an example, write the type label Label μ Can be represented as 00100, Label for read operation μ Labels that can be represented as 00010, write and read operations μ It can be expressed as 00110.
[0079] As an example, it may be determined by the IOPS identifier whether the data to be written corresponds to a high IOPS or a low IOPS.
[0080] As an example, the maximum IOPS of the regular storage area of the UFS device may be measured (which may be represented as v low ) and the IOPS of the process corresponding to the IO request (which can be represented as v ρ ), and when ρ ≥0.8*υ low , it can be determined that the data to be written corresponds to high IOPS, when υ ρ <0.8*υ low When , it can be determined that the data to be written corresponds to a low IOPS, and the high IOPS can be represented as 00001 and the low IOPS can be represented as 00000.
[0081] As an example, the total label of the data to be written can be calculated according to the following equation: sum :
[0082] Label sum =Label λ ∨Label μ ∨Label ρ .
[0083] As an example, the data weight D can be calculated based on the following equation: w The value f(D w ):
[0084]
[0085] The D corresponding to other cases not shown in the above equation is w f(D w ) can be 0, that is, D for all cases except those corresponding to values 1, 2, and 3 w f(D w ) are all 0.
[0086] As an example, the data may be split according to Table 1 below.
[0087] Table 1
[0088] Data weight Data Response Level flow Data storage location 0 Low Non-accelerated flow General storage area 1 middle Real-time write stream Conventional TW area 2 high High priority flow Temporary fixed area 3 urgent Core System Flow Permanent fixed area
[0089] The above describes a specific implementation method for determining the storage location of the data to be written based on the type of process corresponding to the IO request, the type of the IO request, and the IOPS of the process. Those skilled in the art should understand that the above embodiments are only examples and do not limit the present disclosure.
[0090] As an example, the storage location of the data to be written may be determined based only on the type of process, for example, data corresponding to the core process is written to the permanent fixed area, data corresponding to the foreground process is written to the temporary fixed area, and data corresponding to the background process is written to the regular TW area and / or regular storage area.
[0091] As another example, the storage location corresponding to the data to be written may be determined based only on the IOPS of the process. ρ With low The data to be written corresponding to the process whose ratio is greater than the first predetermined threshold is stored in the permanent fixed area, and v ρ With low The data to be written corresponding to the process whose ratio is not greater than the first predetermined threshold and greater than the second predetermined threshold is stored in the temporary fixed area, and v ρ With low The data to be written corresponding to the process whose ratio is not greater than the second predetermined threshold and greater than the third predetermined threshold is stored in the conventional TW area, and v ρ With low The to-be-written data corresponding to the processes whose ratio is not greater than the third predetermined threshold are stored in the regular storage area.
[0092] As data is written, a lot of invalid data will be stored in the data storage area of DPA and TPA, so the invalid data needs to be cleaned up.
[0093] As an example, Figure 5 The method shown may also include: determining whether the remaining available storage space in the second area and / or the third area is less than a second threshold; when the remaining available storage space is less than the second threshold, determining whether the proportion of invalid data in the third area to the data stored in the third area is greater than a third threshold, allocating another area in the cache as a new third area based on the result of determining whether the proportion of invalid data in the third area to the data stored in the third area is greater than the third threshold, migrating valid data in the third area to another area, deleting data in the third area, and migrating at least part of the high-frequency read data in the conventional storage area to the other area.
[0094] As an example, the step of allocating another area includes: when the proportion of invalid data in the third area to the data stored in the third area is greater than a third threshold, allocating another area in the buffer memory having the same storage capacity as the storage capacity of the third area as a new third area; and / or, when the proportion of invalid data in the third area to the data stored in the third area is not greater than a third threshold, allocating another area in the buffer memory having a storage capacity larger than the storage capacity of the third area as a new third area.
[0095] As an example, Figure 5 The method shown may also include: when the remaining available storage space in the second area and / or the third area is less than a second threshold, migrating the data in the second area to the conventional storage area and deleting the data in the second area; and / or determining whether the proportion of invalid data in the second area to the data stored in the second area is greater than a fourth threshold, and when the proportion of invalid data in the second area to the data stored in the second area is not greater than the fourth threshold, expanding the storage capacity of the second area.
[0096] As an example, a Pinning Invalid Data Manager (PIDM) module may be used to clean up invalid data.
[0097] As an example, the PIDM module may include a space monitor, an invalid data monitor, a space size manager, a fixed garbage collection controller, and a migration controller.
[0098] Those skilled in the art should understand that the PIDM module may further include other modules, any module included therein may be split, and at least two modules included therein may be combined.
[0099] As an example, the space monitor may monitor the remaining space situation of the DPA, TPA, and / or NTA.
[0100] As an example, the invalid data monitor may monitor the proportion of invalid data to stored data in the DPA and / or TPA.
[0101] As an example, when the space monitor monitors that the remaining available storage space in the DPA and / or TPA is less than a preset threshold, the invalid data monitor may monitor or calculate the proportion of invalid data in the DPA and / or TPA to the stored data.
[0102] As an example, when the proportion of invalid data in the DPA to the data stored in the DPA is greater than a preset threshold, the space size manager may allocate another area in the SLC buffer as a new DPA area, wherein the storage capacity of the new DPA is the same as the storage capacity of the original DPA; when the proportion of invalid data in the DPA is not greater than the preset threshold, the space size manager may allocate another area in the SLC buffer with a storage capacity greater than the storage capacity of the original DPA as a new DPA.
[0103] As an example, after the space size manager completes its operation, the fixed garbage collection controller can migrate valid data in the original DPA to the new DPA and release the original DPA. In addition, after migrating the valid data in the original DPA to the new DPA, some high-frequency read data in the regular storage area can be migrated to the remaining storage space of the new DPA.
[0104] As an example, when it is determined that the remaining storage capacity of the DPA and / or TPA is less than a threshold, the migration controller may migrate the data in the TPA to the regular storage area.
[0105] As an example, when the proportion of invalid data in the TPA to the data stored in the TPA is lower than a threshold, the TPA may be expanded (for example, the storage capacity of the expanded TPA is increased by 20%).
[0106] Fig. 9 An example flowchart of cleaning invalid data according to an embodiment of the present disclosure is shown.
[0107] Reference Fig. 9 , in step ①, determine whether the remaining storage space of DPA and / or TPA is less than a threshold.
[0108] In step ②, when it is less than a threshold, the ratio of invalid data in DPA and / or TPA to the total stored data is calculated.
[0109] In step ③, adjust the size of DPA and / or TPA according to the ratio calculated in step ②. As described above, when the ratio of invalid data in DPA to data stored in DPA is greater than a threshold, allocate another high-speed buffer with the same storage space size as the original DPA as the new DPA, otherwise allocate another larger high-speed buffer as the new DPA. In step ④, migrate the valid data in the original DPA to the new DPA, and release the original DPA. In addition, at least part of the high-frequency access data in TLC / QLC is migrated to the new DPA.
[0110] In step ⑤, the valid data in TPA is migrated to TLC / QLC. Fig. 9Not shown, but if the proportion of invalid data in TPA is less than a threshold, TPA can be expanded after the valid data in TPA is migrated to TLC / QLC.
[0111] Compared with the method in the related art of cleaning up invalid data by migrating all valid data in a fixed area to TLC / QLC, the method disclosed in the present invention can ensure that some high-frequency access data (for example, data in the TPA area in the present application) is always stored in a high-speed buffer, so that this part of the data can be accessed quickly.
[0112] The above refers to Figures 1 to Fig. 9 The data storage method according to the embodiment of the present disclosure is described. Fig.10 A data storage device according to an embodiment of the present disclosure is described.
[0113] Fig.10 A block diagram showing the structure of a data storage device according to an embodiment of the present disclosure.
[0114] Reference Fig.10 , the data storage device 10 may include a first determining unit 101, a second determining unit 102, and a writing unit 103. Those skilled in the art should understand that the data storage device 10 may further include other components, and at least one of the components included in the data storage device 10 may be combined or split.
[0115] As an example, the first determining unit 101 may be configured to determine a data response level of an IO request in response to receiving the IO request.
[0116] As an example, the second determining unit 102 may be configured to determine, according to the data response level, a storage area in the UFS device for storing the to-be-written data corresponding to the IO request.
[0117] As an example, the write unit 103 may be configured to write the data to be written into a determined storage area, wherein the UFS includes a cache memory and a regular storage area, wherein the cache memory includes a first area, a second area, and a third area, wherein the data stored in the first area is flushed into the regular storage area based on a first preset rule, the data stored in the second area is flushed into the regular storage area based on a second preset rule, and the data stored in the third area is not flushed into the regular storage area, wherein the data reading and writing speed of the cache memory is greater than the reading and writing speed of the regular storage area, wherein the first area, the second area, the third area and the regular storage area respectively correspond to different data response levels.
[0118] As an example, the first determination unit 101 can be configured to: determine the data response level based on at least one of the type of process corresponding to the IO request, the type of the IO request, and the IOPS of the process, wherein the type of the process indicates one of a foreground process, a background process, and a core process, and the type of the IO request indicates one of a read operation request, a write operation request, or a read-write operation request.
[0119] As an example, the first determination unit 101 may be configured to: when a first condition is met, determine the data response level as the first level, wherein the first condition indicates that the process is a foreground process and the IO request is a write operation request; when a second condition is met, determine the data response level as the second level, wherein the second condition indicates that the process is a foreground process, the IO request is a read / write operation request, and the ratio of the IOPS of the process to the maximum IOPS of the conventional storage area is greater than a first threshold; when a third condition is met, determine the data response level as the third level, wherein the third condition indicates that the process is a core process and the ratio of the IOPS of the process to the maximum IOPS of the conventional storage area is greater than a first threshold; and when the first condition, the second condition and the third condition are not met, determine the data response level as the zeroth level, wherein the conventional storage area, the first area, the second area and the third area correspond to the zeroth level, the first level, the second level and the third level, respectively.
[0120] As an example, the first preset rule indicates that when the UFS device enters sleep mode, the data in the first area is flushed into the regular storage area, and the second preset rule indicates that when the process changes from a foreground process to a background process, the data in the first area is flushed into the regular storage area.
[0121] As an example, the data storage device 10 may also include: a first invalid data management unit (not shown), configured to: determine whether the remaining available storage space of the second area and / or the third area is less than a second threshold value, when the remaining available storage space is less than the second threshold value, determine whether the proportion of invalid data in the third area to the data stored in the third area is greater than the third threshold value, based on the result of determining whether the proportion of invalid data in the third area to the data stored in the third area is greater than the third threshold value, allocate another area in the cache as a new third area, migrate valid data in the third area to another area, delete data in the third area, and migrate at least part of the high-frequency read data in the conventional storage area to the other area.
[0122] As an example, the first invalid data management unit may be configured to: when the proportion of invalid data in the third area to the data stored in the third area is greater than a third threshold, allocate another area in the buffer having the same storage capacity as the storage capacity of the third area as a new third area; and / or, when the proportion of invalid data in the third area to the data stored in the third area is not greater than a third threshold, allocate another area in the buffer having a storage capacity larger than the storage capacity of the third area as a new third area.
[0123] As an example, the data storage device 10 may also include: a second invalid data management unit, configured to migrate the data in the second area to the conventional storage area and delete the data in the second area when the remaining available storage space in the second area and / or the third area is less than a second threshold; and / or determine whether the proportion of invalid data in the second area to the data stored in the second area is greater than a fourth threshold, and when the proportion of invalid data in the second area to the data stored in the second area is not greater than the fourth threshold, expand the storage capacity of the second area.
[0124] As an example, the high-speed buffer is a single-layer cell flash memory, and the conventional storage area is a multi-layer cell flash memory.
[0125] According to an embodiment of the present disclosure, a computer-readable storage medium storing instructions may also be provided, wherein when the instructions are executed by at least one processor, the at least one processor performs the data storage method according to the embodiment of the present disclosure. Examples of computer-readable storage media here include: read-only memory (ROM), random access programmable read-only memory (PROM), electrically erasable programmable read-only memory (EEPROM), random access memory (RAM), dynamic random access memory (DRAM), static random access memory (SRAM), flash memory, non-volatile memory, CD-ROM, CD-R, CD+R, CD-RW, CD+RW, DVD-ROM, DVD-R, DVD+R, DVD-RW, DVD+RW, DVD-RAM, BD-ROM, BD-R, BD-R LTH, BD-RE, Blu-ray or optical disk storage, hard disk drive (HDD), solid state drive (SSD), card storage (such as, multimedia card, secure digital (SD) card or extreme digital (XD) card), magnetic tape, floppy disk, magneto-optical data storage device, optical data storage device, hard disk, solid state disk and any other device, any other device is configured to store computer programs and any associated data, data files and data structures in a non-transitory manner and provide the computer programs and any associated data, data files and data structures to a processor or computer so that the processor or computer can execute the computer program. The computer program in the above-mentioned computer-readable storage medium can be run in an environment deployed in a computer device such as a client, a host, an agent device, a server, etc. In addition, in one example, the computer program and any associated data, data files and data structures are distributed on a networked computer system, so that the computer program and any associated data, data files and data structures are stored, accessed and executed in a distributed manner by one or more processors or computers.
[0126] According to an embodiment of the present disclosure, a computer program product may also be provided, and instructions in the computer program product may be executed by a processor of a computer device to complete the data storage method described herein.
[0127] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
Claims
1. A data storage method, the method comprising: In response to receiving an input / output (IO) request, determining a data response level of the IO request; determining, according to the data response level, a storage area in the UFS device for storing the to-be-written data corresponding to the IO request; and Writing the data to be written into a determined storage area, The UFS device includes a high-speed buffer and a conventional storage area, wherein the high-speed buffer includes a first area, a second area and a third area, wherein data stored in the first area is flushed into the conventional storage area based on a first preset rule, data stored in the second area is flushed into the conventional storage area based on a second preset rule, and data stored in the third area is not flushed into the conventional storage area, wherein the data reading and writing speed of the high-speed buffer is greater than the reading and writing speed of the conventional storage area, wherein the first area, the second area and the third area and the conventional storage area respectively correspond to different data response levels.
2. The method of claim 1, wherein: The step of determining the data response level comprises: The data response level is determined based on at least one of a type of a process corresponding to the IO request, a type of the IO request, and input / output operations per second (IOPS) of the process, wherein the type of the process indicates one of a foreground process, a background process, and a core process, and the type of the IO request indicates one of a read operation request, a write operation request, or a read-write operation request.
3. The method of claim 2, wherein: The step of determining the data response level comprises: When a first condition is met, determining the data response level as a first level, wherein the first condition indicates that the process is a foreground process and the IO request is a write operation request; When a second condition is met, determining the data response level as a second level, wherein the second condition indicates that the process is a foreground process, the IO request is a read / write operation request, and a ratio of the IOPS of the process to the maximum IOPS of the regular storage area is greater than a first threshold; When a third condition is met, determining the data response level as a third level, wherein the third condition indicates that the process is a core process, and a ratio of the IOPS of the process to the maximum IOPS of the regular storage area is greater than a first threshold; and When the first condition, the second condition and the third condition are not met, the data response level is determined to be the zeroth level, The conventional storage area, the first area, the second area and the third area correspond to the zeroth level, the first level, the second level and the third level respectively.
4. The method of claim 3, wherein: The first preset rule indicates that when the UFS device enters the sleep mode, the data in the first area is flushed into the regular storage area. The second preset rule indicates that when the process changes from a foreground process to a background process, the data in the first area is flushed into the regular storage area.
5. The method of claim 1, further comprising: determining whether the remaining available storage space of the second area and / or the third area is less than a second threshold; When the remaining available storage space is less than a second threshold, determining whether a proportion of invalid data in the third area to data stored in the third area is greater than a third threshold; allocating another area in the cache as a new third area based on a result of determining whether a ratio of invalid data in the third area to data stored in the third area is greater than a third threshold; Migrate valid data in the third region to another region; Delete the data in the third area; as well as At least part of the high-frequency read data in the regular storage area is migrated to the another area.
6. The method of claim 5, wherein: The step of allocating another area comprises: When the proportion of invalid data in the third area to data stored in the third area is greater than a third threshold, allocating another area in the high-speed buffer with the same storage capacity as the third area as a new third area; And / or, when the proportion of invalid data in the third area to data stored in the third area is not greater than a third threshold, another area in the cache having a storage capacity larger than that of the third area is allocated as a new third area.
7. The method of claim 5, further comprising: When the remaining available storage space in the second area and / or the third area is less than a second threshold, migrating the data in the second area to the conventional storage area, and deleting the data in the second area; And / or, determining whether the proportion of invalid data in the second region to data stored in the second region is greater than a fourth threshold; when the proportion of invalid data in the second region to data stored in the second region is not greater than the fourth threshold, expanding the storage capacity of the second region.
8. The method of claim 1, wherein: The high-speed buffer is a single-layer cell flash memory, and the conventional storage area is a multi-layer cell flash memory.
9. A data storage device, comprising: A first determining unit, configured to determine a data response level of an input / output IO request in response to receiving the IO request; a second determining unit configured to determine, according to the data response level, a storage area in the UFS device for storing the to-be-written data corresponding to the IO request; as well as a writing unit, configured to write the data to be written into a determined storage area, The UFS device includes a high-speed buffer and a conventional storage area, wherein the high-speed buffer includes a first area, a second area and a third area, wherein data stored in the first area is flushed into the conventional storage area based on a first preset rule, data stored in the second area is flushed into the conventional storage area based on a second preset rule, and data stored in the third area is not flushed into the conventional storage area, wherein the data reading and writing speed of the high-speed buffer is greater than the reading and writing speed of the conventional storage area, wherein the first area, the second area and the third area and the conventional storage area respectively correspond to different data response levels.
10. A computer-readable storage medium storing a computer program, wherein: When the computer program is executed by a processor, the processor is caused to implement the data storage method according to any one of claims 1 to 8.