Data storage method, device, storage medium and electronic device

By monitoring the number of accesses and data flips in the access frequency information list of the target flash memory, and determining the substitute blocks from the blockchain list without using the blockchain list, the data in the target block is copied into the substitute block, and the read interference problem caused by frequent read access by read-only partitions is solved, and the security and reliability of the data is achieved.

CN119806435BActive Publication Date: 2025-06-10ZHEJIANG DAHUA TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510297024.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-03-13
Publication Date
2025-06-10
Estimated Expiration
2045-03-13

AI Technical Summary

Technical Problem

The prior art is difficult to effectively solve the read interference problem caused by frequent read access of read-only partitions.

Method used

By monitoring the number of accesses of the target block in the access frequency information list of the target flash memory, when the number of accesses exceeds the first preset threshold, it is determined that the number of data flips in the data in the target page is determined. If the number of flips exceeds the second preset threshold, the substitution block is not determined from the blockchain list, the data in the target block is copied into the substitution block, and the mapping relationship is established.

Benefits of technology

It effectively solves the read interference problem caused by frequent read access of read-only partitions, ensuring that data loss or file system corruption will not occur when power is lost during data refresh or migration.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119806435B_ABST
    Figure CN119806435B_ABST
Patent Text Reader

Abstract

An embodiment of the present invention provides a data storage method, apparatus, storage medium, and electronic device. Among them, the method includes: when the access count of a target block included in the access frequency information linked list of a target flash memory is greater than a first preset threshold, determining the first number of data flips that occur in each target page included in the target block; when there is a number greater than a second preset threshold among the first numbers, determining a replacement block from the unused block linked list of the target flash memory; copying the data in the target block to the replacement block, and deleting the node corresponding to the replacement block from the unused block linked list; establishing a mapping relationship between a target access address and the replacement block, where the target access address is the address that has a mapping relationship with the target block. Through the present invention, the problem of difficult to solve the read interference caused by frequent read access to a read-only partition is solved, and the technical effect of effectively solving the read interference problem caused by frequent read access to a read-only partition is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present invention relate to the field of data storage, and more particularly, to a method, apparatus, storage medium, and electronic device for storing data. Background Art

[0002] In the related art, due to its own structural characteristics, NAND Flash has a problem of read disturb, that is, when reading and writing the flash memory, electrons enter the floating gate, and the abnormal change of the charge in the floating gate means data loss.

[0003] It can be seen that in the related art, there is a technical problem that it is difficult to solve the read disturb caused by frequent read access to the read-only partition.

[0004] At present, no effective solution has been proposed for the above problems existing in the related art. Summary of the Invention

[0005] Embodiments of the present invention provide a method, apparatus, storage medium, and electronic device for storing data, so as to at least solve the problem of read disturb caused by frequent read access to the read-only partition in the related art.

[0006] According to an embodiment of the present invention, a method for storing data is provided, including: when the access times of a target block included in an access frequency information linked list of a target flash memory are greater than a first preset threshold, determining the first number of data flips of the data in each target page included in the target block; when there are times greater than a second preset threshold in the first number, determining a replacement block from an unused block linked list of the target flash memory; copying the data in the target block to the replacement block, and deleting the node corresponding to the replacement block from the unused block linked list; establishing a mapping relationship between a target access address and the replacement block, where the target access address is an address that has a mapping relationship with the target block.

[0007] In an exemplary embodiment, before determining the replacement block from the unused block linked list of the target flash memory, the method further includes: determining the error correction ability of an error correction algorithm of the target flash memory; obtaining a preset fault tolerance quantity; determining the second preset threshold based on the error correction ability and the fault tolerance quantity.

[0008] In an exemplary embodiment, determining the second preset threshold based on the error correction ability and the fault tolerance quantity includes: determining a first product of the fault tolerance quantity and the error correction ability; determining a first sum value of the first product and a first constant; determining a target difference value between the first sum value and a second constant; determining a first upward rounding value of a ratio of the target difference value to the first constant as the second preset threshold.

[0009] In an exemplary embodiment, determining a replacement block from the unused block linked list of the target flash memory includes: determining a data block located at a predetermined position included in the unused block linked list; and determining the data block as the replacement block.

[0010] In an exemplary embodiment, after copying the data in the target block to the replacement block, the method further includes: determining a second number of times of data refresh that occurs in the target block included in the access frequency information linked list; erasing the target block when the second number is greater than a third preset threshold; deleting a node of the target block included in the access frequency information linked list from the access frequency information linked list, and adding a node corresponding to the target block to the unused block linked list; and when the second number is less than or equal to the third preset threshold, erasing the target block, copying the data stored in the replacement block to the target block, and adding a node corresponding to the replacement block to the unused block linked list.

