Flow control method of solid state hard disk, solid state hard disk and storage medium
By obtaining the number of available blocks and data volume of the solid-state drive, determining the corresponding flag variables and permission values, and adjusting the garbage collection and data writing process, the problem that the flow control of the solid-state drive is difficult to cope with different situations is solved, and the random writing performance and System stability.
Patent Information
- Application Number
- CN202410882699.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-03
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2044-07-03
AI Technical Summary
Existing SSD flow control methods are difficult to effectively control the flow in the face of different situations, resulting in fluctuations in SSD random write performance and increased latency, affecting system performance.
By obtaining the number of remaining available blocks of the solid state drive and the amount of valid and invalid data in the target data block, determine the garbage collection flag variable, host flag variable and permission value, and adjust garbage collection and data writing based on the time difference and the receive queue overflow situation. entry process to ensure traffic balance and delay control.
Effectively adjust the solid-state drive garbage collection and data writing process, improve random write performance, stabilize the performance of the solid-state drive, and adapt to different usage scenarios.
Smart Images

Figure CN118409719B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of solid state hard disks, and in particular to a flow control method for a solid state hard disk, a solid state hard disk and a storage medium. Background Art
[0002] When the garbage collection mechanism is enabled, system resources are required, which limits the writing of user data. Therefore, in order to prevent the free blocks from being exhausted and unable to accept data, while ensuring the performance of writing data, a flow control strategy needs to be used to balance the garbage collection mechanism and the host write process. However, the current flow control methods have their own application scenarios and limitations in flow management, and cannot well cope with different situations in SSDs to control flow. At the same time, it is also easy to cause performance fluctuations, affecting the performance and latency of random writes. Summary of the invention
[0003] The purpose of the present invention includes, for example, providing a flow control method for a solid-state hard disk, a solid-state hard disk and a storage medium, which are used to control the delay according to the current state of the solid-state hard disk and improve the random write performance of the solid-state hard disk.
[0004] In a first aspect, the present invention provides a flow control method for a solid state drive, the method comprising:
[0005] After the garbage collection mode of the solid state drive is turned on, the number of remaining available blocks of the flash memory in the solid state drive and the target data blocks that need to be garbage collected are obtained, and the amount of valid data and the amount of invalid data of the target data blocks are determined;
[0006] Determine a garbage collection flag variable, a host flag variable and a permitted amount value according to the remaining available block quantity, the valid data quantity and the invalid data quantity;
[0007] Obtaining a current time value and a corresponding past time value in the solid state drive, determining a time difference between the current time value and the past time value, and determining whether the time difference is greater than a time threshold;
[0008] If the time difference is greater than the time threshold, reading the permitted value;
[0009] Applying for cache space from the solid state drive according to the size of the permission value and the overflow of the receiving queue, and transferring the user data to the cache space to obtain the data to be written;
[0010] Based on the garbage collection flag variable and the host flag variable, garbage collection is performed on the solid state drive, or the data to be written is written into the flash memory of the solid state drive.
[0011] In one embodiment, the determining the garbage collection flag variable, the host flag variable and the permission value according to the valid data amount and the invalid data amount includes:
[0012] Determine the size of the invalid data amount and the valid data amount;
[0013] If the valid data amount is greater than the invalid data amount, determining a first quotient value of the valid data amount and the invalid data amount, using the first quotient value as the garbage collection flag variable, and using the first flag preset value as the host flag variable;
[0014] If the valid data amount is less than the invalid data amount, determining a second quotient of the invalid data amount and the valid data amount, using the second quotient as the host flag variable, and using a second flag preset value as the garbage collection flag variable;
[0015] The product of the second quotient value and the configuration parameter value is used as the allowable value.
[0016] In one embodiment, the performing garbage collection on the solid state drive or writing the to-be-written data into the flash memory of the solid state drive based on the garbage collection flag variable and the host flag variable includes:
[0017] When the garbage collection flag variable is the first quotient value and the host flag variable is the first flag preset value, garbage collection is performed on the solid state drive based on the first quotient value;
[0018] When the garbage collection flag variable is the second flag preset value and the host flag variable is the second quotient value, the to-be-written data is written into the flash memory based on the second quotient value.
[0019] In one embodiment, the first flag preset value is the same as the second flag preset value.
[0020] In one embodiment, after determining whether the time difference is greater than a time threshold, the method further includes:
[0021] If the time difference is less than or equal to the time threshold, the current time value is used as the past time value.
[0022] In one embodiment, applying for cache space from the solid state drive according to the size of the permission value and the overflow of the receiving queue, and transferring user data to the cache space to obtain data to be written, includes:
[0023] Determining whether to apply for the cache space according to the size of the permitted amount value and the overflow condition of the receiving queue;
[0024] If the cache space is applied for, the permission value is reduced by one, and the user data is transferred to the cache space to obtain the data to be written.
[0025] In one embodiment, the determining whether to apply for the cache space according to the size of the permitted amount and the overflow condition of the receiving queue includes:
[0026] Determining whether the permitted value is greater than a permitted threshold;
[0027] If the permitted amount value is greater than the permitted threshold, applying for the cache space;
[0028] If the permitted amount value is less than or equal to the permitted threshold, determining whether the data of the receiving queue overflows;
[0029] If the data in the receiving queue does not overflow, applying for the buffer space;
[0030] If the data of the receiving queue overflows, the current time value is used as the past time value.
[0031] In one embodiment, the effective data amount is the effective data amount after compensation, and the method further includes:
[0032] Calculate the difference between the quantity threshold and the quantity of the remaining available blocks;
[0033] The compensated effective data amount is calculated according to the quantity difference and the effective data amount.
[0034] In one embodiment, the calculation formula for obtaining the compensated effective data amount according to the quantity difference and the effective data amount is: = + ×quantity difference, where is the amount of valid data before compensation, is the effective data quantity after compensation, and quantity difference is the quantity difference.
[0035] In a second aspect, the present invention proposes a solid state drive comprising a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the steps of the solid state drive flow control method as described in the first aspect are implemented.
[0036] In a third aspect, the present invention proposes a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the flow control method for a solid state drive as described in the first aspect.
[0037] The flow control method, solid-state hard disk and storage medium proposed in the present invention, after the garbage collection mode of the solid-state hard disk is turned on, the number of remaining available blocks of the solid-state hard disk flash memory and the target data block that needs to be garbage collected are obtained, and the valid data volume and invalid data volume of the target data block are determined; the garbage collection flag variable, the host flag variable and the permission value are determined according to the remaining number of available blocks, the valid data volume and the invalid data volume; the current time value and the corresponding past time value in the solid-state hard disk are obtained, the time difference between the current time value and the past time value is determined, and it is judged whether the time difference is greater than the time threshold; if the time difference is greater than the time threshold, the permission value is read; according to the size of the permission value and the overflow of the receiving queue, the cache space is applied to the solid-state hard disk, and the user data is transferred to the cache space to obtain the data to be written; based on the garbage collection flag variable and the host flag variable, the solid-state hard disk is garbage collected, or the data to be written is written into the flash memory of the solid-state hard disk. In this way, the garbage collection flag variable, host flag variable and permission value are determined according to the current state of the solid-state hard disk, and then the corresponding cache space is applied for storing the data to be written according to the permission value, so as to control the delay, and finally garbage collection is performed according to the garbage collection flag variable and the host flag variable, or the data to be written is written to the solid-state hard disk flash memory, so as to adjust the balance between the solid-state hard disk's execution of garbage collection and data writing processes, and then control the traffic in response to different situations in the solid-state hard disk, and stabilize the random write performance of the solid-state hard disk. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0039] Figure 1 A schematic diagram of a flow chart of the flow control method of the solid state drive proposed in this embodiment;
[0040] Figure 2 Another schematic diagram of the flow control method of the solid state drive proposed in this embodiment;
[0041] Figure 3 This is another flow chart of the flow control method of the solid state drive proposed in this embodiment;
[0042] Figure 4 A schematic diagram of the structure of the flow control device of the solid state hard disk proposed in this embodiment.
[0043] Icons: 400 - flow control device of solid state hard disk; 401 - first determination module; 402 - second determination module; 403 - acquisition module; 404 - reading module; 405 - moving module; 406 - execution module. DETAILED DESCRIPTION
[0044] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and cannot be understood as limiting the present invention.
[0045] It should be noted that the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the present invention, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.
[0046] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein in the specification of the template are only for the purpose of describing specific embodiments and are not intended to limit the present invention. The term "and / or" used herein includes any and all combinations of one or more related listed items. It should be noted that the features in the embodiments of the present invention may be combined with each other without conflict.
[0047] Example 1
[0048] Please refer to Figure 1 This embodiment provides a flow control method for a solid state drive, which is used to control the delay according to the current state of the solid state drive and improve the random write performance of the solid state drive. The method includes steps S101 to S106, and each step is described in detail below.
[0049] Step S101, after the garbage collection mode of the solid state drive is turned on, the number of remaining available blocks of the flash memory in the solid state drive and the target data blocks that need to be garbage collected are obtained, and the valid data volume and invalid data volume of the target data blocks are determined.
[0050] In this embodiment, when the invalid blocks in the SSD that no longer contain valid data are less than a certain limit, the SSD will trigger the garbage collection mechanism (GC). Through garbage collection, the SSD can reclaim the space of these invalid blocks for new data. When both data writing and garbage collection processes exist in the SSD at the same time, flow control becomes particularly important. This is because both data writing and garbage collection will occupy SSD resources. If they are not regulated, it may cause system performance degradation or resource conflicts.
[0051] Therefore, when the garbage collection mode of the SSD is turned on, in order to balance the garbage collection and writing of the SSD, the SSD also enters the flow control mode. First, the number of remaining available blocks in the current SSD flash memory and the target data blocks that the current garbage collection mechanism needs to process are obtained, and the valid data volume (valid frag count, VFC) and invalid data volume (invalid frag count, IVFC) of the target data blocks are obtained. The valid data volume and invalid data volume provide information about the storage space usage and performance, and also provide a basis and reference for optimizing the storage system and improving performance.
[0052] Step S102, determining a garbage collection flag variable, a host flag variable and a permitted value according to the remaining number of available blocks, the valid data amount and the invalid data amount.
[0053] In this embodiment, the garbage collection flag variable (GC Flag), the host flag variable (Host Flag) and the permission value (perimitValue) are determined according to the number of remaining available blocks, the amount of valid data and the amount of invalid data. Subsequently, cache space can be applied for delay control based on the permission value, and the garbage collection process and data writing process of the solid state drive can be regulated according to the garbage collection flag variable and the host flag variable, so as to adjust the balance between the garbage collection process and the writing process, control and improve performance.
[0054] See also Figure 2 In a specific embodiment, the effective data amount is the effective data amount after compensation, and the method further includes steps S1011~S1012, and each step is described in detail below.
[0055] Step S1011, calculating the difference between the quantity threshold and the quantity of the remaining available blocks.
[0056] In this embodiment, the quantity difference between the quantity threshold (threshold) and the number of remaining available blocks (Block num) is calculated, wherein the quantity threshold is a value determined by simulation and multiple tests, the quantity threshold in this embodiment may be 7, and the quantity threshold may also be other values in other embodiments. The specific calculation formula may be expressed as quantity difference = threshold - Block num.
[0057] Step S1012: Calculate the compensated valid data amount according to the quantity difference and the valid data amount.
[0058] In this embodiment, according to the quantity difference and the effective data amount before compensation ( ) Calculate the effective data volume after compensation ( ). The specific calculation formula can be expressed as = + ×quantity difference. The purpose of compensating the effective data volume here is to increase trend correction and stabilize performance. In this way, the purpose of determining multiple parameters based on the effective data volume after compensation is to increase the GC ratio when the number of remaining available blocks is small, thereby ensuring that the solid-state drive has available data blocks for use.
[0059] It should be noted that after obtaining the garbage collection flag variable, host flag variable and permission value, the amount of valid data, the amount of invalid data and the number of remaining available blocks need to be initialized to 0. Because these three variables are global variables, they must be reinitialized after each operation to prepare for the next operation. The purpose is to ensure that some variables are consistent for each operation.
[0060] In a specific embodiment, determining the garbage collection flag variable, the host flag variable and the permission value based on the valid data amount and the invalid data amount includes: judging the size of the invalid data amount and the valid data amount; if the valid data amount is greater than the invalid data amount, determining a first quotient of the valid data amount and the invalid data amount, using the first quotient as the garbage collection flag variable, and using a first flag preset value as the host flag variable; if the valid data amount is less than the invalid data amount, determining a second quotient of the invalid data amount and the compensated valid data amount, using the second quotient as the host flag variable, and using the second flag preset value as the garbage collection flag variable; and using the product of the second quotient and the configuration parameter value as the permission value.
[0061] In this embodiment, the invalid data volume (IVFC) and the valid data volume after compensation ( )’s size relationship.
[0062] Furthermore, if the effective data volume after compensation ( ) is greater than the amount of invalid data (IVFC), then the amount of valid data after compensation is determined ( ) and the first quotient of the invalid data volume (IVFC), and the first quotient is used as the garbage collection flag variable (GC Flag). The specific calculation formula is GC Flag= / IVFC, and the first flag preset value is used as the host flag variable.
[0063] Furthermore, if the effective data volume after compensation ( ) is less than the amount of invalid data (IVFC), then determine the amount of invalid data (IVFC) and the amount of valid data after compensation ( ) and use the second quotient as the host flag variable (Host Flag). The specific calculation formula is Host Flag=IVFC / , and the second flag preset value is used as a garbage collection flag variable.
[0064] Furthermore, the product of the second quotient and the configuration parameter (percent) is used as the permitted value, that is, the calculation formula for calculating the permitted value is permitValue = percent ×INFC / VFC. From the formula, it can be seen that when the Host write is increased, the value of permitValue will also increase, and when the GC is increased, the value of permitValue will decrease. This is because the Host write will cause the user data to be written to the flash memory (Nand), thereby increasing the amount of invalid data on the block, while the GC will reduce the amount of invalid data.
[0065] In a specific embodiment, the first mark preset value is the same as the second mark preset value.
[0066] In this embodiment, the first mark preset value is the same as the second mark preset value, and can be both 0, or can be other marks, which is not limited in this embodiment.
[0067] Step S103, obtaining the current time value of the solid state drive and its corresponding past time value, determining the time difference between the current time value and the past time value, and judging whether the time difference is greater than a time threshold.
[0068] In this embodiment, when the solid state drive starts the garbage collection mode, it is also necessary to obtain the current time value of the solid state drive and its corresponding past time value. When the current time value is obtained for the first time, its corresponding past time value is 0.
[0069] Further, a time difference between the current time value and the past time value is determined, and it is determined whether the time difference is greater than a time threshold.
[0070] Step S104: if the time difference is greater than the time threshold, read the permitted value.
[0071] In this embodiment, if the time difference is greater than the time threshold, the permitted amount value determined in step S102 is read.
[0072] In a specific embodiment, after determining whether the time difference is greater than a time threshold, the method further includes: if the time difference is less than or equal to the time threshold, taking the current time value as the past time value.
[0073] In this embodiment, if the time difference is less than or equal to the time threshold, the current time difference is used as the past time value, and the past time value here is the past time value corresponding to the next acquisition of the current time value. The time threshold is also obtained based on simulation and multiple tests. In this embodiment, the time threshold can be 10ms, and in other embodiments, it can be other values.
[0074] Step S105 , applying for cache space from the solid state drive according to the size of the permission value and the overflow of the receiving queue, and transferring the user data to the cache space to obtain data to be written.
[0075] In this embodiment, after reading the permission value, the static random access memory (SRAM) in the solid state drive is applied for cache space according to the size of the permission value and the data overflow of the receiving queue; after applying for the cache space, the user data received by the front end of the solid state drive and stored in the receiving queue (receive queue, RCQ) is transferred to the cache space by asynchronously calling the move buffer function (MoveBuffer) to obtain the data to be written. In this way, the user data waiting to be written to the flash memory of the solid state drive in the receiving queue is moved to the cache space for storage, which can effectively control the delay.
[0076] See also Figure 3 In a specific embodiment, the step of applying for cache space from the solid state drive and transferring user data to the cache space to obtain data to be written is performed according to the size of the permission value and the overflow of the receiving queue, including steps S1041~S1042. Each step is described in detail below.
[0077] Step S1041, judging whether to apply for the cache space according to the size of the permission value and the overflow condition of the receiving queue.
[0078] In this embodiment, whether to apply for buffer space is determined according to the data overflow of the receiving queue of the size of the permitted amount, so that the buffer space can be obtained in time according to the permitted amount and the receiving queue to control the delay.
[0079] Step S1042: if the cache space is applied for, the permission value is reduced by one, and the user data is transferred to the cache space to obtain the data to be written.
[0080] In this embodiment, if it is necessary to apply for cache space, the permission value is reduced by one, and the user data is transferred to the cache space to obtain the data to be written; and the current time value is used as the past time value, and the process goes to step S103 to loop to obtain the current time value and its corresponding time value, and determine whether to apply for cache space. In this way, the permission value becomes a variable that controls the frequency of determining whether to apply for cache space, so that cache space can be applied according to the permission value that reflects the current storage situation of the solid-state hard disk, which is used to effectively control the delay, ensure the continuity of input data, and prevent command timeouts.
[0081] It should be noted that when the Host has more write operations and fewer GCs, it can be seen that the SSD is currently in a relatively idle state and has more space available for writing. In this case, by applying for the corresponding cache space according to a larger license value to increase the amount of data written, the performance of the storage device can be fully utilized to make data write faster, thereby reducing latency. At the same time, when the Host has fewer write operations and more GCs, it means that there is a lot of invalid data in the SSD that needs to be recycled, or the space of the SSD is already relatively tight. In this case, if a large amount of data continues to be written, it may cause the SSD to quickly run out of space, thereby affecting its continued usability. Therefore, reducing the amount of data written according to a smaller license value can ensure the stability and durability of the storage device. Although doing so will slow down data writing, in the long run, it can ensure the continued usability of the disk.
[0082] In a specific embodiment, the determining whether to apply for the cache space based on the size of the permission value and the overflow of the receiving queue includes: determining whether the permission value is greater than a permission threshold; if the permission value is greater than the permission threshold, applying for the cache space; if the permission value is less than or equal to the permission threshold, determining whether the data of the receiving queue overflows; if the data of the receiving queue does not overflow, applying for the cache space; if the data of the receiving queue overflows, using the current time value as the past time value.
[0083] In this embodiment, when judging whether to apply for cache space, first judge whether the current permission value is greater than the permission threshold; if the current permission value is greater than the permission threshold, apply for cache space from SRAM; if the current permission value is less than or equal to the permission threshold, continue to judge whether the current receiving queue has data overflow, if the data of the current receiving queue does not overflow, apply for cache space from SRAM; if the current receiving queue has data overflow, the current time value is used as the past time value, and the past time value is the past time value corresponding to the next acquisition of the current time value. This judgment based on the overflow of the receiving queue is to prevent data from being unable to be received. Among them, the target value can be 1, but the value of the target value is not limited here, and the target value can also be other values in other embodiments.
[0084] Step S106: performing garbage collection on the solid state drive based on the garbage collection flag variable and the host flag variable, or writing the data to be written into the flash memory of the solid state drive.
[0085] In this embodiment, garbage collection is performed on the solid state drive according to the value of the garbage collection flag variable and the value of the host flag variable, or the data to be written in the cache space is written into the flash memory of the solid state drive. In this way, the GC and Host write processes are flexibly adjusted according to the value of the garbage collection flag variable and the value of the host flag variable, thereby improving and stabilizing performance.
[0086] In a specific embodiment, performing garbage collection on the solid-state hard disk or writing the to-be-written data into the flash memory of the solid-state hard disk based on the garbage collection flag variable and the host flag variable includes: when the garbage collection flag variable is the first quotient value and the host flag variable is the first flag preset value, performing garbage collection on the solid-state hard disk based on the first quotient value; when the garbage collection flag variable is the second flag preset value and the host flag variable is the second quotient value, writing the to-be-written data into the flash memory based on the second quotient value.
[0087] In this embodiment, when the effective data amount after compensation ( ) is greater than the amount of invalid data (IVFC), the value of the garbage collection flag variable is the first quotient value, and the value of the host flag variable is the first flag preset value. At this time, garbage collection is performed on the solid state drive according to the first quotient value; when the amount of valid data after compensation ( ) is less than the amount of invalid data (IVFC), the value of the garbage collection flag variable is the second flag preset value, and the value of the host flag variable is the second quotient value. At this time, the data to be written in the cache space is written to the flash memory of the solid-state drive according to the second quotient value. Among them, the larger the Host Flag and GC Flag are, the more corresponding Host writes and GCs there are. At the same time, according to the above formula for calculating the Host Flag and the permission value, it can be seen that when the Host Flag is larger, the corresponding permission value is also larger. At this time, the more data to be written in the cache space, the more data to be written in the cache space is written to the flash memory based on the Host Flag. In this way, the GC and Host write process are balanced and adjusted according to the garbage collection flag variable, the host flag variable and the permission value obtained according to the current state of the solid-state drive, which is very good for controlling traffic in different situations in the solid-state drive.
[0088] The flow control method of the solid-state hard disk proposed in this embodiment, after the garbage collection mode of the solid-state hard disk is turned on, the number of remaining available blocks in the flash memory of the solid-state hard disk and the target data blocks that need to be garbage collected are obtained, and the valid data volume and invalid data volume of the target data blocks are determined; the garbage collection flag variable, the host flag variable and the permission value are determined according to the remaining number of available blocks, the valid data volume and the invalid data volume; the current time value and the corresponding past time value in the solid-state hard disk are obtained, the time difference between the current time value and the past time value is determined, and it is judged whether the time difference is greater than the time threshold; if the time difference is greater than the time threshold, the permission value is read; according to the size of the permission value and the overflow of the receiving queue, the cache space is applied to the solid-state hard disk, and the user data is transferred to the cache space to obtain the data to be written; based on the garbage collection flag variable and the host flag variable, garbage collection is performed on the solid-state hard disk, or the data to be written is written into the flash memory of the solid-state hard disk. In this way, the garbage collection flag variable, host flag variable and permission value are determined according to the current state of the solid-state hard disk, and then the corresponding cache space is applied for storing the data to be written according to the permission value, so as to control the delay, and finally garbage collection is performed according to the garbage collection flag variable and the host flag variable, or the data to be written is written to the solid-state hard disk flash memory, so as to adjust the balance between the solid-state hard disk's execution of garbage collection and data writing processes, and then control the traffic in response to different situations in the solid-state hard disk, and stabilize the random write performance of the solid-state hard disk.
[0089] Example 2
[0090] In addition, the present disclosure provides a flow control device 400 for a solid state hard disk, see Figure 4 , the device comprises:
[0091] The first determination module 401 is used to obtain the number of remaining available blocks of the flash memory in the solid state drive and the target data blocks that need to be garbage collected after the garbage collection mode of the solid state drive is turned on, and determine the amount of valid data and the amount of invalid data of the target data blocks;
[0092] A second determination module 402 is used to determine a garbage collection flag variable, a host flag variable and a permitted value according to the remaining available block quantity, the valid data quantity and the invalid data quantity;
[0093] The acquisition module 403 is used to acquire the current time value and the corresponding past time value in the solid state drive, determine the time difference between the current time value and the past time value, and determine whether the time difference is greater than a time threshold;
[0094] A reading module 404, configured to read the permitted value if the time difference is greater than the time threshold;
[0095] A moving module 405 is used to apply for a cache space from the solid state drive according to the size of the permission value and the overflow of the receiving queue, and to transfer the user data to the cache space to obtain the data to be written;
[0096] The execution module 406 is used to perform garbage collection on the solid state drive based on the garbage collection flag variable and the host flag variable, or write the data to be written into the flash memory of the solid state drive.
[0097] Optionally, the second determination module 402 is also used to determine the size of the invalid data amount and the valid data amount; if the valid data amount is greater than the invalid data amount, then determine a first quotient of the valid data amount and the invalid data amount, use the first quotient as the garbage collection flag variable, and use the first flag preset value as the host flag variable; if the valid data amount is less than the invalid data amount, then determine a second quotient of the invalid data amount and the valid data amount, use the second quotient as the host flag variable, and use the second flag preset value as the garbage collection flag variable; and use the product of the second quotient and the configuration parameter value as the permitted quantity value.
[0098] Optionally, the execution module 406 is also used to perform garbage collection on the solid-state hard disk based on the first quotient value when the garbage collection flag variable is the first quotient value and the host flag variable is the first flag preset value; when the garbage collection flag variable is the second flag preset value and the host flag variable is the second quotient value, write the data to be written into the flash memory based on the second quotient value; the first flag preset value is the same as the second flag preset value.
[0099] Optionally, the acquisition module 403 is further configured to use the current time value as the past time value if the time difference is less than or equal to the time threshold.
[0100] Optionally, the moving module 405 is also used to determine whether to apply for the cache space based on the size of the permission value and the overflow of the receiving queue; if the cache space is applied, the permission value is reduced by one, and the user data is transferred to the cache space to obtain the data to be written.
[0101] Optionally, the moving module 405 is also used to determine whether the permitted value is greater than a permitted threshold; if the permitted value is greater than the permitted threshold, apply for the cache space; if the permitted value is less than or equal to the permitted threshold, determine whether the data in the receiving queue overflows; if the data in the receiving queue does not overflow, apply for the cache space; if the data in the receiving queue overflows, use the current time value as the past time value.
[0102] Optionally, the first determining module 401 is further used to calculate the quantity difference between the quantity threshold and the quantity of the remaining available blocks; and obtain the effective data quantity after compensation according to the quantity difference and the effective data quantity; and the calculation formula for obtaining the effective data quantity after compensation according to the quantity difference and the effective data quantity is: = + ×quantity difference, where is the amount of valid data before compensation, is the effective data quantity after compensation, and quantity difference is the quantity difference.
[0103] The device provided in the embodiment of the present disclosure can execute the steps of the solid state hard disk flow control method provided in Example 1, which will not be described again to avoid repetition.
[0104] The flow control device of the solid-state hard disk proposed in this embodiment, after turning on the garbage collection mode of the solid-state hard disk, obtains the number of remaining available blocks in the flash memory of the solid-state hard disk and the target data blocks that need to be garbage collected, and determines the valid data volume and invalid data volume of the target data blocks; determines the garbage collection flag variable, the host flag variable and the permission value according to the remaining number of available blocks, the valid data volume and the invalid data volume; obtains the current time value and the corresponding past time value in the solid-state hard disk, determines the time difference between the current time value and the past time value, and judges whether the time difference is greater than the time threshold; if the time difference is greater than the time threshold, reads the permission value; applies for cache space from the solid-state hard disk according to the size of the permission value and the overflow of the receiving queue, and transfers user data to the cache space to obtain the data to be written; performs garbage collection on the solid-state hard disk based on the garbage collection flag variable and the host flag variable, or writes the data to be written into the flash memory of the solid-state hard disk. In this way, the garbage collection flag variable, host flag variable and permission value are determined according to the current state of the solid-state hard disk, and then the corresponding cache space is applied for storing the data to be written according to the permission value, so as to control the delay, and finally garbage collection is performed according to the garbage collection flag variable and the host flag variable, or the data to be written is written to the solid-state hard disk flash memory, so as to adjust the balance between the solid-state hard disk's execution of garbage collection and data writing processes, and then control the traffic in response to different situations in the solid-state hard disk, and stabilize the random write performance of the solid-state hard disk.
[0105] Example 3
[0106] In addition, an embodiment of the present disclosure provides a solid state drive, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the flow control method of the solid state drive described in Example 1 is implemented.
[0107] The solid state drive provided in the embodiment of the present disclosure can execute the steps of the solid state drive flow control method provided in Example 1, which will not be described again to avoid repetition.
[0108] Example 4
[0109] The embodiment of the present disclosure provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, the flow control method of the solid state drive described in the embodiment 1 is implemented.
[0110] In this embodiment, the computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0111] The computer-readable storage medium provided in this embodiment can implement the flow control method of the solid state hard disk provided in Example 1, and will not be described again here to avoid repetition.
[0112] In all examples shown and described herein, any specific values should be interpreted as merely exemplary and not as limiting, and thus other examples of the exemplary embodiments may have different values.
[0113] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0114] The above-mentioned embodiments only express several implementation methods of the present invention, and the description thereof is relatively specific and detailed, but it cannot be understood as limiting the scope of the present invention. It should be pointed out that for ordinary technicians in this field, several modifications and improvements can be made without departing from the concept of the present invention, which all belong to the protection scope of the present invention.
Claims
1. A flow control method for a solid state hard disk, characterized in that: The method comprises: After the garbage collection mode of the solid state drive is turned on, the number of remaining available blocks of the flash memory in the solid state drive and the target data blocks that need to be garbage collected are obtained, and the amount of valid data and the amount of invalid data of the target data blocks are determined; Determine a garbage collection flag variable, a host flag variable and a permitted amount value according to the remaining available block quantity, the valid data quantity and the invalid data quantity; Obtaining a current time value and a corresponding past time value in the solid state drive, determining a time difference between the current time value and the past time value, and determining whether the time difference is greater than a time threshold; If the time difference is greater than the time threshold, reading the permitted value; Applying for cache space from the solid state drive according to the size of the permission value and the overflow of the receiving queue, and transferring the user data to the cache space to obtain the data to be written; Performing garbage collection on the solid state drive based on the garbage collection flag variable and the host flag variable, or writing the to-be-written data into the flash memory of the solid state drive; The step of determining the garbage collection flag variable, the host flag variable, and the permission value according to the valid data amount and the invalid data amount includes: Determine the size of the invalid data amount and the valid data amount; If the valid data amount is greater than the invalid data amount, determining a first quotient value of the valid data amount and the invalid data amount, using the first quotient value as the garbage collection flag variable, and using the first flag preset value as the host flag variable; If the valid data amount is less than the invalid data amount, determining a second quotient of the invalid data amount and the valid data amount, using the second quotient as the host flag variable, and using a second flag preset value as the garbage collection flag variable; The product of the second quotient value and the configuration parameter value is used as the allowable value.
2. The flow control method of a solid state hard disk according to claim 1, characterized in that: The performing garbage collection on the solid state drive or writing the to-be-written data into the flash memory of the solid state drive based on the garbage collection flag variable and the host flag variable comprises: When the garbage collection flag variable is the first quotient value and the host flag variable is the first flag preset value, garbage collection is performed on the solid state drive based on the first quotient value; When the garbage collection flag variable is the second flag preset value and the host flag variable is the second quotient value, the to-be-written data is written into the flash memory based on the second quotient value.
3. The flow control method of a solid state hard disk according to claim 2, characterized in that: The first mark preset value is the same as the second mark preset value.
4. The flow control method of a solid state hard disk according to claim 1, characterized in that: After determining whether the time difference is greater than the time threshold, the method further includes: If the time difference is less than or equal to the time threshold, the current time value is used as the past time value.
5. The flow control method of a solid state drive according to claim 1, characterized in that: The step of applying for cache space from the solid state drive according to the size of the permission value and the overflow of the receiving queue, and transferring the user data to the cache space to obtain the data to be written, includes: Determining whether to apply for the cache space according to the size of the permitted amount value and the overflow condition of the receiving queue; If the cache space is applied for, the permission value is reduced by one, and the user data is transferred to the cache space to obtain the data to be written.
6. The flow control method of a solid state hard disk according to claim 5, characterized in that: The step of determining whether to apply for the cache space according to the size of the permitted amount and the overflow condition of the receiving queue includes: Determining whether the permitted value is greater than a permitted threshold; If the permitted amount value is greater than the permitted threshold, applying for the cache space; If the permitted amount value is less than or equal to the permitted threshold, determining whether the data of the receiving queue overflows; If the data in the receiving queue does not overflow, applying for the buffer space; If the data of the receiving queue overflows, the current time value is used as the past time value.
7. The flow control method of a solid state hard disk according to any one of claims 1 to 6, characterized in that: The effective data volume is the effective data volume after compensation, and the method further includes: Calculate the difference between the quantity threshold and the quantity of the remaining available blocks; The compensated effective data amount is calculated according to the quantity difference and the effective data amount.
8. The flow control method of a solid state hard disk according to claim 7, characterized in that: The calculation formula for obtaining the compensated effective data amount according to the quantity difference and the effective data amount is: = + ×quantity difference, where is the amount of valid data before compensation, is the effective data quantity after compensation, and quantity difference is the quantity difference.
9. A solid state hard disk, characterized in that: It comprises a memory and a processor, the memory stores a computer program, and when the computer program is executed by the processor, the steps of the flow control method of the solid state hard disk as described in any one of claims 1 to 8 are implemented.
10. A computer-readable storage medium, characterized in that: It stores a computer program, which, when executed by a processor, implements the steps of the flow control method for a solid state hard disk as described in any one of claims 1 to 8.
