Method, apparatus, electronic device, and storage medium for bad block processing

By dynamically adjusting the allocation and address mapping of replacement blocks in Nand Flash memory, the problem of waste of storage space in bad block processing is solved, and efficient utilization of replacement blocks in memory and optimized storage of user data is achieved.

CN115525217BActive Publication Date: 2025-08-05QINGDAO HAIER INTELLIGENT HOME APPLIANCE TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210994945.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-18
Publication Date
2025-08-05
Estimated Expiration
2042-08-18

AI Technical Summary

Technical Problem

In the prior art, when Nand Flash memory processes bad blocks, it is easy to waste storage space because when the number of bad blocks in the memory is small, the reserved replacement blocks cannot be fully utilized.

Method used

By decrementing from the highest address of the memory to the lowest address, replacing blocks are allocated to the target flash block, and the address mapping relationship is updated in the index table, the number of replacing blocks is dynamically adjusted to adapt to the change in the number of bad blocks.

Benefits of technology

Avoid waste of storage space, ensure that replacement blocks can still be effectively utilized when the number of bad blocks changes, and improves memory usage efficiency and user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115525217B_ABST
    Figure CN115525217B_ABST
Patent Text Reader

Abstract

The present application relates to the field of storage technology and discloses a method for bad block processing, comprising: upon receiving an operation instruction, determining whether the target flash memory block corresponding to the operation instruction is a bad block. In the case that the target flash memory block is a bad block, allocating a target replacement block to the target flash memory block; the allocation of target replacement blocks decreases in sequence from the highest address to the lowest address of the memory. The operation corresponding to the operation instruction is performed on the target replacement block. In this way, the number of flash memory blocks in the memory that serve as replacement blocks can change as the number of bad blocks in the memory changes, thereby avoiding wasting storage space. Furthermore, in the case where the number of bad blocks in the memory is large, there will be no problem of being unable to process due to a small number of reserved replacement blocks. The present application also discloses a device, electronic device, and storage medium for bad block processing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of storage technology, for example, to a method, device, electronic device and storage medium for bad block processing. Background Art

[0002] Nand Flash memory, a type of Flash memory, currently offers a cost-effective solution for implementing large-capacity solid-state memory. Its advantages include large capacity and fast rewrite speed, making it suitable for storing large amounts of data. However, existing Nand Flash manufacturing processes can lead to bad blocks during production and use. The current method for handling bad blocks is to create a bad block information table and reserve a set number of replacement blocks.

[0003] During the implementation of the embodiments of the present disclosure, it was found that at least the following problems exist in the related art:

[0004] In order to process bad blocks in a memory, the prior art usually reserves a large number of replacement blocks. However, if the number of bad blocks in the memory is small, some replacement blocks may be unusable, resulting in a waste of storage space. Summary of the Invention

[0005] In order to provide a basic understanding of some aspects of the disclosed embodiments, a brief summary is given below. The summary is not an extensive review, nor is it intended to identify key / critical elements or delineate the scope of protection of these embodiments, but rather serves as a prelude to the detailed description that follows.

[0006] The embodiments of the present disclosure provide a method, apparatus, electronic device, and storage medium for bad block processing, so as to avoid wasting storage space.

[0007] In some embodiments, the method for handling a bad block includes: upon receiving an operation instruction, determining whether a target flash memory block corresponding to the operation instruction is a bad block; if the target flash memory block is a bad block, allocating a target replacement block for the target flash memory block; allocating the target replacement blocks in descending order from the highest address to the lowest address in the memory; modifying the address of the actually used block corresponding to the target flash memory block to the address of the target replacement block in an index table; the index table storing the correspondence between the address of the actually used block corresponding to the flash memory block and the address of the flash memory block; and performing the operation corresponding to the operation instruction on the target replacement block.

[0008] In some embodiments, allocating a target replacement block to the target flash memory block includes: obtaining an alternative address in an index table; when the alternative address is greater than 0, decreasing the alternative address toward the lowest address in sequence until the first alternative replacement block corresponding to the alternative address is unused and is a good block, and determining the first alternative replacement block as the target replacement block; and modifying the alternative address stored in the index table to the difference between the address of the target replacement block and 1.

[0009] In some embodiments, allocating a target replacement block to the target flash memory block includes: obtaining an alternative address in an index table; when the alternative address is equal to 0 and the operation instruction is used to represent reading the first data in the target flash memory block, obtaining a second alternative replacement block corresponding to the target flash memory block in a memory; the label of the target flash memory block corresponding to the second alternative replacement block is the same as the label of the second alternative replacement block; obtaining the usage frequency of the second data stored in the second alternative replacement block and the usage frequency of the first data; when the usage frequency of the first data is greater than or equal to the usage frequency of the second data, using the second alternative replacement block as the target replacement block of the target flash memory block.