[0011] In an exemplary embodiment, before determining a first number of times of data flipping that occurs in the data of each target page included in the target block, the method further includes: determining a data storage block and an unused block included in the target flash memory; creating the access frequency information linked list, where the access frequency information linked list includes a physical block number, an access number, and a data refresh number of each data storage block; and creating the unused block linked list, where the unused block linked list includes physical block numbers of the unused blocks.

[0012] In an exemplary embodiment, before determining a first number of times of data flipping that occurs in the data of each target page included in the target block, the method further includes: determining a page number of a to-be-accessed page to be accessed; determining a target number of pages included in the target block; determining a second floor value of a ratio of the page number to the target number; adding 1 to an access number of the target physical block number corresponding to the second floor value when the target physical block number corresponding to the second floor value exists in the access frequency information linked list; and creating a block with a physical block number of the second floor value in the unused block linked list when the target physical block number corresponding to the second floor value does not exist in the access frequency information linked list.

[0013] In an exemplary embodiment, before determining the first number of data flips that occur in the data of each target page included in the target block, the method further includes: determining the usage rate of the processor of the device where the target flash memory is located; and in the case where the usage rate is less than a fourth preset threshold, determining the magnitude relationship between the access count of the target block included in the access frequency information linked list of the target flash memory and the first preset threshold.

[0014] According to another embodiment of the present invention, there is provided a data storage device, including: a first determination module, configured to determine the first number of data flips that occur in the data of each target page included in the target block in the case where the access count of the target block included in the access frequency information linked list of the target flash memory is greater than a first preset threshold; a second determination module, configured to determine an alternative block from the unused block linked list of the target flash memory in the case where there is a number greater than a second preset threshold among the first numbers; a deletion module, configured to copy the data in the target block to the alternative block and delete the node corresponding to the alternative block from the unused block linked list; and an establishment module, configured to establish a mapping relationship between a target access address and the alternative block, where the target access address is the address that has a mapping relationship with the target block.

[0015] According to still another embodiment of the present invention, there is further provided a computer-readable storage medium, in which a computer program is stored, where the computer program is configured to execute the steps in any one of the above method embodiments when running.

[0016] According to still another embodiment of the present invention, there is further provided an electronic device, including a memory and a processor, where 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.

[0017] According to still another embodiment of the present invention, there is further provided a computer program product, including a computer program, where the computer program, when executed by a processor, implements the steps of the method in each embodiment of the present application.

[0018] According to the present invention, when it is determined that the access count of the target block in the access frequency information linked list of the target flash memory is greater than the first preset threshold, and the first number of data flips of the data in each target page included in the target block exists a number greater than the second preset threshold, an alternative block can be determined from the unused block linked list of the target flash memory. Copy the data in the target block to the alternative block, delete the node corresponding to the alternative block from the unused block linked list, and establish a mapping relationship between the target access address and the alternative block. Since the data in the target block can be copied to the alternative block, power failure during data refresh or migration will not cause data loss or file system damage. Therefore, the problem of difficult to solve the read interference caused by frequent read access to the read-only partition in the related art can be solved, and the technical effect of effectively solving the read interference problem caused by frequent read access to the read-only partition can be achieved. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 FIG. is a hardware structure block diagram of a mobile terminal for a data storage method according to an embodiment of the present invention;

[0020] Figure 2 FIG. is a flowchart of a data storage method according to an embodiment of the present invention;

[0021] Figure 3 FIG. is a flowchart for monitoring and managing read information of a read-only partition flash block according to an embodiment of the present invention;

[0022] Figure 4 FIG. is a schematic structural diagram of a read-only partition according to an embodiment of the present invention;

[0023] Figure 5 FIG. is a structure block diagram of a free_block_list linked list according to an embodiment of the present invention;

[0024] Figure 6 FIG. is a structure block diagram of a read-only partition flash block access frequency information linked list according to an embodiment of the present invention;

[0025] Figure 7 FIG. is a schematic diagram for constructing a read-only partition flash block access frequency information node according to an embodiment of the present invention;

[0026] Figure 8 FIG. is a structure block diagram of a data storage device according to an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0027] Hereinafter, embodiments of the present invention will be described in detail with reference to the accompanying drawings and in conjunction with the embodiments.

[0028] It should be noted that the terms "first", "second", etc. in the specification, claims and above-mentioned drawings of the present invention are used to distinguish similar objects, and do not necessarily have to be used to describe a specific order or sequence.

