Data storage method and device, storage medium and electronic device

By monitoring the number of accesses and data flips in the target flash memory access frequency information list, and never determining the alternative blocks in the blockchain list, the read interference problem caused by frequent read access of read-only partitions is solved, and data security and file system stability are achieved.

CN119806435AActive Publication Date: 2025-04-11ZHEJIANG DAHUA TECH CO LTD
View PDF 10 Cites 0 Cited by

Patent Information

Application Number
CN202510297024.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-13
Publication Date
2025-04-11
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 substitute block is not determined from the blockchain list, the data in the target block is copied into the substitute 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 CN119806435A_ABST
    Figure CN119806435A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a data storage method and device, a storage medium and an electronic device.The method comprises the steps that under the condition that the access frequency of a target block included in an access frequency information linked list of a target flash memory is larger than a first preset threshold value, the access frequency of the target block is larger than the first preset threshold value; determining a first number of times of data flipping of data in each target page included in the target block; under the condition that the number of times greater than a second preset threshold exists in the first number of times, determining a replacement block from an unused block linked list of the target flash memory; copying data in the target block into the replacement block, and deleting a node corresponding to the replacement block from the unused block linked list; and establishing a mapping relationship between the target access address and the replacement block, the target access address being an address establishing the mapping relationship with the target block. Through the method and the device, the problem of read interference caused by frequent read access to the read-only partition is difficult to solve, and the technical effect of effectively solving the problem of read interference caused by frequent read access to the read-only partition is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of data storage, and in particular, to a data storage method, device, storage medium and electronic device. Background Art

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

[0003] It can be seen from this that the related art has a technical problem that is difficult to solve, that is, read interference caused by frequent read access to read-only partitions.

[0004] With respect to the above-mentioned problems existing in the related technologies, no effective solution has been proposed yet. Summary of the invention

[0005] Embodiments of the present invention provide a data storage method, device, storage medium and electronic device to at least solve the problem of read interference caused by frequent read access to a read-only partition that is difficult to solve in the related art.

[0006] According to one embodiment of the present invention, a data storage method is provided, comprising: in a case where the number of accesses to a target block included in an access frequency information linked list of a target flash memory is greater than a first preset threshold, determining a first number of data flippings that occur to data in each target page included in the target block; in a case where there is a number greater than a second preset threshold among 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, wherein the target access address is an address that establishes a mapping relationship with the target block.

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

[0008] In an exemplary embodiment, determining the second preset threshold based on the error correction capability and the fault tolerance number includes: determining a first product of the fault tolerance number 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; and determining a first upward integer value of the ratio of the target difference to the first constant as the second preset threshold.

[0009] In an exemplary embodiment, determining the replacement block from the unused block linked list of the target flash memory includes: determining a data block located at a predetermined position and 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 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.

[0011] In an exemplary embodiment, before determining the first number of data flips that occur in the data in 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, wherein the access frequency information linked list includes the physical block number, access times and data refresh times of each of the data storage blocks; and creating the unused block linked list, wherein the unused block linked list includes the physical block number of the unused block.

[0012] In an exemplary embodiment, before determining the first number of data flips that occur in the data in each target page included in the target block, the method also includes: determining the page number of the page to be accessed; determining the 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 there is a target physical block number corresponding to the second floor value 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; if 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.

[0013] 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 also includes: determining 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, determining the 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.

[0014] According to another embodiment of the present invention, there is provided a data storage device, comprising: a first determination module, for determining a first number of data flippings occurring to 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 determination module, for determining a replacement block from an unused block linked list of the target flash memory 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 deletion module, 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; and an establishment module, for 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.

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

[0016] According to yet another embodiment of the present invention, there is provided an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

[0017] According to yet another embodiment of the present invention, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the steps of the method described in each embodiment of the present application are implemented.

[0018] Through the present invention, when it is determined that the number of accesses to the target block in the access frequency information linked list of the target flash memory is greater than the first preset threshold value, the first number of data flipping occurs in the data in each target page included in the target block, and when there is a number greater than the second preset threshold value in the first number, a replacement block can be determined from the unused block linked list of the target flash memory. The data in the target block is copied to the replacement block, the node corresponding to the replacement block is deleted from the unused block linked list, and a mapping relationship between the target access address and the replacement block is established. Since the data in the target block can be copied to the replacement block, when power failure occurs during data refresh or migration, data loss or file system damage will not occur. Therefore, the problem of read interference caused by frequent read access to read-only partitions that is difficult to solve in the related art can be solved, and the technical effect of effectively solving the read interference problem caused by frequent read access to read-only partitions can be achieved. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0020] Figure 2 is a flow chart of a method for storing data according to an embodiment of the present invention;

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

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

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

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

