A storage device and its control method

By using the main controller and timing module in the flash chip memory to transmit instruction data in multiple batches, and interrupting background operations within the maximum idle time, the problem of transmission failure caused by long-term no feedback in the flash chip memory is solved, and the storage device is improved data transmission efficiency and reliability.

CN118426710BActive Publication Date: 2024-09-27合肥康芯威存储技术有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410895385.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-05
Publication Date
2024-09-27
Estimated Expiration
2044-07-05

AI Technical Summary

Technical Problem

In flash chip memory, failure to receive feedback from the host for a long time may cause background operation transmission to fail, affecting storage performance and data reliability.

Method used

A storage device is designed, including a flash memory chip, a main controller and a timing module. It transmits instruction data in multiple batches, interrupts background operations within the maximum idle time, and continues to write the next instruction data to ensure data transmission efficiency and Process independence.

Benefits of technology

It improves the data transmission efficiency of storage devices, avoids the problem of long-term host non-reply caused by background operations, and ensures that data is less prone to errors and has high transmission efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118426710B
    Figure CN118426710B
Patent Text Reader

Abstract

The present invention provides a storage device and a control method thereof, wherein the storage device comprises: a flash memory chip; a main controller, which is electrically connected to the flash memory chip and a host computer, and when the main controller executes the command of the host computer, the command data of the host computer is transmitted in multiple transactions, wherein the main controller stores the maximum idle time of the host computer; a timing module, which is electrically connected to the main controller, wherein the timing module stores the transmission time of the command data and the execution time of the background operation; and a memory, which is electrically connected to the main controller and the timing module, wherein the memory stores the control firmware, and within the maximum idle time, the main controller is allowed to call the control firmware, and when the execution time of the background operation reaches the maximum allowed time, the background operation is interrupted, and the next command data is continued to be written. The present invention provides a storage device and a control method thereof, which can improve the storage efficiency of the storage device.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of storage technology, and in particular to a storage device and a control method thereof. Background Art

[0002] For a storage device that uses flash memory chips as storage media, the storage device must also perform background operations while responding to host commands. For example, it must perform garbage collection (GC), update the address mapping table, and flush the address mapping table. To ensure the reliability of data storage, the working time of background operations is limited by limiting the amount of data transmitted by background operations. If the host does not receive feedback for a long time, the task transmission may fail, and this may also leave the user with the impression of poor storage performance. Summary of the invention

[0003] The object of the present invention is to provide a storage device and a control method thereof, which can improve the storage efficiency of the storage device.

[0004] In order to solve the above technical problems, the present invention is achieved through the following technical solutions:

[0005] The present invention provides a storage device, comprising:

[0006] Flash memory chips;

[0007] A main controller is electrically connected to the flash memory chip and the host computer, and when the main controller executes the command of the host computer, the command data of the host computer is transmitted in multiple transactions, wherein the main controller stores the maximum idle time of the host computer;

[0008] a timing module, electrically connected to the main controller, wherein the timing module stores the transmission duration of the instruction data and the execution duration of the background operation; and

[0009] A memory is electrically connected to the main controller and the timing module, and the control firmware is stored in the memory. Within the maximum idle time, the main controller is allowed to call the control firmware. When the execution time of the background operation reaches the maximum allowed time, the background operation is interrupted and the next instruction data is continued to be written.

[0010] In one embodiment of the present invention, the timing module includes an instruction timing unit, the timing starting point of the instruction timing unit is zero, and when the host computer starts to write the instruction data, the timing of the instruction timing unit is started, and when the host computer finishes writing the instruction data, the timing of the instruction timing unit is turned off, wherein the instruction timing unit stores the transmission duration of the instruction data.

[0011] In one embodiment of the present invention, the timing module includes multiple process timing units, the timing starting point of the process timing unit is the maximum allowed time, and when the instruction data is fully written, the timing of the process timing unit is started, and when the timing of the process timing unit is cleared, the timing of the process timing unit is turned off, wherein the maximum allowed time is the difference between the maximum idle time and the instruction data writing time.

[0012] In one embodiment of the present invention, the control firmware includes a task query module, which stores multiple task query instructions. When writing the instruction data, the task query module cyclically executes the task query instructions. When the instruction data is written, the task query module generates a timing start signal, and the timing start signal is sent to the timing module.