[0029] The method embodiments provided in the embodiments of the present application can be executed on a mobile terminal, a computer terminal or a similar computing device. Taking running on a mobile terminal as an example, Figure 1 is a hardware structure block diagram of a mobile terminal for a data storage method according to an embodiment of the present invention. As Figure 1 shown, the mobile terminal may include one or more ( Figure 1 only one is shown in the figure) processors 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 103 for storing data. Among them, the above-mentioned mobile terminal may further include a transmission device 106 for communication functions and an input / output device 108. Those of ordinary skill in the art can understand that Figure 1 the structure shown is only schematic and does not limit the structure of the above-mentioned mobile terminal. For example, the mobile terminal may further include more or fewer components than Figure 1 shown in the figure, or have a different configuration from Figure 1 shown in the figure.

[0030] The memory 103 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 storage method in the embodiments of the present invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 103, that is, implements the above-mentioned method. The memory 103 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 memories, or other non-volatile solid-state memories. In some instances, the memory 103 may further include a memory remotely disposed relative to the processor 102, and these remote memories may be connected to the mobile terminal through a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an enterprise intranet, a local area network, a mobile communication network, and combinations thereof.

[0031] The transmission device 106 is used to receive or send data via a network. Specific examples of the above-mentioned network may include a wireless network provided by a communication provider of the mobile terminal. In one instance, the transmission device 106 includes a network adapter (Network Interface Controller, abbreviated as NIC), which can be connected to other network devices through a base station and thus can communicate with the Internet. In one instance, the transmission device 106 may be a radio frequency (Radio Frequency, abbreviated as RF) module, which is used to communicate with the Internet wirelessly.

[0032] In this embodiment, a data storage method is provided. Figure 2 It is a flowchart of the data storage method according to an embodiment of the present invention. As Figure 2 shown, this process includes the following steps:

[0033] Step S202: When the access count of the target block included in the access frequency information linked list of the target flash memory is greater than a first preset threshold, determine the first number of data flips that occur in the data of each target page included in the target block;

[0034] Step S203: When there is a number greater than a second preset threshold among the first numbers, determine a replacement block from the unused block linked list of the target flash memory;

[0035] Step S206: Copy the data in the target block to the replacement block, and delete the node corresponding to the replacement block from the unused block linked list;

[0036] Step S208: Establish a mapping relationship between the target access address and the replacement block, where the target access address is the address that has a mapping relationship with the target block.

[0037] In the above embodiment, due to the reservation for the read-only partition based on program expansion or bad blocks during the nand flash partition planning, the size of the read-only partition is usually set to be larger than the actual size of the program. However, this reserved space will not be accessed during the actual use of the device, and it can be called the unused area. This unused area can be managed by constructing a free_block_list linked list (i.e., the above-mentioned unused block linked list), and it can be used when refreshing or migrating the flash data block block.

[0038] In the above embodiment, the monitoring and management of the read-only partition flash block read information can be completed by the read-only partition flash block read information monitoring thread. Figure 3 It is a flowchart of the monitoring and management of the read-only partition flash block read information according to an embodiment of the present invention. As Figure 3 shown, this process includes:

[0039] Step S302: Start;

[0040] Step S304: Determine whether the current CPU of the flash block read information monitoring thread is busy. If it is, execute step S302; if not, execute step S306;

[0041] Step S306: Traverse the block access frequency information linked list;

[0042] Step S308: Determine whether the read count of the current block N reaches the threshold. If yes, execute Step S310; if no, execute Step S328;

[0043] Step S310: Traverse the pages included in the current block N;

[0044] Step S312: Determine whether the bit flip of the current page is greater than the bitfilp threshold. If yes, execute Step S316; if no, execute Step S314;

[0045] Step S314: Traverse the next element of the block access frequency information linked list;

[0046] Step S316: Find the free block M in the first node of the free_block_list linked list, copy the data of block N to block M, establish the mapping, and delete this node from this linked list;

[0047] Step S318: Determine whether the reflush_num information of block N is greater than max_reflush_num. If yes, execute Step S320; if no, execute Step S322;

[0048] Step S320: Erase block N, delete the block N node from the block access frequency information linked list, and insert it into the tail of the free_block_list linked list, and maintain the information of block M in the block access frequency information linked list;

[0049] Step S322: Erase block N, copy the data in block M back to block N, re - establish the mapping, increment the reflush_num of block N by 1, and re - insert block M into the tail of the free_block_list linked list;

[0050] Step S324: Determine whether all pages of block N have been traversed. If yes, execute Step S328; if no, execute Step S326;

[0051] Step S326: Traverse the next page included in the current block N;

[0052] Step S328: Determine whether the block access frequency information linked list has been traversed. If yes, execute Step S302; if no, execute Step S330;

[0053] Step S330: Traverse the next element of the block access frequency information linked list;

