Disclosure of Invention
Embodiments of the present invention provide a method, an apparatus, a device, and a computer readable storage medium for reading and writing data of a solid state disk, which are based on a multi-plane and simultaneously perform operations on a plurality of addresses, so as to improve the reading and writing speed of the solid state disk, and further improve the performance of the entire solid state disk.
In order to solve the above technical problems, embodiments of the present invention provide the following technical solutions:
an embodiment of the present invention provides a data read-write method for a solid state disk, which is based on a multi-plane and includes:
receiving a user read-write instruction, and identifying the type of the read-write instruction;
if the type of the read-write instruction is a write message instruction, acquiring the number of effective addresses of an effective plane group of the solid state disk, and simultaneously writing a plurality of groups of data to be written by users into the NAND flash memory; the number of groups of data to be written by the user is the same as the number of the effective addresses;
if the type of the read-write instruction is a read message instruction, reading data from a cache of the NAND flash memory when a preset condition is met; and the preset condition is that when the last operation of the current operation is a read operation and the address corresponding to the read message instruction belong to the same plane set.
Optionally, when the preset condition is not satisfied, reading data from the NAND flash memory.
Optionally, the obtaining the number of effective addresses of the effective plane set of the solid state disk, and writing the multiple groups of data to be written by the user into the NAND flash memory at the same time includes:
distributing the data blocks in the solid state disk to each plane group in advance according to grouping instructions;
selecting an effective plane set from each plane set according to the received available plane instruction;
judging whether the number of effective addresses contained in the effective plane set is not less than the number of groups of data to be written;
if so, simultaneously writing a plurality of groups of data to be written by the user into the NAND flash memory;
and if not, writing the data to be written of the user in the NAND flash memory in batches according to the number of the effective addresses in the effective plane set and the number of the groups of the data to be written.
Optionally, the method further includes:
and feeding back error prompt information when the number of effective addresses contained in the effective plane set is 0.
Another aspect of the embodiments of the present invention provides a data read/write apparatus for a solid state disk, which is based on a multi-plane, and includes:
the command receiving module is used for receiving a user read-write command and identifying the type of the read-write command;
the write message optimization module is used for acquiring the number of effective addresses of the effective plane set of the solid state disk and simultaneously writing a plurality of groups of data to be written by the user into the NAND flash memory when the type of the read-write instruction is the write message instruction; the number of groups of data to be written by the user is the same as the number of the effective addresses;
the read message optimization module is used for reading data from the cache of the NAND flash memory when the type of the read-write instruction is a read message instruction and a preset condition is met; and the preset condition is that when the last operation of the current operation is a read operation and the address corresponding to the read message instruction belong to the same plane set.
Optionally, the read message optimization module is a module that reads data from the NAND flash memory when the preset condition is not satisfied.
Optionally, the write message optimization module includes:
the grouping submodule is used for allocating the data blocks in the solid state disk to each plane group in advance according to a grouping instruction;
the effective plane set selection module is used for selecting an effective plane set from each plane set according to the received available plane instruction;
the judging submodule is used for judging whether the number of the effective addresses contained in the effective plane set is not less than the number of the groups of the data to be written;
the judgment execution module is used for writing a plurality of groups of data to be written of users into the NAND flash memory simultaneously when the number of effective addresses contained in the effective plane set is not less than the number of groups of the data to be written; and when the number of the effective addresses contained in the effective plane set is less than the group number of the data to be written, writing the data to be written of the user in the NAND flash memory in batches according to the number of the effective addresses in the effective plane set and the group number of the data to be written.
Optionally, the method further includes:
and the feedback module is used for feeding back error prompt information when the number of the effective addresses contained in the effective plane set is 0.
The embodiment of the present invention further provides a data reading and writing device for a solid state disk, including a processor, where the processor is configured to implement the steps of the data reading and writing method for a solid state disk according to any one of the foregoing embodiments when executing a computer program stored in a memory.
The embodiment of the present invention finally provides a computer-readable storage medium, where a data read-write program of the solid state disk is stored on the computer-readable storage medium, and the step of implementing the data read-write method of the solid state disk as described in any one of the preceding items is implemented when the data read-write program of the solid state disk is executed by a processor.
The embodiment of the invention provides a data reading and writing method of a solid state disk, which is based on a multi-plane, and simultaneously writes data to be written of users in arrays with the same number as the effective addresses of an effective plane set of the solid state disk into a NAND flash memory if the type of a reading and writing instruction is a write message instruction. If the type of the read-write instruction is a read message instruction, reading data from a cache of the NAND flash memory when a preset condition is met; the preset condition is that when the last operation of the current operation is a read operation and the address corresponding to the read message instruction belong to the same plane set.
The technical scheme provided by the application has the advantages that based on multi-plane characteristics, aiming at the write message, the data to be written of a user can be written into the NAND flash memory at the same time, the data volume written into the NAND flash memory at one time is increased, when the user has a large amount of data to be written, the data writing time can be greatly shortened, and the data writing efficiency is improved; aiming at the read information, when the data in the address of the same plane group is read, the data can be directly read in the cache of the NAND flash memory without reading the data by the NAND flash memory, so that the data reading efficiency is improved, and the hit rate of the read cache is improved; by optimizing the solid state disk reading and writing method based on the multi-plane characteristic, the reading and writing speed of the solid state disk is effectively improved, the performance of the whole solid state disk is improved, and the competitiveness of the solid state disk is further enhanced.
In addition, the embodiment of the invention also provides a corresponding implementation device, equipment and a computer readable storage medium for the data reading and writing method of the solid state disk, so that the method has higher practicability, and the device, the equipment and the computer readable storage medium have corresponding advantages.
Detailed Description
In order that those skilled in the art will better understand the disclosure, the invention will be described in further detail with reference to the accompanying drawings and specific embodiments. It is to be understood that the described embodiments are merely exemplary of the invention, and not restrictive of the full scope of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The terms "first," "second," "third," "fourth," and the like in the description and claims of this application and in the above-described drawings are used for distinguishing between different objects and not for describing a particular order. Furthermore, the terms "comprising" and "having," as well as any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those steps or elements but may include other steps or elements not expressly listed.
Having described the technical solutions of the embodiments of the present invention, various non-limiting embodiments of the present application are described in detail below.
Referring to fig. 1, fig. 1 is a schematic flow chart of a data read-write method of a solid state disk according to an embodiment of the present invention, where the embodiment of the present invention includes the following contents based on a multi-plane:
s101: and receiving a read-write instruction of a user and identifying the type of the read-write instruction.
The user read-write command comprises a user read data command and a user write data command, namely a read message command and a write message command. The operation of the current user can be identified as read operation or write operation according to different instruction information input by the user.
S102: and if the type of the read-write instruction is a write message instruction, acquiring the number of effective addresses of an effective plane group of the solid state disk, and simultaneously writing a plurality of groups of data to be written by the user into the NAND flash memory.
The valid plane set is a plane with normal physical characteristics of the storage medium, that is, a plane set which is not damaged and can perform read-write operations.
After the system creates a plurality of planes, the data blocks in the solid state disk are allocated to each plane group in advance according to the grouping instruction. For example, when there are n planes in a lun and there are m effective addresses in the first plane set, each data block in the plane set may be named blockmn、blockmn+1、…、blockmn+n-1。
The number of valid addresses of a plane set is the number of available data blocks in the set. The number of groups of data to be written by a user is the same as the number of effective addresses, that is, the number of effective addresses of the plane group where the current address is located is the same, and the number of groups of data can be written into the NAND flash memory at the same time. When the number of the groups of the data to be written is larger than the number of the effective addresses of the plane group where the current address is located, the data can be written in batches, which data can be randomly selected and written in each batch, and the data can also be determined according to a pre-established LAB table, which does not affect the implementation of the application.
For example, if the number of effective addresses of the plane set where the current address is located is 5 and the number of sets of data to be written includes 10, 5 sets of data can be written to the NAND flash memory twice at a time.
When the number of the effective addresses of the plane group where the current address is located is 0, the current solid state disk may operate abnormally or be damaged, and the system can automatically feed back error prompt information so as to prompt a user or a worker to search and maintain as soon as possible and reduce user loss.
S103: and if the type of the read-write instruction is a read message instruction, reading data from the cache of the NAND flash memory when a preset condition is met.
The preset condition may be that when the last operation of the current operation is a read operation and the address corresponding to the read message instruction belong to the same plane set.
In the technical scheme provided by the embodiment of the invention, based on multi-plane characteristics, aiming at a write message, the data to be written of a user can be simultaneously written into the NAND flash memory, so that the data volume written into the NAND flash memory at one time is increased, when the user has a large amount of data to be written, the data writing time can be greatly shortened, and the data writing efficiency is improved; aiming at the read information, when the data in the address of the same plane group is read, the data can be directly read in the cache of the NAND flash memory without reading the data by the NAND flash memory, so that the data reading efficiency is improved, and the hit rate of the read cache is improved; by optimizing the solid state disk reading and writing method based on the multi-plane characteristic, the reading and writing speed of the solid state disk is effectively improved, the performance of the whole solid state disk is improved, and the competitiveness of the solid state disk is further enhanced.
Based on the foregoing embodiment, the present application further provides another embodiment, please refer to fig. 2, which specifically includes:
s201: judging whether the user read-write instruction is a message write instruction, if so, executing S202; if not, go to S206.
S202: an active plane set is selected from the respective plane sets according to the received available plane instructions.
S203: and judging whether the number of effective addresses contained in the effective plane set is not less than the number of groups of data to be written, if so, executing S204, and if not, executing S205.
S204: and simultaneously writing a plurality of groups of data to be written of users into the NAND flash memory.
S205: and writing the data to be written of the user in the NAND flash memory in batches.
S206: and judging whether a preset condition is met, if so, executing S207, and otherwise, executing S208.
The preset condition is that when the last operation of the current operation is a read operation and the address corresponding to the read message instruction belong to the same plane set.
S207: and reading data from the cache of the NAND flash memory.
S208: data is read from the NAND flash memory.
That is, when the operation immediately preceding the current operation is a write operation, the current read operation can only be read from the NAND flash memory; when the previous operation of the current operation is a read operation, but the address of the read data and the address of the current read data do not belong to the same plane, the current read operation can only read from the NAND flash memory.
After reading the data from the NAND flash memory, the last saved read information may be further updated for subsequent use.
As can be seen from the above, the embodiment of the present invention is based on the multi-plane, and performs operations on multiple addresses at the same time, so as to improve the read-write speed of the solid state disk, and further improve the performance of the entire solid state disk.
The embodiment of the invention also provides a corresponding implementation device for the data reading and writing method of the solid state disk, so that the method has higher practicability. The following introduces a data reading and writing apparatus of a solid state disk according to an embodiment of the present invention, and the data reading and writing apparatus of the solid state disk described below and the data reading and writing method of the solid state disk described above may be referred to correspondingly.
Referring to fig. 3, fig. 3 is a structural diagram of a data reading and writing apparatus of a solid state disk according to an embodiment of the present invention in a specific implementation manner, and based on a multi-plane, the apparatus may include:
the instruction receiving module 301 is configured to receive a read-write instruction of a user and identify a type of the read-write instruction.
The write message optimization module 302 is configured to, when the type of the read-write instruction is a write message instruction, acquire the number of effective addresses of an effective plane set of the solid state disk, and write a plurality of groups of data to be written by the user into the NAND flash memory at the same time; the number of groups of data to be written by the user is the same as the number of effective addresses.
The read message optimization module 303 is configured to, when the type of the read-write instruction is a read message instruction, read data from a cache of the NAND flash memory when a preset condition is met; the preset condition is that when the last operation of the current operation is a read operation and the address corresponding to the read message instruction belong to the same plane set.
In a specific embodiment, the read message optimization module 303 may be a module that reads data from the NAND flash memory when a preset condition is not satisfied.
Optionally, in another embodiment, the write message optimization module 302 may further include:
the grouping submodule is used for allocating the data blocks in the solid state disk to each plane group in advance according to the grouping instruction;
the effective plane set selection module is used for selecting an effective plane set from each plane set according to the received available plane instruction;
the judging submodule is used for judging whether the number of the effective addresses contained in the effective plane set is not less than the number of the groups of the data to be written;
the judgment execution module is used for writing a plurality of groups of data to be written of users into the NAND flash memory simultaneously when the number of effective addresses contained in the effective plane set is not less than the number of groups of the data to be written; and when the number of the effective addresses contained in the effective plane set is less than the group number of the data to be written, writing the data to be written of the user in the NAND flash memory in batches according to the number of the effective addresses in the effective plane set and the group number of the data to be written.
Optionally, in some embodiments of this embodiment, referring to fig. 4, the apparatus may further include:
a feedback module 304, configured to feed back an error notification message when the number of effective addresses included in the effective plane set is 0.
The functions of the functional modules of the data reading and writing device of the solid state disk according to the embodiments of the present invention may be specifically implemented according to the method in the above method embodiments, and the specific implementation process may refer to the description related to the above method embodiments, which is not described herein again.
As can be seen from the above, the embodiment of the present invention is based on the multi-plane, and performs operations on multiple addresses at the same time, so as to improve the read-write speed of the solid state disk, and further improve the performance of the entire solid state disk.
The embodiment of the present invention further provides a data read-write device for a solid state disk, which specifically includes:
a memory for storing a computer program;
and the processor is used for executing the computer program to realize the steps of the data reading and writing method of the solid state disk according to any one of the above embodiments.
The functions of the functional modules of the data reading and writing device of the solid state disk according to the embodiments of the present invention may be specifically implemented according to the method in the above method embodiments, and the specific implementation process may refer to the description related to the above method embodiments, which is not described herein again.
As can be seen from the above, the embodiment of the present invention is based on the multi-plane, and performs operations on multiple addresses at the same time, so as to improve the read-write speed of the solid state disk, and further improve the performance of the entire solid state disk.
The embodiment of the invention also provides a computer readable storage medium, which stores a data reading and writing program of the solid state disk, wherein the data reading and writing program of the solid state disk is executed by a processor, and the steps of the data reading and writing method of the solid state disk are as described in any one of the above embodiments.
The functions of the functional modules of the computer-readable storage medium according to the embodiment of the present invention may be specifically implemented according to the method in the foregoing method embodiment, and the specific implementation process may refer to the related description of the foregoing method embodiment, which is not described herein again.
As can be seen from the above, the embodiment of the present invention is based on the multi-plane, and performs operations on multiple addresses at the same time, so as to improve the read-write speed of the solid state disk, and further improve the performance of the entire solid state disk.
The embodiments are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same or similar parts among the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in Random Access Memory (RAM), memory, Read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
The detailed description is given above of a data read-write method, device, apparatus and computer readable storage medium for a solid state disk provided by the present invention. The principles and embodiments of the present invention are explained herein using specific examples, which are presented only to assist in understanding the method and its core concepts. It should be noted that, for those skilled in the art, it is possible to make various improvements and modifications to the present invention without departing from the principle of the present invention, and those improvements and modifications also fall within the scope of the claims of the present invention.