[0013] In one embodiment of the present invention, the control firmware further includes:

[0014] A timing start module, electrically connected to the timing module, when the timing of the process timing unit is reset, the timing start module generates a continue writing signal, an operation interruption signal and a timing reset signal, wherein the continue writing signal is output to the host computer, and the host computer and the main controller continue to transmit the next instruction data;

[0015] an operation interruption module, electrically connected to the timing start module, the operation interruption module receiving the operation interruption signal and interrupting the ongoing background operation; and

[0016] The timing reset module is electrically connected to the timing start module, and the timing reset module receives the timing reset signal and resets multiple timing units in the timing module to zero.

[0017] In one embodiment of the present invention, the main controller includes:

[0018] A first buffer area is electrically connected to the host computer and receives the instruction data, wherein when the first buffer area is full, the task query module generates a first timing start signal, and the instruction timing unit starts timing;

[0019] a second buffer area, electrically connected to the first buffer area, the second buffer area receives the instruction data and stores processing information of the instruction data, when the instruction data is all transferred to the second buffer area, the task query module generates a second timing start signal, and the process timing unit starts timing; and

[0020] The third cache area is electrically connected between the second cache area and the flash memory chip. The storage capacity of the third cache area is greater than the storage capacity of the first cache area, and the third cache area is allowed to store multiple instruction data.

[0021] In one embodiment of the present invention, the control firmware includes a marking module, which stores an interrupt variable. The value of the interrupt variable is an initial value or a marking value. When the background operation is interrupted, the marking module sets the value of the interrupt variable to the marking value.

[0022] The present invention provides a method for controlling a storage device, comprising the following steps:

[0023] The main controller receives and executes the instructions from the host computer;

[0024] When the main controller executes the instruction of the host computer, the instruction data of the host computer is transmitted in multiple transactions, wherein the main controller stores the maximum idle time of the host computer;

[0025] After the instruction data is written into the main controller, performing background operations during the remaining time of the maximum idle time;

[0026] Acquiring the transmission duration of the instruction data and the execution duration of the background operation through a timing module; and

[0027] Within the maximum idle time, when the execution time of the background operation reaches the maximum allowed time, the background operation is interrupted and the next instruction data is continued to be written, wherein the maximum allowed time is the difference between the maximum idle time and the instruction data writing time.

[0028] In one embodiment of the present invention, the step of obtaining the transmission duration of the instruction data and the execution duration of the background operation includes:

[0029] When all the instruction data are written into the first buffer area, the instruction timing unit starts timing and transfers the instruction data to the second buffer area;

[0030] When all the instruction data are transferred to the second buffer area, the instruction timing unit stops timing and records the timing data as a first time, wherein the first time is the transmission duration of the instruction data;

[0031] Obtaining a maximum allowed time according to a difference between the first time and the maximum idle time;

[0032] The process timing unit starts timing from the maximum allowed time and starts executing the background operation at the same time until the timing of the process timing unit is reset to zero, and the process timing unit stops timing and interrupts the background operation.

[0033] In one embodiment of the present invention, when the background operation is interrupted, the value of the interrupt variable is set to a mark value, and in the next processing step of the instruction data, the step of executing the background operation includes:

[0034] querying the interrupt variable, and when the value of the interrupt variable is the mark value, obtaining the interrupt position of the last background operation process, and continuing to execute the last background operation process at the interrupt position; and

[0035] When the value of the interrupt variable is the initial value, a new background operation process is executed.

[0036] As described above, the present invention provides a storage device and a control method thereof, which can take into account the background operation of the storage device while executing the host command, thereby improving the data transmission efficiency. In addition, in the present invention, the restriction on the background operation is not implemented by conditional judgment, and the problem of the host not receiving a reply for a long time and judging the data transmission failure due to the background operation will not occur. In addition, in the present invention, the data writing and data processing processes do not affect each other, the data is not prone to errors and the transmission efficiency is high.

[0037] Of course, any product implementing the present invention does not necessarily need to achieve all of the advantages described above at the same time. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0039] Figure 1 FIG. 4 is a schematic diagram of the structure of a storage device in an embodiment of the present invention.

[0040] Figure 2 Schematic diagram of the structure of the control firmware and the timing module in one embodiment of the present invention.

[0041] Figure 3 It is a structural diagram of a background operation execution module in one embodiment of the present invention.