[0054] In the above embodiments, the frequency information linked list can be understood as a linked list that records the number of read accesses that occur in a block. The frequency information linked list of the read-only partition flash block can be traversed to determine whether the number of read accesses that occur in the target block in the linked list reaches a first preset threshold. The direct impact of frequent read accesses is that it will cause the internal data of the flash to be unstable, and the instability of the flash data will in turn cause bit flips in the data. Therefore, when the number of accesses to the target block is greater than the first preset threshold, the number of times of the first bit flip that occurs in each target page in the target block can be determined. Among them, since the occurrence of read interference is directly related to the number of accesses, that is, the more read accesses, the greater the probability of data errors, and there is no fixed relationship between the specific number of read accesses and the occurrence of data errors. There are differences between flashes of different manufacturers, and there are also differences between different blocks of the same flash of the same manufacturer. Therefore, the first preset threshold can be set based on the flash, and the present invention does not limit this.

[0055] In the above embodiments, when there is a number greater than a second preset threshold among the number of times of the first bit flip that occurs in each target page in the target block, it can indicate that the risk of subsequent data errors in the page data corresponding to this number is relatively high, and the data of the block needs to be refreshed or migrated. An idle block M (i.e., the above replacement block) can be found from the free_block_list unused block linked list of the target flash, and the data in the target block is copied to the idle block M. The node corresponding to the idle block M in the free_block_list unused block linked list is deleted, and a mapping relationship between the replacement block and the target block is established. Among them, the second preset threshold can be understood as the bit flip threshold bitflip threshold, which can be 10 times, 50 times, 100 times, etc., but is not limited thereto.

[0056] Through the present invention, when it is determined that the access count of the target block in the access frequency information linked list of the target flash memory is greater than a first preset threshold, and the first number of data flips of the data in each target page included in the target block, and when there is a number greater than a second preset threshold among the first numbers, an alternative block can be determined from the unused block linked list of the target flash memory. Copy the data in the target block to the alternative block, delete the node corresponding to the alternative block from the unused block linked list, and establish a mapping relationship between the target access address and the alternative block. Since the data in the target block can be copied to the alternative block, data loss or file system damage will not occur when power failure occurs during data refresh or migration. Therefore, the problem of difficult to solve the read interference caused by frequent read access to the read-only partition in the related art can be solved, and the technical effect of effectively solving the read interference problem caused by frequent read access to the read-only partition can be achieved.

[0057] Optionally, the execution subject of the above steps may be a background processor, or may also be a server, a terminal, etc., but is not limited thereto.

[0058] In an exemplary embodiment, before determining the alternative block from the unused block linked list of the target flash memory, the method further includes: determining the error correction ability of the error correction algorithm of the target flash memory; obtaining a preset tolerance quantity; and determining the second preset threshold based on the error correction ability and the tolerance quantity.

[0059] In the above embodiment, the error correction ability of the ECC (Error Correction Code) algorithm adopted by the device can be determined first, and then a preset tolerance quantity can be determined according to the value determined by experience or test, which is used to define the maximum number of bit flip errors that can be tolerated during the read operation. Among them, the ECC algorithm is a key technology for detecting and correcting bit errors caused by storage medium defects or aging. Different NAND Flash chips may have different ECC error correction capabilities. For example, some NAND Flash chips may have the ability to correct 1 bit error, while others may have the ability to correct 4 bit errors. The tolerance quantity can be set by comprehensively considering the actual usage of the flash memory and the error correction ability of the ECC algorithm to balance data reliability and storage efficiency.

[0060] In the above embodiments, based on the ECC error correction capability of the target flash memory and a preset number of tolerable errors, a more accurate second preset threshold can be calculated, which can be used to determine whether the bit flip errors in the block exceed the acceptable range, so as to decide whether to migrate the data to an alternative block. Through this method, it can be ensured that when selecting an alternative block from the unused block list of the target flash memory, the selected block can effectively carry the data without encountering bit flip errors prematurely. In addition, it can also be ensured that the data migration strategy is based on the current status of the flash memory and the preset error tolerance strategy, improving the pertinence and efficiency of data protection.

[0061] In an exemplary embodiment, determining the second preset threshold based on the error correction capability and the number of tolerable errors includes: determining a first product of the number of tolerable errors and the error correction capability; determining a first sum value of the first product and a first constant; determining a target difference between the first sum value and a second constant; and determining a first upward rounding value of the ratio of the target difference to the first constant as the second preset threshold.