[0025] 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;

[0026] Figure 8 is a structural block diagram of a data storage device according to an embodiment of the present invention. DETAILED DESCRIPTION

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

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

[0029] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Taking running on a mobile terminal as an example, Figure 1 FIG. 1 is a hardware structure block diagram of a mobile terminal of a data storage method according to an embodiment of the present invention. Figure 1 As shown, the mobile terminal may include one or more ( Figure 1 Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 103 for storing data, wherein the mobile terminal may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the mobile terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.

[0030] The memory 103 can be used to store computer programs, for example, software programs and modules of application software, such as computer programs corresponding to the data storage method in the embodiment of the present invention. The processor 102 executes various functional applications and data processing by running the computer programs stored in the memory 103, that is, to implement the above 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 memory, or other non-volatile solid-state memory. In some examples, the memory 103 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the mobile terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

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

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

[0033] Step S202, 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;

[0034] Step S203, when there is a number greater than a second preset threshold in the first number of times, determining a replacement block from the unused block linked list of the target flash memory;

[0035] Step S206, 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;

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

[0037] In the above embodiment, since the read-only partition is based on program expansion or bad block reservation during 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, the device will not access this reserved space during actual use, which can be called an unused area. This unused area can be managed by constructing a free_block_list linked list (i.e., the unused block linked list) and can be used when refreshing or migrating in the flash data block block.

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

[0039] Step S302, start;

[0040] Step S304, determining whether the current CPU of the flash block reading information monitoring thread is busy, if yes, executing step S302, if no, executing step S306;

[0041] Step S306, traverse the block access frequency information linked list;

[0042] Step S308, determining whether the number of read times of the current block N reaches a threshold, if yes, executing step S310, if no, executing step S328;

[0043] Step S310, traverse the pages included in the current block N;

[0044] Step S312, determine whether the current page bit flip 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 a mapping, and delete the node in the linked list;

[0047] Step S318, determining whether the block N reflush_num information is greater than max_reflush_num, if yes, executing step S320, if no, executing 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 end of the free_block_list linked list, and maintain the block M information into 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, increase block N reflush_num by 1, and reinsert block M to the end 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, determining whether the block access frequency information linked list has been traversed, if yes, executing step S302, if no, executing step S330;

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

[0054] In the above embodiment, the frequency information linked list can be understood as a linked list that records the number of read accesses that occur in the block. By traversing the read-only partition flash block access frequency information linked list, it can be determined whether the number of read accesses that occur to the target block in the linked list has reached the first preset threshold. The direct impact of frequent read accesses is that the internal data of the flash will be unstable, and the instability of the flash data will cause the data to be bit flipped. Therefore, when the number of accesses to the target block is greater than the first preset threshold, the first number of bit flips in the data of 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 will be differences between flashes of different manufacturers, and there will also be 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 embodiment, when the first number of bit flips in each target page in the target block is greater than the second preset threshold, it can be indicated that the page data corresponding to the number has a high risk of subsequent data errors, and the block data needs to be refreshed or migrated. A free block M (i.e., the above-mentioned replacement block) can be found from the free_block_list unused block linked list of the target flash memory, and the data in the target block can be copied to the free block M, the node corresponding to the free 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 to this.

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

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

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

[0059] In the above embodiment, the error correction capability of the ECC (Error Correction Code) algorithm adopted by the device can be determined first, and then a preset fault tolerance number can be determined based on the value determined by experience or test 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 errors, while others may have the ability to correct 4 bit errors. The fault tolerance number can be set based on the actual usage of the flash memory and the error correction capability of the ECC algorithm, so as to balance data reliability and storage efficiency.

[0060] In the above embodiment, based on the ECC error correction capability of the target flash memory and the preset fault tolerance number, a more accurate second preset threshold can be calculated, which can be used to determine whether the bit flip error in the block exceeds the acceptable range, thereby determining whether the data needs to be migrated to a replacement block. Through this method, it can be ensured that when selecting a replacement block from the unused block linked list of the target flash memory, the selected block can effectively carry data without encountering a bit flip error too early. 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 fault tolerance strategy, thereby 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 fault tolerance number includes: determining a first product of the fault tolerance number 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; and determining a first upward integer value of the ratio of the target difference to the first constant as the second preset threshold.

[0062] In the above embodiment, the second preset threshold bitflip threshold can be calculated by the following formula: bitflip threshold = DIV_ROUND_UP (ecc_strength * 3, 4), wherein 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, which can be called rounding up or rounding up, and ecc_strength can be understood as the above error correction capability. DIV_ROUND_UP (n, d) can be understood as (((n) + (d) - 1) / (d)), n can be understood as the first product of the error correction capability and the fault tolerance number 3, 1 is the above second constant, d can be understood as the first constant, which can be 4, but is not limited to this, n+d is the above first sum, and n+d-1 is the above target difference. 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 the replacement block from the unused block linked list of the target flash memory includes: determining a data block located at a predetermined position and included in the unused block linked list; and determining the data block as the replacement block.

[0064] In the above embodiment, when determining the replacement block, a free block (i.e., the above data block) can be found from the first node (i.e., the above predetermined position) of the free_block_list unused block linked list, and this data block is determined as the replacement block. If there is no free block M at 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 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.

[0066] In the above embodiment, see Figure 3 , the number of times reflush_num occurs in the target block (i.e., the second number of data refreshes mentioned above) can also be determined from the access frequency information linked list. When the second number is greater than the maximum refresh number max_reflush_num (i.e., the third preset threshold), it can be indicated that the target block has performed multiple refresh operations but the data is still unstable and there is a risk of becoming a bad block, so it needs to be used less. The target block can be deleted from the block access frequency information linked list and inserted into the node corresponding to the tail of the free_block_list linked list. When the second number is less than the maximum refresh number max_reflush_num, the data in the target block can be refreshed, that is, the target block can be erased, and the data stored in the replacement block can be copied back to the target block, and the mapping of the target block can be re-established. At the same time, the target block reflush_num value can be increased by 1, which can indicate that a data refresh operation has been completed on the target block this time, and then the replacement block is re-imported into the node corresponding to the tail of the free_block_list linked list.

[0067] In the above embodiments, the copying, mapping, and remapping operations of block data are extremely critical. When executing data refresh or migration, data copying and mapping can be used to avoid data loss when abnormal power failure occurs during block data refresh or block data migration, thereby causing file system damage. Example: When a power failure occurs during a data refresh operation, the data in the target block is incomplete at this time, but because the data in the target block has been copied to the replacement block, and the mapping of the replacement block has been established, the next time the device is powered on again and the upper-level software accesses the target block, the replacement block is actually accessed, and the data in the replacement block is complete, so there will be no problems such as data loss. If a power failure occurs during the migration of target block data, since the mapping relationship of the original target block has not been modified, the next time the device is powered on again and the software accesses the target block, it will actually access the normal data in the target block, and there will be no problem.

[0068] In an exemplary embodiment, before determining the first number of data flips that occur in the data in 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, wherein the access frequency information linked list includes the physical block number, access times and data refresh times of each of the data storage blocks; and creating the unused block linked list, wherein the unused block linked list includes the physical block number of the unused block.

[0069] In the above embodiment, the read-only partition may include data storage blocks and unused blocks. The structure diagram of the read-only partition can be found in Figure 4 , Figure 4 is a schematic diagram of the structure of a read-only partition according to an embodiment of the present invention. Figure 4 As shown, block 1 to block m are the actual data areas of the program (i.e., the data storage blocks mentioned above), 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 from block m+1 to block k. Figure 5 According to the free_block_list linked list structure diagram of the embodiment of the present invention, as shown in Figure 5 As 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 is a structure diagram of a read-only partition flash block access frequency information linked list according to an embodiment of the present invention, such as Figure 6As shown, each linked list node may contain three data: block_num data recording the physical block number of the flash block where read access occurs, read_num data recording the number of times the block is read accessed, and reflush_num data recording the number of times the block is refreshed.

[0070] In an exemplary embodiment, before determining the first number of data flips that occur in the data in each target page included in the target block, the method also includes: determining the page number of the page to be accessed; determining the 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 there is a target physical block number corresponding to the second floor value 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; if 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, before the node information is constructed, the linked list can be initialized, which can include the initialization of the read-only partition flash block access frequency information linked list and the initialization of the free_block_list linked list. 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 the flash block read information.

[0072] In the above embodiment, since the nand flash is read and written in units of pages, the block access frequency information node can be constructed in the page read interface. Figure 7 Schematic diagram of building a read-only partition flash block access frequency information node according to an embodiment of the present invention. Figure 7As shown, the page number of the page (i.e., the access page mentioned above) can be converted into the block number of the corresponding flash physical block (the block number of the flash physical block (i.e., the target block number mentioned above) can be determined by the ratio of the page number to the number of pages contained in each block (i.e., the target number)). 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 is already in the linked list node. If the target block number exists, the access count read_num in the corresponding node can be increased by 1 on the original basis, which can indicate that the target block has been read accessed again; if the target block number does not exist, a block access frequency information node can be created and initialized, and the target physical block number can be assigned to block_num. Since a read access has occurred, block_num needs to be assigned to 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 each target page included in the target block, the method also includes: determining 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, determining the 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.

[0074] In the above embodiment, since the operation of the flash block read monitoring thread involves linked list access, page access, block data erasure and copying, it will bring certain performance overhead and requires the CPU to operate when it is idle. Therefore, the flash block read monitoring thread can first determine whether the processor CPU is in a busy state. When the CPU usage rate 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, the 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; when the CPU usage rate is greater than the fourth preset threshold, the CPU is in a busy state, and the flash block read monitoring thread continues to sleep. Among them, the fourth preset threshold can be a CPU usage rate of 50%, or it can be 60%, and the present invention does not limit this.

[0075] In the above embodiment, the data protection strategy of the NAND flash read-only partition can effectively solve the read interference problem of the read-only partition, and ensure the safety and reliability of the read-only partition data. In the case of power failure during data refresh or migration, data loss or file system damage will not be caused. In addition, by using the unused space of the flash read-only partition, the flash space utilization rate can be improved, and the normal business of the device can be ensured not to be affected, and the data protection mechanism will not cause performance problems when working.

[0076] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present invention.

[0077] In the present embodiment, a data storage device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.

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

[0079] A first determining module 802 is used to determine a first number of data flippings that occur 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;

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

[0081] A deletion module 806, configured to 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;

[0082] The establishing module 808 is used to establish a mapping relationship between the target access address and the replacement block, wherein the target access address is an address that establishes a mapping relationship with the target block.

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

[0084] In an exemplary embodiment, the device can determine the second preset threshold based on the error correction capability and the fault tolerance number in the following manner: determine a first product of the fault tolerance number and the error correction capability; determine a first sum of the first product and a first constant; determine a target difference between the first sum and a second constant; and determine a first upward integer value of the 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 the 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; and determine the data block as the replacement block.

[0086] In an exemplary embodiment, the device can also be used to, after copying the data in the target block to the replacement block: determine a second number of data refreshes that occur in the target block included in the access frequency information linked list; when 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 a node corresponding to the target block in the unused block linked list; when 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 in the unused block linked list.

[0087] In an exemplary embodiment, the device can also be used to, before determining the first number of data flips that occur in each target page included in the target block: determine the data storage blocks and unused blocks included in the target flash memory; create 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 of the data storage blocks; and create the unused block linked list, wherein the unused block linked list includes the physical block number of the unused block.

[0088] In an exemplary embodiment, the device can also be used to: determine the page number of the page to be accessed; determine the target number of pages included in the target block; determine a second rounded-down value of the ratio of the page number to the target number before determining the first number of data flips that occur in each target page included in the target block; and, if a target physical block number corresponding to the second rounded-down value exists in the access frequency information linked list, increase the number of accesses of the target physical block number included in the access frequency information linked list by 1; if a target physical block number corresponding to the second rounded-down value does not exist in the access frequency information linked list, create a block with a physical block number whose physical block number is the second rounded-down value in the unused block linked list.

[0089] In an exemplary embodiment, the device can also be used to: determine the usage rate of the processor of the device where the target flash memory is located before determining the first number of data flips that occur in each target page included in the target block; and when the usage rate is less than a fourth preset threshold, determine the 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.

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

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

[0092] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.

[0093] An embodiment of the present invention further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

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

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

[0096] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.

[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 computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order than here, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.

[0098] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A data 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 value among the first times, determining a replacement block from the unused block linked list of 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; A mapping relationship is established 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.

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 After copying the data in the target block to the replacement block, the method further comprises: Determine a second number of times data refresh occurs in the target block included in the access frequency information linked list; When the second number of times 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 in the unused block linked list; When the second number of times is less than or equal to a third preset threshold, the target block is erased, the data stored in the replacement block is copied to the target block, and a node corresponding to the replacement block is added to the unused block linked list.

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 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.

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 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.

8. 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.

9. 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, configured to determine a replacement block from an unused block linked list of the target flash memory when a number greater than a second preset threshold exists among the first numbers; 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 is 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.

10. 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 8 when executed.

11. 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 8.

12. 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 8 are implemented.

Citation Information

Patent Citations

  • Exception handling method and device

    CN111880990A

  • Disk management method and device, equipment and storage medium

    CN114625579A

  • Bad block management method of flash memory, storage medium, electronic device and solid state disk

    CN116467225A

  • Operation method and device of memory, storage medium and electronic device

    CN116893981A

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

    CN117742600A