[0042] Figure 4 Schematic diagram of the structure of the main controller in one embodiment of the present invention.

[0043] Figure 5 FIG. 1 is a schematic diagram of transmission of command data in an embodiment of the present invention.

[0044] Figure 6 The figure is a flow chart of a method for controlling a storage device in one embodiment of the present invention.

[0045] Figure 7 FIG. 1 is a flow chart of step S300 in an embodiment of the present invention.

[0046] In the figure: 10, storage device; 20, main controller; 201, microprocessor; 202, host interface controller; 203, cache controller; 204, buffer; 205, flash memory controller; 206, error correction module; 210, first cache area; 220, second cache area; 230, third cache area; 30, flash memory chip; 40, memory; 50, control firmware; 501, background operation execution module; 5011, first execution unit; 5012, second execution unit; 502, task query module; 503, timing start module; 504, operation interrupt module; 505, marking module; 506, timing reset module; 60, host; 70, timing module; 701, instruction timing unit; 702, first timing unit; 703, second timing unit; 70N, Nth timing unit. DETAILED DESCRIPTION

[0047] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0048] The host computer sends control instructions to the storage device, such as write instructions, read instructions, and edit instructions. When data is transmitted between the host computer and the storage device, the data will be divided into multiple records and written or read from the storage device separately. Figure 1As shown, in one embodiment of the present invention, the main controller 20 includes a microprocessor 201, a host interface controller 202, a cache controller 203, a buffer 204, a flash chip controller 205, and an error correction module 206. The microprocessor 201 is a Reduced Instruction System Computer (RISC), and is specifically an ARM processor. The microprocessor 201 is electrically connected to the host interface controller 202, the cache controller 203, and the flash chip controller 205. The host interface controller 202 is electrically connected to the host 60 through an interface to receive instructions and data from the host 60 and to feed back data from the main controller 20. The connection interface between the host 60 and the main controller 20 can be a SATA hard disk, a high-speed serial computer expansion bus interface (Peripheral Component Interconnect express, PCIe), or a SAS interface. The cache controller 203 is electrically connected to the memory 40 and the buffer 204 to control the transfer and storage of data. In this embodiment, the flash memory chip controller 205 is electrically connected to the error correction module 206 to perform error correction on the data read out of the flash memory chip 30 during the reading process of the flash memory chip 30. The error correction module 206 can complete the error checking and correction of the flash memory chip 30 through the Low Density Parity-Check Code (LDPC).

[0049] See also Figure 1 and Figure 2 As shown, in one embodiment of the present invention, the storage device 10 further includes a timing module 70. The timing module 70 is electrically connected to the microprocessor 201. The timing module 70 is used to time the operation execution process inside the storage device 10. In this embodiment, the timing module 70 includes, for example, a plurality of timing units. Specifically, the timing module 70 includes an instruction timing unit 701 and N process timing units, where N is a positive integer greater than or equal to 3. In this embodiment, the instruction timing unit 701 is used to time the time for the main controller 20 to process the storage data. In this embodiment, the process timing unit is used to time the background operation process of the storage device 10. As shown in FIG. Figure 2 The first timing unit 702, the second timing unit 703, to the Nth timing unit 70N are shown. The multiple process timing units are respectively used to time different background operation processes.

[0050] See also Figures 1 to 3As shown, in one embodiment of the present invention, the control firmware 50 is stored in the memory 40. The microprocessor 201 calls the control firmware 50 to implement various operations on the flash memory chip 30. The control firmware 50 includes a background operation execution module 501, a task query module 502, a timing start module 503, an operation interruption module 504, a marking module 505 and a timing reset module 506. The background operation execution module 501 includes at least two execution units. For example, in this embodiment, the background operation execution module 501 includes a first execution unit 5011 and a second execution unit 5012. The first execution unit 5011 is used, for example, to execute the garbage collection process of the storage device 10. The second execution unit 5012 is used, for example, to execute the table update process of the storage device 10. In other embodiments of the present invention, the execution units of the background operation execution module 501 can be, for example, 3, 4, etc., and are used to implement the scanning process and other background processes of the storage device 10.

