Patent Publication Number: US-2020278810-A1

Title: Method for Mitigating Writing-Performance Variation and Preventing IO Blocking in a Solid-State Drive

Description:
BACKGROUND OF INVENTION 
     1. Field of Invention 
     The present invention relates to a solid-state drive and, more particularly, to a method for mitigating writing-performance variation and preventing IO blocking in a solid-state drive. 
     2. Related Prior Art 
     A solid-state drive runs firmware to execute system tasks and/or read/write system data. The system tasks and/or reading/writing inevitably reduce writing performance. Such variation of the writing performance is not desirable. IO blocking is also not desirable. “IO blocking” is a situation where the input/output per second is zero, i.e., the system appears to be non-responsive. The primary reason for a low or zero IOPS is that garbage collection occupies most of the bandwidth of a flash memory of the solid-state drive. A method for preventing a low or zero IOPS is to delay the garbage collection. However, such delayed garbage collection could cause inadequate storing capacity of the solid-state drive. Another method for preventing a low or zero IOPS is to provide the solid-state drive with several cores. One of the cores is used to read/write. The other core is used to execute garbage collection. However, every added core increases the cost of the solid-state drive. 
     The present invention is therefore intended to obviate or at least alleviate the problems encountered in the prior art. 
     SUMMARY OF INVENTION 
     It is the primary objective of the present invention to provide an effective and inexpensive method for mitigating writing-performance variation and preventing IO blocking. 
     To achieve the foregoing objective, the method includes the steps of receiving a request, determining whether status of a SSD is normal or constrained, fulfilling the request if the status is normal, inserting the request in a queue if the status is constrained, monitoring a first request in the queue and calculating expected time of waiting, determining whether elapsed time of the first request is longer than or identical to the expected time of waiting, waiting for some time before returning to the step of monitoring the first request and calculating the expected time of waiting if the elapsed time is shorter than the expected time of waiting, fulfilling and removing the first request from the queue if the elapsed time is longer than or identical to the expected time of waiting, determining whether the queue is empty, returning to the step of waiting for some time if the queue is not empty, and ending if the queue is empty. 
     Other objectives, advantages and features of the present invention will be apparent from the following description referring to the attached drawings. 
    
    
     
       BRIEF DESCRIPTION OF DRAWINGS 
       The present invention will be described via detailed illustration of the preferred embodiment referring to the drawings wherein: 
         FIG. 1  is a block diagram of a data storage apparatus such as solid-state drive that can execute a method for mitigating writing-performance variation and preventing IO blocking according to the preferred embodiment of the present invention; 
         FIG. 2  is a flow chart of the method for mitigating writing-performance variation and preventing IO blocking according to the preferred embodiment of the present invention; 
         FIG. 3  is a flow chart of a subroutine of the method shown in  FIG. 2 ; 
         FIG. 4  is a flow chart of another subroutine of the method shown in  FIG. 2 ; and 
         FIG. 5  is a flow chart of another subroutine of the method shown in  FIG. 2 . 
     
    
    
     DETAILED DESCRIPTION OF PREFERRED EMBODIMENT 
     Referring to  FIG. 1 , a host  10  is connected to a solid-state drive controller  16 . The solid-state drive controller  16  includes two central processor units  11  and  13  and a shared memory  15 . In the industry, the central processor unit  11  is called “Core 1” and connected to the host  10 , the central processor unit  13  is called “Core 0” and connected to the central processor unit  11 . The memory  15  is connected to the central processor units  11  and  13 . 
     In use, the central processor unit  11  runs firmware  12  to receive a request for writing (the “request”) from the host  10 . The central processor unit  13  runs firmware  14  to receive from the central processor unit  11  the request. The central processor unit  13  provides two variables, i.e., “control flow” and “garbage collection efficiency.” These variables are stored in the memory  15 . The control flow is given according to the status of the solid-state drive. The control flow includes two values, i.e., “normal” and “constrained.” “Garbage collection efficiency” is the amount of data recycled per unit of time. The solid-state drive controller  16  executes a method for mitigating writing-performance variation and preventing IO blocking according to the preferred embodiment of the present invention executable. The control flow and the garbage collection efficiency are used in the method for mitigating writing-performance variation and preventing IO blocking according to the preferred embodiment of the present invention. 
     Referring to  FIG. 2 , shown is the method for mitigating writing-performance variation and preventing IO blocking according to the preferred embodiment of the present invention. At S 10 , the solid-state drive controller  16  is turned on. Then, the process goes to S 20 . 
     Referring to  FIG. 3 , S 20  is an initializing process. In the initializing process, at S 22 , central processor unit  13  executes firmware  14 . Then, the process goes to S 24 . 
     At S 24 , the memory  15  is initialized. Then, the process goes to S 26 . 
     At S 26 , the control flow is set to be normal. Then, the process goes to S 28 . 
     At S 28 , the garbage collection efficiency is set to be N. N is a default. Then, the process goes to S 30 . 
     At S 30 , the central processor unit  13  calls the central processor unit  11  to run the firmware  12 . Then, the central processor unit  13  executes S 40 , and the central processor unit  11  executes S 70  ( FIG. 2 ). 
     Referring to  FIG. 2 , at S 40 , the central processor unit  13  monitors the amount of free blocks. Then, the process goes to S 42 . 
     At S 42 , it is determined whether the amount of the free blocks is smaller than or identical to a first threshold. The process goes to S 44  to recycle garbage if the amount of the free blocks is smaller than or identical to the first threshold. The process returns to S 40  if the amount of the free blocks is larger than the first threshold. 
     At S 44 , the control flow is set to be constrained. Now, the amount of the free blocks is smaller than the first threshold so that writing cannot be performed at a normal rate. Therefore, the control flow is set to be “constrained.” Then, the process goes to S 46 . 
     At S 46 , a block is selected for garbage collection, and a timer is started. Then, the process goes to S 48 . Such recycled blocks become free blocks. 
     At S 48 , the amount of the recycled garbage of the selected block is calculated. Then, the process goes to S 50 . 
     At S 50 , the timer is stopped, and the garbage collection efficiency is calculated and stored in the memory  15 . The garbage collection efficiency is calculated by dividing the amount of the recycled garbage by the time recorded by the timer. Then, the process goes to S 52 . 
     At S 52 , it is determined whether the amount of the free blocks is larger than or identical to a second threshold. The process returns to S 46  if the amount of the free blocks is smaller than the second threshold. The process goes to S 54  if the amount of the free blocks is larger than or identical to the second threshold. The second threshold should be properly larger than the first threshold, or the garbage collection would be executed in many rounds and each round of the garbage collection would last for a very short period of time. 
     At S 54 , the control flow is set to be “normal.” Then, the process returns to S 40 . 
     Referring to  FIGS. 4 and 5 , S 70  represents another subroutine. At S 70 , the central processor unit  11  handles the request. 
     At S 72 , the central processor unit  11  receives from the host  10  the request. Then, the process goes to S 74 . 
     At S 74 , it is determined whether the control flow is normal. The process goes to S 76  if so, and goes to S 78  if otherwise. 
     S 76 , the request is handled. In specific, the central processor unit  11  sends the request to the central processor unit  13 . Then, the central processor unit  13  handles the request. 
     At S 78 , the request is inserted in a queue. That is, the request is arranged after previous requests for writing to be handled. Then, the process goes to S 80 . 
     At S 80 , the first request in the queue is monitored, and expected time of waiting is calculated. The so called “expected time of waiting” is a calculated period of time for which the first request is expected to wait before data is written in the data storage apparatus according to the first request. To calculate the expected time of waiting, the central processor unit  11  reads the garbage collection efficiency from the memory  15 , and divides the amount of the data of the first request by the garbage collection efficiency. Then, the process goes to S 82 . 
     At S 82 , it is determined whether elapsed time is longer than or identical to the expected time of waiting. The “elapsed time” is the time for which the first request has been in the queue. The elapsed is measured from the point of time at which the central processor unit  11  begins to monitor the first request. The process goes to S 86  if so, and the process goes to S 84  if otherwise. 
     At S 84 , the system waits for a proper period of time such as several seconds. Then, the process returns to S 80 . 
     At S 86 , the first request is fulfilled and removed from the queue. To fulfill the first request, the central processor unit  11  sends the first request to the central processor unit  13 . Then, then central processor unit  13  stores data in the data storage apparatus according to the first request. Then, the process goes to S 88 . 
     At S 88 , it is determined whether the queue is empty. The process goes to S 90  if so, and returns to S 84  if otherwise. 
     At S 90 , the process ends. 
     The present invention has been described via the illustration of the preferred embodiment. Those skilled in the art can derive variations from the preferred embodiment without departing from the scope of the present invention. Therefore, the preferred embodiment shall not limit the scope of the present invention defined in the claims.