[0010] In some embodiments, after determining whether the target flash memory block is a bad block, the method further includes: if the target flash memory block is a good block, performing an operation corresponding to the operation instruction on the target flash memory block.

[0011] In some embodiments, an operation corresponding to the operation instruction is performed on the target flash memory block, including: when the operation instruction is used to represent writing third data to the target flash memory block, determining whether the target flash memory block is in use; when the target flash memory block is not in use, writing the third data to the target flash memory block; and / or, when the target flash memory block is in use, determining whether the first data in the target flash memory block can be replaced; when the first data in the target flash memory block can be replaced, erasing the first data from the target flash memory block and then writing the third data to the target flash memory block.

[0012] In some embodiments, determining whether the first data in the target flash memory block can be replaced includes: determining whether the address of the target flash memory block is within a preset threshold range; if the address of the target flash memory block is within the preset threshold range, determining that the first data in the target flash memory block can be replaced; and / or, if the address of the target flash memory block is not within the preset threshold range, determining that the first data in the target flash memory block cannot be replaced.

[0013] In some embodiments, determining whether the first data in the target flash memory block can be replaced includes: determining whether the value stored in the preset byte in the target flash memory block is a preset value; if the value stored in the preset byte is the preset value, determining that the first data in the target flash memory block can be replaced; and / or, if the value stored in the preset byte is not the preset value, determining that the first data in the target flash memory block cannot be replaced.

[0014] In some embodiments, the device for bad block processing includes: a judgment module, configured to determine whether the target flash memory block corresponding to the operation instruction is a bad block when an operation instruction is received; an allocation module, configured to allocate a target replacement block to the target flash memory block when the target flash memory block is a bad block; the allocation of target replacement blocks starts from the highest address of the memory and decreases in sequence to the lowest address; a modification module, configured to modify the address of the actually used block corresponding to the target flash memory block to the address of the target replacement block in the index table; the index table stores the correspondence between the address of the actually used block corresponding to the flash memory block and the address of the flash memory block.

[0015] An address mapping relationship between the address of a flash memory block and the address of its corresponding actually used block; an execution module configured to execute an operation corresponding to the operation instruction on the target replacement block.

[0016] In some embodiments, the electronic device includes a processor and a memory storing program instructions, and the processor is configured to execute the above-mentioned method for bad block processing when running the program instructions.

[0017] In some embodiments, the storage medium stores program instructions, and when the program instructions are run, the above-mentioned method for bad block processing is executed.

[0018] The method, apparatus, electronic device, and storage medium for bad block processing provided by the embodiments of the present disclosure can achieve the following technical effects: by allocating target replacement blocks to target flash memory blocks in descending order from the highest address in the memory to the lowest address, the number of flash memory blocks in the memory used as replacement blocks can change as the number of bad blocks in the memory changes, thereby avoiding wasting storage space. Furthermore, even if the number of bad blocks in the memory is large, there will be no problem of being unable to process the bad blocks due to a small number of reserved replacement blocks.

[0019] The above general description and the following description are exemplary and explanatory only and are not intended to limit the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] One or more embodiments are exemplarily described by corresponding drawings. These exemplary descriptions and drawings do not limit the embodiments. Elements with the same reference numerals in the drawings are shown as similar elements. The drawings do not constitute a scale limitation. In addition,

[0021] Figure 1 is a schematic diagram of a method for bad block processing provided by an embodiment of the present disclosure;

[0022] Figure 2 is a schematic diagram of another method for bad block processing provided by an embodiment of the present disclosure;

[0023] Figure 3 is a schematic diagram of another method for bad block processing provided by an embodiment of the present disclosure;

[0024] Figure 4 is a schematic diagram of another method for bad block processing provided by an embodiment of the present disclosure;

[0025] Figure 5 is a schematic diagram of a device for bad block processing provided by an embodiment of the present disclosure;

[0026] Figure 6 is a schematic diagram of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION

[0027] In order to be able to understand the features and technical content of the embodiments of the present disclosure in more detail, the implementation of the embodiments of the present disclosure is described in detail below in conjunction with the accompanying drawings. The accompanying drawings are for reference only and are not used to limit the embodiments of the present disclosure. In the following technical description, for the sake of convenience of explanation, a full understanding of the disclosed embodiments is provided through multiple details. However, one or more embodiments can still be implemented without these details. In other cases, to simplify the drawings, well-known structures and devices can be simplified for display.

[0028] In the description and claims of the embodiments of the present disclosure, as well as in the accompanying drawings, the terms "first," "second," and the like are used to distinguish similar items and are not necessarily used to describe a particular order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate to describe the embodiments of the present disclosure herein. In addition, the terms "including," "having," and any variations thereof are intended to cover non-exclusive inclusions.