[0051] It should be noted that the garbage collection process is used to transfer the valid data of some storage blocks to new storage blocks, and clear the invalid data of the original storage blocks, thereby freeing up new available blank storage blocks. According to the address mapping table of the stored data, if the logical data of the stored data corresponds to the actual physical address, the current stored data is valid data, otherwise it is invalid data. When editing the stored data, the address mapping table of the corresponding stored data is updated in time to avoid abnormal problems causing loss or error of stored data. The table update process is used to update the address mapping table of the stored data and transfer the address mapping table from the cache to the flash memory.

[0052] See also Figures 1 to 4As shown, in one embodiment of the present invention, the task query module 502 is used to query the task execution progress in the storage device 10. In this embodiment, the main controller 20 includes a first cache area 210, a second cache area 220 and a third cache area 230. After the host 60 sends data, the main controller 20 receives the data and temporarily stores the data in the first cache area 210. Specifically, when the data fills the first cache area 210, the main controller 20 stops receiving data. The second cache area 220 is electrically connected to the first cache area 210. When the main controller 20 processes the write data of the host 60, the data is transferred from the first cache area 210 to the second cache area 220. The third cache area 230 is electrically connected to the second cache area 220. After the main controller 20 processes the write data, the data is transferred from the second cache area 220 to the third cache area 230, and then the data is transferred from the third cache area 230 to the flash memory chip 30 for stable storage. It should be noted that the storage capacities of the first cache area 210, the second cache area 220, and the third cache area 230 may be different, and the storage capacity of the first cache area 210 may be smaller than the storage capacity of the third cache area 230, so as to quickly receive data transmitted by the host 60 and reduce the hardware area occupied. In this embodiment, the third cache area 230 can accommodate multiple data, and when the data fills the third cache area 230 or the data storage capacity reaches the flush threshold of the third cache area 230, the data is transferred to the flash memory chip 30.

[0053] See also Figures 1 to 4 As shown, in one embodiment of the present invention, the task query module 502 is used to query the processing progress of the written data. Specifically, the task query module 502 can store a variety of query statements for cyclically querying the current task progress position of the main controller 20. For example, if the instruction data has been written, the task query module 502 queries whether the first buffer area 210 is full. If the instruction data starts to be processed, the task query module 502 queries whether the data in the first buffer area 210 has been transferred to the second buffer area 220. And the task query module 502 can obtain the corresponding task execution progress based on the task processing result. It should be noted that querying the task execution progress refers to querying whether the current task is completed. After the task query module 502 queries the task execution progress, if the result that the task has been completed is obtained, a start signal is output to the timing start module 503. If the result that the task has been completed is not obtained, continue to query.

[0054] See also Figures 1 to 4As shown, in one embodiment of the present invention, the task query module 502 queries whether the current instruction data has been transmitted to the first buffer area 210. When the first buffer area 210 is filled with data, it is considered that the host 60 has completed the transmission of the current storage data. If the task query module 502 finds that the first buffer area 210 is filled with data, it generates a first timing start signal and sends the first timing start signal to the instruction timing unit 701. Then the task query module 502 queries whether the data processing process in the second buffer area 220 is completed. If the data processing process is completed, the task query module 502 generates a second timing start signal and sends the second timing start signal to the instruction timing unit 701 and the timing start module 503. The data processing process can be a process for generating an address mapping table for storage data, or a process for updating an address mapping table for storage data. The updated or generated address mapping table is stored in the second buffer area 220. In other embodiments of the present invention, the data processing process refers to the transfer of storage data. That is, if the pen storage data is completely transferred from the first buffer area 210 to the second buffer area 220, the current data processing process ends, and the task query module 502 generates a second timing start signal. It should be noted that the processing process of the pen storage data by the microprocessor 201 and the query process of the task query module 502 are independent working processes.

[0055] See also Figures 1 to 5 As shown, in one embodiment of the present invention, as Figure 5 As shown, the host 60 writes the instruction data data into the first buffer area 210, and the time point when the instruction data data is completely written into the first buffer area 210 is the time node A. Among them, at time node A, the task query module 502 generates a stop write signal Clock1 and a first timing start signal Clock2. The stop write signal Clock1 is fed back to the host 60, and after the host 60 receives the stop write signal Clock1, it stops writing data to the first buffer area 210. Among them, the first timing start signal Clock2 is sent to the instruction timing unit 701. When the instruction timing unit 701 receives the first timing start signal, the instruction timing unit 701 starts timing. Specifically, the instruction timing unit 701 starts timing from zero.