[0062] In the above embodiments, the second preset threshold bitflip threshold can be calculated by the following formula: bitflip threshold = DIV_ROUND_UP(ecc_strength * 3, 4), where DIV_ROUND_UP can be understood as a variant of the division operation, which can ensure that when the division result has a decimal part, it is always rounded up to the nearest integer, and can be referred to as rounding up or ceiling. ecc_strength can be understood as the above-mentioned error correction capability. DIV_ROUND_UP(n, d) can be understood as (((n) + (d) - 1) / (d)), where n can be the first product of the error correction capability and the number of tolerable errors 3, 1 is the above-mentioned second constant, d can be the first constant, which can be 4, but is not limited thereto, n + d is the above-mentioned first sum value, and n + d - 1 is the above-mentioned target difference. For example, when the error correction capability ecc_strength is 8, the second preset threshold bitflip threshold = (((8 * 3) + (4) - 1) / (4)) = 6.

[0063] In an exemplary embodiment, determining an alternative block from the unused block list of the target flash memory includes: determining a data block included in the unused block list at a predetermined position; and determining the data block as the alternative block.

[0064] In the above embodiments, when determining the replacement block, a free block (i.e., the above data block) can be found from the first node of the free_block_list unused block linked list (i.e., the above predetermined position), and this data block is determined as the replacement block. If there is no free block M in the first node, the free block M is determined from the second node of the free_block_list unused block linked list, and so on.

[0065] In an exemplary embodiment, after copying the data in the target block to the replacement block, the method further includes: determining a second number of times that data flushing occurs in the target block included in the access frequency information linked list; in the case where the second number is greater than a third preset threshold, erasing the target block; deleting the node of the target block included in the access frequency information linked list from the access frequency information linked list, and adding the node corresponding to the target block to the unused block linked list; in the case where the second number is less than or equal to the third preset threshold, erasing the target block, copying the data stored in the replacement block to the target block, and adding the node corresponding to the replacement block to the unused block linked list.

[0066] In the above embodiments, continue to refer to Figure 3 , it is also possible to determine the number of times reflush_num occurs in the target block (i.e., the above second number of times that data flushing occurs) from the access frequency information linked list. When the second number is greater than the maximum flushing number max_reflush_num (i.e., the above third preset threshold), it can indicate that the target block has performed multiple reflushing operations but the data is still unstable and there is a risk of becoming a bad block. Therefore, it is necessary to reduce its use. The target block can be deleted from the block access frequency information linked list and inserted into the corresponding node at the tail of the free_block_list linked list. When the second number is less than the maximum flushing number max_reflush_num, the data in the target block can be reflushed, that is, the target block is erased, the data stored in the replacement block is copied back to the target block, the mapping of the target block is re-established, and at the same time, the value of reflush_num of the target block can be incremented by 1, which can indicate that a data flushing operation on the target block is completed this time, and then the replacement block is re-imported into the corresponding node at the tail of the free_block_list linked list.

[0067] In the above embodiments, the operations of copying, mapping, and remapping block data are extremely crucial. When performing data refreshing or migration, data loss during abnormal power-off during block data refreshing or block data migration can be avoided through data copying and mapping, thereby preventing the problem of file system corruption caused by data loss. Example: When a power-off occurs during data refreshing operation, the data in the target block is incomplete. However, since the data in the target block has been copied to the replacement block and the mapping of the replacement block has been established, when the upper-layer software accesses the target block after the device is powered on again, the actual accessed block is the replacement block, and the data in the replacement block is complete. Therefore, there will be no problems such as data loss. If a power-off occurs during the migration of the target block data, since the original mapping relationship of the target block has not been modified, when the software accesses the target block after the device is powered on again, the normal data in the target block is actually accessed, and there will be no problems either.

[0068] In an exemplary embodiment, before determining the first number of data flips that occur in the data of each target page included in the target block, the method further includes: determining the data storage blocks and unused blocks included in the target flash memory; creating the access frequency information linked list, where the access frequency information linked list includes the physical block numbers, access times, and data refresh times of each of the data storage blocks; creating the unused block linked list, where the unused block linked list includes the physical block numbers of the unused blocks.

[0069] In the above embodiments, the read-only partition may include data storage blocks and unused blocks. For the structure diagram of the read-only partition, refer to Figure 4 , Figure 4 FIG. is the structure schematic diagram of the read-only partition according to an embodiment of the present invention. As Figure 4 shown, block 1 to block m are the actual data areas of the program (i.e., the above-mentioned data storage blocks), and block m + 1 to block k are unused blocks. A free_block_list linked list structure can be constructed based on the unused blocks of block m + 1 to block k. Figure 5 According to the structure schematic diagram of the free_block_list linked list of an embodiment of the present invention, as Figure 5 shown, the unused block linked list includes the physical block number List_head of the unused block. A read-only partition flash block access frequency information linked list can also be established. Figure 6 FIG. is the structure schematic diagram of the read-only partition flash block access frequency information linked list according to an embodiment of the present invention. As Figure 6As shown, each linked list node may include three pieces of data: the block_num data that records the physical block number of the flash block where read access occurs, the read_num data that records the number of times the block has been read, and the reflush_num data that records the number of times the block has been refreshed.