[0029] Unless otherwise stated, the term "plurality" means two or more.

[0030] In the embodiment of the present disclosure, the character " / " indicates that the preceding and following objects are in an "or" relationship. For example, A / B means: A or B.

[0031] The term "and / or" describes an association between objects, indicating that three relationships can exist. For example, A and / or B means: A or B, or A and B.

[0032] The term "correspondence" may refer to an association relationship or a binding relationship. The correspondence between A and B means that there is an association relationship or a binding relationship between A and B.

[0033] Combine Figure 1 As shown, the embodiment of the present disclosure provides a method for bad block processing, including:

[0034] In step S101, upon receiving an operation instruction, the electronic device determines whether a target flash memory block corresponding to the operation instruction is a bad block.

[0035] Step S102: when the target flash memory block is a bad block, the electronic device allocates a target replacement block to the target flash memory block; the allocation of the target replacement blocks starts from the highest address of the memory and decreases in sequence to the lowest address.

[0036] In step S103, the electronic device modifies the address of the actual used block corresponding to the target flash memory block to the address of the target replacement block in the index table; the index table stores the correspondence between the address of the actual used block corresponding to the flash memory block and the address of the flash memory block.

[0037] Step S104: the electronic device performs an operation corresponding to the operation instruction on the target replacement block.

[0038] The method for handling bad blocks provided by the embodiments of the present disclosure allocates target replacement blocks to target flash memory blocks by sequentially assigning replacement blocks from the highest address in the memory to the lowest address. This allows the number of flash memory blocks in the memory to be used as replacement blocks to vary with the number of bad blocks in the memory, thereby avoiding wasting storage space. Furthermore, even if there are a large number of bad blocks in the memory, there is no problem of being unable to handle the bad blocks due to a small number of reserved replacement blocks.

[0039] In some embodiments, the index table is stored in two flash memory blocks with non-adjacent addresses. This way, the index tables in the two flash memory blocks back up each other, preventing the existence of consecutive bad blocks in the memory, which would render the index table unusable. In some embodiments, if the flash memory block at address 10 is a good block, the address of the corresponding block actually in use is 10.

[0040] Optionally, the target flash memory block corresponding to the operation instruction is determined in the following manner: the flash memory block corresponding to the address in the operation instruction is determined as the target flash memory block corresponding to the operation instruction.

[0041] Optionally, a target replacement block is assigned to the target flash memory block, including: obtaining an alternative address in an index table. When the alternative address is greater than 0, the alternative address is decremented toward the lowest address in sequence until the first alternative replacement block corresponding to the alternative address is unused and is a good block, and the first alternative replacement block is determined as the target replacement block. The alternative address stored in the index table is modified to the difference between the address of the target replacement block and 1. In this way, when a bad block appears in the memory again and a replacement block needs to be assigned to it, the replacement block can be searched for in descending order from the alternative address stored in the index table. There is no need to consider the alternative addresses that have been traversed, that is, there is no need to consider the flash memory blocks with addresses greater than the alternative addresses, thereby improving the replacement speed.

[0042] In some embodiments, the memory contains a total of 384 flash memory blocks, each with an address ranging from 0 to 383. When receiving an operation instruction, since the operation instruction includes the address "300," the flash memory block at address 300 is determined as the target flash memory block. If the target flash memory block is a bad block, the alternative address "350" is obtained from the index table. The address is decremented sequentially from 350, i.e., first determining whether the first alternative replacement block corresponding to address 350 is unused and a good block. If not, determining whether the first alternative replacement block corresponding to address 349 is unused and a good block, and continuing until the first alternative replacement block corresponding to the alternative address is unused and a good block, the first alternative replacement block is determined as the target replacement block. In some embodiments, when the alternative address 350 is decremented to 325, the first alternative replacement block corresponding to address 325 is unused and a good block, and the first alternative replacement block corresponding to address 325 is determined as the target replacement block. The alternative address stored in the index table is then modified to 324.

[0043] Optionally, performing an operation corresponding to the operation instruction on the target replacement block includes: if the operation instruction is used to indicate reading first data from the target flash memory block and the target replacement block allocated for the target flash memory block is unused, storing the first data from the target flash memory block into the target replacement block and then reading the first data from the target replacement block; and if the operation instruction is used to indicate writing third data to the target flash memory block and the target replacement block allocated for the target flash memory block is unused, writing the third data to the target replacement block.

