Memory data processing method and apparatus, computer device, and storage medium
By determining whether the candidate block meets the data transfer processing conditions, the target block is selected and wear leveling is performed, which solves the problem of uneven wear caused by blocks with a large number of flash memory erase/write cycles and achieves effective wear leveling of the memory.
Patent Information
- Application Number
- PCT/CN2025/092698
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-06-06
- Filing Date
- 2025-04-30
- Publication Date
- 2025-12-11
AI Technical Summary
In scenarios involving changes in both hot and cold data, the wear of blocks with a high number of write/erase cycles in flash memory becomes more uneven, leading to uneven wear of the memory.
By determining whether the candidate block meets the data transfer processing conditions, the target block is selected, and the data block to be transferred is moved to the target block through wear leveling, thereby controlling the usage frequency of blocks with a large number of flash memory erase/write cycles.
This effectively prevents the number of erase/write cycles of large flash memory blocks from continuously increasing, thus achieving wear leveling of the memory.
Smart Images

Figure CN2025092698_11122025_PF_FP_ABST
Abstract
Description
Memory data processing method and device, computer device, and storage medium
[0001] Cross-reference to Related Applications
[0002] This application claims priority to the Chinese patent application No. 202410725793.7, filed on June 6, 2024, and entitled "Memory data processing method and device, computer device, and storage medium", the entire contents of which are incorporated herein by reference. TECHNICAL FIELD
[0003] The present application relates to the technical field of memory, and in particular to a memory data processing method, device, computer device, and storage medium. BACKGROUND
[0004] The hot and cold conditions of data will not remain unchanged and will change with the use of the user, so there is wear leveling to move the cold data on the block with less flash erase-write times to the block with more flash erase-write times, and then the cold data becomes hot data again. When the data on the block with more flash erase-write times is released by the host, the wear leveling continues to move the data on the block with less flash erase-write times to the block with more flash erase-write times that is released, so that the block with more flash erase-write times continues to become larger, and the wear is more uneven. SUMMARY
[0005] Therefore, the purpose of the present application includes, for example: in order to overcome the deficiencies in the related art, a memory data processing method, device, equipment and storage medium are provided, which are used for selecting a target block for moving data when selecting a block to move data, by judging whether the selected block meets the data moving processing condition, to control the use frequency of the block with more flash erase-write times, thereby solving the problem of more uneven wear caused by performing wear leveling in the cold and hot data change scenario.
[0006] The present application provides the following technical solutions:
[0007] An embodiment of the present application provides a memory data processing method, which comprises:
[0008] When the host writes data to the memory and triggers the memory block replacement, it is judged whether wear leveling needs to be performed according to the flash erase-write times of the memory;
[0009] If the wear leveling needs to be performed, the block with the maximum flash erase-write times is found from the memory as a candidate block to be moved in, and it is judged whether the candidate block meets the data moving processing condition;
[0010] The step of judging whether the candidate moving-in block meets the data moving processing condition comprises: judging whether the candidate moving-in block is a data moving-in block when wear leveling is performed; if the candidate moving-in block is not the data moving-in block when wear leveling is performed, the candidate moving-in block meets the data moving processing condition, and the candidate moving-in block is determined as the target moving-in block.
[0011] The data to be moved of the data block to be moved is moved to the target moving-in block by the wear leveling.
[0012] In an embodiment, after the data to be moved of the data block to be moved is moved to the target moving-in block by the wear leveling, the method comprises:
[0013] A data write in the target moving-in block is recorded as a wear leveling data write mark, and a current write data sequence number is updated to the target moving-in block as a historical write data sequence number, and the write mark is configured to indicate whether the candidate moving-in block is a data moving-in block when wear leveling is performed.
[0014] The current write data sequence number is determined according to the number of times of writing flash memory.
[0015] In an embodiment, after the step of judging whether the candidate moving-in block is a data moving-in block when wear leveling is performed, the method further comprises:
[0016] If the candidate moving-in block is the data moving-in block when wear leveling is performed, a sequence number difference between a historical write data sequence number and a current write data sequence number of the candidate moving-in block is determined, and whether the sequence number difference is greater than a target threshold is judged.
[0017] If the sequence number difference is greater than the target threshold, the candidate moving-in block meets the data moving processing condition, and the candidate moving-in block is determined as the target moving-in block.
[0018] The target threshold is determined according to a product of a target multiple and a sequence number increase value after a full-disk write round of the host to the memory.
[0019] In an embodiment, after the step of judging whether the sequence number difference is greater than the target threshold, the method further comprises:
[0020] If the sequence number difference is less than or equal to the target threshold, the candidate moving-in block does not meet the data moving processing condition, a new candidate moving-in block is searched from the memory again based on the number of times of flash memory erasing and writing of the candidate moving-in block, and the step of judging whether the candidate moving-in block meets the processing condition is performed on the new candidate moving-in block.
[0021] In an embodiment, the re-finding the new candidate move-in block from the memory based on the flash erase count of the candidate move-in block comprises:
[0022] taking the flash erase count of the candidate move-in block as a search upper limit;
[0023] finding the new candidate move-in block from the memory based on the search upper limit.
[0024] In an embodiment, the judging whether the wear leveling needs to be performed comprises:
[0025] judging whether a number of times of not performing wear leveling of the memory is a first value;
[0026] if the number of times of not performing wear leveling is not the first value, decreasing the number of times of not performing wear leveling;
[0027] if the number of times of not performing wear leveling is the first value, determining a flash erase difference between a maximum flash erase count and a minimum flash erase count of the memory, and judging whether the flash erase difference is greater than or equal to a tolerable threshold value;
[0028] if the flash erase difference is greater than or equal to the tolerable threshold value, the wear leveling needs to be performed.
[0029] In an embodiment, the method further comprises:
[0030] if the number of times of finding the candidate move-in block not satisfying the data move processing condition is greater than a target number of times, stopping the step of re-finding the new candidate move-in block from the memory, and updating the number of times of not performing wear leveling from the first value to a second value.
[0031] In an embodiment, the target multiple is 4.
[0032] In an embodiment, the target number of times is set to 5, the first value is 0, and the second value is 100.
[0033] Embodiments of the present application provide a memory data processing device, the device comprising:
[0034] a judging module configured to judge whether a wear leveling needs to be performed according to a flash erase count of a memory when the memory is triggered to be replaced by a host writing data to the memory;
[0035] a finding module configured to, if the wear leveling needs to be performed, find a maximum flash erase block from the memory as a candidate move-in block, and judge whether the candidate move-in block satisfies a data move processing condition;
[0036] The searching module is further configured to determine whether the candidate data moving-in block is a data moving-in block for performing wear leveling, and if the candidate data moving-in block is not a data moving-in block for performing wear leveling, the candidate data moving-in block satisfies a data moving processing condition, and the candidate data moving-in block is determined as a target data moving-in block.
[0037] The moving module is configured to move the data to be moved of the data block to be moved to the target data moving-in block by the wear leveling.
[0038] In an embodiment, the moving module is further configured to record a data write in the target data moving-in block as a wear leveling data write mark, and the write mark is configured to indicate whether the candidate data moving-in block is a data moving-in block for performing wear leveling.
[0039] In an embodiment, the searching module is further configured to, if the serial number difference value is less than or equal to the target threshold value, the candidate data moving-in block does not satisfy a data moving processing condition, and a new candidate data moving-in block is searched from the memory based on the flash erase number of the candidate data moving-in block, and the step of determining whether the candidate data moving-in block satisfies a processing condition is performed on the new candidate data moving-in block.
[0040] In an embodiment, the searching module is further configured to take the flash erase number of the candidate data moving-in block as a searching upper limit, and search the new candidate data moving-in block from the memory based on the searching upper limit.
[0041] In an embodiment, the determining module is further configured to determine whether a wear leveling non-performing number of the memory is a first value, if the wear leveling non-performing number is not the first value, the wear leveling non-performing number is decremented, if the wear leveling non-performing number is the first value, a flash erase difference value between a maximum value and a minimum value of the flash erase number in the memory is determined, and it is determined whether the erase difference value is greater than or equal to a tolerable threshold value, and if the erase difference value is greater than or equal to the tolerable threshold value, the wear leveling needs to be performed.
[0042] Embodiments of the present application provide a computer device, including a memory and a processor, the memory stores a computer program, and the computer program is executed by the processor to implement steps of the memory data processing method according to the foregoing embodiments.
[0043] Embodiments of the present application provide a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement steps of the memory data processing method according to the foregoing embodiments.
[0044] In the memory data processing method, device, equipment and storage medium disclosed in the present application, after the host writes data to the memory, it is judged whether the wear leveling needs to be performed according to the flash memory erase-write times of the memory; if the wear leveling needs to be performed, the flash memory erase-write times maximum block in the memory is found as a candidate moving-in block, and it is judged whether the candidate moving-in block meets the data moving processing condition; wherein the step of judging whether the candidate moving-in block meets the data moving processing condition comprises: judging whether the candidate moving-in block is the data moving-in block during the wear leveling; if the candidate moving-in block is not the data moving-in block during the wear leveling, the candidate moving-in block meets the data moving processing condition, and the candidate moving-in block is determined as a target moving-in block; if the candidate moving-in block is not the data moving-in block during the wear leveling, it is judged whether the sequence number difference between the historical write data sequence number and the current write data sequence number of the candidate moving-in block is greater than a target threshold; if yes, the data moving processing condition is met; otherwise, the candidate moving-in block is re-found based on the wear times of the candidate moving-in block as an upper limit, the finding times reach a certain number, the number of times that the memory does not perform the wear leveling is set, the value is decreased each time when it is judged whether the wear leveling is performed, and until the value is 0, the wear leveling is performed according to the maximum and minimum wear difference of the memory; the data to be moved of the data block to be moved is moved to the target moving-in block through the wear leveling. In this way, by judging whether the candidate moving-in block meets the data moving processing condition, the use frequency of the block with large flash memory erase-write times is controlled, the flash memory erase-write times of the block with large flash memory erase-write times in the memory is prevented from continuously increasing, and thus the effective wear leveling is ensured.
[0045] In order to make the above objectives, features and advantages of the present application more apparent and easy to understand, the following will specifically describe a preferred embodiment in conjunction with the accompanying drawings. BRIEF DESCRIPTION OF DRAWINGS
[0046] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiments. It should be understood that the following drawings only show some embodiments of the present application, and thus should not be regarded as a limitation to the scope. For those skilled in the art, other related drawings can also be obtained without paying creative labor on the basis of these drawings.
[0047] Fig. 1 shows a flowchart of the memory data processing method proposed in the present application;
[0048] Fig. 2 shows another flowchart of the memory data processing method proposed in the present application;
[0049] Fig. 3 shows still another flowchart of the memory data processing method proposed in the present application;
[0050] FIG. 4 shows another flow diagram of the memory data processing method according to the present application;
[0051] FIG. 5 shows a structural diagram of the memory data processing apparatus according to the present application. DETAILED DESCRIPTION
[0052] Embodiments of the present application are described in detail below with reference to the accompanying drawings. The same or similar components are denoted by the same or similar reference numerals throughout the drawings, and repeated description is omitted. The embodiments described below are examples for explaining the present application, and should not be construed as limiting the present application.
[0053] It should be noted that the terms "first", "second" are used only for descriptive purposes, and should not be construed as indicating or implying relative importance or implying the number of the technical features indicated. Therefore, the features with "first", "second" can explicitly or implicitly include one or more features. In the description of the present application, the meaning of "plurality" is two or more, unless otherwise specifically defined.
[0054] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used in the description of the specification of the template is only for the purpose of describing specific embodiments and is not intended to limit the present application. The term "and / or" used herein includes any and all combinations of one or more related listed items.
[0055] Embodiments of the present application provide a memory data processing method for selecting a target block for moving data in a candidate block, by judging whether the candidate block meets the data moving processing condition, to control the frequency of use of the block with a large number of flash erase times, thereby solving the problem of more uneven wear caused by performing wear leveling in the cold and hot data change scenario.
[0056] Referring to FIG. 1, the memory data processing method includes steps S101-S103, which are described in detail below.
[0057] S101, when the host triggers the memory block change after writing data to the memory, it is determined whether wear leveling needs to be performed according to the flash erase times of the memory.
[0058] In the embodiment, when a new block is applied for writing host data, the new block is first erased and then data is written, at this time, the data is written to the erased new block, which changes the flash memory Program / Erase Cycle (PE), so the memory needs to determine whether the PE is unbalanced, and then determine whether the wear leveling (WL) needs to be performed, so that the wear degree of each flash memory particle can be kept in a relatively consistent state and finally scrapped at the same time.
[0059] In an embodiment, the determining whether the wear leveling needs to be performed includes: determining whether the number of times of not performing the wear leveling is a first value; if the number of times of not performing the wear leveling is not the first value, the number of times of not performing the wear leveling is decremented; if the number of times of not performing the wear leveling is the first value, a PE difference between a maximum value of the flash memory Program / Erase Cycle (PE) and a minimum value of the flash memory PE in the memory is determined, and it is determined whether the PE difference is greater than or equal to a tolerable threshold; if the PE difference is greater than or equal to the tolerable threshold, the wear leveling needs to be performed.
[0060] It should be noted that the number of times of not performing the wear leveling is a variable set, which can be used to control whether the wear leveling needs to be performed after the memory applies for a new block. For example, if the number of times of not performing the wear leveling is set to 2, after the variable is set, the value of the variable is decremented each time the memory applies for a new block, and when the value of the variable is 0, it is necessary to determine whether the wear leveling needs to be performed.
[0061] In the embodiment, after the memory applies for a new block, the memory needs to determine whether the number of times of not performing the wear leveling is a first value, and the first value can be 0; when the number of times of not performing the wear leveling is not 0, that is, the wear leveling does not need to be performed this time the memory applies for a new block, the number of times of not performing the wear leveling is decremented by 1; if the number of times of not performing the wear leveling is 0, that is, the wear leveling can be performed this time, a PE difference between a maximum value of the flash memory Program / Erase Cycle (PE) and a minimum value of the flash memory PE in the memory is determined, and the memory further determines whether the PE difference is greater than or equal to a tolerable threshold; if the PE difference is greater than or equal to the tolerable threshold, the wear leveling needs to be performed, so as to ensure that the PE difference in the memory is small.
[0062] In step S102, if the wear leveling needs to be performed, a maximum block of the flash memory Program / Erase Cycle (PE) is found from the memory as a candidate block to be moved in, and it is determined whether the candidate block to be moved in satisfies a data moving processing condition.
[0063] In the embodiment, when the wear leveling is not performed for 0 times, the PE difference between the maximum PE value and the minimum PE value in the memory is greater than or equal to the tolerable threshold, and the wear leveling needs to be performed, the data block with the maximum PE value is found from the free blocks in the memory as the candidate moved-in block, and it is determined whether the candidate moved-in block satisfies the data moving condition. In this way, the data block with the maximum PE value can be avoided from being moved in the hot data again, so that the wear leveling is avoided to be more uneven.
[0064] Referring to FIG. 2, in an embodiment, the step of determining whether the candidate moved-in block satisfies the data moving processing condition includes steps S1021-S1022, which are described in detail as follows.
[0065] In step S1021, it is determined whether the candidate moved-in block is the data moved-in block when the wear leveling is performed.
[0066] In step S1022, if the candidate moved-in block is not the data moved-in block when the wear leveling is performed, the candidate moved-in block satisfies the data moving processing condition, and the candidate moved-in block is determined as the target moved-in block.
[0067] In the embodiment, after the candidate moved-in block is found, it is determined according to the metadata of the candidate moved-in block whether the candidate moved-in block is the data moved-in block when the wear leveling is performed. If the candidate moved-in block is not the data moved-in block when the wear leveling is performed, the candidate moved-in block satisfies the data moving processing condition, and the candidate moved-in block is determined as the target moved-in block.
[0068] It should be noted that if the candidate moved-in block is the data moved-in block when the wear leveling is performed, it indicates that the candidate moved-in block is the block with the large PE value to which the cold data is written last time, and the candidate moved-in block is released and written with new data. It indicates that the data written in the candidate moved-in block is not the cold data, but the hot data, and the candidate moved-in block will have a larger PE value if the data is continuously written, and the wear leveling will be more uneven. Therefore, to avoid the wear leveling to be more uneven, the data needs to be moved into the candidate moved-in block when the candidate moved-in block is not the data moved-in block when the wear leveling is performed.
[0069] In step S103, the data to be moved in the data block to be moved is moved to the target moved-in block by the wear leveling.
[0070] In the embodiment, the block with the small PE value is taken as the data block to be moved in, and after the target moved-in block satisfying the data moving processing condition is determined, the valid data, i.e., the data to be moved, on the data block to be moved in is moved to the target moved-in block. In this way, the data on the block with the small PE value is avoided from being continuously moved to the block with the large PE value from which the data is released, so that the PE value of the block with the large PE value is avoided from continuously increasing.
[0071] In a specific embodiment, after the to-be-carried data of the to-be-carried data block is carried to the target carrying-in block by the wear leveling, the method further comprises: recording a write mark of data write as wear leveling data in the target carrying-in block, and updating a current write data sequence number to a historical write data sequence number of the target carrying-in block, the write mark being configured to indicate whether the to-be-selected carrying-in block is a data carrying-in block when wear leveling is performed; and wherein the current write data sequence number is determined according to the number of times of writing the memory to the flash memory.
[0072] In the embodiment, each time the host writes data to the memory, a write mark is recorded in the metadata of the target carrying-in block, indicating whether the target carrying-in block is a data carrying-in block when wear leveling is performed, i.e., whether the to-be-selected carrying-in block meets the data carrying processing condition is determined according to whether the write mark is contained in the metadata of the to-be-selected carrying-in block.
[0073] The current write data sequence number is generated according to the number of times of writing data, and when a data block of the memory is carried by the WL as a carrying-in block, the carrying-in block synchronously records the current write data sequence number as a historical write data sequence number of the carrying-in block. For example, when the memory writes data to the flash memory for the 3001th time, the current write data sequence number is generated as 3001, and when the WL carries data after the host writes data, the current write data sequence number 3001 is recorded as a historical write data sequence number of the carrying-in block.
[0074] Referring to FIG. 3, in a specific embodiment, after it is determined whether the to-be-selected carrying-in block is a data carrying-in block when wear leveling is performed, the method further comprises steps S1023-S1024, which are described in detail as follows.
[0075] In step S1023, if the to-be-selected carrying-in block is a data carrying-in block when wear leveling is performed, the sequence number difference between the historical write data sequence number and the current write data sequence number of the to-be-selected carrying-in block is determined, and it is determined whether the sequence number difference is greater than a target threshold.
[0076] In step S1024, if the sequence number difference is greater than the target threshold, the to-be-selected carrying-in block meets the data carrying processing condition, and the to-be-selected carrying-in block is determined as the target carrying-in block.
[0077] In the embodiment, the sequence number increase value of the host writing a round of data to all data blocks in the memory is determined, and the target threshold is determined according to the product of the target multiple and the sequence number increase value. The target multiple can be 4. If the to-be-selected moving-in block is a data moving-in block when wear leveling is performed, the sequence number difference between the historical write data sequence number of the to-be-selected moving-in block and the current write data sequence number corresponding to the write data of the host this time is determined, and it is determined whether the sequence number difference is greater than the target threshold. If the sequence number difference is greater than the target threshold, the to-be-selected moving-in block satisfies the data moving processing condition, and the to-be-selected moving-in block is determined as the target moving-in block.
[0078] It should be noted that if the sequence number difference between the historical write data sequence number and the current write data sequence number of the to-be-selected moving-in block is greater than the sequence number increase value of writing a round of data to all blocks, it indicates that the data in the to-be-selected moving-in block is written and then not released or erased for a long time and then used after being released or erased, and the sequence number increase value greater than 4 times is to control the use of the block storing hot data for 4 times, and the block is used again to reduce the use frequency of the PE large block.
[0079] In a specific embodiment, after the step of determining whether the sequence number difference is greater than the target threshold, the method further includes: if the sequence number difference is less than or equal to the target threshold, the to-be-selected moving-in block does not satisfy the data moving processing condition, a new to-be-selected moving-in block is searched from the memory based on the flash erase-write times of the to-be-selected moving-in block, and the step of determining whether the to-be-selected moving-in block satisfies the data moving processing condition is performed on the new to-be-selected moving-in block.
[0080] In the embodiment, if the sequence number difference is less than or equal to the target threshold, the to-be-selected moving-in block 1 does not satisfy the data moving processing condition, and a new to-be-selected moving-in block is searched from the idle blocks in the memory except the to-be-selected moving-in block corresponding to the sequence number difference, that is, the data block with the largest PE value in the memory except the to-be-selected moving-in block corresponding to the sequence number difference is searched as the new to-be-selected moving-in block, and it is determined whether the new to-be-selected moving-in block satisfies the data moving processing condition.
[0081] It should be noted that before the step of determining whether the new to-be-selected moving-in block satisfies the data moving processing condition, it is further needed to determine whether the PE difference between the PE value of the new to-be-selected moving-in block and the minimum PE value of the memory is within the tolerable threshold of triggering the WL data moving, and if the PE difference at this time is less than the tolerable threshold, the searching of the new to-be-selected moving-in block is stopped, and the WL data moving process this time is cancelled.
[0082] Referring to FIG. 4, in a specific embodiment, the step of searching the new to-be-selected moving-in block from the memory based on the flash erase-write times of the to-be-selected moving-in block includes steps S401-S402, which are described in detail as follows.
[0083] Step S401, the number of flash erase and write of the candidate block to be moved in is taken as the upper limit of the search.
[0084] Step S402, the new candidate block to be moved in is searched from the memory based on the upper limit of the search.
[0085] In the embodiment, the PE value of the candidate block to be moved in is taken as the upper limit of the search, and the data block with the largest PE value is searched downward according to the upper limit of the search as the new candidate block to be moved in.
[0086] In a specific embodiment, if the number of times of searching the candidate block to be moved in that does not meet the data moving processing condition is greater than the target number, the step of searching the candidate block to be moved in from the memory is stopped, and the number of times of not performing wear leveling is updated from the first value to a second value.
[0087] In the embodiment, if the number of times of searching the candidate block to be moved in that does not meet the data moving processing condition is greater than the target number, the step of searching the new candidate block to be moved in from the memory is stopped, and the WL data moving process is cancelled, and the number of times of not performing wear leveling is updated from the first value to a second value.
[0088] The target number can be set to 5, and after the candidate block to be moved in searched by step S102 does not meet the data moving processing condition, the new candidate block to be moved in is searched again for four times, and also does not meet the data moving processing condition, at this time, the searching of the new candidate block to be moved in from the memory is stopped. At the same time, the second value can also be set to other values except the first value according to actual needs, for example, in the case of the first value being 0, the second value can be 100. When the memory applies a new block, the second value is reduced by 1, until the second value 100 is reduced to the first value 0, and it is determined whether the tolerable threshold of triggering WL is reached to determine whether WL needs to be performed. In this way, when the block to be moved in for WL cannot be found, frequent searching can be avoided.
[0089] The memory data processing method provided in the embodiment is used for judging whether wear leveling needs to be performed according to the flash memory erase times of the memory after a new block of the memory is applied for once; if the wear leveling needs to be performed, a block with the maximum flash memory erase times is found from the memory as a candidate moving-in block, and whether the candidate moving-in block meets data moving processing conditions is judged; wherein the step of judging whether the candidate moving-in block meets the data moving processing conditions comprises judging whether the candidate moving-in block is a data moving-in block when the wear leveling is performed; if the candidate moving-in block is not the data moving-in block when the wear leveling is performed, the candidate moving-in block meets the data moving processing conditions, and the candidate moving-in block is determined as a target moving-in block; and the data to be moved of the data block to be moved is moved to the target moving-in block through the wear leveling. In this way, by judging whether the candidate moving-in block meets the data moving processing conditions, the use frequency of the block with the larger flash memory erase times is controlled, and the flash memory erase times of the block with the larger flash memory erase times in the memory is prevented from continuously increasing, so that effective wear leveling is ensured.
[0090] In addition, the embodiment of the application provides a memory data processing device 500, please see Figure 5, the device comprises:
[0091] The judging module 501 is configured to judge whether wear leveling needs to be performed according to the flash memory erase times of the memory when the host triggers the memory block replacement after writing data to the memory;
[0092] The finding module 502 is configured to find a block with the maximum flash memory erase times from the memory as a candidate moving-in block if the wear leveling needs to be performed, and judge whether the candidate moving-in block meets data moving processing conditions;
[0093] The finding module 502 is further configured to judge whether the candidate moving-in block is a data moving-in block when the wear leveling is performed; if the candidate moving-in block is not the data moving-in block when the wear leveling is performed, the candidate moving-in block meets the data moving processing conditions, and the candidate moving-in block is determined as a target moving-in block;
[0094] The moving module 503 is configured to move the data to be moved of the data block to be moved to the target moving-in block through the wear leveling.
[0095] Optionally, the moving module 503 is further configured to record data writing as a wear leveling data writing mark in the target moving-in block, and update the current writing data serial number to the target moving-in block as a historical writing data serial number, and the writing mark is configured to indicate whether the candidate moving-in block is a data moving-in block when the wear leveling is performed;
[0096] The device further comprises a comprehensive module configured to determine the current write data sequence number according to the number of times of writing flash memory of the memory.
[0097] Optionally, the searching module 502 is further configured to, if the to-be-selected move-in block is a data move-in block in the execution of wear leveling, determine a sequence number difference value between the historical write data sequence number and the current write data sequence number of the to-be-selected move-in block, and determine whether the sequence number difference value is greater than a target threshold value; if the sequence number difference value is greater than the target threshold value, the to-be-selected move-in block satisfies a data move processing condition, and the to-be-selected move-in block is determined as a target move-in block.
[0098] The comprehensive module is further configured to determine a sequence number increase value after a full-disk write round of the host to the memory, and determine the target threshold value according to a product of a target multiple and the sequence number increase value.
[0099] Optionally, the searching module 502 is further configured to, if the sequence number difference value is less than or equal to the target threshold value, the to-be-selected move-in block does not satisfy the data move processing condition, and a new to-be-selected move-in block is searched from the memory again based on the number of times of flash memory erasing and writing of the to-be-selected move-in block, and the step of determining whether the to-be-selected move-in block satisfies the processing condition is performed on the new to-be-selected move-in block.
[0100] Optionally, the searching module 502 is further configured to take the number of times of flash memory erasing and writing of the to-be-selected move-in block as a search upper limit; and search the new to-be-selected move-in block from the memory based on the search upper limit.
[0101] Optionally, the determining module 501 is further configured to determine whether the number of times of not executing wear leveling of the memory is a first value; if the number of times of not executing wear leveling is not the first value, the number of times of not executing wear leveling is decremented; if the number of times of not executing wear leveling is the first value, a difference value of the maximum number of times of flash memory erasing and writing and the minimum number of times of flash memory erasing and writing in the memory is determined, and it is determined whether the difference value of erasing and writing is greater than or equal to a tolerable threshold value; if the difference value of erasing and writing is greater than or equal to the tolerable threshold value, the wear leveling needs to be executed.
[0102] Optionally, the searching module 502 is further configured to, if the number of times of searching the to-be-selected move-in block that does not satisfy the data move processing condition is greater than a target number of times, stop performing the step of searching the new to-be-selected move-in block from the memory, and update the number of times of not executing wear leveling from the first value to a second value.
[0103] The device provided by the embodiment of the present application can perform the steps of the memory data processing method provided in the foregoing embodiments, and thus will not be described again.
[0104] The memory data processing apparatus provided in the embodiment can judge whether the wear leveling needs to be performed according to the flash erase-write times of the memory after the host writes data to the memory; if the wear leveling needs to be performed, a flash erase-write times maximum block in the memory is found as a candidate moving-in block, and whether the candidate moving-in block satisfies a data moving processing condition is judged; wherein the step of judging whether the candidate moving-in block satisfies the data moving processing condition comprises judging whether the candidate moving-in block is a data moving-in block during the wear leveling; if the candidate moving-in block is not the data moving-in block during the wear leveling, the candidate moving-in block satisfies the data moving processing condition, and the candidate moving-in block is determined as a target moving-in block; and the data to be moved of the data block to be moved is moved to the target moving-in block through the wear leveling. In this way, by judging whether the candidate moving-in block satisfies the data moving processing condition, the use frequency of the block with large flash erase-write times is controlled, and the flash erase-write times of the block with large flash erase-write times in the memory is prevented from continuously increasing, so that effective wear leveling is ensured.
[0105] In addition, the embodiment of the present application provides a computer device, comprising a memory and a processor, the memory stores a computer program, and the computer program is executed by the processor to implement the memory data processing method provided in the foregoing embodiments.
[0106] The device provided in the embodiments of the present application can execute the steps of the memory data processing method provided in the foregoing embodiments, and thus will not be described herein again.
[0107] The embodiment of the present application provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the memory data processing method provided in the foregoing embodiments.
[0108] In the embodiment, the computer readable storage medium can be a read-only memory (READ-ONLY MEMORY, ROM for short), a random access memory (RANDOM ACCESS MEMORY, RAM for short), a magnetic disk or an optical disk, etc.
[0109] The computer readable storage medium provided in the embodiment can implement the memory data processing method provided in the foregoing embodiments, and thus will not be described herein again.
[0110] In all the examples shown and described herein, any specific value should be interpreted as merely exemplary and not as a limitation, and thus other examples of the example embodiments can have different values.
[0111] It should be noted that like reference numerals and characters refer to like items throughout the attached drawings and that different shows are meant to cross-reference like items for a successive drawing.
[0112] The above-described embodiments are merely illustrative for several embodiments of the present application, and the description is relatively specific and detailed, but should not be understood as limiting the scope of the present application. It should be noted that for those of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Industrial applicability
[0113] The present application provides a memory data processing method and device, which avoids the continuous increase of the flash erase-write times of the large block of flash memory in the memory, thereby ensuring effective wear leveling and improving the storage effect.
[0114] In addition, it can be understood that the memory data processing device of the present application is reproducible and can be widely applied to the field of memory.
Claims
1. A memory data processing method, characterized by, The method comprises: When the host triggers the memory block replacement after writing data to the memory, it is determined whether wear leveling needs to be performed according to the flash erase times of the memory; If the wear leveling needs to be performed, a flash erase time maximum block in the memory is found as a candidate block to be moved in, and it is determined whether the candidate block to be moved in meets data moving processing conditions; The step of determining whether the candidate block to be moved in meets data moving processing conditions comprises: determining whether the candidate block to be moved in is a data moving in block when wear leveling is performed; if the candidate block to be moved in is not the data moving in block when wear leveling is performed, the candidate block to be moved in meets data moving processing conditions, and the candidate block to be moved in is determined as a target block to be moved in; The wear leveling is used to move data to be moved of a data block to be moved to the target block to be moved in; After the wear leveling is used to move the data to be moved of the data block to be moved to the target block to be moved in, the following steps are performed: A current write data serial number is updated to the target block to be moved in as a historical write data serial number, wherein the current write data serial number is determined according to the number of times that the memory writes flash; After the step of determining whether the candidate block to be moved in is the data moving in block when wear leveling is performed, the following steps are performed: If the candidate block to be moved in is the data moving in block when wear leveling is performed, a serial number difference between a historical write data serial number and a current write data serial number of the candidate block to be moved in is determined, and it is determined whether the serial number difference is greater than a target threshold value; If the serial number difference is greater than the target threshold value, the candidate block to be moved in meets data moving processing conditions, and the candidate block to be moved in is determined as the target block to be moved in; The target threshold value is determined according to a product of a target multiple and a serial number increase value after the host performs a full-disk write round to the memory.
2. The memory data processing method of claim 1, wherein, After the wear leveling is used to move the data to be moved of the data block to be moved to the target block to be moved in, the following steps are performed: A write mark of wear leveling data is recorded in the target block to be moved in, and the write mark is configured to indicate whether the candidate block to be moved in is the data moving in block when wear leveling is performed.
3. The memory data processing method of claim 1, wherein, After the step of determining whether the serial number difference is greater than the target threshold value, the following steps are performed: If the serial number difference is less than or equal to the target threshold value, the candidate block to be moved in does not meet data moving processing conditions, a new candidate block to be moved in is found from the memory again based on a flash erase time of the candidate block to be moved in, and the step of determining whether the candidate block to be moved in meets processing conditions is performed on the new candidate block to be moved in.
4. The memory data processing method according to claim 3, wherein, The new candidate block to be moved in is found from the memory again based on the flash erase time of the candidate block to be moved in, which comprises: The flash erase time of the candidate block to be moved in corresponding to the serial number difference is taken as an upper limit for searching; The new candidate block to be moved in is found from the memory based on the upper limit for searching.
5. The memory data processing method of claim 1, wherein, The step of determining whether wear leveling needs to be performed comprises: It is determined whether a number of times that the memory does not perform wear leveling is a first value; If the number of times of not performing wear leveling is not the first value, the number of times of not performing wear leveling is decremented; If the number of times of not performing wear leveling is the first value, a wear difference between a maximum number of times of flash erase and write and a minimum number of times of flash erase and write in the memory is determined, and it is determined whether the wear difference is greater than or equal to a tolerable threshold value; If the wear difference is greater than or equal to the tolerable threshold value, the wear leveling needs to be performed.
6. The memory data processing method of claim 5, wherein, The method further comprises: If the number of times of not performing wear leveling is not the first value, the number of times of not performing wear leveling is decremented; 7. The memory data processing method of claim 1, wherein, The target multiple is 4.
8. The memory data processing method of claim 6, wherein, The target number is set to 5, the first value is 0, and the second value is 100.
9. A memory data processing device, characterized by The device: The determining module is configured to determine whether wear leveling needs to be performed according to a situation of flash erase and write of the memory when the host triggers block replacement of the memory after writing data to the memory; The finding module is configured to find a block with a maximum number of times of flash erase and write as a candidate block to be moved in from the memory if the wear leveling needs to be performed, and determine whether the candidate block to be moved in satisfies a data moving processing condition; The finding module is further configured to determine whether the candidate block to be moved in is a data block to be moved in when wear leveling is performed; if the candidate block to be moved in is not the data block to be moved in when wear leveling is performed, the candidate block to be moved in satisfies the data moving processing condition, and the candidate block to be moved in is determined as a target block to be moved in; The moving module is configured to move data to be moved of a data block to be moved to the target block to be moved in through the wear leveling; The moving module is further configured to update a current write data sequence number to the target block to be moved in as a historical write data sequence number; The device further comprises a synthesizing module configured to determine the current write data sequence number according to a number of times of writing flash of the memory; The finding module is further configured to determine a sequence number difference between a historical write data sequence number and a current write data sequence number of the candidate block to be moved in if the candidate block to be moved in is the data block to be moved in when wear leveling is performed, and determine whether the sequence number difference is greater than a target threshold value; If the sequence number difference is greater than the target threshold value, the candidate block to be moved in satisfies the data moving processing condition, and the candidate block to be moved in is determined as the target block to be moved in; The synthesizing module is further configured to determine a sequence number increase value after a full-disk write round of the host to the memory, and determine the target threshold value according to a product of a target multiple and the sequence number increase value.
10. The memory data processing device of claim 9, wherein, The moving module is further configured to record data write in the target block to be moved in as a wear leveling data write mark, and the write mark is configured to indicate whether the candidate block to be moved in is the data block to be moved in when wear leveling is performed.
11. The memory data processing device of claim 9, wherein, The search module is further configured to, if the sequence number difference is less than or equal to the target threshold, determine that the candidate block does not satisfy the data migration processing condition, search for a new candidate block from the memory based on the flash erase count of the candidate block, and perform the step of determining whether the new candidate block satisfies the processing condition.
12. The memory data processing device of claim 9, wherein, The search module is further configured to take the flash erase count of the candidate block as a search upper limit, and search for the new candidate block from the memory based on the search upper limit.
13. The memory data processing device of claim 9, wherein, The determination module is further configured to determine whether the number of times of not performing wear leveling of the memory is a first value, if the number of times of not performing wear leveling is not the first value, decrease the number of times of not performing wear leveling, if the number of times of not performing wear leveling is the first value, determine a wear difference between a maximum value and a minimum value of the flash erase count in the memory, and determine whether the wear difference is greater than or equal to a tolerable threshold, and if the wear difference is greater than or equal to the tolerable threshold, determine that the wear leveling needs to be performed.
14. A computer device, comprising: A computer program product, comprising a memory and a processor, wherein the memory stores a computer program, and the computer program is executed by the processor to implement the steps of the memory data processing method according to any one of claims 1 to 8.
15. A computer-readable storage medium, characterized in that, A computer program product, comprising a memory and a processor, wherein the memory stores a computer program, and the computer program is executed by the processor to implement the steps of the memory data processing method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Wear equalization method, device and apparatus based on erasing upper limit
CN109542354A
Wear leveling method and device for Nand Flash
CN111966299A
Wear leveling method and device, storage control chip and SD (Secure Digital) card
CN117971116A
Memory data processing method and device, computer equipment and storage medium
CN118295604A
System and Method of Updating a Memory to Maintain Even Wear
US20070294490A1