[0070] In an exemplary embodiment, before determining the first number of data flips that occur in each target page included in the target block, the method further includes: determining the page number of the page to be accessed; determining the target number of pages included in the target block; determining the second floor value of the ratio of the page number to the target number; when there is a target physical block number corresponding to the second floor value in the access frequency information linked list, incrementing by 1 the access count of the target physical block number included in the access frequency information linked list; when there is no target physical block number corresponding to the second floor value in the access frequency information linked list, creating a block with a physical block number of the second floor value in the unused block linked list.

[0071] In the above embodiment, the linked list can be initialized before constructing the node information, which may include initializing the read-only partition flash block access frequency information linked list and the free_block_list linked list. All the data blocks maintained in the free_block_list linked list need to be erased and can be used for subsequent block data copying. A flash block read information monitoring thread can also be constructed to prepare for processing flash block read information.

[0072] In the above embodiment, since NAND flash performs read and write access in units of pages, the construction of the block access frequency information node can be implemented in the page read interface. Figure 7 It is a schematic diagram of constructing a read-only partition flash block access frequency information node according to an embodiment of the present invention, as Figure 7As shown, the page number of the page (i.e., the above-mentioned access page) can be converted into the block number of the corresponding flash physical block (the block number of the flash physical block (i.e., the above-mentioned target block number) can be determined by the ratio of the page number of the page to the number of pages included in each block (i.e., the above-mentioned target quantity)). Before constructing the block access frequency information node, the read-only partition flash block access frequency information linked list can be traversed to determine whether the target block number exists in the linked list node. If the target block number exists, the access count read_num in the corresponding node can be incremented by 1 on the original basis, indicating that a read access has occurred again for the target block. If the target block number does not exist, a block access frequency information node can be created and initialized, the target physical block number can be assigned to block_num, and since a read access has occurred, block_num needs to be assigned 1, and the reflush_num of the created block access frequency information node can be initialized to 0. After the node is created, the new node can be inserted into the head of the read-only partition flash block access frequency information linked list.

[0073] In an exemplary embodiment, before determining the first number of data flips that occur in the data of each target page included in the target block, the method further includes: determining the usage rate of the processor of the device where the target flash memory is located; and in the case where the usage rate is less than a fourth preset threshold, determining the magnitude relationship between the access count of the target block included in the access frequency information linked list of the target flash memory and the first preset threshold.

[0074] In the above embodiment, since the flash block read monitoring thread operation involves linked list access, page access, block data erasure, and copying, it will bring a certain performance overhead and needs to be operated when the cpu is idle. Therefore, the flash block read monitoring thread can first determine whether the processor cpu is in a busy state. When the usage rate of the cpu is less than the fourth preset threshold, it means that the cpu is idle at this time, and the flash block read monitoring thread can be entered, that is, to determine the magnitude relationship between the access count of the target block included in the access frequency information linked list of the target flash memory and the first preset threshold. When the usage rate of the cpu is greater than the fourth preset threshold, the cpu is in a busy state, and the flash block read monitoring thread continues to be in a sleep state. Among them, the fourth preset threshold can be 50% of the cpu usage rate or 60%, and the present invention does not limit this.

[0075] In the above embodiments, through the data protection policy of the nand flash read-only partition, the read interference problem of the read-only partition can be effectively solved. When ensuring the security and reliability of the data in the read-only partition, power failure during data refresh or migration will not cause data loss or file system damage. In addition, by using the unused space in the flash read-only partition, the utilization rate of the flash space can be increased, ensuring that the normal services of the device are not affected and the data protection mechanism will not cause performance problems during operation.

[0076] Through the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by means of software plus a necessary general hardware platform. Of course, it 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, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to enable a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in various embodiments of the present invention.

[0077] In this embodiment, a data storage device is further provided. This device is used to implement the above embodiments and preferred implementation manners, and those that have been described will not be repeated. As used below, the term "module" can be a combination of software and / or hardware that can achieve a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware is also possible and contemplated.

[0078] Figure 8 is a structural block diagram of the data storage device according to an embodiment of the present invention. As Figure 8 shown, the device includes:

[0079] A first determination module 802, configured to determine the first number of data flips of the data in each target page included in the target block when the access count of the target block included in the access frequency information linked list of the target flash memory is greater than a first preset threshold;

[0080] A second determination module 803, configured to determine an alternative block from the unused block linked list of the target flash memory when there is a number greater than a second preset threshold in the first number;

