Data processing method, device, storage medium and electronic device
By storing data in a solid-state drive with page size alignment based on the information and continuity conditions of write requests in a solid-state drive, the problem of not being able to effectively improve the read performance of solid-state drives in the prior art is solved, and the effect of improving data storage and improving read performance is achieved at the root of the root cause.
Patent Information
- Application Number
- CN202210945807.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-08
- Publication Date
- 2025-05-16
- Estimated Expiration
- 2042-08-08
AI Technical Summary
The reading performance of solid-state drives cannot be effectively improved in the prior art, mainly because the problem is solved only from the reading aspect, and the storage of data on the solid-state drive is not improved from the root.
When receiving a write request, the information of the target data is determined based on the request instruction, and when a specific condition is met, the data is stored in the solid state drive according to the rules aligned with the page size. This method judges the number of consecutive write requests and data continuity through the target flag bits, ensuring the physical distribution of data optimization.
The physical distribution optimization of data written in solid-state drives is realized, which improves the reading performance of solid-state drives, and avoids the limitation of improving performance only from the read aspect without solving the problem from the root.
Smart Images

Figure CN115291801B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of data processing technology, and in particular, to a data processing method, device, storage medium and electronic device. Background Art
[0002] With the rapid development of technologies such as the Internet, cloud computing, and big data, massive amounts of data are generated all the time, and these data need to be processed and stored. Solid-state drives (SSDs) have been widely used due to their fast read and write speeds and low energy consumption, and the performance requirements for hard drives will become increasingly higher. For example, consumer solid-state drives need to give priority to read requests, which is related to the intuitive experience of customers when using the product, so the firmware will do some optimization processing for host read requests. Commonly used technologies include: setting read commands to have higher priority than other commands; improving the parallelism of read commands, etc. For example, there is a method of pre-caching data that is adjacent to the current read instruction sequence into a solid-state cache to reduce the response time for subsequent instruction reads. However, in the related art, when the host read pressure is large, the firmware has no time to read data that is adjacent to the logical address, or if the logical address is adjacent but the physical address is not adjacent, it will lead to a decrease in read performance. The main disadvantage of the related art is that the problem is only solved from the read aspect, and the problem is not considered to be solved from the root, for example, how to improve the storage of data on the solid-state hard drive, that is, there is a problem in the related art that the read performance of the solid-state hard drive cannot be effectively improved.
[0003] With regard to the problem in the related art that the reading performance of the solid state drive cannot be effectively improved, no effective solution has been proposed yet. Summary of the invention
[0004] The embodiments of the present invention provide a data processing method, device, storage medium and electronic device to at least solve the problem in the related art that the reading performance of a solid state drive cannot be effectively improved.
[0005] According to one embodiment of the present invention, there is provided a data processing method, comprising: upon receiving a first request instruction for requesting to write first target data, determining first target information of the first target data based on the first request instruction; upon determining that the first target information satisfies a first predetermined condition, and upon determining that a target flag bit satisfies a second predetermined condition, storing the first target data in a target solid-state hard disk according to a predetermined rule, wherein the predetermined rule is used to indicate a rule aligned with a page size, and the target flag bit is used to indicate whether a target number of requests for consecutive requests to write data received before the first request instruction is currently received is greater than or equal to a first predetermined threshold, and the target information of the target data indicated by each request included in the target number of requests satisfies the first predetermined condition.
[0006] In an exemplary embodiment, when it is determined that the first target information satisfies a first predetermined condition and when it is determined that the target flag bit satisfies a second predetermined condition, the first target data is stored in the target solid-state hard disk according to a predetermined rule, including: when it is determined that the first target information satisfies the first predetermined condition and when it is determined that the value of the target flag bit is a first predetermined value, the first target data is stored in the target solid-state hard disk according to the predetermined rule, wherein the value of the target flag bit is set to the first predetermined value when it is determined that the number of target requests is greater than or equal to the first predetermined threshold.
[0007] In an exemplary embodiment, when it is determined that the first target information satisfies a first predetermined condition, and when it is determined that the value of the target flag bit satisfies a second predetermined condition, the first target data is stored in a target solid-state hard disk according to a predetermined rule, including: determining the first logical block address LBA information and the first target length information included in the first target information, wherein the first target length information is information indicating the length of the first target data; determining whether the first LBA information and the second LBA information meet a continuous condition, wherein the second target information includes the second LBA information, and the second target information is information of the second target data determined based on a second request instruction, and the second request instruction is used to indicate an instruction for requesting to write the second target data received before the first request instruction; when it is determined that the first LBA information and the second LBA information meet the continuous condition, and when it is determined that the length of the first target data indicated by the first target length information is greater than or equal to a second predetermined value, it is determined that the first target information meets the first predetermined condition; when it is determined that the first target information meets the first predetermined condition, and when it is determined that the target flag bit meets the second predetermined condition, the first target data is stored in the target solid-state hard disk according to the predetermined rule.
[0008] In an exemplary embodiment, determining whether the first LBA information and the second LBA information satisfy a continuity condition includes: comparing the first LBA information with the second LBA information and second target length information to determine whether the first LBA information and the second LBA information satisfy the continuity condition, wherein the second target information also includes the second target length information, and the second target length information is used to indicate information about the length of the second target data.
[0009] In an exemplary embodiment, the first LBA information is compared with the second LBA information and the second target length information to determine whether the first LBA information and the second LBA information meet the continuity condition, including: comparing the first LBA information with the second LBA information and the second target length information to obtain a comparison result; when the comparison result indicates that the first LBA corresponding to the first LBA information is equal to the sum of the second LBA corresponding to the second LBA information and the second target length, determining that the first LBA information and the second LBA information meet the continuity condition; when the comparison result indicates that the first LBA corresponding to the first LBA information is not equal to the sum of the second LBA corresponding to the second LBA information and the second target length, determining that the first LBA information and the second LBA information do not meet the continuity condition.
[0010] In an exemplary embodiment, the first target data is stored in a target solid-state hard disk according to a predetermined rule, including: storing the first target data in the target solid-state hard disk starting from the starting position of a target page and according to a rule aligned with the size of the page, wherein the target page is used to indicate the next page of the current page, the current page is used to indicate the last page occupied by the second target data requested to be written by the second request instruction in the target solid-state hard disk, and the second request instruction is used to indicate the instruction for requesting to write the second target data received before the first request instruction.
[0011] In an exemplary embodiment, the method further includes: filling a remaining space of the current page with invalid data if it is determined that the current page is not full.
[0012] According to another embodiment of the present invention, a data processing device is also provided, including: a determination module, for determining first target information of the first target data based on a first request instruction for requesting to write first target data when a first request instruction is received; a processing module, for storing the first target data in a target solid-state hard disk according to a predetermined rule when it is determined that the first target information satisfies a first predetermined condition and when it is determined that a target flag bit satisfies a second predetermined condition, wherein the predetermined rule is used to indicate a rule of alignment with a page size, and the target flag bit is used to indicate whether a target number of requests for consecutive requests to write data received before the first request instruction is currently received is greater than or equal to a first predetermined threshold, and the target information of the target data indicated by each request included in the target number of requests satisfies the first predetermined condition.
[0013] According to yet another embodiment of the present invention, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the steps of any one of the above method embodiments when run.
[0014] According to yet another embodiment of the present invention, there is provided an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0015] Through the present invention, when a first request instruction requesting to write first target data is received, first target information of the first target data is determined based on the first request instruction, and when it is determined that the first target information satisfies the first predetermined condition and the target flag bit satisfies the second predetermined condition, the first target data is stored in the target solid-state hard disk according to the rule of aligning with the page size, wherein the target flag bit is used to indicate whether the number of target requests for continuous requests to write data received before the first request instruction is currently received is greater than or equal to the first predetermined threshold, and the target information of the target data of each request corresponding to the number of target requests satisfies the above-mentioned first predetermined condition, that is, when the first target information of the first target data requested to be written currently satisfies the first predetermined condition and the data write requests for the target request number that have been continuously received before this all satisfy the first predetermined condition, the first target data is stored in the target solid-state hard disk according to the rule of aligning with the page size, so that the purpose of storing as much data that meets the first predetermined condition as possible on the target solid-state hard disk according to the page size alignment rule can be achieved. Therefore, the purpose of improving the physical distribution of data written to the target solid-state hard disk is achieved, avoiding the problem in the related art of only solving the read performance from the read aspect but not improving the read performance from the root. Therefore, the problem in the related art that the read performance of the solid-state hard disk cannot be effectively improved is solved, and the effect of improving the read performance of the solid-state hard disk is achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 is a hardware structure block diagram of a mobile terminal of a data processing method according to an embodiment of the present invention;
[0017] Figure 2 is a flow chart of a data processing method according to an embodiment of the present invention;
[0018] Figure 3 is a schematic diagram of a method for reading data according to a specific embodiment of the present invention;
[0019] Figure 4 is a flow chart of a method for writing data according to a specific embodiment of the present invention;
[0020] Figure 5 is a structural block diagram of a data processing device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0021] Hereinafter, embodiments of the present invention will be described in detail with reference to the accompanying drawings and in combination with the embodiments.
[0022] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0023] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Taking running on a mobile terminal as an example, Figure 1 1 is a block diagram of the hardware structure of a mobile terminal according to the data processing method of an embodiment of the present invention. Figure 1 As shown, the mobile terminal may include one or more ( Figure 1 Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data, wherein the mobile terminal may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the mobile terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.
[0024] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the data processing method in the embodiment of the present invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the mobile terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0025] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the mobile terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0026] In this embodiment, a data processing method is provided. Figure 2 is a flow chart of a data processing method according to an embodiment of the present invention. Figure 2 As shown, the process includes the following steps:
[0027] Step S202, when a first request instruction for requesting to write first target data is received, determining first target information of the first target data based on the first request instruction;
[0028] Step S204, when it is determined that the first target information satisfies the first predetermined condition, and when it is determined that the target flag bit satisfies the second predetermined condition, the first target data is stored in the target solid-state hard disk according to a predetermined rule, wherein the predetermined rule is used to indicate the rule of alignment with the page size, and the target flag bit is used to indicate whether the target number of requests for continuous requests to write data received before the first request instruction is received for the current time is greater than or equal to a first predetermined threshold, and the target information of the target data indicated by each request included in the target number of requests satisfies the first predetermined condition.
[0029] Through the above steps, when a first request instruction requesting to write first target data is received, the first target information of the first target data is determined based on the first request instruction, and when it is determined that the first target information satisfies the first predetermined condition and the target flag bit satisfies the second predetermined condition, the first target data is stored in the target solid-state hard disk according to the rule of aligning with the page size, wherein the target flag bit is used to indicate whether the number of target requests for continuous requests to write data received before the first request instruction is currently received is greater than or equal to the first predetermined threshold, and the target information of the target data corresponding to each request in the number of target requests satisfies the above first predetermined condition, that is, when the first target information of the first target data requested to be written currently satisfies the first predetermined condition, and the data write requests for the target request number that have been continuously received before this all satisfy the first predetermined condition, the first target data is stored in the target solid-state hard disk according to the rule of aligning with the page size, so that the purpose of storing as much data that meets the first predetermined condition as possible on the target solid-state hard disk according to the page size alignment rule can be achieved. Therefore, the purpose of improving the physical distribution of data written to the target solid-state hard disk is achieved, avoiding the problem in the related art of only solving the read performance from the read aspect but not improving the read performance from the root. Therefore, the problem in the related art that the read performance of the solid-state hard disk cannot be effectively improved is solved, and the effect of improving the read performance of the solid-state hard disk is achieved.
[0030] The execution subject of the above steps may be a controller, for example, a solid-state hard disk controller, or a terminal, or a server, or a processor with human-computer interaction capabilities configured on a storage device, or a processing device or processing unit with similar processing capabilities, etc., but not limited thereto. The following takes the solid-state hard disk controller (hereinafter referred to as the "controller") performing the above operations as an example (only an exemplary description, in actual operation, other devices or modules may also be used to perform the above operations) for explanation:
[0031] In the above embodiment, when the controller receives a first request instruction for requesting to write the first target data, the controller determines the first target information of the first target data based on the first request instruction. For example, when the controller receives a write request instruction (corresponding to the above first request instruction) from the host, that is, the host requests to write the first target data, the controller determines the first target information of the first target data based on the first request instruction. For example, the first target information may include the logical block address LBA information of the first target data, and the first target information may also include the data length information of the first target data, such as the data length is 32K, or 64K, or 128K or other lengths; after determining that the first target information satisfies the first predetermined condition, and after determining that the target flag bit satisfies the first predetermined condition, the controller determines the first target information of the first target data based on the first request instruction. Under the second predetermined condition, the first target data is stored in the target solid-state hard disk according to the predetermined rule, wherein the predetermined rule is used to indicate the rule of alignment with the page size, and the target flag is used to indicate whether the target number of requests for continuous requests to write data received before the first request instruction is received for the current time is greater than or equal to the first predetermined threshold, and the target information of the target data indicated by each request included in the target request number satisfies the first predetermined condition. For example, the above-mentioned first predetermined threshold is 3 times (or 5 times, or other values), and the target flag indicates whether the target number of requests for continuous requests to write data received before the first request instruction is received for the current time is greater than or equal to 3 times, and the target information of the target data indicated by each request included in the target request number satisfies the first predetermined condition. The target information of the target data to be written indicated satisfies the first predetermined condition. For example, the first predetermined condition includes that the LBA of the target data currently requested to be written is continuous with the LBA of the target data previously requested to be written, and / or the first predetermined condition may also include that the data length of the target data requested to be written each time is greater than a preset length threshold. For example, the preset length threshold is 128K (or 64K, or 32K, or other). That is, the target flag is used to indicate whether there are three consecutive requests to write target data before the current time, all of which satisfy the above-mentioned first predetermined condition. In actual applications, the controller sets the above-mentioned target flag. For example, when the target flag is 1 (or True), it indicates that the data continuously requested to be written satisfy the above-mentioned first predetermined condition. The number of requests for a predetermined condition reaches a first predetermined threshold (such as 3 times as mentioned above), and when the target flag is 0 (or False), it means that the number of requests for data continuously requested to be written that meet the first predetermined condition has not reached the first predetermined threshold. In this way, when the controller determines that the first target information of the first target data currently requested to be written meets the above-mentioned first predetermined condition, and the target flag meets the second predetermined condition, it can control the first target data to be stored in the target solid-state hard disk according to the predetermined rule, that is, starting from the source of data writing on the solid-state hard disk, the physical distribution of the data stored on the solid-state hard disk is improved to achieve the purpose of storing as much data that meets the first predetermined condition as possible on the target solid-state hard disk according to the page size alignment rule.The problem of solving the reading performance only from the reading aspect but not improving the reading performance from the root in the related art is avoided. Therefore, the problem of being unable to effectively improve the reading performance of the solid-state hard disk in the related art is solved, and the effect of improving the reading performance of the solid-state hard disk is achieved.
[0032] In an optional embodiment, when it is determined that the first target information satisfies a first predetermined condition and when it is determined that the target flag bit satisfies a second predetermined condition, the first target data is stored in the target solid-state hard disk according to a predetermined rule, including: when it is determined that the first target information satisfies the first predetermined condition and when it is determined that the value of the target flag bit is a first predetermined value, the first target data is stored in the target solid-state hard disk according to the predetermined rule, wherein the value of the target flag bit is set to the first predetermined value when it is determined that the number of target requests is greater than or equal to the first predetermined threshold. In this embodiment, when it is determined that the first target information satisfies the first predetermined condition, and when it is determined that the value of the target flag is the first predetermined value, for example, the first predetermined condition includes that the LBA of the target data currently requested to be written is continuous with the LBA of the target data previously requested to be written, and / or, the first predetermined condition may also include that the data length of the target data requested to be written each time is greater than a preset length threshold, that is, the LBA address of the target data requested to be written is continuous relative to the LBA address of the data previously written, and / or, the target data requested to be written is large data, and the large data here is relative and can be preset, for example, the data length greater than or equal to 32K (or 64K, or 128K) can be preset as large data, and at this time, 1K or 4K is small data, and the above-mentioned first predetermined value can be set to 1, that is, when the first target information satisfies the first predetermined condition and the value of the target flag is 1, the first target data can be written to the target solid state drive according to the predetermined rule. Through this embodiment, the purpose of storing the first target data in the target solid state drive according to the predetermined rule is achieved when it is determined that the first target data currently requested to be written and the value of the target flag meet the conditions.
[0033] In an optional embodiment, when it is determined that the first target information satisfies a first predetermined condition, and when it is determined that the value of the target flag bit satisfies a second predetermined condition, the first target data is stored in a target solid-state hard disk according to a predetermined rule, including: determining the first logical block address LBA information and the first target length information included in the first target information, wherein the first target length information is information indicating the length of the first target data; determining whether the first LBA information and the second LBA information meet a continuity condition, wherein the second target information includes the second LBA information, and the second target information is information of the second target data determined based on a second request instruction, and the second request instruction is used to indicate an instruction for requesting to write the second target data received before the first request instruction; when it is determined that the first LBA information and the second LBA information meet the continuity condition, and when it is determined that the length of the first target data indicated by the first target length information is greater than or equal to a second predetermined value, determining that the first target information meets the first predetermined condition; when it is determined that the first target information meets the first predetermined condition, and when it is determined that the target flag bit meets the second predetermined condition, storing the first target data in the target solid-state hard disk according to the predetermined rule. In this embodiment, the first LBA information and the first target length information included in the first target information, that is, the logical block address information of the first target data requested to be written by the host and the length information of the first target data can be determined; then it is determined whether the first LBA information and the second LBA information meet the continuity condition, wherein the second LBA information is the logical block address information of the request to write the second target data received before the first request instruction; when it is determined that the first LBA information and the second LBA information meet the continuity condition, and the length of the first target data is greater than the second predetermined threshold, it can be determined that the first target information meets the first predetermined condition, and the second predetermined threshold corresponds to the preset length threshold in the aforementioned embodiment, for example, the second predetermined threshold is 128K (or 64K, or 32K, or other); then, when it is determined that the first target information meets the first predetermined condition, and the target flag bit meets the second predetermined condition, for example, the value of the target flag bit is the first predetermined value, at this time, the first target data can be stored in the target solid-state hard disk according to the predetermined rule. Through this embodiment, the purpose of determining whether the first target information meets the first predetermined condition is achieved, and then the purpose of storing the first target data in the target solid state drive according to a predetermined rule is achieved when the first target information meets the first predetermined condition and the target flag meets the second predetermined condition.
[0034] In an optional embodiment, determining whether the first LBA information and the second LBA information meet the continuity condition includes: comparing the first LBA information with the second LBA information and the second target length information to determine whether the first LBA information and the second LBA information meet the continuity condition, wherein the second target information also includes the second target length information, and the second target length information is used to indicate the length of the second target data. In this embodiment, by comparing the first LBA information with the second LBA information and the second target length information, it is determined whether the first LBA information and the second LBA information meet the continuity condition. For example, the second LBA address (i.e., the logical block address of the second target data) is 100, and the length of the second target data is 64K. Assuming that an LBA is 1K (it can also be 512B, or other), if the first LBA address is 164 (=100+64), it can be determined that the first LBA address and the second LBA address are continuous. Through this embodiment, the purpose of determining whether the first LBA information and the second LBA information are continuous is achieved.
[0035] In an optional embodiment, the first LBA information is compared with the second LBA information and the second target length information to determine whether the first LBA information and the second LBA information meet the continuity condition, including: comparing the first LBA information with the second LBA information and the second target length information to obtain a comparison result; when the comparison result indicates that the first LBA corresponding to the first LBA information is equal to the sum of the second LBA corresponding to the second LBA information and the second target length, determining that the first LBA information and the second LBA information meet the continuity condition; when the comparison result indicates that the first LBA corresponding to the first LBA information is not equal to the sum of the second LBA corresponding to the second LBA information and the second target length, determining that the first LBA information and the second LBA information do not meet the continuity condition. In this embodiment, when the first LBA is equal to the sum of the second LBA and the second target length, it can be determined that the first LBA information and the second LBA information meet the continuity condition, that is, if the logical block address (i.e., the first LBA) in the current first request instruction is equal to the sum of the logical block address (i.e., the second LBA) in the previous instruction and the data length requested to be written in the previous instruction (i.e., the second target data length), it can be determined that the logical block addresses of the previous and next two instructions meet the continuity condition. On the contrary, if the first LBA is not equal to the sum of the second LBA and the second target data length, it can be determined that the first LBA information and the second LBA information do not meet the continuity condition. It should be noted that the above request instructions all refer to instructions requesting to write data. Through this embodiment, the purpose of determining whether the first LBA information and the second LBA information meet the continuity condition based on the first LBA, the second LBA and the second target length is achieved.
[0036] In an optional embodiment, storing the first target data in the target solid state drive according to a predetermined rule includes: storing the first target data in the target solid state drive starting from the starting position of the target page and according to the rule of aligning with the size of the page, wherein the target page is used to indicate the next page of the current page, the current page is used to indicate the last page occupied by the second target data requested to be written by the second request instruction in the target solid state drive, and the second request instruction is used to indicate the instruction for requesting to write the second target data received before the first request instruction. In this embodiment, the first target data is stored in the target solid state drive starting from the starting position of the target page and according to the rule of aligning with the size of the page (or called size), the size of the above-mentioned page can also be called the page size, the target page is the next page of the current page, the current page refers to the last page occupied by the second target data requested to be written by the previous instruction of the first request instruction (such as the aforementioned second request instruction) in the target solid state drive, for example, the current page is the Mth page, then the first target data will be stored in the target solid state drive starting from the starting position of the M+1th page according to the rule of aligning with the size of the page, that is, the first target data is stored starting from the new page according to the rule of aligning with the size of the page. According to the rule of aligning with the size of the page, the data is stored in the target solid-state hard disk. Of course, in the subsequent write request instruction (such as the third request instruction) after the first request instruction, as long as the logical block address information (such as the third LBA information) included in the third request instruction meets the continuity condition with the first LBA information, and so on, that is, the LBA information in the current instruction meets the LBA information in the previous instruction, and the data length (such as the third target data length) included in the third request instruction is greater than or equal to the preset length threshold, the data requested to be written in the subsequent request instruction (such as the third target data) is also stored in the target solid-state hard disk according to the rule of aligning with the size of the page. Through this embodiment, the purpose of storing the first target data in the target solid-state hard disk starting from the starting position of the target page and according to the rule of aligning with the size of the page is achieved.
[0037] In an optional embodiment, the method further includes: when it is determined that the current page is not full, filling the remaining space of the current page with invalid data. In this embodiment, if the current page is not full, such as in the aforementioned embodiment, if the Mth page (i.e., the current page) is not full, the remaining space of the current page can be filled with invalid data, so that the first target data requested to be written by the current request instruction (i.e., the first request instruction mentioned above) can be stored in the target solid state drive starting from a new page.
[0038] Obviously, the above described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. The present invention will be specifically described below in conjunction with the embodiments.
[0039] This embodiment provides a method for reading data. The purpose of this embodiment is to improve the reading of sequential data. Because it is found through investigation that most of the user's data is sequential data, the following description is made using a NAND Flash solid state drive as an example.
[0040] In order to improve the sequential data reading performance, the firmware will use the NAND cache read command, which can send the next PAGE data while completing the transmission of the current PAGE data. In this way, when the next read is made, the data has been read from the NAND cell to the NAND cache register, which is equivalent to saving a TR time and improving the reading performance. Figure 3 As shown, Figure 3 The method for reading data according to a specific embodiment of the present invention includes: 1) the first read data LBA=x, the length is the page size, and the data physical address is: n, a cache read command is issued to transfer the data of physical page n to the cache register of NAND, and at the same time, a read command for the next page n+1 is issued; 2) the page data is transmitted, and at the same time, NAND transfers the data of page n+1 to the data register. The cache can prepare the next data while the data is being transmitted, thereby improving the reading performance.
[0041] To use cache read, the logical address must be continuous while the physical address must also be continuous, and the data to be read must be located in the entire PAGE. In actual use, if a user is copying a large file, due to the existence of the OS, the OS needs to save important data of the OS and file system in real time, which will be inserted into the user data, causing the continuous data to be interrupted. As a result, the logically continuous data is physically discontinuous. If the user reads these logically continuous data next time, the read performance will be reduced due to its physical discontinuity.
[0042] Therefore, this embodiment also provides a method for writing data to fundamentally improve the read performance of the solid state drive. The method includes:
[0043] Step 1: When receiving a write request from the host, record the current LBA and the length of the write request data. If the length of the data request is greater than or equal to the threshold we set (corresponding to the aforementioned second predetermined value, or the aforementioned preset length threshold), then mark the current command as valid, otherwise record it as invalid;
[0044] Step 2: When the next write request is received, if the current command data request length is greater than or equal to the threshold we set and is continuous with the previous LBA, then the valid count increases by 1, otherwise it is marked invalid;
[0045] Step 3: Repeat steps 1-2. When the valid count is greater than or equal to the continuous LBA threshold we set (corresponding to the aforementioned first predetermined threshold), the flag (corresponding to the aforementioned target flag bit) will be set to true.
[0046] Step 4: When the Flash Translation Layer (FTL) detects that the flag of the write command is true, it will require the write command to be aligned according to the page size to ensure that subsequent write commands are aligned according to the page size.
[0047] In this way, it can be ensured that as much continuous data as possible is stored in the NAND FLASH and the data is aligned according to the page size.
[0048] Figure 4 is a flow chart of a method for writing data according to a specific embodiment of the present invention, the process comprising:
[0049] S402, receiving a host write command;
[0050] S404, determining whether the data length is greater than or equal to a threshold (corresponding to the aforementioned second predetermined value, or the aforementioned preset length threshold);
[0051] S406, if the data request length is greater than the threshold we set, then mark the current command as valid, otherwise record it as invalid;
[0052] The above S402 to S406 correspond to the above step 1;
[0053] S408, continue writing commands and determine the length and continuity of the data;
[0054] S410, counting valid count; that is, when the data request length in the current write request instruction is greater than or equal to the set threshold and satisfies the continuity condition with the LBA in the previous instruction, the valid count is increased by 1;
[0055] If necessary, an initial value of count (such as 0, 1, or other values) may be preset in the above step S406; the above steps S408 to S410 are repeatedly executed, and if it is determined in step S408 that the data length and / or continuity conditions are not met, the process returns to step S402 and starts again;
[0056] S412, determining whether the valid count is greater than or equal to the LBA threshold;
[0057] S414, when it is determined in the above step S412 that the valid count is greater than or equal to the LBA threshold, the current data is written as a whole page; that is, the data currently requested to be written is stored in the NAND Flash according to the rule of alignment with the page size.
[0058] Compared with the related art that only solves the problem of read performance from the read aspect, in the embodiments of the present invention, the read performance is not only improved from the read aspect, but also improved from the root of the read data (i.e., the physical distribution of the data on the NAND Flash), that is, the purpose of improving the read performance of the solid state drive from the host write is achieved. Through the above embodiments, the read performance is improved by ensuring that the data is stored in the NAND FLASH in accordance with the page size alignment.
[0059] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0060] In this embodiment, a data processing device is also provided. Figure 5 is a structural block diagram of a data processing device according to an embodiment of the present invention. Figure 5 As shown, the device comprises:
[0061] A determination module 502, configured to determine first target information of the first target data based on a first request instruction for requesting to write first target data when a first request instruction is received;
[0062] The processing module 504 is used to store the first target data in the target solid-state hard disk according to a predetermined rule when it is determined that the first target information satisfies a first predetermined condition and when it is determined that the target flag bit satisfies a second predetermined condition, wherein the predetermined rule is used to indicate a rule of alignment with the page size, and the target flag bit is used to indicate whether the target number of requests for continuous requests to write data received before the first request instruction is received for the current time is greater than or equal to a first predetermined threshold, and the target information of the target data indicated by each request included in the target number of requests satisfies the first predetermined condition.
[0063] In an optional embodiment, the processing module 504 includes: a first processing sub-module, for storing the first target data in the target solid-state hard disk according to the predetermined rule when it is determined that the first target information satisfies the first predetermined condition and when it is determined that the value of the target flag bit is the first predetermined value, wherein the value of the target flag bit is set to the first predetermined value when it is determined that the number of target requests is greater than or equal to the first predetermined threshold.
[0064] In an optional embodiment, the processing module 504 includes: a first determination submodule, used to determine the first logical block address LBA information and the first target length information included in the first target information, wherein the first target length information is information indicating the length of the first target data; a second determination submodule, used to determine whether the first LBA information and the second LBA information meet a continuity condition, wherein the second target information includes the second LBA information, and the second target information is information of the second target data determined based on a second request instruction, and the second request instruction is used to indicate an instruction for requesting to write the second target data received before the first request instruction; a third determination submodule, used to determine that the first target information meets the first predetermined condition when it is determined that the first LBA information and the second LBA information meet the continuity condition and when it is determined that the length of the first target data indicated by the first target length information is greater than or equal to a second predetermined value; a second processing submodule, used to store the first target data in the target solid-state hard disk according to the predetermined rule when it is determined that the first target information meets the first predetermined condition and when it is determined that the target flag meets the second predetermined condition.
[0065] In an optional embodiment, the above-mentioned second determination submodule includes: a comparison unit, used to compare the first LBA information with the second LBA information and the second target length information to determine whether the first LBA information and the second LBA information meet the continuity condition, wherein the second target information also includes the second target length information, and the second target length information is used to indicate the length of the second target data.
[0066] In an optional embodiment, the comparison unit includes: a comparison subunit, used to compare the first LBA information with the second LBA information and the second target length information to obtain a comparison result; a first determination subunit, used to determine that the first LBA information and the second LBA information satisfy the continuity condition when the comparison result indicates that the first LBA corresponding to the first LBA information is equal to the sum of the second LBA corresponding to the second LBA information and the second target length; and a second determination subunit, used to determine that the first LBA information and the second LBA information do not satisfy the continuity condition when the comparison result indicates that the first LBA corresponding to the first LBA information is not equal to the sum of the second LBA corresponding to the second LBA information and the second target length.
[0067] In an optional embodiment, the above-mentioned processing module 504 includes: a third processing sub-module, used to store the first target data in the target solid-state hard disk starting from the starting position of the target page and according to the rule of alignment with the size of the page, wherein the target page is used to indicate the next page of the current page, and the current page is used to indicate the last page occupied by the second target data requested to be written by the second request instruction in the target solid-state hard disk, and the second request instruction is used to indicate the instruction for requesting to write the second target data received before the first request instruction.
[0068] In an optional embodiment, the above-mentioned device further includes: a filling module, which is used to fill the remaining space of the current page with invalid data when it is determined that the current page is not full.
[0069] It should be noted that the above modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited to: the above modules are all located in the same processor; or the above modules are located in different processors in any combination.
[0070] An embodiment of the present invention further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.
[0071] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.
[0072] An embodiment of the present invention further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0073] In an exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0074] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.
[0075] Obviously, those skilled in the art should understand that the above modules or steps of the present invention can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order than here, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.
[0076] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A data processing method, characterized in that: include: In case of receiving a first request instruction for requesting to write first target data, determining first target information of the first target data based on the first request instruction; When it is determined that the first target information satisfies a first predetermined condition, and when it is determined that the target flag bit satisfies a second predetermined condition, the first target data is stored in a target solid-state hard disk according to a predetermined rule, wherein the predetermined rule is used to indicate a rule of alignment with a page size, and the target flag bit is used to indicate whether the number of target requests for continuous requests to write data received before the first request instruction is currently received is greater than or equal to a first predetermined threshold, and the target information of the target data indicated by each request included in the number of target requests satisfies the first predetermined condition, and the first predetermined condition includes that the LBA of the target data requested to be written in the current time is continuous with the LBA of the target data requested to be written in the previous time, and / or the data length of the target data requested to be written in each time is greater than a preset length threshold; When it is determined that the first target information satisfies the first predetermined condition and when it is determined that the target flag bit satisfies the second predetermined condition, the first target data is stored in the target solid-state hard disk according to a predetermined rule, including: when it is determined that the first target information satisfies the first predetermined condition and when it is determined that the value of the target flag bit is a first predetermined value, the first target data is stored in the target solid-state hard disk according to the predetermined rule, wherein the value of the target flag bit is set to the first predetermined value when it is determined that the number of target requests is greater than or equal to the first predetermined threshold and the target information of the target data indicated by each request included in the number of target requests satisfies the first predetermined condition.
2. The method according to claim 1, characterized in that When it is determined that the first target information satisfies a first predetermined condition, and when it is determined that the value of the target flag bit satisfies a second predetermined condition, storing the first target data in a target solid state drive according to a predetermined rule includes: Determine first LBA information and first target length information included in the first target information, wherein the first target length information is used to indicate information about the length of the first target data; Determining whether the first LBA information and the second LBA information meet a continuity condition, wherein the second target information includes the second LBA information, the second target information is information of second target data determined based on a second request instruction, and the second request instruction is used to indicate an instruction for requesting to write the second target data received before the first request instruction; When it is determined that the first LBA information and the second LBA information satisfy the continuity condition, and when it is determined that the length of the first target data indicated by the first target length information is greater than or equal to a second predetermined value, determining that the first target information satisfies the first predetermined condition; When it is determined that the first target information satisfies the first predetermined condition, and when it is determined that the target flag bit satisfies the second predetermined condition, the first target data is stored in the target solid state drive according to the predetermined rule.
3. The method according to claim 2, characterized in that Determining whether the first LBA information and the second LBA information meet a continuity condition includes: The first LBA information is compared with the second LBA information and the second target length information to determine whether the first LBA information and the second LBA information meet the continuity condition, wherein the second target information also includes the second target length information, and the second target length information is used to indicate the length of the second target data.
4. The method according to claim 3, characterized in that Comparing the first LBA information with the second LBA information and the second target length information to determine whether the first LBA information and the second LBA information meet the continuity condition, including: Comparing the first LBA information with the second LBA information and the second target length information to obtain a comparison result; When the comparison result indicates that the first LBA corresponding to the first LBA information is equal to the sum of the second LBA corresponding to the second LBA information and the second target length, determining that the first LBA information and the second LBA information satisfy the continuity condition; When the comparison result indicates that the first LBA corresponding to the first LBA information is not equal to the sum of the second LBA corresponding to the second LBA information and the second target length, it is determined that the first LBA information and the second LBA information do not satisfy the continuity condition.
5. The method according to claim 1, characterized in that Storing the first target data in a target solid state drive according to a predetermined rule includes: The first target data is stored in the target solid state drive starting from the starting position of the target page and in accordance with the rule of alignment with the size of the page, wherein the target page is used to indicate the next page of the current page, the current page is used to indicate the last page occupied by the second target data requested to be written by the second request instruction in the target solid state drive, and the second request instruction is used to indicate the instruction for requesting to write the second target data received before the first request instruction.
6. The method according to claim 5, characterized in that The method further comprises: When it is determined that the current page is not full, the remaining space of the current page is filled with invalid data.
7. A data processing device, characterized in that: include: a determining module, configured to determine first target information of the first target data based on a first request instruction when receiving the first request instruction for requesting to write the first target data; A processing module, configured to store the first target data in a target solid-state hard disk according to a predetermined rule when it is determined that the first target information satisfies a first predetermined condition and when it is determined that a target flag bit satisfies a second predetermined condition, wherein the predetermined rule is used to indicate a rule of alignment with a page size, the target flag bit is used to indicate whether the number of target requests for continuous requests to write data received before the first request instruction is currently received is greater than or equal to a first predetermined threshold, and the target information of the target data indicated by each request included in the number of target requests satisfies the first predetermined condition, the first predetermined condition including that an LBA of the target data requested to be written in the current time is continuous with an LBA of the target data requested to be written in the previous time, and / or that the data length of the target data requested to be written in each time is greater than a preset length threshold; The processing module implements the following method: when it is determined that the first target information satisfies the first predetermined condition and when it is determined that the target flag bit satisfies the second predetermined condition, the first target data is stored in the target solid-state hard disk according to a predetermined rule: when it is determined that the first target information satisfies the first predetermined condition and when it is determined that the value of the target flag bit is a first predetermined value, the first target data is stored in the target solid-state hard disk according to the predetermined rule, wherein the value of the target flag bit is set to the first predetermined value when it is determined that the number of target requests is greater than or equal to the first predetermined threshold and the target information of the target data indicated by each request included in the number of target requests satisfies the first predetermined condition.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program implements the steps of the method described in any one of claims 1 to 6 when executed by a processor.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method described in any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Writing performance optimization method and device and storage system
CN105320460A
Method for efficient grouping of cache requests for datapath scheduling
CN110827384A