Disclosure of Invention
The invention provides a solid state disk write instruction sequencing method and a solid state disk, aiming at the defect that the average delay time is unreasonable due to the fact that the sequence among write instructions is not considered in the prior art.
The technical scheme adopted by the invention for solving the technical problems is as follows: a method for sequencing write instructions of a solid state disk is constructed, and comprises the following steps:
s1: when the write-in command queue is processed, judging whether the available space number of the write-in buffer is smaller than the command size of the current write-in command or not;
s2: if yes, skipping the write-in instruction, and judging whether the available space number is smaller than the instruction size of the next write-in instruction after the write-in instruction in the write-in instruction queue;
s3: if not, executing the write-in instruction with the instruction size larger than or equal to the available space number; if yes, the step S2 is executed.
Preferably, in the method for ordering write instructions in a solid state disk according to the present invention, the step S2 further includes:
s21: and after skipping the writing instruction, recording the skipping times of the writing instruction.
Further, the method for ordering the solid state disk write-in instructions according to the present invention further includes:
s4: and writing the write-in instruction with the skipping times of the write-in instruction being larger than a preset skipping time threshold into a linked list.
Preferably, in the method for ordering write instructions in a solid state disk according to the present invention, the step S4 includes:
s41: the linked list comprises an LCL linked list and an SCL linked list, the writing instruction with the writing instruction size larger than a preset instruction size threshold value is recorded in the LCL linked list, and the writing instruction with the writing instruction size smaller than or equal to the instruction size threshold value is recorded in the SCL linked list.
Further, the method for ordering the solid state disk write-in instructions according to the present invention further includes:
s5: and selecting a write instruction of the LCL linked list or the SCL linked list according to the available space number for execution.
Preferably, in the method for ordering write instructions in a solid state disk according to the present invention, the step S5 includes:
s51: if the available space number is larger than the instruction size threshold, selecting a write-in instruction of the LCL linked list for execution;
s52: and if the available space number is less than or equal to the instruction size threshold, selecting a write instruction of the SCL linked list for execution.
Preferably, in the method for ordering write instructions in a solid state disk according to the present invention, the step S5 further includes:
s53: and before the write-in instructions of the LCL linked list and the SCL linked list are processed, the write-in instructions are not added into the LCL linked list and the SCL linked list.
Preferably, in the method for sorting write instructions in a solid state disk according to the present invention, the priority of the write instructions in the LCL linked list is increased, and the step S51 includes:
and if the available space number is larger than the instruction size threshold, selecting the write-in instruction with high priority in the LCL linked list for execution.
Preferably, the method for sorting write instructions in a solid state disk according to the present invention, wherein the increasing the priority of the write instructions in the LCL linked list includes:
and setting the priority of the writing instruction according to the size of the writing instruction, wherein the priority of the writing instruction is in direct proportion to the size of the writing instruction.
In addition, the invention also discloses a solid state disk, and the solid state disk uses the solid state disk writing instruction sequencing method.
The invention discloses a solid state disk write instruction sequencing method and a solid state disk, wherein the method comprises the following steps: when the write-in command queue is processed, judging whether the available space number of the write-in buffer is smaller than the command size of the current write-in command or not; if the available space number is smaller than the current writing instruction, skipping the writing instruction, and judging whether the available space number is smaller than the instruction size of the next writing instruction after the writing instruction in the writing instruction queue; if not, executing the write command with the command size larger than or equal to the available space number. By implementing the method and the device, the average delay time is reduced by adjusting the sequence among the write-in instructions, and the read-write speed of the solid state disk is improved.
Detailed Description
For a more clear understanding of the technical features, objects and effects of the present invention, embodiments of the present invention will now be described in detail with reference to the accompanying drawings.
Fig. 1 is a schematic flow chart of a method for ordering write commands in a solid state disk according to the present invention.
Specifically, the solid state disk write instruction sequencing method includes:
s1: when the write command queue is processed, whether the available space number of the write buffer is smaller than the command size of the current write command is judged.
Specifically, in the solid state disk, the write buffer is used for loading host data carried by the write command. In the process of executing the write command, the write command is loaded into the write buffer first, and then the write command is executed. It should be appreciated that when the amount of available space in the write buffer is less than the number of write instructions, i.e., there is not enough space to load the write instructions, the write buffer is not loaded with the write instructions. In addition, the amount of space available for writing to the buffer is dynamically changed during instruction execution. The write command queue includes a plurality of write commands, and the write commands are arranged in a certain order, for example, in a time sequence. Therefore, when the firmware processes the write command queue, it first determines whether the available space number of the write buffer is smaller than the command size of the current write command, and processes the current write command according to the determination result.
S2: and if the available space number of the write-in buffer is smaller than the instruction size of the current write-in instruction, skipping the write-in instruction, and judging whether the available space number is smaller than the instruction size of the next write-in instruction after the write-in instruction in the write-in instruction queue.
Specifically, by determining that the number of available spaces of the write buffer is smaller than the instruction size of the current write instruction, it is indicated that the number of available spaces of the write buffer is not enough to load the write instruction, so that the write instruction cannot be executed currently. At this time, the write instruction should be skipped, the next instruction in the instruction queue is continuously judged, whether the available space number of the write buffer is smaller than the instruction size of the next write instruction is judged, and the current write instruction is processed according to the judgment result.
If the available space of the write buffer is larger than or equal to the instruction size of the current write instruction, the current write instruction is executed.
The method avoids the additional burden of waiting for a sufficient amount of available space or breaking down write instructions.
S3: if not, executing a write-in instruction with the instruction size larger than or equal to the available space number; if yes, go to step S2.
Specifically, if the available space of the write buffer is larger than or equal to the instruction size of the next write instruction, the write instruction is executed.
If the available space number of the write buffer is smaller than the instruction size of the next write instruction, which indicates that the remaining available space number of the write buffer is not enough to load the write instruction, step S2 is executed to skip the write instruction and continue to determine whether the available space number is smaller than the instruction size of the next write instruction after the write instruction in the write instruction queue. According to the above method, all write commands in the write command queue are judged circularly. It should be understood that the number of available spaces in the write buffer is a dynamically changing value, and when the execution of the write command in the write buffer is completed, the space in the corresponding write buffer is released.
Preferably, step S2 further includes:
s21: after skipping the write command, recording the skipping times of the write command.
By the judgment, if the available space number of the write buffer is smaller than the instruction size of the current write instruction, skipping the write instruction, and recording the skipping times of the write instruction. The skipping times of the instruction are accumulated once every time the write instruction skips. Preferably, a write command may be skipped due to insufficient space available in the write buffer, or during a seek for the next write command.
In the process of circularly judging the writing instruction queue, once per cycle, if the writing instruction can not be executed, the skipping times of the instruction are accumulated once.
Preferably, a special storage area is arranged in the solid state disk to store the skipping times.
S4: and writing the write-in instruction with the skipping times of the write-in instruction being larger than a preset skipping time threshold into the linked list.
Specifically, a preset skipping number threshold value is set, and the preset skipping number threshold value represents an upper limit of the number of times that the writing instruction is skipped. The write command with the skip number exceeding the preset skip number threshold is preferentially executed. The linked list is used for recording the writing instructions with the skipping times larger than a preset skipping time threshold value.
Preferably, for a write instruction with a skip number exceeding a preset skip number threshold, step S4 includes:
s41: further, the linked list is divided into an LCL (Large Command List) linked list and an SCL (Small Command List) linked list, wherein, a write-in Command with a write-in Command size larger than a preset Command size threshold value is recorded in the LCL linked list, and a write-in Command with a write-in Command size smaller than or equal to the Command size threshold value is recorded in the SCL linked list.
S5: when the write-in instruction with the skipping times exceeding the preset skipping time threshold is processed, the available space number of the write-in buffer is acquired at first, and the write-in instruction of the LCL linked list or the SCL linked list is selected to be executed according to the available space number.
Specifically, referring to fig. 2, a schematic diagram of an execution flow of an LCL linked list in the method for sorting write instructions of a solid state disk according to the present invention is shown. Step S5 includes:
s51: comparing the available space number of the write buffer with an instruction size threshold, and if the available space number is greater than the instruction size threshold, selecting a write instruction of the LCL linked list for execution;
s52: and comparing the available space number of the write buffer with an instruction size threshold, and if the available space number is less than or equal to the instruction size threshold, selecting the write instruction of the SCL linked list to execute.
S53: before the write-in instructions of the LCL linked list and the SCL linked list are processed, no write-in instruction is newly added to the LCL linked list and the SCL linked list, so that long-term waiting events are avoided.
By the method, the available space number of the write buffer is fully utilized, the situation that when the available space number is large, the write buffer is occupied by a small write command, the available space number of the write buffer cannot be fully utilized, and meanwhile, a large write command cannot easily obtain the sufficient available space number to wait for a long time is avoided.
Preferably, for the LCL linked list, during the execution of the write command, the larger write command cannot easily obtain enough available space, so the priority of the larger write command should be properly increased, so that when the available space is sufficient, it can be processed preferentially.
Specifically, the step S51 includes:
and if the number of the available spaces is larger than the instruction size threshold, selecting a write-in instruction with high priority in the LCL linked list for execution.
Preferably, the method for sorting write instructions in a solid state disk of the present invention improves the priority of the write instructions in the LCL linked list, and includes:
the priority of the write command is set according to the size of the write command, and the priority of the write command is in direct proportion to the size of the write command, namely, the larger the write command is, the higher the priority of the write command is. Preferably, the priority of the write instruction is set according to the number of skip times of the write instruction, and the priority of the write instruction is in direct proportion to the number of skip times of the write instruction, that is, the higher the number of skip times of the write instruction is, the higher the priority of the write instruction is.
In addition, the invention also discloses a solid state disk, and the solid state disk uses the solid state disk writing instruction sequencing method.
The invention takes the size relation between the instruction size and the available space number of the write buffer into consideration to adjust the sequence between the write instructions, thereby reducing the average delay time of the instructions. Further, in order to avoid long-term waiting for the occurrence of the event, the invention records that the skipped times exceed the preset skipped times threshold value and processes the skipped times preferentially. In order to fully utilize the write buffer, the invention separately records the large write command and the small write command, determines to preempt the large write command or preempt the small write command according to the available space number of the write buffer, and properly increases the priority of the large write command, so as to balance the balance of the large write command and the small write command, reduce the average delay time and increase the read-write speed of the solid state disk.
The above embodiments are merely illustrative of the technical ideas and features of the present invention, and are intended to enable those skilled in the art to understand the contents of the present invention and implement the present invention, and not to limit the scope of the present invention. All equivalent changes and modifications made within the scope of the claims of the present invention should be covered by the claims of the present invention.