[0081] A deletion module 806, configured to copy the data in the target block to the alternative block, and delete the node corresponding to the alternative block from the unused block linked list;

[0082] A building module 808 is used to establish a mapping relationship between a target access address and the replacement block, where the target access address is the address that has established a mapping relationship with the target block.

[0083] In an exemplary embodiment, the device can be used before determining a replacement block from the unused block linked list of the target flash memory: determine the error correction capability of the error correction algorithm of the target flash memory; obtain a preset tolerance quantity; determine the second preset threshold based on the error correction capability and the tolerance quantity.

[0084] In an exemplary embodiment, the device can determine the second preset threshold based on the error correction capability and the tolerance quantity in the following manner: determine a first product of the tolerance quantity and the error correction capability; determine a first sum value of the first product and a first constant; determine a target difference between the first sum value and a second constant; determine a first upward rounding value of a ratio of the target difference to the first constant as the second preset threshold.

[0085] In an exemplary embodiment, the second determination module 803 can determine a replacement block from the unused block linked list of the target flash memory in the following manner: determine a data block located at a predetermined position included in the unused block linked list; determine the data block as the replacement block.

[0086] In an exemplary embodiment, the device can also be used after copying the data in the target block to the replacement block: determine a second number of times of data refreshing that occurs in the target block included in the access frequency information linked list; in the case where the second number is greater than a third preset threshold, erase the target block; delete a node of the target block included in the access frequency information linked list from the access frequency information linked list, and add a node corresponding to the target block to the unused block linked list; in the case where the second number is less than or equal to the third preset threshold, erase the target block, copy the data stored in the replacement block to the target block, and add a node corresponding to the replacement block to the unused block linked list.

[0087] In an exemplary embodiment, the device can also be used before determining a first number of times of data flipping that occurs in the data of each target page included in the target block: determine data storage blocks and unused blocks included in the target flash memory; create the access frequency information linked list, where the access frequency information linked list includes the physical block number, access times, and data refreshing times of each data storage block; create the unused block linked list, where the unused block linked list includes the physical block numbers of the unused blocks.

[0088] In an exemplary embodiment, the apparatus may also be used before determining the first number of data flips that occur in the data of each target page included in the target block: determine the page number of the to-be-accessed page to be accessed; determine the target number of pages included in the target block; determine the second floor value of the ratio of the page number to the target number; when there is a target physical block number corresponding to the second floor value in the access frequency information linked list, increment by 1 the access count of the target physical block number included in the access frequency information linked list; when there is no target physical block number corresponding to the second floor value in the access frequency information linked list, create a block with a physical block number of the second floor value in the unused block linked list.

[0089] In an exemplary embodiment, the apparatus may also be used before determining the first number of data flips that occur in the data of each target page included in the target block: determine the usage rate of the processor of the device where the target flash memory is located; when the usage rate is less than a fourth preset threshold, determine the magnitude relationship between the access count of the target block included in the access frequency information linked list of the target flash memory and the first preset threshold.

[0090] It should be noted that the above-mentioned respective modules may be implemented by software or hardware. For the latter, it may be implemented in the following ways, but not limited thereto: the above-mentioned modules are all located in the same processor; or, the above-mentioned respective modules are separately located in different processors in any combination form.

[0091] An embodiment of the present invention also provides a computer-readable storage medium, in which a computer program is stored, and wherein the computer program is configured to execute the steps in any one of the above method embodiments when running.

[0092] In an exemplary embodiment, the above computer-readable storage medium may include, but is not limited to: USB flash drives, read-only memories (ROM for short), random access memories (RAM for short), mobile hard disks, magnetic disks, or optical discs and other various media that can store computer programs.

[0093] An embodiment of the present invention also 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.

[0094] In an exemplary embodiment, the above electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the above processor, and the input / output device is connected to the above processor.

[0095] An embodiment of the present invention further provides a computer program product, including a computer program which, when executed by a processor, implements the steps of the methods in the various embodiments of the present application.

[0096] Specific examples in this embodiment may refer to the examples described in the above embodiments and the exemplary embodiments, and will not be elaborated herein.

[0097] Obviously, those skilled in the art should understand that the above modules or steps of the present invention can be implemented by a general-purpose 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 program codes executable by the 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 from here, or they can be separately made into individual integrated circuit modules, or multiple modules or steps among them can be made into a single integrated circuit module to implement. Thus, the present invention is not limited to any specific combination of hardware and software.