[0044] Optionally, allocating a target replacement block to the target flash memory block includes: obtaining an alternative address in the index table, and when the alternative address is equal to 0 and the operation instruction is used to represent the reading of the first data in the target flash memory block, obtaining a second alternative replacement block corresponding to the target flash memory block in the memory; the label of the target flash memory block corresponding to the second alternative replacement block is the same as the label of the second alternative replacement block. Obtaining the usage frequency of the second data and the usage frequency of the first data stored in the second alternative replacement block. When the usage frequency of the first data is greater than or equal to the usage frequency of the second data, the second alternative replacement block is used as the target replacement block for the target flash memory block. In this way, when all flash memory blocks in the memory are used, data can be saved according to the usage frequency of the data, so that the data stored in the memory is data that meets user needs.

[0045] Combine Figure 2 As shown, the embodiment of the present disclosure provides a method for bad block processing, including:

[0046] Step S201: When receiving an operation instruction, the electronic device determines whether a target flash memory block corresponding to the operation instruction is a bad block.

[0047] Step S202: When the target flash memory block is a bad block, the electronic device obtains an alternative address from the index table.

[0048] In step S203, when the alternative address is equal to 0 and the operation instruction is used to represent reading the first data in the target flash memory block, the electronic device obtains a second alternative replacement block corresponding to the target flash memory block in the memory; the label of the target flash memory block corresponding to the second alternative replacement block is the same as the label of the second alternative replacement block.

[0049] Step S204: The electronic device obtains the usage frequency of the second data and the usage frequency of the first data stored in the second candidate replacement block.

[0050] Step S205: When the usage frequency of the first data is greater than or equal to the usage frequency of the second data, the electronic device uses the second candidate replacement block as a target replacement block for the target flash memory block.

[0051] Step S206 , the electronic device modifies the address of the actual used block corresponding to the target flash memory block to the address of the target replacement block in the index table; the index table stores the correspondence between the address of the actual used block corresponding to the flash memory block and the address of the flash memory block.

[0052] Step S207: The electronic device performs an operation corresponding to the operation instruction on the target replacement block.

[0053] By adopting the method for bad block processing provided by the embodiment of the present disclosure, target replacement blocks are allocated to target flash memory blocks by decreasing from the highest address to the lowest address in the memory. In this way, the number of flash memory blocks in the memory used as replacement blocks can change as the number of bad blocks in the memory changes, thereby not wasting storage space. Moreover, in the case where there are a large number of bad blocks in the memory, there will be no problem of being unable to process due to a small number of reserved replacement blocks. Moreover, in the case where all flash memory blocks in the memory are used and bad blocks appear in the memory again, the flash memory blocks can be adjusted according to the frequency of user data use, thereby reserving flash memory blocks that store data that the user wants to use, thereby improving the user's experience of using the memory.

[0054] Optionally, assigning a target replacement block to a target flash memory block includes: when an operation instruction indicates reading first data from the target flash memory block, obtaining a second candidate replacement block corresponding to the target flash memory block from a memory; the tag of the target flash memory block corresponding to the second candidate replacement block being the same as the tag of the second candidate replacement block; obtaining a usage frequency of the second data and a usage frequency of the first data stored in the second candidate replacement block; if the usage frequency of the first data is greater than or equal to the usage frequency of the second data, selecting the second candidate replacement block as the target replacement block for the target flash memory block; if the usage frequency of the first data is less than the usage frequency of the second data, obtaining a candidate address from an index table; if the candidate address is greater than 0, decrementing the candidate address until the first candidate replacement block corresponding to the candidate address is unused and good, and determining the first candidate replacement block as the target replacement block; and modifying the candidate address stored in the index table to the difference between the address of the target replacement block and 1. In this way, the data stored in the memory can be adjusted based on the frequency of user usage, so that the data stored in the memory is frequently used by the user. Furthermore, the first data in the target flash memory block can be transferred to an unused first candidate replacement block, so that the user can read the first data from the first candidate replacement block.

[0055] Optionally, an operation corresponding to the operation instruction is performed on the target replacement block, including: when the operation instruction is used to represent reading the first data in the target flash memory block and the target replacement block allocated to the target flash memory block has been used, after erasing the second data in the target replacement block, the first data in the target flash memory block is stored in the target replacement block, and then the first data is read from the target replacement block.

[0056] In some embodiments, upon receiving the operation instruction "read the first data stored in the flash memory block at address 200," the flash memory block at address 200 is determined as the target flash memory block, and the target flash memory block is labeled as a page image. A second candidate replacement block corresponding to the target flash memory block is obtained from the memory, with address 205 and also a page image label. The first data stored in the target flash memory block is an animal image, and the second data stored in the second candidate replacement block corresponding to the target flash memory block is a landscape image. The usage frequency of the animal images is obtained, i.e., the number of times the first data is read within a preset time range is counted. The usage frequency of the landscape images is obtained, i.e., the number of times the second data is read within a preset time range is counted. If the usage frequency of the first data is greater than or equal to the usage frequency of the second data, i.e., the number of times the user reads animal images more than the number of times they read landscape images within the preset time range, the second candidate replacement block corresponding to the target flash memory block is determined as the target replacement block corresponding to the target flash memory block. The address of the actually used block corresponding to the target flash memory block in the index table is modified to 250. Then, the second data stored in the second candidate replacement block is erased, the first data stored in the target flash memory block is written into the second candidate replacement block, and then the first data is read from the second candidate replacement block.

