Bad block processing method and device, equipment and storage medium
By creating permission constraint files in the file system of the terminal device and mapping their block addresses to bad blocks, the problem of low memory space utilization caused by bad blocks in Nand Flash memory is solved, and higher memory space utilization and data integrity are achieved.
Patent Information
- Application Number
- CN202311310828.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-10
- Publication Date
- 2025-04-11
AI Technical Summary
Due to its special physical structure and characteristics in Nand Flash memory, bad blocks are prone to occur, resulting in low memory space utilization of the storage module.
Create a permission constraint file in the file system of the terminal device and map its block address to the bad block, establish an association between the permission constraint file and the bad block to constrain the function of the bad block.
By not setting a reserved space for handling bad blocks, the memory space available to users is increased, thereby improving the memory space utilization of the storage module and ensuring data integrity.
Smart Images

Figure CN119807096A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of data storage, and in particular to a bad block processing method, device, equipment and storage medium. Background Art
[0002] Nand Flash memory is a type of Flash memory that provides a cheap and effective solution for the implementation of solid-state large-capacity memory. Nand Flash memory has the advantages of large capacity and fast rewrite speed, and is suitable for storing large amounts of data, such as embedded products including digital cameras, memory cards, and compact USB flash drives. Nand Flash is a non-volatile memory that can be used in embedded systems. However, due to its special physical structure and characteristics, bad blocks may appear in Nand Flash. In order to ensure the reliability and stability of Nand Flash, bad block management is required. Summary of the invention
[0003] The present disclosure provides a bad block processing method, device, equipment and storage medium to overcome the problem of low memory space utilization of a storage module.
[0004] According to a first aspect of the present disclosure, a bad block processing method is provided, comprising: when a power-on event is detected, determining the number of bad blocks from a preset bad block table of a storage module; based on the number of bad blocks, creating a permission constraint file in a file system of a terminal device; wherein the permission constraint file does not have a garbage collection function; and the storage module maps the block address of the permission constraint file to the bad block to associate the block address of the permission constraint file with the block address of the bad block.
[0005] In some embodiments, based on the number of bad blocks, a permission constraint file is created in the file system of the terminal device, including: obtaining the memory space of the bad blocks; determining the target memory space according to the number of bad blocks and the memory space of the bad blocks; and creating the permission constraint file in the file system according to the target memory space.
[0006] In some embodiments, a permission constraint file is created in the file system according to the target memory space, including: according to the target memory space, determining at least two consecutive blocks among all blocks of the file system, the memory space of at least two blocks being greater than or equal to the target memory space; and creating the permission constraint file on at least two consecutive blocks.
[0007] In some embodiments, the storage module maps the block address of the permission constraint file to the bad block, including: determining the block address of the permission constraint file according to the address of the block where the permission constraint file is located in the file system; determining the block address of the bad block according to the address of the block where the bad block is located in the storage module; and associating and saving the block address of the permission constraint file with the block address of the bad block.
[0008] In some embodiments, the method further includes: when a garbage collection instruction is detected, not performing memory release processing on a bad block of a block address that maps a permission constraint file.
[0009] In some embodiments, the method further includes: if a bad block is generated during data storage in the storage module, writing the data to be stored into the next block adjacent to the bad block.
[0010] In some embodiments, the method further includes: adjusting a freezing threshold of the storage module based on the number of bad blocks; and switching the storage module to a non-working state when the number of bad blocks is greater than the adjusted freezing threshold.
[0011] In some embodiments, determining the target memory space according to the number of bad blocks and the memory space of the bad blocks includes: determining the target memory space based on the product between the number of bad blocks and the memory space of the bad blocks.
[0012] According to a second aspect of the present disclosure, a bad block processing device is provided, which includes: a control module, configured to determine the number of bad blocks from a preset bad block table of a storage module when a power-on event is detected; the control module is also configured to create a permission constraint file in a file system of a terminal device based on the number of bad blocks; wherein the permission constraint file does not have a garbage collection function; and the storage module is configured to map a block address of the permission constraint file to a bad block, so as to associate the block address of the permission constraint file with the block address of the bad block.
[0013] In some embodiments, the control module is configured to: obtain the memory space of the bad blocks; determine the target memory space according to the number of bad blocks and the memory space of the bad blocks; and create a permission constraint file in the file system according to the target memory space.
[0014] In some embodiments, the control module is configured to: determine at least two consecutive blocks among all blocks of the file system according to the target memory space, and the memory space of at least two blocks is greater than or equal to the target memory space; and create a permission constraint file on at least two consecutive blocks.
[0015] In some embodiments, the storage module is configured to: determine the block address of the permission constraint file based on the address of the block where the permission constraint file is located in the file system; determine the block address of the bad block based on the address of the block where the bad block is located in the storage module; and associate and save the block address of the permission constraint file with the block address of the bad block.
[0016] In some embodiments, the control module is further configured to: when a garbage collection instruction is detected, not perform memory release processing on the bad block of the block address mapping the permission constraint file.
[0017] In some embodiments, the control module is further configured to: if a bad block is generated during the process of data storage in the storage module, write the data to be stored into the next block adjacent to the bad block.
[0018] In some embodiments, the control module is further configured to: adjust the freezing threshold of the storage module based on the number of bad blocks; and switch the storage module to a non-working state when the number of bad blocks is greater than the adjusted freezing threshold.
[0019] In some embodiments, the control module is configured to determine the target memory space based on the product of the number of bad blocks and the memory space of the bad blocks.
[0020] According to a third aspect of the present disclosure, an electronic device is provided, comprising: a memory for storing processor executable instructions; a processor connected to the memory; wherein the processor is used to execute the bad block processing method as described in the first aspect of the present disclosure.
[0021] According to a fourth aspect of the present disclosure, a non-transitory computer-readable storage medium is provided. When instructions in the storage medium are executed by a processor of a computer, the computer is enabled to execute the method described in the first aspect of the present disclosure.
[0022] The technical solution provided by the present disclosure may have the following beneficial effects:
[0023] The present disclosure creates a permission constraint file in the file system of the terminal device, maps the block address of the permission constraint file to the bad block in the storage module, and associates the block address of the permission constraint file with the block address of the bad block. By establishing an association relationship between the block address of the permission constraint file and the block address of the bad block, the permission constraint file is used to constrain the function of the bad block, so that there is no need to set a reserved space for processing the bad block, so that the memory space available to the user becomes larger, thereby improving the utilization rate of the memory space of the storage module.
[0024] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0026] Figure 1 The following is a flow chart of a bad block processing method according to an exemplary embodiment of the present disclosure. Figure 1 ;
[0027] Figure 2 The following is a flow chart of a bad block processing method according to an exemplary embodiment of the present disclosure. Figure 2 ;
[0028] Figure 3 The following is a flow chart of a bad block processing method according to an exemplary embodiment of the present disclosure. Figure 3 ;
[0029] Figure 4 It is a flowchart of a bad block processing method provided by an embodiment of the present disclosure;
[0030] Figure 5 is a block diagram of a bad block processing device according to an exemplary embodiment;
[0031] Figure 6 It is a hardware structure block diagram of a bad block processing device 600 according to an exemplary embodiment. DETAILED DESCRIPTION
[0032] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices consistent with some aspects of the present disclosure as detailed in the appended claims.
[0033] It should be noted that the bad block processing method in the present disclosure can be applied to terminal devices. The terminal devices may include but are not limited to: mobile phones, tablet computers, virtual reality (VR) devices, augmented reality (AR) devices, drones, 3D games, monitoring systems, personal digital assistants (PDAs), digital recorders, MP3 players, electronic toys, etc.
[0034] In some embodiments, the storage module may be a unit in a terminal device that can store data. For example, the storage module may be a non-volatile memory, which may include: NAND flash memory (Nand Flash), NOR flash memory (Nor Flash), low power double data rate synchronous dynamic random access memory (LPDDRL) and embedded MultiMediaCard (eMMC), etc. Among them, Nand Flash is a non-volatile memory based on NAND technology. Nand Flash memory has the characteristics of high storage density, low power consumption and long life. Nand Flash memory is mainly composed of NAND chips, capacitors, resistors and other components.
[0035] Since the process of Nand Flash memory cannot guarantee that the memory array of Nand Flash maintains reliable performance during its life cycle (charge may not be locked due to other abnormal reasons), bad blocks will be generated during the production and use of Nand Flash. For example, a flash area in Nand Flash that cannot be erased or written can be determined as a bad block, where one unit area is a bad block.
[0036] It should be noted that Nand Flash includes universal flash storage (UFS) and solid state disk (SSD). In the related technology, some blocks are fixedly reserved in the storage space of Nand Flash as reserved blocks. When a bad block is encountered, a block is selected from the reserved blocks to replace the bad block, and the data originally written to the bad block is written to the replacement block.
[0037] For example, Nand Flash can be set with a fixed reserved space after leaving the factory to replace bad blocks. However, for users, the product may not be used during the entire life cycle, or only a small amount of reserved space may be used to replace bad blocks. If a fixed reserved space is set, it may lead to space waste. Therefore, how to increase the user's usable space while taking into account the bad block processing is a problem that needs to be solved urgently.
[0038] The disclosed embodiment provides a bad block processing method to overcome the problem of low memory space utilization of a storage module.
[0039] Figure 1The following is a flow chart of a bad block processing method according to an exemplary embodiment of the present disclosure. Figure 1 . See Figure 1 As shown, the bad block processing method includes:
[0040] In step 101, when a power-on event is detected, the number of bad blocks is determined from a preset bad block table of the storage module.
[0041] It can be understood that when the device is powered on, the control module in the terminal device sends a first command to the storage module, and the first command is used to instruct the storage module in the terminal device to determine the number of bad blocks by querying a preset bad block table, wherein the bad block table records and identifies the status information of each block (i.e., bad block or good block), and the storage module can confirm the number of bad blocks by confirming the number of status information marked as bad blocks in the bad block table. After confirming the number of bad blocks, the storage module can return the number of bad blocks to the control module.
[0042] In the embodiment of the present disclosure, the control module may be a central processing unit (CPU), and the storage module may be a Nand Flash.
[0043] Among them, due to the characteristics of Nand Flash, Nand Flash is more likely to have bad blocks. When Nand Flash leaves the factory, it is necessary to manage the factory bad blocks, establish a bad block table (BBT), and record the information of the factory bad blocks in the bad block table. Bad blocks (i.e., newly added bad blocks) that appear during the use of Nand Flash will also be recorded in the bad block table.
[0044] In some embodiments, a bad block table may be created in the first block of the storage module, and information of all blocks of the storage module may be recorded in the bad block table.
[0045] It is understandable that the first block of a Nand Flash must be a good block when it leaves the factory, otherwise the entire Nand Flash cannot be used. Therefore, in the prior art, a bad block table is stored in the first block of the Nand Flash. The bad block table records information about all blocks in the Nand Flash.
[0046] In one example, when a 1-bit number is used to identify a block in the Nand Flash, in the bad block table, 0 indicates a good block and 1 indicates a bad block.
[0047] In another example, when a 2-bit number is used to identify blocks in Nand Flash, in the bad block table, 00 indicates a good block, 01 indicates a bad block that fails to program, 10 indicates a bad block that fails to read, and 11 indicates a bad block that fails to erase.
[0048] In step 102, based on the number of bad blocks, a permission constraint file is created in the file system of the terminal device.
[0049] The permission constraint file does not have the garbage collection (GC) function. Garbage collection is an automatic memory management mechanism that is responsible for detecting and cleaning up unused objects at runtime to release memory resources.
[0050] It should be noted that the file system is software in a terminal device that is responsible for managing and storing file information, and the file system is located in a control module of the terminal device.
[0051] It can be understood that after obtaining the number of bad blocks returned by the storage module, the control module in the terminal device can determine the size of the memory space of the bad blocks based on the number of bad blocks, and create a permission constraint file in the file system. The size of the memory space of the permission constraint file can be greater than or equal to the size of the memory space of the bad blocks.
[0052] In the disclosed embodiment, the permission constraint file does not have any permissions (such as read permission, modify permission, permission to read and write files, and permission to read and execute files, etc.), and does not participate in garbage collection. For example, the permission constraint file can be a zombie file, where a zombie file refers to a file that has been deleted by the server but cannot release disk space due to being called by some process.
[0053] In one example, after receiving the number of bad blocks sent by the storage module, the control module of the terminal device can create a permission constraint file based on the number of bad blocks, and the size of the memory space of the permission constraint file can be greater than or equal to the size of the memory space of the bad blocks.
[0054] In step 103, the storage module maps the block address of the permission constraint file to the bad block to associate the block address of the permission constraint file with the block address of the bad block.
[0055] The block address of the permission-constrained file can be one of a logical block address (LBA) and a linear address. LBA is used to specify an operand or the address of an instruction in a machine language instruction. A linear address, also known as a virtual address, is a 32-bit unsigned integer that can be used to represent an address greater than 4GB.
[0056] It can be understood that after creating the permission constraint file, the control module of the terminal device can send a second command to the storage module, where the second command is used to instruct the storage module to map the block address of the permission constraint file to the bad block.
[0057] In one example, after creating the permission constraint file, the control module of the terminal device can send a command (i.e., a second command) to the storage module, which carries the block address of the permission constraint file. The storage module receives the command and responds by mapping the block address of the permission constraint file to the bad block to associate the block address of the permission constraint file with the block address of the bad block. After the mapping is completed, the storage module sends a notification message to the control module, which is used to indicate that the storage module has completed the mapping.
[0058] In some embodiments, after the block address of the permission constraint file is mapped to the bad block, if a garbage collection instruction is received, the bad block stored in association with the block address of the permission constraint file may not be released from memory.
[0059] In the embodiment of the present disclosure, the first command and the second command are both custom commands, which can be set according to actual conditions, and the embodiment of the present disclosure does not specifically limit this.
[0060] In the disclosed embodiment, a permission constraint file is created in the file system of the terminal device, and the block address of the permission constraint file is mapped to the bad block in the storage module, so that the block address of the permission constraint file is associated with the block address of the bad block. By establishing an association relationship between the block address of the permission constraint file and the block address of the bad block, the permission constraint file is used to constrain the function of the bad block, so that there is no need to set a reserved space for processing the bad block, so that the memory space available to the user becomes larger, thereby improving the utilization rate of the memory space of the storage module.
[0061] In some possible implementations, Figure 2 The following is a flow chart of a bad block processing method according to an exemplary embodiment of the present disclosure. Figure 2 , see Figure 2 As shown, the above step 102 may include the following steps:
[0062] In step 201, the memory space of the bad block is obtained.
[0063] In some embodiments, when the storage module leaves the factory, the size of the memory space of the block is set, and the control module can determine the memory space of the bad block according to the model, parameters and other information of the storage module.
[0064] In other embodiments, the size of the memory space of the block in the storage module can be adjusted according to actual conditions, and the control module can determine the memory space of the bad block by reading the information of the block in the storage module.
[0065] In step 202, a target memory space is determined according to the number of bad blocks and the memory space of the bad blocks.
[0066] In some embodiments, the memory spaces of the bad blocks may be the same or different.
[0067] In some embodiments, the control module can determine the target memory space of the permission constraint file based on the product between the number of bad blocks and the memory space of the bad blocks, and the size of the target memory space is equal to the product between the number of bad blocks and the memory space of the bad blocks.
[0068] In other embodiments, when the memory spaces of the bad blocks are different, the control module may first determine the sizes of the memory spaces of the bad blocks, and then determine the sum of the sizes of the memory spaces of the bad blocks as the target memory space of the permission-constrained file.
[0069] In step 203, a permission constraint file is created in the file system according to the target memory space.
[0070] It is understandable that after the control module determines the size of the target memory space by calculation, it can create at least one permission constraint file in the file system. The sum of the memory space sizes of the at least one permission constraint file is equal to the size of the target memory space. That is, when a permission constraint file is created, the size of the memory space of the permission constraint file is equal to the size of the target memory space; when multiple permission constraint files are created, the sum of the memory space sizes of the multiple permission constraint files is equal to the size of the target memory space.
[0071] In the embodiment of the present disclosure, by determining the target memory space based on the number of bad blocks and the memory space, and then creating a permission constraint file in the file system according to the target memory space, wherein the size of the target memory space is greater than or equal to the product of the number of bad blocks and the memory space of the bad blocks, the possibility of being unable to map due to insufficient memory of the permission constraint file can be reduced.
[0072] In some possible implementations, the above step 203 may include: according to the target memory space, determining at least two consecutive blocks among all blocks of the file system, the size of the memory space of the at least two consecutive blocks being greater than or equal to the size of the target memory space; and creating a permission constraint file on the at least two consecutive blocks.
[0073] It can be understood that the control module can search for continuous blocks in all blocks of the file system according to the size of the target memory space, the sum of the sizes of the memory spaces of these continuous blocks should be greater than or equal to the size of the target memory space, and then create permission constraint files on these continuous blocks.
[0074] It should be noted that in the embodiment of the present disclosure, the block used to create the permission constraint file is not limited to the above setting method. The block address of the permission constraint file can also be discontinuous, that is, the control module can create the permission constraint file on discontinuous blocks.
[0075] In the disclosed embodiment, creating a permission constraint file on continuous blocks can make the block addresses of the permission constraint file continuous. The continuous block addresses reduce the fragmentation of the permission constraint file and have little impact on the reading performance of the storage module.
[0076] In some possible implementations, Figure 3 The following is a flow chart of a bad block processing method according to an exemplary embodiment of the present disclosure. Figure 3 , see Figure 3 As shown, the above step 103 may include:
[0077] In step 301, the block address of the permission constraint file is determined according to the address of the block where the permission constraint file is located in the file system.
[0078] It can be understood that the logical number of the block where the permission constraint file is located is the block address of the permission constraint file.
[0079] In step 302, the block address of the bad block is determined according to the address of the block where the bad block is located in the storage module.
[0080] The block address of the bad block may be one of a physical block address (PBA) and a linear address, wherein the PBA is a unique code assigned to different physical storage devices according to the hardware characteristics and address rules of the storage device.
[0081] It can be understood that the actual physical address of the block where the bad block is located is the PBA of the bad block.
[0082] In step 303, the block address of the permission constraint file is associated with the block address of the bad block and stored.
[0083] It can be understood that the storage module can map the block address of the permission constraint file to the bad block by associating and storing the block address of the permission constraint file with the block address of the bad block.
[0084] In the disclosed embodiment, by associating and saving the block address of the permission constraint file with the block address of the bad block, the block address of the permission constraint file can be mapped to the bad block, thereby realizing the function of the permission constraint file to constrain the bad block.
[0085] In some possible implementations, the bad block processing method may further include: when a garbage collection instruction is detected, not performing memory release processing on the bad block of the block address of the mapping permission constraint file.
[0086] It is understandable that when the storage module maps the block address of the permission constraint file to the bad block, a notification message can be returned to the control module. After receiving the notification message, when the control module receives a garbage collection instruction, it will respond accordingly to the detected garbage collection instruction, that is, when releasing the memory of the storage module, the bad block will not be released.
[0087] In some embodiments, after garbage collection is not performed on the bad block to which the block address of the permission-constrained file is mapped, the data originally written to the bad block can be rewritten to the good block in the storage module.
[0088] In the embodiment of the present disclosure, by not performing memory release processing on the bad block of the block address of the mapping permission constraint file when a garbage collection instruction is detected, the data stored in the bad block can be retained to ensure the data integrity of the storage module.
[0089] In some possible implementations, the bad block processing method may further include: if a bad block is generated during data storage in the storage module, writing the data to be stored into a next block adjacent to the bad block.
[0090] It can be understood that the above bad block processing method processes the bad blocks that exist when the device is turned on. For the bad blocks generated during use, the data to be stored can be written into the good blocks by skipping the bad blocks. That is, the data to be stored is written to the next block adjacent to the bad block. If the next block is still a bad block, it is continued to be written until the data to be stored is written into the good block. As for the bad blocks generated during use, the above bad block processing method can be executed on these bad blocks when the terminal device is turned on next time.
[0091] In some embodiments, the above-mentioned bad block skipping strategy can make the data to be stored all written in good blocks, and the skipped bad blocks will be marked as invalid, and the bad block information will be stored in the bad block table of the storage module.
[0092] In the disclosed embodiment, during the process of data storage in the storage module, if a bad block is generated, the data to be stored is written to the next block adjacent to the bad block, so that all the data to be stored can be written into good blocks, reducing the occurrence of situations where data cannot be read due to being written into bad blocks.
[0093] In some possible implementations, the bad block processing method may further include: adjusting a freezing threshold of the storage module based on the number of bad blocks; and switching the storage module to a non-working state when the number of bad blocks is greater than the adjusted freezing threshold.
[0094] It is understandable that in the prior art, when the number of bad blocks is large, the storage module will be frozen, which will cause the terminal device to be unable to read and write normally. Therefore, the above problem can be solved by adjusting the freezing threshold of the storage module. The specific steps are: determine the current number of bad blocks, and adjust the freezing threshold of the storage module according to the number of bad blocks. After new bad blocks are generated during use, the number of bad blocks will also change accordingly. When the number of bad blocks is greater than the freezing threshold of the storage module, the control module will switch the storage module to a non-working state by sending a control command.
[0095] It should be noted that the above adjustment of the freezing threshold can be set through software, and can also be dynamically adjusted during use based on actual conditions.
[0096] In the disclosed embodiment, the freezing threshold is adjusted according to the number of bad blocks, which can ensure the normal reading and writing functions of the terminal device, thereby improving the user experience.
[0097] The implementation process of the above bad block processing method in an actual application scenario can be found in Figure 4 , Figure 4 This is a flowchart of a bad block processing method provided by an embodiment of the present disclosure. Figure 4 The steps shown are explained.
[0098] For example, the control module is the CPU, the storage module is the Nand Flash, and the permission constraint file is the zombie file. The CPU is equivalent to the host end of the terminal device, and the Nand Flash is equivalent to the device end of the terminal device. Nand Flash does not reserve any space for replacing bad blocks, such as replacement blocks (replace area) and reserved blocks (spare area), when it leaves the factory.
[0099] In step 401, the terminal device is turned on.
[0100] In step 402, the number of bad blocks is determined.
[0101] The host sends a command to the device when the terminal device is just turned on to confirm the current number of bad blocks.
[0102] In step 403, the number of bad blocks is returned.
[0103] After receiving the command, the Device checks the saved bad block table and returns the number of bad blocks.
[0104] In step 404, a permission constraint file having a size equal to the bad block memory space is created.
[0105] The file system on the host side creates a permission-constrained file (for example, a zombie file) with a memory space size equal to the bad block.
[0106] In step 405, the block address of the permission constraint file is sent to the Device.
[0107] The host sends a command to the device, the command carrying the block address of the permission constraint file, and the command is used to instruct the device to map the block address (eg, LBA) of the permission constraint file to the bad block.
[0108] In step 406, the block address of the permission constraint file is mapped to the bad block.
[0109] In response to the command sent by the host, the device associates the block address of the permission constraint file with the block address of the bad block.
[0110] In step 407, the bad blocks of the block addresses corresponding to the permission constraint file are controlled not to participate in garbage collection.
[0111] When the host detects a garbage collection instruction, it does not release the memory of the bad block that maps the block address of the permission-constrained file.
[0112] The disclosed embodiment establishes an association between the block address of the permission constraint file and the block address of the bad block, so as to realize the function of the permission constraint file to constrain the bad block. In this way, it is not necessary to set a reserved space for processing the bad block, so that the memory space available to the user becomes larger, thereby improving the utilization rate of the memory space of the storage module. At the same time, by not performing memory release processing on the bad block that maps the block address of the permission constraint file when a garbage collection instruction is detected, the data stored in the bad block can be retained to ensure the data integrity of the storage module.
[0113] Figure 5is a block diagram of a bad block processing device according to an exemplary embodiment. Figure 5 As shown, the bad block processing device 500 includes: a control module 501, configured to determine the number of bad blocks from a preset bad block table of the storage module when a power-on event is detected;
[0114] The control module 501 is further configured to create a permission constraint file in the file system of the terminal device based on the number of bad blocks; wherein the permission constraint file does not have a garbage collection function;
[0115] The storage module 502 is configured to map the block address of the permission constraint file to the bad block, so as to associate the block address of the permission constraint file with the block address of the bad block.
[0116] In some embodiments, the control module 501 is configured to: obtain the memory space of the bad blocks; determine the target memory space according to the number of bad blocks and the memory space of the bad blocks; and create a permission constraint file in the file system according to the target memory space.
[0117] In some embodiments, the control module 501 is configured to: determine at least two consecutive blocks among all blocks of the file system according to the target memory space, and the memory space of at least two blocks is greater than or equal to the target memory space; create a permission constraint file on at least two consecutive blocks.
[0118] In some embodiments, the storage module 502 is configured to: determine the block address of the permission constraint file based on the address of the block where the permission constraint file is located in the file system; determine the block address of the bad block based on the address of the block where the bad block is located in the storage module; and associate and save the block address of the permission constraint file with the block address of the bad block.
[0119] In some embodiments, the control module 501 is further configured to: when a garbage collection instruction is detected, not perform memory release processing on the bad block of the block address mapping the permission constraint file.
[0120] In some embodiments, the control module 501 is further configured to: if a bad block is generated during the process of data storage in the storage module, write the data to be stored into the next block adjacent to the bad block.
[0121] In some embodiments, the control module 501 is further configured to: adjust the freezing threshold of the storage module based on the number of bad blocks; and switch the storage module to a non-working state when the number of bad blocks is greater than the adjusted freezing threshold.
[0122] In some embodiments, the control module 501 is configured to determine the target memory space based on the product of the number of bad blocks and the memory space of the bad blocks.
[0123] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0124] Figure 6 It is a hardware structure block diagram of a bad block processing device 600 according to an exemplary embodiment. For example, the bad block processing device 600 can be a mobile phone, a tablet computer, a VR device, an AR device, a drone, a 3D game, a monitoring system, a PDA, a digital recorder, an MP3 player, an electronic toy, etc.
[0125] refer to Figure 6 The bad block processing device 600 may include one or more of the following components: a processing component 602, a memory 604, a power component 606, a multimedia component 608, an audio component 610, an input / output (I / O) interface 612, a sensor component 614, and a communication component 616.
[0126] The processing component 602 generally controls the overall operation of the device 600, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 602 may include one or more processors 620 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 602 may include one or more modules to facilitate the interaction between the processing component 602 and other components. For example, the processing component 602 may include a multimedia module to facilitate the interaction between the multimedia component 608 and the processing component 602.
[0127] The memory 604 is configured to store various types of data to support operations on the device 600. Examples of such data include instructions for any application or method operating on the device 600, contact data, phone book data, messages, pictures, videos, etc. The memory 604 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0128] The power supply component 606 provides power to the various components of the device 600. The power supply component 606 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device 600.
[0129] The multimedia component 608 includes a screen that provides an output interface between the device 600 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 608 includes a front camera and / or a rear camera. When the device 600 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0130] The audio component 610 is configured to output and / or input audio signals. For example, the audio component 610 includes a microphone (MIC), and when the device 600 is in an operating mode, such as a call mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 604 or sent via the communication component 616. In some embodiments, the audio component 610 also includes a speaker for outputting audio signals.
[0131] I / O interface 612 provides an interface between processing component 602 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.
[0132] The sensor assembly 614 includes one or more sensors for providing various aspects of status assessment for the device 600. For example, the sensor assembly 614 can detect the open / closed state of the device 600, the relative positioning of components, such as the display and keypad of the device 600, and the sensor assembly 614 can also detect the position change of the device 600 or a component of the device 600, the presence or absence of user contact with the device 600, the orientation or acceleration / deceleration of the device 600, and the temperature change of the device 600. The sensor assembly 614 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 614 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 614 may also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0133] The communication component 616 is configured to facilitate wired or wireless communication between the device 600 and other devices. The device 800 can access a wireless network based on a communication standard, such as Wi-Fi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 616 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0134] In an exemplary embodiment, the apparatus 600 may be implemented by one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components to perform the above method.
[0135] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 604 including instructions, and the instructions can be executed by a processor 620 of the device 600 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0136] The embodiment of the present disclosure provides a non-temporary computer-readable storage medium. When the instructions in the storage medium are executed by a processor of a computer, the computer can execute the bad block processing method described in one or more of the above-mentioned technical solutions.
[0137] When the processor executes the instruction, it can at least perform the following steps:
[0138] When a power-on event is detected, the number of bad blocks is determined from a preset bad block table of the storage module; based on the number of bad blocks, a permission constraint file is created in the file system of the terminal device; wherein the permission constraint file does not have a garbage collection function; the storage module maps the block address of the permission constraint file to the bad block to associate the block address of the permission file with the block address of the bad block.
[0139] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0140] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A bad block processing method, characterized in that: The method comprises: When a power-on event is detected, determining the number of bad blocks from a preset bad block table of the storage module; Based on the number of bad blocks, creating a permission constraint file in the file system of the terminal device; wherein the permission constraint file does not have a garbage collection function; The storage module maps the block address of the permission constraint file to the bad block to associate the block address of the permission constraint file with the block address of the bad block.
2. The method according to claim 1, characterized in that The step of creating a permission constraint file in a file system of a terminal device based on the number of bad blocks includes: Obtaining the memory space of the bad block; Determining a target memory space according to the number of the bad blocks and the memory space of the bad blocks; The permission constraint file is created in the file system according to the target memory space.
3. The method according to claim 2, characterized in that The step of creating the permission constraint file in the file system according to the target memory space includes: According to the target memory space, determining at least two consecutive blocks among all blocks of the file system, wherein the memory spaces of the at least two blocks are greater than or equal to the target memory space; The permission constraint file is created on the at least two consecutive blocks.
4. The method according to claim 2, characterized in that: The determining the target memory space according to the number of the bad blocks and the memory space of the bad blocks includes: The target memory space is determined based on the product of the number of the bad blocks and the memory space of the bad blocks.
5. The method according to claim 1, characterized in that The storage module maps the block address of the permission constraint file to the bad block, including: Determine the block address of the permission constraint file according to the address of the block where the permission constraint file is located in the file system; Determine the block address of the bad block according to the address of the block where the bad block is located in the storage module; The block address of the permission constraint file is associated with the block address of the bad block and stored.
6. The method according to claim 1, characterized in that The method further comprises: When a garbage collection instruction is detected, no memory release processing is performed on the bad block that maps the block address of the permission constraint file.
7. The method according to claim 1, characterized in that The method further comprises: During the process of storing data in the storage module, if the bad block is generated, the data to be stored is written into the next block adjacent to the bad block.
8. The method according to any one of claims 1 to 7, characterized in that: The method further comprises: Based on the number of bad blocks, adjusting a freezing threshold of the storage module; When the number of bad blocks is greater than the adjusted freezing threshold, the storage module is switched to a non-working state.
9. A bad block processing device, characterized in that: The device comprises: The control module is configured to determine the number of bad blocks from a preset bad block table of the storage module when a power-on event is detected; The control module is further configured to create a permission constraint file in the file system of the terminal device based on the number of bad blocks; wherein the permission constraint file does not have a garbage collection function; The storage module is configured to map the block address of the permission constraint file to the bad block, so as to associate the block address of the permission constraint file with the block address of the bad block.
10. An electronic device, characterized in that: include: a memory for storing processor-executable instructions; A processor connected to the memory; The processor is used to execute the bad block processing method as described in any one of claims 1 to 8.
11. A non-transitory computer-readable storage medium, when instructions in the storage medium are executed by a processor of a computer, the computer is enabled to execute the bad block processing method according to any one of claims 1 to 8.