[0056] See also Figures 1 to 5 As shown, in one embodiment of the present invention, as Figure 5As shown, the second buffer area 220 includes a transmission segment 221 and a processing segment 222. The transmission segment 221 is used to receive the current instruction data data. The processing segment 222 is used to store the processing data of the current instruction data data, such as the address mapping table of the current instruction data data, and the address mapping table read from the flash memory chip 30. At time node A, the current instruction data data in the first buffer area 210 continues to be transmitted to the transmission segment 221. It should be noted that, since the time of hardware opening and closing and signal generation is extremely short, in this embodiment, the generation and issuance of the stop write signal Clock1 and the first timing start signal Clock2, and the process of the current instruction data data being transmitted to the transmission segment 221 are regarded as being started simultaneously without time difference. In this embodiment, the time point when the current instruction data data is completely transmitted to the second buffer area 220 is set as time node B. At time node B, the task query module 502 generates a second timing start signal Clock3, and sends the second timing start signal Clock3 to the instruction timing unit 701 and the process timing unit. When the instruction timing unit 701 receives the second timing start signal Clock3, the instruction timing unit 701 stops timing. When the instruction timing unit 701 stops timing, the instruction timing unit 701 stores the processing time of the stored data, that is, the first time T0. The instruction timing unit 701 sends the first time T0 to the process timing unit. It should be noted that there are multiple process timing units. In the present invention, according to the background operation that needs to be processed at this time, the process timing unit corresponding to the background operation is started. The background operation to be performed at this time is jointly determined by the marking module 505 and the background operation execution module 501.

[0057] See also Figures 1 to 5As shown, in one embodiment of the present invention, the maximum idle time length T of the host 60 is stored in the process timing unit. After the host 60 receives the stop writing signal Clock1, it will enter the idle state. When the host 60 receives the continue writing signal of the storage device 10, the host 60 continues to write the next data to the first buffer area 210. The maximum idle time length T refers to the longest time that the host 60 can maintain in the idle state. This time can be set by the designer, or obtained through testing, or it can be a time parameter provided by the host 60. In this embodiment, after the process timing unit receives the second timing start signal, the process timing unit obtains the timing length of the process timing unit, that is, the second time T1, according to the maximum idle time length T and the first time T0. In this embodiment, T1=T-T0. In this embodiment, the second time T1 is the allowed execution time length of the background operation. It should be noted that no matter whether the background operation executed at this time is the first execution unit 5011 or the second execution unit 5012, the timing length of the process timing unit is the second time T1. Specifically, the process timing unit starts timing from the second time T1 until it is reset.

[0058] See also Figures 1 to 5 As shown, in one embodiment of the present invention, the time point at which the timing time of the process timing unit is reset to zero is set as time node C. At time node C, the timing start module 503 simultaneously generates a continue write signal Clock4 and a task interrupt signal Clock5. The continue write signal Clock4 is fed back to the host 60. When the host 60 receives the continue write signal Clock4, it continues to write new current instruction data data to the first buffer area 210. The task interrupt signal Clock5 is transmitted to the operation interrupt module 504 and the marking module 505. When the operation interrupt module 504 receives the task interrupt signal Clock5, it stops the currently ongoing background operation process. When the marking module 505 receives the task interrupt signal Clock5, it sets an interrupt mark at the interrupt position of the background operation process. For example, in the garbage collection process, the interrupt mark is set, and the location of the storage page currently being recycled is recorded. The interrupt mark is a global variable. It should be noted that this judgment process occurs during the writing process of each current instruction data data. And for the writing process of each current instruction data data, even if the data volume of the current instruction data data is the same, the writing time may be different. Therefore, the second time T1 is a value that changes with each transaction.

[0059] See also Figures 1 to 5As shown, in one embodiment of the present invention, within the second time T1, if all background operations are in the completed state, the background operation execution module 501 feeds back the operation completion signal Clock6 to the timing start module 503. When the timing module 70 receives the operation completion signal Clock6, the timing start module 503 generates a continue writing signal Clock4 separately, and feeds back the continue writing signal Clock4 to the host 60.