[0057] Optionally, after determining whether the target flash memory block is a bad block, the method further includes: if the target flash memory block is a good block, performing an operation corresponding to the operation instruction on the target flash memory block.

[0058] Optionally, performing an operation corresponding to the operation instruction on the target flash memory block includes: when the operation instruction is used to indicate reading first data in the target flash memory block, in response to the operation instruction, reading the first data from the target flash memory block; and when the operation instruction is used to indicate erasing the first data in the target flash memory block, in response to the operation instruction, erasing the first data stored in the target flash memory block.

[0059] Optionally, performing an operation corresponding to the operation instruction on the target flash memory block includes: if the operation instruction is used to indicate writing the third data into the target flash memory block, determining whether the target flash memory block is in use; if the target flash memory block is not in use, writing the third data into the target flash memory block; and / or, if the target flash memory block is in use, determining whether the first data in the target flash memory block can be replaced; if the first data in the target flash memory block can be replaced, erasing the first data from the target flash memory block and then writing the third data into the target flash memory block.

[0060] Optionally, after determining whether the first data in the target flash memory block can be replaced, the method further includes: issuing a first prompt message to prompt the user that the target flash memory block is unusable.

[0061] Combine Figure 3As shown, the embodiment of the present disclosure provides a method for bad block processing, including:

[0062] Step S301: upon receiving an operation instruction, the electronic device determines whether a target flash memory block corresponding to the operation instruction is a bad block;

[0063] In step S302, if the target flash memory block is a good block and the operation instruction indicates writing the third data into the target flash memory block, the electronic device determines whether the target flash memory block is in use. If not, the electronic device executes step S303. If yes, the electronic device executes step S304.

[0064] Step S303: The electronic device writes the third data into the target flash memory block, and then ends.

[0065] In step S304, the electronic device determines whether the first data in the target flash memory block can be replaced. If so, the electronic device executes step S305. Otherwise, the electronic device executes step S306.

[0066] Step S305: After erasing the first data from the target flash memory block, the electronic device writes the third data into the target flash memory block, and then ends.

[0067] Step S306: The electronic device sends a first prompt message to prompt the user that the target flash memory block is unusable.

[0068] By adopting the method for processing bad blocks provided by the embodiment of the present disclosure, the flash memory blocks can be adjusted according to the frequency of user data use, thereby reserving flash memory blocks for storing data that the user wants to use, thereby improving the user experience of using the memory.

[0069] Optionally, determining whether the first data in the target flash memory block can be replaced includes: determining whether the address of the target flash memory block is within a preset threshold range; if the address of the target flash memory block is within the preset threshold range, determining that the first data in the target flash memory block can be replaced; and / or, if the address of the target flash memory block is not within the preset threshold range, determining that the first data in the target flash memory block cannot be replaced.

[0070] Optionally, determining whether the first data in the target flash memory block can be replaced includes: determining whether a value stored in a preset byte in the target flash memory block is a preset value; if the value stored in the preset byte is the preset value, determining that the first data in the target flash memory block can be replaced; and / or if the value stored in the preset byte is not the preset value, determining that the first data in the target flash memory block cannot be replaced.

[0071] Furthermore, after erasing the first data from the target flash memory block and writing the third data to the target flash memory block, the method further includes: sending a second prompt message to the user terminal to prompt the user to determine whether the third data is important. If the user terminal responds that the third data is important, a preset value (e.g., 1) is written into a preset byte of the target flash memory block. If the user terminal responds that the third data is not important, a value other than the preset value (e.g., 0) is written into the preset byte of the target flash memory block.

[0072] Combine Figure 4 As shown, the embodiment of the present disclosure provides a method for bad block processing, including:

[0073] Step S401: upon receiving an operation instruction, the electronic device determines whether a target flash memory block corresponding to the operation instruction is a bad block;

[0074] In step S402, if the target flash memory block is a good block and the operation instruction indicates writing the third data into the target flash memory block, the electronic device determines whether the target flash memory block is in use. If not, the electronic device executes step S403. If yes, the electronic device executes step S404.

[0075] In step S403, the electronic device writes the third data into the target flash memory block, and then proceeds to step S407.

[0076] In step S404, the electronic device determines whether the first data in the target flash memory block can be replaced. If so, the electronic device executes step S405. Otherwise, the electronic device executes step S406.

[0077] Step S405: After erasing the first data from the target flash memory block, the electronic device writes the third data into the target flash memory block, and then proceeds to step S407.