[0098] The above are only the preferred embodiments of the present invention and are not used to limit the present invention. For those skilled in the art, the present invention can have various changes and modifications. 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 storage method, characterized in that: include: When the number of accesses to the target block included in the access frequency information linked list of the target flash memory is greater than a first preset threshold, determining a first number of data flips occurring in each target page included in the target block; In the case that there is a number greater than a second preset threshold among the first number of times, determining a replacement block from an unused block linked list of the target flash memory, wherein the unused block linked list is used to manage unused areas of the read-only partition included in the target flash memory; Copy the data in the target block to the replacement block, and delete the node corresponding to the replacement block from the unused block linked list; Establishing a mapping relationship between a target access address and the replacement block, wherein the target access address is an address that establishes a mapping relationship with the target block; After copying the data in the target block to the replacement block, the method further includes: determining a second number of data refreshes occurring in the target block included in the access frequency information linked list; erasing the target block when the second number is greater than a third preset threshold; deleting the node of the target block included in the access frequency information linked list from the access frequency information linked list, and adding a node corresponding to the target block to the unused block linked list; and erasing the target block when the second number is less than or equal to the third preset threshold, copying the data stored in the replacement block to the target block, and adding a node corresponding to the replacement block to the unused block linked list.

2. The method according to claim 1, characterized in that Before determining a replacement block from the unused block linked list of the target flash memory, the method further includes: Determining an error correction capability of an error correction algorithm of the target flash memory; Get the preset fault tolerance number; The second preset threshold is determined based on the error correction capability and the error tolerance number.

3. The method according to claim 2, characterized in that Determining the second preset threshold based on the error correction capability and the fault tolerance number includes: Determining a first product of the error tolerance amount and the error correction capability; determining a first sum of the first product and a first constant; determining a target difference between the first sum and a second constant; A first rounded-up value of the ratio of the target difference to the first constant is determined as the second preset threshold.

4. The method according to claim 1, characterized in that: Determining a replacement block from the unused block linked list of the target flash memory comprises: Determine a data block located at a predetermined position included in the unused block linked list; The data block is determined as the replacement block.

5. The method according to claim 1, characterized in that Before determining a first number of times data flipping occurs in each target page included in the target block, the method further includes: Determine data storage blocks and unused blocks included in the target flash memory; Creating the access frequency information linked list, wherein the access frequency information linked list includes the physical block number, access times and data refresh times of each data storage block; The unused block linked list is created, wherein the unused block linked list includes the physical block numbers of the unused blocks.

6. The method according to claim 1, characterized in that Before determining a first number of times data flipping occurs in each target page included in the target block, the method further includes: Determine the page number of the page to be accessed; determining a target number of pages included in the target block; determining a second floor value of the ratio of the page number to the target number; If the target physical block number corresponding to the second rounded-down value exists in the access frequency information linked list, adding 1 to the number of accesses of the target physical block number included in the access frequency information linked list; When the target physical block number corresponding to the second rounded-down value does not exist in the access frequency information linked list, a block whose physical block number is the second rounded-down value is created in the unused block linked list.

7. The method according to claim 1, characterized in that Before determining a first number of times data flipping occurs in each target page included in the target block, the method further includes: Determine the usage rate of the processor of the device where the target flash memory is located; When the usage rate is less than a fourth preset threshold, a relationship between the number of accesses to the target block included in the access frequency information linked list of the target flash memory and the first preset threshold is determined.

8. A data storage device, characterized in that: include: A first determining module, configured to determine a first number of data flippings occurring in data in each target page included in the target block when the number of accesses to the target block included in the access frequency information linked list of the target flash memory is greater than a first preset threshold; A second determining module is used to determine a replacement block from an unused block linked list of the target flash memory when there is a number greater than a second preset threshold among the first number of times, wherein the unused block linked list is used to manage an unused area of ​​a read-only partition included in the target flash memory; A deletion module, used for copying the data in the target block to the replacement block, and deleting the node corresponding to the replacement block from the unused block linked list; An establishing module, used to establish a mapping relationship between a target access address and the replacement block, wherein the target access address is an address that establishes a mapping relationship with the target block; The device is also used to, after copying the data in the target block to the replacement block: determine the second number of data refreshes that occur in the target block included in the access frequency information linked list; if the second number is greater than a third preset threshold, erase the target block; delete the node of the target block included in the access frequency information linked list from the access frequency information linked list, and add the node corresponding to the target block in the unused block linked list; if the second number is less than or equal to the third preset threshold, erase the target block, copy the data stored in the replacement block to the target block, and add the node corresponding to the replacement block to the unused block linked list.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program is configured to execute the method according to any one of claims 1 to 7 when executed.

10. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to run the computer program to perform the method according to any one of claims 1 to 7.

11. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method described in any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Data processing method and device of storage equipment, terminal equipment and storage medium

    CN117742600A

  • Data processing method and device, equipment and storage medium

    CN119166072A