[0060] See also Figures 1 to 5 As shown, in one embodiment of the present invention, the timing start module 503 generates a timing reset signal Clock7 before generating the continue writing signal Clock4, and feeds back the timing reset signal Clock7 to the timing reset module 506. In this embodiment, when the timing reset module 506 receives the timing reset signal Clock7, all timing information in the timing module 70 is cleared to restore each timing unit to an initial state. Among them, in the initial state, the initial position of the instruction timing unit 701 is 0. The initial position of the process timing unit is not defined. In the present invention, the maximum timing time of the process timing unit is calculated based on the timing data of the instruction timing unit 701.

[0061] See also Figures 1 to 6 As shown, the present invention provides a storage device control method, including steps S100 to S400.

[0062] Step S100, the main controller receives and executes the instruction of the host computer. When the main controller executes the instruction of the host computer, the instruction data of the host computer is transmitted in multiple transactions, wherein the main controller stores the maximum idle time of the host computer.

[0063] Step S200: After the instruction data is written into the main controller, background operations are performed within the remaining time of the maximum idle time.

[0064] Step S300: Obtain the transmission duration of the instruction data and the execution duration of the background operation through a timing module.

[0065] Step S400: within the maximum idle time, when the execution time of the background operation reaches the maximum allowed time, the background operation is interrupted and the next instruction data is continued to be written, wherein the maximum allowed time is the difference between the maximum idle time and the instruction data writing time.

[0066] See also Figures 1 to 7As shown, in one embodiment of the present invention, in step S100, the host computer is the host 60 in this embodiment. After receiving the instruction of the host 60, the main controller 20 responds and executes the instruction of the host 60. Whether writing data to the flash memory chip 30 or reading data, data transmission is achieved through the cache area and the interface. In this embodiment, the main controller 20 receives and transmits the instruction data of the host 60 in multiple transactions. In step S200 and step S300, the remaining time of the maximum idle time is the maximum allowed time for performing background operations. Within the maximum idle time, the transmission time of the instruction data inside the main controller is removed, which is the remaining time of the maximum idle time. Specifically, step S300 includes steps S310 to S340.

[0067] Step S310: When all the instruction data are written into the first buffer area, the instruction timing unit starts timing and transfers the instruction data to the second buffer area.

[0068] Step S320: When all the instruction data are transferred to the second buffer area, the instruction timing unit stops timing and records the timing data as a first time, wherein the first time is the transmission duration of the instruction data.

[0069] Step S330: Obtain the maximum allowed time according to the difference between the first time and the maximum idle time.

[0070] Step S340: the process timing unit starts timing from the maximum allowed time and starts executing the background operation at the same time until the timing of the process timing unit is reset to zero, the process timing unit stops timing, and the background operation is interrupted.

[0071] See also Figures 1 to 7 As shown, in one embodiment of the present invention, in step S400, when the execution time of the background operation reaches the maximum allowed time, the operation interruption module 504 interrupts the background operation. The timing start module 503 generates a continue writing signal and feeds it back to the host 60, and continues to write the next instruction data to the first buffer area 210. And continue the same steps S100 to step S500.

[0072] See also Figures 1 to 7 As shown, in one embodiment of the present invention, when the background operation is interrupted, the value of the interrupt variable is set to the mark value, and in the processing step of the next instruction data, in the step of executing the background operation, the interrupt variable is queried, and when the value of the interrupt variable is the mark value, the interrupt position of the previous background operation process is obtained, and the previous background operation process is continued at the interrupt position. When the value of the interrupt variable is the initial value, a new background operation process is executed.

[0073] The embodiments of the present invention disclosed above are only used to help illustrate the present invention. The embodiments do not describe all the details in detail, nor do they limit the invention to the specific embodiments described. Obviously, many modifications and changes can be made according to the content of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the present invention, so that those skilled in the art can understand and use the present invention well. The present invention is limited only by the claims and their full scope and equivalents.

Claims