[0078] Step S406: The electronic device issues a first prompt message to the user to inform him that the target flash memory block is unusable. The process then ends.

[0079] Step S407: The electronic device sends a second prompt message to the user terminal to prompt the user to determine whether the third data is important.

[0080] By adopting the method for processing bad blocks provided by the embodiment of the present disclosure, the flash memory blocks can be adjusted according to the frequency of user data use, thereby reserving flash memory blocks for storing data that the user wants to use, thereby improving the user experience of using the memory.

[0081] Optionally, determining whether the first data in the target flash memory block can be replaced includes: if the first data is information stream data, determining that the first data in the target memory block can be replaced. In some embodiments, the information stream data includes data entered by a user when accessing a web page and data fed back to the user terminal by the web page.

[0082] Combine Figure 5 As shown, an embodiment of the present disclosure provides a device for bad block processing, including a judgment module 501, an allocation module 502, a modification module 503 and an execution module 504. The judgment module 501 is configured to, upon receiving an operation instruction, determine whether the target flash memory block corresponding to the operation instruction is a bad block. The allocation module 502 is configured to allocate a target replacement block to the target flash memory block when the target flash memory block is a bad block; the allocation of the target replacement block decreases from the highest address to the lowest address of the memory. The modification module 503 is configured to modify the address of the actual use block corresponding to the address of the target flash memory block to the address of the target replacement block in the index table; the index table stores the correspondence between the address of the actual use block corresponding to the flash memory block and the address of the flash memory block. The execution module 504 is configured to perform an operation corresponding to the operation instruction on the target replacement block.

[0083] The apparatus for handling bad blocks provided by the embodiments of the present disclosure allocates target replacement blocks to target flash memory blocks by sequentially assigning replacement blocks from the highest address in the memory to the lowest address. This allows the number of flash memory blocks in the memory to be used as replacement blocks to vary with the number of bad blocks in the memory, thereby avoiding wasting storage space. Furthermore, even if the number of bad blocks in the memory is large, there is no problem of being unable to handle the bad blocks due to a small number of reserved replacement blocks.

[0084] Optionally, the allocation module is configured to allocate a target replacement block to the target flash memory block by: obtaining a candidate address from an index table; if the candidate address is greater than 0, decreasing the candidate address in descending order toward the lowest address until the first candidate replacement block corresponding to the candidate address is unused and good, and determining the first candidate replacement block as the target replacement block; and modifying the candidate address stored in the index table to the difference between the address of the target replacement block and 1.

[0085] Optionally, the allocation module is configured to allocate a target replacement block to the target flash memory block in the following manner: obtaining an alternative address from an index table; when the alternative address is equal to 0 and the operation instruction is used to indicate reading the first data in the target flash memory block, obtaining a second alternative replacement block corresponding to the target flash memory block from a memory; the tag of the target flash memory block corresponding to the second alternative replacement block is the same as the tag of the second alternative replacement block. Obtaining the usage frequency of the second data and the usage frequency of the first data stored in the second alternative replacement block. If the usage frequency of the first data is greater than or equal to the usage frequency of the second data, using the second alternative replacement block as the target replacement block for the target flash memory block.

[0086] Optionally, the execution module is further configured to execute an operation corresponding to the operation instruction on the target flash memory block when the target flash memory block is a good block.

[0087] Optionally, the execution module is configured to perform an operation corresponding to the operation instruction on the target flash memory block in the following manner: if the operation instruction is used to indicate that the third data is to be written to the target flash memory block, determining whether the target flash memory block is in use; if the target flash memory block is not in use, writing the third data to the target flash memory block; and / or, if the target flash memory block is in use, determining whether the first data in the target flash memory block can be replaced; and if the first data in the target flash memory block can be replaced, erasing the first data from the target flash memory block and then writing the third data to the target flash memory block.

[0088] Optionally, determining whether the first data in the target flash memory block can be replaced includes: determining whether an address of the target flash memory block is within a preset threshold range. If the address of the target flash memory block is within the preset threshold range, determining that the first data in the target flash memory block can be replaced. And / or, if the address of the target flash memory block is not within the preset threshold range, determining that the first data in the target flash memory block cannot be replaced.

[0089] Optionally, determining whether the first data in the target flash memory block can be replaced includes: determining whether a value stored in a preset byte in the target flash memory block is a preset value. If the value stored in the preset byte is the preset value, determining that the first data in the target flash memory block can be replaced. And / or, if the value stored in the preset byte is not the preset value, determining that the first data in the target flash memory block cannot be replaced.

