Data writing method, device, readable storage medium and electronic device
By judging the mixed mode identification and third-level storage unit block count value in NAND Flash, the data writing mode is controlled, which solves the problem of reduced TLC Block life in mixed mode, extends the device life and improves the stability of data writing.
Patent Information
- Application Number
- CN202110986647.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-26
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2041-08-26
AI Technical Summary
The existing mixed mode causes the TLC Block lifespan to be reduced in NAND Flash, especially when the host repeatedly performs erase and write operations at fixed addresses, causing data instability or loss in NAND devices before the specified lifespan.
Obtain the mixed mode identifier and third-level storage unit block count value when receiving a data write request. Only when certain conditions are met (mixed mode is turned on and the count value is less than or equal to the preset value), the mixed mode is used for data writing, otherwise Use regular mode to avoid unnecessary TLC Block erase and write operations.
It effectively avoids the problem of TLC Block life reduction caused by continuous writing in mixed mode, prolongs the service life of NAND devices and improves the stability of data writing.
Smart Images

Figure CN113867624B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of memory, and in particular to a data writing method, device, readable storage medium and electronic device. Background Art
[0002] NAND Flash (computer flash memory device) includes SLC (Single Level Cell) and TLC (Triple Level Cell). Although the performance of SLC is higher than that of TLC, the data storage capacity of TLC is three times that of SLC. Therefore, in order to meet the performance and capacity requirements of the market, the data area of the entire NAND is mainly divided into SLCQueue (data cache area, hereinafter referred to as SLCQ) and TLC Queue (data main storage area, hereinafter referred to as TLCQ).
[0003] When NAND is writing data, it usually writes the data into SLCQ to meet the performance requirements of fast writing. However, due to the limitation of SLCQ storage size, GC (Garbage Collection) is required after SLCQ is full. The introduction of GC greatly reduces the writing speed.
[0004] At present, in order to further improve the speed, MixMode is usually used for data writing. That is, the TLCBlock in TLCQ is used as SLCBlock through a specific erasure method. After the fixed-size SLCQ is consumed, the storage area for data writing can be switched from SLCQ to TLCQ. The equivalent SLCBlock is taken out from TLCQ for use, thereby increasing the duration of high-speed performance.
[0005] However, the existing hybrid mode has a serious disadvantage: erasing TLCBlock as SLCBlock will greatly reduce the life of TLCBlock. In special scenarios, such as when MixMode is enabled, when the host repeatedly performs erase and write operations on a fixed address of TLCBlock, NAND will remain in TLCQ and cannot exit. And constantly using TLCBlock for erase and write will greatly reduce the life of TLCQ, that is, NAND will show data instability or even data loss in the early and middle stages of the specified life. Summary of the invention
[0006] The technical problem to be solved by the present invention is to provide a data writing method to avoid the problem of shortened NAND life in hybrid mode.
[0007] In order to solve the above technical problems, the technical solution adopted by the present invention is:
[0008] A data writing method comprises the steps of:
[0009] receiving a data write request, and obtaining a mixed mode identifier according to the data write request;
[0010] Determine whether the hybrid mode is in the on state according to the hybrid mode identifier. If so, obtain the third-level storage unit block count value and determine whether the third-level storage unit block count value is less than or equal to the first preset value. If so, use the hybrid mode to write data, otherwise, use the normal mode to write data.
[0011] In order to solve the above technical problems, another technical solution adopted by the present invention is:
[0012] A data writing device, comprising:
[0013] A receiving module, used for receiving a data writing request, and obtaining a mixed mode identifier according to the data writing request;
[0014] The judgment module judges whether the hybrid mode is in the on state according to the hybrid mode identifier. If so, obtains the count value of the third-level storage unit block and judges whether the count value of the third-level storage unit block is less than or equal to the first preset value. If so, the hybrid mode is used for data writing, otherwise, the normal mode is used for data writing.
[0015] In order to solve the above technical problems, another technical solution adopted by the present invention is:
[0016] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the computer program implements the steps in the above-mentioned data writing method.
[0017] In order to solve the above technical problems, another technical solution adopted by the present invention is:
[0018] An electronic device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements each step of the above-mentioned data writing method when executing the computer program.
[0019] The beneficial effects of the present invention are as follows: a hybrid mode identifier and a third-level storage cell block count value are added, and when a data write request is received, the hybrid mode identifier and the third-level storage cell block count value are obtained to determine whether the hybrid mode can be used for data writing in the current state. Only when the hybrid mode identifier is in the on state and the third-level storage cell block count value is less than or equal to the first preset value, can the third-level storage cell block be equivalent to a single-level storage cell block for data writing. Otherwise, the conventional mode is used for data writing, thereby avoiding the problem that data is always written in the hybrid mode, causing the host to repeatedly perform erase and write operations at a fixed address, resulting in a greatly reduced NAND life. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 A flowchart of a method for writing data according to an embodiment of the present invention;
[0021] Figure 2 Another step flow chart of a data writing method according to an embodiment of the present invention;
[0022] Figure 3 Another step flow chart of a data writing method according to an embodiment of the present invention;
[0023] Figure 4 A schematic diagram of the structure of a data writing device according to an embodiment of the present invention;
[0024] Figure 5 The figure is a schematic diagram of the structure of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0025] In order to explain the technical content, achieved objectives and effects of the present invention in detail, the following is an explanation in conjunction with the implementation modes and the accompanying drawings.
[0026] Please refer to Figure 1 , a data writing method, comprising the steps of:
[0027] receiving a data write request, and obtaining a mixed mode identifier according to the data write request;
[0028] Determine whether the hybrid mode is in the on state according to the hybrid mode identifier. If so, obtain the third-level storage unit block count value and determine whether the third-level storage unit block count value is less than or equal to the first preset value. If so, use the hybrid mode to write data, otherwise, use the normal mode to write data.
[0029] From the above description, it can be seen that the beneficial effects of the present invention are: adding a hybrid mode identifier and a third-level storage cell block count value, when receiving a data write request, obtaining the hybrid mode identifier and the third-level storage cell block count value to determine whether the hybrid mode can be used for data writing in the current state, and only when the hybrid mode identifier is in the on state and the third-level storage cell block count value is less than or equal to the first preset value, can the third-level storage cell block be equivalent to a single-level storage cell block for data writing, otherwise, the conventional mode is used for data writing, thereby avoiding the problem of always being in the hybrid mode for writing data, causing the host to repeatedly perform erase and write operations at a fixed address, resulting in a greatly reduced NAND life.
[0030] Furthermore, if the hybrid mode flag is in an on state and the third-level storage unit block count value is greater than the first preset value, the hybrid mode flag and the third-level storage unit block count value are reset, and a garbage collection step is performed.
[0031] From the above description, it can be seen that the hybrid mode flag is used to determine whether to enter the hybrid mode, and the storage unit is garbage collected when it is in the closed state, thereby avoiding the problem of reducing the life of the tertiary storage unit due to enabling hybrid mode writing when the tertiary storage unit does not meet the writing conditions.
[0032] Furthermore, the adopting the hybrid mode to write data includes:
[0033] Switching the data writing area to the third-level storage unit area;
[0034] Acquire a third-level storage unit block, and update a count value of the third-level storage unit block;
[0035] The data is written into the third-level storage unit block until the current third-level storage unit block is filled and all data writing is completed.
[0036] From the above description, it can be seen that when obtaining the tertiary storage cell block, the tertiary storage cell block count value is updated, so as to record the third-level storage cell block used, so as to avoid the third-level storage cell block being used exceeding the preset value, resulting in excessive use of the third-level storage cell block and reduced lifespan.
[0037] Furthermore, after the current third-level storage unit block is filled, the step of:
[0038] Determine whether all data have been written. If not, return to the step of determining whether the count value of the third-level storage unit block is less than or equal to the first preset value until all data have been written.
[0039] From the above description, it can be seen that after each tertiary storage cell block is written, when a new tertiary storage cell block is acquired for data writing, it is necessary to determine again whether the tertiary storage cell block count value is less than or equal to the first preset value, so as to make a judgment on each access of the tertiary storage cell block, and update the usage statistics of the tertiary storage cell block in real time to avoid continuously accessing a number of tertiary storage cell blocks exceeding the preset value limit in order to write data.
[0040] Furthermore, after all the data are written, the following steps are included:
[0041] Enter the idle state and perform garbage collection;
[0042] After the garbage collection is completed, the mixed mode flag and the third-level storage unit block count value are reset.
[0043] From the above description, it can be seen that when entering the idle state, garbage collection is performed on the storage unit, and the idle time is effectively used for garbage collection, which can reduce the time for garbage collection in the busy state, and the hybrid mode flag is set to the on state and the third-level storage unit block count value is reset, so that the hybrid mode can be entered again for data writing, thereby improving the efficiency of data writing.
[0044] Furthermore, the step of obtaining the mixed mode identifier according to the data write request includes the following steps:
[0045] Obtain the available amount of the single-level storage unit block, determine whether the available amount of the single-level storage unit block is greater than or equal to the amount of data to be written, if so, write the data into the single-level storage unit block, if not, execute the step of obtaining the mixed mode identification according to the data write request.
[0046] From the above description, it can be seen that by judging whether the available amount of the single-level storage unit block is greater than the amount of data to be written, when the available amount of the single-level storage unit block is sufficient, data can be directly written using the single-level storage unit block, thereby improving data writing efficiency.
[0047] Furthermore, if the hybrid mode is in an on state, it also includes:
[0048] Get the available number of third-order storage unit blocks;
[0049] Determine whether the available number of the tertiary storage unit blocks is greater than or equal to a second preset value, and if so, obtain a tertiary storage unit block count value.
[0050] From the above description, it can be seen that by obtaining the available number of tertiary storage units and determining whether the available number is greater than or equal to the second preset value, the tertiary storage units can be obtained for data writing only when the available number of tertiary storage units is greater than the required number.
[0051] Please refer to Figure 4 Another embodiment of the present invention provides a data writing device, comprising:
[0052] A receiving module, used for receiving a data writing request, and obtaining a mixed mode identifier according to the data writing request;
[0053] The judgment module judges whether the hybrid mode is in the on state according to the hybrid mode identifier. If so, obtains the count value of the third-level storage unit block and judges whether the count value of the third-level storage unit block is less than or equal to the first preset value. If so, the hybrid mode is used for data writing, otherwise, the normal mode is used for data writing.
[0054] Another embodiment of the present invention provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned data writing method are implemented.
[0055] Please refer to Figure 5 Another embodiment of the present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements each step of the above-mentioned data writing method when executing the computer program.
[0056] The data writing method, device, computer-readable storage medium and electronic device of the present invention can be applied to storage devices with mixed mode writing, such as NAND Flash products, and are described below through specific implementation methods:
[0057] Embodiment 1
[0058] Please refer to Figure 1 , a data writing method, comprising the steps of:
[0059] S1, receiving data writing request;
[0060] S2, obtaining the available amount of the single-level storage unit block, determining whether the available amount of the single-level storage unit block is greater than or equal to the amount of data to be written, if so, writing the data into the single-level storage unit block, if not, executing S3;
[0061] S3, obtaining a mixed mode identifier according to the data write request;
[0062] S4, judging whether the hybrid mode is in the on state according to the hybrid mode identifier, if so, obtaining the count value of the third-level storage unit block, judging whether the count value of the third-level storage unit block is less than or equal to the first preset value, if so, adopting the hybrid mode to write data, otherwise, adopting the normal mode to write data; the normal mode is a process of writing data to the single-level storage unit block, and when the single-level storage unit block is insufficient, performing garbage collection on the single-level storage unit block and then writing again;
[0063] If the hybrid mode flag is in the on state and the third-level storage unit block count value is greater than the first preset value, the hybrid mode flag and the third-level storage unit block count value are reset, and a garbage collection step is performed; in an optional implementation, the method further includes: obtaining the available number of third-level storage unit blocks; determining whether the available number of third-level storage unit blocks is greater than or equal to the second preset value, and if so, obtaining the third-level storage unit block count value;
[0064] The hybrid mode for data writing includes:
[0065] Switch the data writing area to the third-level storage unit area; obtain the third-level storage unit block, and update the third-level storage unit block count value; write the data to the third-level storage unit block until the current third-level storage unit block is full; after the data is full of the current third-level storage unit block, determine whether all the data has been written, if not, return to the step of determining whether the third-level storage unit block count value is less than or equal to the first preset value until all the data has been written;
[0066] Please refer to Figure 2 , set the mixed mode flag to MixModeEn, and when MixModeEn is 1, it indicates the on state, and when MixModeEn is 0, it indicates the off state; set the third-level storage unit block count value to MixBlkCnt; set the first preset value to N, and the N value depends on the type of NAND and the needs of the user; set the available number of the third-level storage unit block to TLCBlock number; set the second preset value to Num; the specific steps are as follows:
[0067] After receiving the data write request, determine whether the current number of SCLBlocks (single-level storage unit blocks) is greater than the data write amount. If so, set the data write area to SLCQ and write the data into SLCBlock; if less, determine whether the current MixModeEn value is set to 1. If it is 0, it means that the current mixed mode is in the off state, and perform garbage collection; if it is 1, it means that the current mixed mode is in the on state, and then determine whether the current MixBlkCnt is less than or equal to N and whether the TLCBlock number is greater than or equal to Num;
[0068] If MixBlkCnt and TLCBlock number satisfy the above conditions at the same time, the data write area is set to TLCQ (third-level storage unit block), MixBlkCnt is incremented by 1 while obtaining TLCBlock, and then the data is written into the current TLCBlock; when the data fills the current TLCBlock, determine whether all the data has been written into the TLCBlock. If more data needs to be written, return to the step of determining whether the current MixBlkCnt is less than or equal to N and whether the TLCBlock number is greater than or equal to Num; when all the data has been written but the current TLCBlock has not been filled, wait for the next write instruction, and write the data corresponding to the write instruction into the current TLCBlock until the current TLCBlock is filled, and then execute the above steps after the data fills the current TLCBlock;
[0069] If either MixBlkCnt or TLCBlock number does not satisfy the above conditions, both MixModeEn and MixBlkCnt are set to zero, and garbage collection is performed; after the above garbage collection is completed, return to the step of determining whether the current number of SCLBlocks is greater than the data write amount.
[0070] Embodiment 2
[0071] The difference between this embodiment and the first embodiment is that it further includes initialization of the mixed mode flag and the count value of the third-level storage unit block;
[0072] Please refer to Figure 3 , after all data is written, it includes:
[0073] Entering an idle state and performing garbage collection; after completing the garbage collection, resetting the mixed mode flag and the third-order storage unit block count value; that is, initializing MixModeEn and MixBlkCnt in the idle state, setting MixModeEn to 1, and clearing the value of MixBlkCnt to zero;
[0074] At the same time, this embodiment further adds a step of how to judge the command sent by the host, specifically:
[0075] After the host sends a command, it is determined whether the command is a write command. If it is a write command, the data writing steps of the above embodiment 1 are executed. If it is not a write command, it is determined whether it is another execution command. If it is an execution command, the execution command is executed and the host is waiting for another command to be sent. If it is not an execution command, the idle state is entered and the steps in the above idle state are executed until the host sends another command.
[0076] When the hybrid mode flag is set to zero, the hybrid mode write state cannot be entered; at this time, the host can send a reset instruction to set the hybrid mode flag to one to enter the hybrid mode write state again; or the host enters the idle state and executes the garbage collection step, and then automatically sets the hybrid mode flag to one to enter the hybrid mode write state.
[0077] Embodiment 3
[0078] Please refer to Figure 4 , a data writing device, comprising:
[0079] A receiving module, used for receiving a data writing request, and obtaining a mixed mode identifier according to the data writing request;
[0080] The judgment module judges whether the hybrid mode is in the on state according to the hybrid mode identifier. If so, obtains the count value of the third-level storage unit block and judges whether the count value of the third-level storage unit block is less than or equal to the first preset value. If so, the hybrid mode is used for data writing, otherwise, the normal mode is used for data writing.
[0081] Embodiment 4
[0082] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements each step of a data writing method described in any one of the first or second embodiments above.
[0083] Embodiment 5
[0084] Please refer to Figure 5 , an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, each step in a data writing method as described in any one of Embodiments 1 or 2 is implemented.
[0085] In summary, the present invention provides a data writing method, device, readable storage medium and electronic device. By adding a hybrid mode identifier and a third-level storage unit block count value, when a data writing request is received, the hybrid mode identifier and the third-level storage unit block count value are obtained to determine whether the hybrid mode can be used for data writing in the current state. Only when the hybrid mode identifier is in the on state and the third-level storage unit block count value is less than or equal to a first preset value, can the third-level storage unit block be equivalent to a single-level storage unit block for data writing, otherwise, the conventional mode is used for data writing; and when writing in the hybrid mode, when the third-level storage unit block count value is greater than the first preset value, the hybrid mode identifier is set to zero and the value of the third-level storage unit block count value is cleared to avoid entering the hybrid mode again; only when entering the idle state and performing the garbage collection operation, the hybrid mode identifier is set to one again and the value of the third-level storage unit block count value is cleared to start the hybrid mode writing, so as to avoid being in the hybrid mode for writing data all the time, so that the host repeatedly performs erase and write operations at a fixed address, resulting in a problem of greatly reducing the life of the NAND.
[0086] In the above embodiments provided in the present application, it should be understood that the disclosed methods, devices, computer-readable storage media, and electronic devices can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation, such as multiple components or modules can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or components or modules, which can be electrical, mechanical or other forms.
[0087] The components described as separate components may or may not be physically separated, and the components shown as components may or may not be physical modules, that is, they may be located in one place or distributed on multiple network modules. Some or all of the components may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0088] In addition, each functional module in each embodiment of the present invention may be integrated into one processing module, or each component may exist physically separately, or two or more modules may be integrated into one module. The above integrated modules may be implemented in the form of hardware or in the form of software functional modules.
[0089] If the integrated module is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0090] It should be noted that, for the convenience of description, the aforementioned method embodiments are all described as a series of action combinations, but those skilled in the art should be aware that the present invention is not limited by the described action sequence, because according to the present invention, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.
[0091] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0092] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent transformations made using the contents of the present invention's specification and drawings, or directly or indirectly applied in related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A data writing method, characterized in that: Includes steps: receiving a data write request, and obtaining a mixed mode identifier according to the data write request; Determine whether the hybrid mode is in the on state according to the hybrid mode identifier, if so, obtain the third-level storage unit block count value, determine whether the third-level storage unit block count value is less than or equal to the first preset value, if so, use the hybrid mode to write data, otherwise, use the normal mode to write data; The hybrid mode for data writing includes: Switching the data writing area to the third-level storage unit area; Acquire a third-level storage unit block, and update a count value of the third-level storage unit block; Writing data into the tertiary storage unit block until the current tertiary storage unit block is full or all data writing is completed; After the current third-level storage unit block is filled, the following steps are also included: Determine whether all data have been written. If not, return to the step of determining whether the count value of the third-level storage unit block is less than or equal to the first preset value until all data have been written.
2. A data writing method according to claim 1, characterized in that: If the hybrid mode flag is in an on state and the third-level storage unit block count value is greater than the first preset value, the hybrid mode flag and the third-level storage unit block count value are reset, and a garbage collection step is performed.
3. A data writing method according to claim 1, characterized in that: After all the data are written, it includes: Enter the idle state and perform garbage collection; After the garbage collection is completed, the mixed mode flag and the third-level storage unit block count value are reset.
4. A data writing method according to any one of claims 1 to 3, characterized in that: The step of obtaining the mixed mode identifier according to the data writing request includes the following steps: Obtain the available amount of the single-level storage unit block, determine whether the available amount of the single-level storage unit block is greater than or equal to the amount of data to be written, if so, write the data into the single-level storage unit block, if not, execute the step of obtaining the mixed mode identification according to the data write request.
5. A data writing method according to any one of claims 1 to 3, characterized in that: If the hybrid mode is turned on, the method further includes: Get the available number of third-order storage unit blocks; Determine whether the available number of the tertiary storage unit blocks is greater than or equal to a second preset value, and if so, obtain a tertiary storage unit block count value.
6. A data writing device, characterized in that: include: A receiving module, used for receiving a data writing request, and obtaining a mixed mode identifier according to the data writing request; a judgment module, judging whether the hybrid mode is in an on state according to the hybrid mode identifier, and if so, obtaining a third-level storage unit block count value, judging whether the third-level storage unit block count value is less than or equal to a first preset value, and if so, adopting the hybrid mode to write data, otherwise, adopting the normal mode to write data; The hybrid mode for data writing includes: Switching the data writing area to the third-level storage unit area; Acquire a third-level storage unit block, and update a count value of the third-level storage unit block; Writing data into the tertiary storage unit block until the current tertiary storage unit block is full or all data writing is completed; After the current third-level storage unit block is filled, the following steps are also included: Determine whether all data have been written. If not, return to the step of determining whether the count value of the third-level storage unit block is less than or equal to the first preset value until all data have been written.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, each step in a data writing method as described in any one of claims 1 to 5 is implemented.
8. 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 processor implements the steps in the data writing method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Data Storage Device and Method for Operating Nonvolatile Memory
CN109147849A
Storage device, data writing method thereof, and storage device
CN109491592A
Method and device for improving writing performance of SSD large file, computer equipment and storage medium
CN110209357A
Data caching method and device, electronic equipment and storage medium
CN112162695A
Memory controller and operating method thereof
CN112306385A