1. A storage device, It is characterized in that include: Flash memory chips; A main controller is electrically connected to the flash memory chip and the host computer, and when the main controller executes the command of the host computer, the command data of the host computer is transmitted in multiple transactions, wherein the main controller stores the maximum idle time of the host computer; A timing module, electrically connected to the main controller, wherein the timing module stores the transmission duration of the instruction data and the execution duration of the background operation; as well as A memory is electrically connected to the main controller and the timing module, wherein the control firmware is stored in the memory, and within the maximum idle time, the main controller is allowed to call the control firmware, and when the execution time of the background operation reaches the maximum allowed time, the background operation is interrupted, and the next instruction data is continuously written, wherein the control firmware includes a task query module, and a plurality of task query instructions are stored in the task query module. When the instruction data is written, the task query module executes the task query instruction cyclically, and when the instruction data is written, the task query module generates a timing start signal, and the timing start signal is sent to the timing module; Wherein, the timing module comprises: an instruction timing unit, wherein the timing starting point of the instruction timing unit is zero, and when the host computer starts to write the instruction data, the timing of the instruction timing unit is started, and when the host computer finishes writing the instruction data, the timing of the instruction timing unit is turned off, wherein the transmission duration of the instruction data is stored in the instruction timing unit; and A plurality of process timing units, wherein the timing starting point of the process timing unit is the maximum allowed time, and when the instruction data is fully written, the timing of the process timing unit is started, and when the timing of the process timing unit is reset, the timing of the process timing unit is turned off, wherein the maximum allowed time is the difference between the maximum idle time and the instruction data writing time; The main controller comprises: A first buffer area is electrically connected to the host computer and receives the instruction data, wherein when the first buffer area is full, the task query module generates a first timing start signal, and the instruction timing unit starts timing; a second buffer area, electrically connected to the first buffer area, the second buffer area receives the instruction data and stores processing information of the instruction data, when the instruction data is all transferred to the second buffer area, the task query module generates a second timing start signal, and the process timing unit starts timing; and The third cache area is electrically connected between the second cache area and the flash memory chip. The storage capacity of the third cache area is greater than the storage capacity of the first cache area, and the third cache area is allowed to store multiple instruction data.

2. A storage device according to claim 1, It is characterized in that The control firmware also includes: A timing start module, electrically connected to the timing module, when the timing of the process timing unit is reset, the timing start module generates a continue writing signal, an operation interruption signal and a timing reset signal, wherein the continue writing signal is output to the host computer, and the host computer and the main controller continue to transmit the next instruction data; an operation interruption module, electrically connected to the timing start module, the operation interruption module receiving the operation interruption signal and interrupting the ongoing background operation; and The timing reset module is electrically connected to the timing start module, and the timing reset module receives the timing reset signal and resets multiple timing units in the timing module to zero.

3. A storage device according to claim 1, It is characterized in that The control firmware includes a marking module, in which an interrupt variable is stored. The value of the interrupt variable is an initial value or a marking value. When the background operation is interrupted, the marking module sets the value of the interrupt variable to the marking value.

4. A method for controlling a storage device, based on the storage device according to claim 1, It is characterized in that The following steps are involved: The main controller receives and executes the instructions from the host computer; When the main controller executes the instruction of the host computer, the instruction data of the host computer is transmitted in multiple transactions, wherein the main controller stores the maximum idle time of the host computer; After the instruction data is written into the main controller, performing background operations during the remaining time of the maximum idle time; Acquire the transmission duration of the instruction data and the execution duration of the background operation through a timing module; as well as Within the maximum idle time, when the execution time of the background operation reaches the maximum allowed time, the background operation is interrupted and the next instruction data is continued to be written, wherein the maximum allowed time is the difference between the maximum idle time and the instruction data writing time.

5. A method for controlling a storage device according to claim 4, It is characterized in that The step of obtaining the transmission duration of the instruction data and the execution duration of the background operation includes: When all the instruction data are written into the first buffer area, the instruction timing unit starts timing and transfers the instruction data to the second buffer area; When all the instruction data are transferred to the second buffer area, the instruction timing unit stops timing and records the timing data as a first time, wherein the first time is the transmission duration of the instruction data; Obtaining a maximum allowed time according to a difference between the first time and the maximum idle time; The process timing unit starts timing from the maximum allowed time and starts executing the background operation at the same time until the timing of the process timing unit is reset to zero, and the process timing unit stops timing and interrupts the background operation.

6. A method for controlling a storage device according to claim 4, It is characterized in that When the background operation is interrupted, the value of the interrupt variable is set to the mark value, and in the next processing step of the instruction data, the step of executing the background operation includes: querying the interrupt variable, and when the value of the interrupt variable is the mark value, obtaining the interrupt position of the last background operation process, and continuing to execute the last background operation process at the interrupt position; and When the value of the interrupt variable is the initial value, a new background operation process is executed.