[0090] Combine Figure 6 As shown, an embodiment of the present disclosure provides an electronic device, including a processor 600 and a memory 601. Optionally, the electronic device may further include a communication interface 602 and a bus 603. The processor 600, the communication interface 602, and the memory 601 may communicate with each other via the bus 603. The communication interface 602 may be used for information transmission. The processor 600 may call logic instructions in the memory 601 to execute the method for bad block processing of the above embodiment.

[0091] With the electronic device provided by the embodiments of the present disclosure, target replacement blocks are allocated to target flash memory blocks by sequentially decreasing the address from the highest to the lowest in the memory. This allows the number of flash memory blocks in the memory used as replacement blocks to change as the number of bad blocks in the memory changes, thereby avoiding wasting storage space. Furthermore, even if there are a large number of bad blocks in the memory, there is no problem of being unable to process them due to a small number of reserved replacement blocks.

[0092] In the embodiments of the present disclosure, the electronic device is a computer, a mobile phone, or a tablet computer.

[0093] In addition, the logic instructions in the memory 601 can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product.

[0094] The memory 601 is a computer-readable storage medium that can be used to store software programs and computer-executable programs, such as program instructions / modules corresponding to the methods in the embodiments of the present disclosure. The processor 600 executes the program instructions / modules stored in the memory 601 to perform functional applications and data processing, thereby implementing the method for bad block processing in the above-mentioned embodiments.

[0095] The memory 601 may include a program storage area and a data storage area. The program storage area may store an operating system and at least one application required for a function; the data storage area may store data generated based on the use of the terminal device. Furthermore, the memory 601 may include a high-speed random access memory and a non-volatile memory.

[0096] An embodiment of the present disclosure provides a storage medium storing program instructions, which, when run, execute the above-mentioned method for bad block processing.

[0097] An embodiment of the present disclosure provides a computer program product, which includes a computer program stored on a computer-readable storage medium. The computer program includes program instructions, which, when executed by a computer, enable the computer to execute the above-mentioned method for bad block processing.

[0098] The aforementioned computer-readable storage medium may be a transient computer-readable storage medium or a non-transitory computer-readable storage medium.

[0099] The technical solution of the embodiments of the present disclosure may be embodied in the form of a software product, which is stored in a storage medium and includes one or more instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in the embodiments of the present disclosure. The aforementioned storage medium may be a non-transitory storage medium, including: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program code, or a transient storage medium.

[0100] The above description and the accompanying drawings fully illustrate the embodiments of the present disclosure so that those skilled in the art can practice them. Other embodiments may include structural, logical, electrical, process and other changes. The embodiments represent only possible variations. Unless explicitly required, individual components and functions are optional, and the order of operations may vary. Parts and features of some embodiments may be included in or replace parts and features of other embodiments. Moreover, the words used in this application are only used to describe the embodiments and are not used to limit the claims. As used in the description of the embodiments and claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to also include plural forms. Similarly, the term "and / or" as used in this application refers to any and all possible combinations of one or more associated listings. In addition, when used in this application, the term "comprise" and its variations "comprises" and / or comprising refer to the presence of stated features, wholes, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or groups of these. In the absence of further restrictions, an element defined by the sentence "comprising a..." does not exclude the presence of other identical elements in the process, method or device that includes the element. In this article, each embodiment may focus on the differences from other embodiments, and the same and similar parts between the various embodiments can be referenced to each other. For the methods, products, etc. disclosed in the embodiments, if they correspond to the method part disclosed in the embodiments, then the relevant parts can be found in the description of the method part.

[0101] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software may depend on the specific application and design constraints of the technical solution. The technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the embodiments of the present disclosure. The technicians will clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0102] In the embodiments disclosed herein, the disclosed methods and products (including but not limited to devices, equipment, etc.) can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the units can be merely a logical functional division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between each other shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, and can be electrical, mechanical or other forms. The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected to implement this embodiment according to actual needs. In addition, the functional units in the embodiments of the present disclosure may be integrated into a processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0103] The flowcharts and block diagrams in the accompanying drawings show the possible implementation architectures, functions and operations of the systems, methods and computer program products according to the embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, program segment or part of the code, and the module, program segment or part of the code contains one or more executable instructions for implementing the specified logical functions. In some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, or they can sometimes be executed in the opposite order, which can depend on the functions involved. In the descriptions corresponding to the flowcharts and block diagrams in the accompanying drawings, the operations or steps corresponding to different boxes can also occur in an order different from that disclosed in the description, and sometimes there is no specific order between different operations or steps. For example, two consecutive operations or steps can actually be executed substantially in parallel, or they can sometimes be executed in the opposite order, which can depend on the functions involved. Each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented by a dedicated hardware-based system that performs the specified function or action, or may be implemented by a combination of dedicated hardware and computer instructions.

Claims

1. A method for bad block processing, characterized in that: include: Upon receiving an operation instruction, determining whether a target flash memory block corresponding to the operation instruction is a bad block; In the case that the target flash memory block is a bad block, a target replacement block is allocated to the target flash memory block; the allocation of the target replacement blocks starts from the highest address of the memory and decreases in sequence to the lowest address; Modifying the address of the actual use block corresponding to the target flash memory block to the address of the target replacement block in the index table; the index table stores the correspondence between the address of the actual use block corresponding to the flash memory block and the address of the flash memory block; performing an operation corresponding to the operation instruction on the target replacement block; Allocating a target replacement block to the target flash memory block includes: obtaining an alternative address in an index table; when the alternative address is equal to 0 and the operation instruction is used to represent reading the first data in the target flash memory block, obtaining a second alternative replacement block corresponding to the target flash memory block in a memory; the label of the target flash memory block corresponding to the second alternative replacement block is the same as the label of the second alternative replacement block; obtaining the usage frequency of the second data stored in the second alternative replacement block and the usage frequency of the first data; when the usage frequency of the first data is greater than or equal to the usage frequency of the second data, using the second alternative replacement block as the target replacement block of the target flash memory block.

2. The method according to claim 1, characterized in that Allocating a target replacement block for the target flash memory block includes: Get the alternative address in the index table; If the candidate address is greater than 0, the candidate address is decremented toward the lowest address until the first candidate replacement block corresponding to the candidate address is unused and good, and the first candidate replacement block is determined as the target replacement block; The candidate address stored in the index table is modified to the difference between the address of the target replacement block and 1.

3. The method according to claim 1, characterized in that After determining whether the target flash memory block is a bad block, the method further includes: In a case where the target flash memory block is a good block, an operation corresponding to the operation instruction is performed on the target flash memory block.

4. The method according to claim 3, characterized in that Executing an operation corresponding to the operation instruction on the target flash memory block includes: In a case where the operation instruction is used to indicate writing third data into the target flash memory block, determining whether the target flash memory block is in use; If the target flash memory block is not in use, writing the third data into the target flash memory block; and / or, If the target flash memory block has been used, determining whether the first data in the target flash memory block can be replaced; In a case where the first data in the target flash memory block can be replaced, the first data is erased from the target flash memory block and then the third data is written into the target flash memory block.

5. The method according to claim 4, characterized in that Determining whether the first data in the target flash memory block can be replaced includes: Determining whether the address of the target flash memory block is within a preset threshold range; If the address of the target flash memory block is within the preset threshold range, determining that the first data in the target flash memory block can be replaced; and / or, When the address of the target flash memory block is not within the preset threshold range, it is determined that the first data in the target flash memory block cannot be replaced.

6. The method according to claim 4, characterized in that Determining whether the first data in the target flash memory block can be replaced includes: Determining whether the value stored in the preset byte in the target flash memory block is a preset value; In a case where the value stored in the preset byte is a preset value, determining that the first data in the target flash memory block can be replaced; and / or, In a case where the value stored in the preset byte is not a preset value, it is determined that the first data in the target flash memory block cannot be replaced.

7. A device for bad block processing, characterized in that: include: a judgment module configured to, upon receiving an operation instruction, judge whether a target flash memory block corresponding to the operation instruction is a bad block; an allocating module configured to allocate a target replacement block to the target flash memory block when the target flash memory block is a bad block; the allocation of the target replacement blocks starts from the highest address of the memory and decreases in sequence to the lowest address; a modification module configured to modify the address of the actually used block corresponding to the target flash memory block to the address of the target replacement block in the index table; the index table stores the correspondence between the address of the actually used block corresponding to the flash memory block and the address of the flash memory block; an execution module, configured to execute an operation corresponding to the operation instruction on the target replacement block; The allocation module is configured to allocate a target replacement block to the target flash memory block in the following manner, including: obtaining an alternative address in an index table; when the alternative address is equal to 0 and the operation instruction is used to represent reading the first data in the target flash memory block, obtaining a second alternative replacement block corresponding to the target flash memory block in a memory; the label of the target flash memory block corresponding to the second alternative replacement block is the same as the label of the second alternative replacement block; obtaining the usage frequency of the second data stored in the second alternative replacement block and the usage frequency of the first data; when the usage frequency of the first data is greater than or equal to the usage frequency of the second data, using the second alternative replacement block as the target replacement block of the target flash memory block.

8. An electronic device comprising a processor and a memory storing program instructions, characterized in that: The processor is configured to execute the method for bad block processing according to any one of claims 1 to 6 when running the program instructions.

9. A storage medium storing program instructions, characterized in that: When the program instructions are executed, the method for bad block processing according to any one of claims 1 to 6 is executed.

Citation Information

Patent Citations

  • Bad block management method facing high-capacity FLASH solid memory

    CN101320596A

  • NAND Flash bad block management method and system

    CN106776359A