Method, device, electronic device and storage medium for recovering address mapping relationship
By storing and updating P2L mapping information in flash storage products, the problem of missing mapping information after device power outage is solved, and faster recovery speed is achieved.
Patent Information
- Application Number
- CN202411228549.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-03
- Publication Date
- 2024-11-29
- Estimated Expiration
- 2044-09-03
AI Technical Summary
In the prior art, after the device is powered off, the mapping information of the physical address to logical address (P2L) is lost, resulting in a very long recovery time when powered on again.
A method for restoring an address mapping relationship is proposed, by storing the first P2L mapping information of each logical data block into a preset information storage block when first responding to a preset condition, and recording the number of physical address page usage . In response to the preset condition the P2L mapping information in the information storage block is updated based on the number of physical address pages in response to the preset conditions the second time and after. When the terminal is powered on again after power off, the latest written physical address is determined from the information storage block, the first P2L mapping information is obtained, and the second P2L mapping information is formed by reading the physical address in the logical data block, and the recovery is completed.
By storing and updating P2L mapping information, the loss of mapping information after the device is powered off is avoided, the recovery time of P2L mapping information is shortened, and the recovery speed is improved.
Smart Images

Figure CN118760622B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of address mapping technology, and in particular to a method, device, electronic device and storage medium for recovering an address mapping relationship. Background Art
[0002] In the related technology, flash storage products need to establish a logical address to physical address (logical_to_physical, L2P) table and a physical address to logical address (physical_to_logical, P2L) table. L2P records the mapping relationship between logical addresses and physical addresses, and the content recorded is the physical address. The address offset of the table is in a one-to-one correspondence with the logical address; P2L records the mapping relationship between physical addresses and logical addresses, and the content recorded is the logical address. The address offset of the table is in a one-to-one correspondence with the physical address. Usually, the L2P table must exist in the flash memory, but the P2L table is not necessarily present.
[0003] When a logical data block is written, it generates P2L mapping information. During this process, if the device loses power, the P2L mapping information is lost. When the device is powered on again, each physical address corresponding to the logical data block needs to be read to restore the P2L mapping information, and the recovery time is very long. Summary of the invention
[0004] The present application aims to solve at least one of the technical problems existing in the prior art. To this end, the present application proposes a method, device, electronic device and storage medium for recovering an address mapping relationship, which can shorten the recovery time of P2L mapping information.
[0005] A method for recovering an address mapping relationship according to an embodiment of the first aspect of the present application is applied to a terminal, and the method includes:
[0006] When responding to the preset condition for the first time, the first physical address to logical address P2L mapping information of each logical data block is stored in a preset information storage block and the number of physical address page usages of each logical data block is recorded; when responding to the preset condition for the second time and thereafter, the first P2L mapping information stored in the information storage block is updated based on the number of physical address page usages;
[0007] When it is detected that the terminal is powered on again after being powered off, determining the latest written physical address of the first P2L mapping information of each logical data block from the information storage block;
[0008] Based on the latest written physical address, acquiring the first P2L mapping information;
[0009] An end physical address is determined based on the first P2L mapping information, and second P2L mapping information is read from a corresponding logical data block based on the end physical address; the second P2L mapping information is P2L mapping information not stored in the information storage block.
[0010] The method for recovering the address mapping relationship according to the embodiment of the present application has at least the following beneficial effects: the method for recovering the address mapping relationship according to the embodiment of the present application, when responding to the preset condition for the first time, stores the first P2L mapping information of each logical data block to a preset information storage block and records the number of physical address pages used by each logical data block; when responding to the preset condition for the second time and thereafter, updates the first P2L mapping information stored in the information storage block based on the number of physical address pages used. When the terminal loses power, since the first P2L mapping information has been stored in the information storage block, the first P2L mapping information will not be lost. When the power is restored, the latest written physical address of the first P2L mapping information of each logical data block is determined from the information storage block. Based on the latest written physical address, the first P2L mapping information can be directly obtained. Since the second P2L mapping information is not stored in the information storage block, it is lost when the power is restored. After the power is restored, the last physical address in the first P2L mapping information is determined, and then based on the last physical address, data is read one by one from the last physical address in the logical data block corresponding to the first P2L mapping information to form the second P2L mapping information. In this way, the recovery of the P2L mapping information of the logical data block is completed. During the recovery process, the first P2L mapping information does not need to be read one by one physically, only the second P2L mapping information needs to be read one by one physically, which can reduce the number of physical addresses read, thereby speeding up the recovery speed of the P2L mapping information and shortening the recovery time of the P2L mapping information.
[0011] According to some embodiments of the present application, the preset condition is:
[0012] The number of used physical address pages of any logical data block reaches a preset number.
[0013] According to some embodiments of the present application, after storing the first P2L mapping information of each logical data block in a preset information storage block, the method includes:
[0014] A mapping information table is formed based on the first P2L mapping information, and the mapping information table is stored in the information storage block; wherein, in the mapping information table, each logical data block corresponds to M table entries, M=(X+N-1) / N, X is the number of available physical address pages of the logical data block, and N is the preset number; each table entry includes a table entry number and address information, the table entry number corresponds one-to-one to the address information, the table entry number is used to represent the number of updates of the first P2L mapping information of the logical data block; the address information is used to represent the write physical address of the first P2L mapping information corresponding to the table entry number.
[0015] According to some embodiments of the present application, the updating of the first P2L mapping information stored in the information storage block based on the number of physical address page usages includes:
[0016] Detect the current number of physical address pages used by the target logical data block;
[0017] When it is detected that the current number of physical address pages in use is greater than the number of physical address pages in use corresponding to the target logical data block recorded in the information storage block, the first P2L mapping information corresponding to the target logical data block in the information storage block is updated based on the current first P2L mapping information of the target logical data block.
[0018] According to some embodiments of the present application, after the updating of the first P2L mapping information corresponding to the target logical data block in the information storage block, the method further includes:
[0019] Determine the write physical address of the first P2L mapping information after update;
[0020] Determine an unfilled table entry number in which the address information is not filled in among the M table entry numbers corresponding to the target logical data block in the mapping information table, and determine a target table entry number with the smallest number value from the unfilled table entry numbers;
[0021] The written physical address is used as the address information corresponding to the target table entry number.
[0022] According to some embodiments of the present application, determining the latest written physical address of the first P2L mapping information of each logical data block from the information storage block includes:
[0023] Determine a filled entry number in which the address information has been filled in among the M entry numbers corresponding to the target logical data block in the mapping information table;
[0024] Determine the target table entry number with the largest number value from the filled table entry numbers;
[0025] The address information corresponding to the target entry number is used as the latest written physical address.
[0026] According to some embodiments of the present application, after reading the second P2L mapping information from the corresponding logical data block based on the last physical address, the method further includes:
[0027] Logical address to physical address L2P mapping information is obtained based on the first P2L mapping information and the second P2L mapping information.
[0028] A second aspect of the present application provides a device for recovering an address mapping relationship, which is applied to a terminal, and the device includes:
[0029] A storage or update module, configured to store the first P2L mapping information of each logical data block in a preset information storage block and record the number of physical address page usages of each logical data block when responding to the preset condition for the first time; and update the first P2L mapping information stored in the information storage block based on the number of physical address page usages when responding to the preset condition for the second time and thereafter;
[0030] An address determination module, configured to determine, when detecting that the terminal is powered on again after being powered off, a latest written physical address of the first P2L mapping information of each logical data block from the information storage block;
[0031] An acquisition module, configured to acquire the first P2L mapping information based on the latest written physical address;
[0032] A reading module is used to determine the end physical address based on the first P2L mapping information, and read the second P2L mapping information from the corresponding logical data block based on the end physical address; the second P2L mapping information is the P2L mapping information not stored in the information storage block.
[0033] An embodiment of the third aspect of the present application provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the method for recovering the address mapping relationship described in any one of the embodiments of the first aspect of the present application is implemented.
[0034] The fourth aspect of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the method for recovering the address mapping relationship described in any one of the embodiments of the first aspect of the present application.
[0035] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] The present application is further described below with reference to the accompanying drawings and embodiments, wherein:
[0037] Figure 1 A schematic diagram of the steps of the method for recovering the address mapping relationship according to an embodiment of the present application;
[0038] Figure 2 A schematic diagram of the storage format of the first P2L mapping information in the information storage block;
[0039] Figure 3 A schematic diagram of a mapping information table in an information storage block;
[0040] Figure 4 for Figure 1 A specific flow chart of step S110;
[0041] Figure 5 Another step flow chart of the method for recovering the address mapping relationship according to an embodiment of the present application;
[0042] Figure 6 for Figure 1 A specific flow chart of step S120;
[0043] Figure 7 A schematic diagram of the structure of a device for recovering an address mapping relationship according to an embodiment of the present application;
[0044] Figure 8 A schematic diagram of the structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0045] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application, and cannot be understood as limiting the present application.
[0046] In the description of the present application, it should be understood that descriptions involving orientation, such as up, down, front, back, left, right, etc., indicating orientations or positional relationships, are based on the orientations or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as a limitation on the present application.
[0047] In the description of this application, "several" means more than one, "more" means more than two, "greater than", "less than", "exceed", etc. are understood to exclude the number itself, and "above", "below", "within", etc. are understood to include the number itself. If there is a description of "first" or "second", it is only used for the purpose of distinguishing technical features, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features or implicitly indicating the order of the indicated technical features.
[0048] In the description of this application, unless otherwise clearly defined, terms such as setting, installing, connecting, etc. should be understood in a broad sense, and technicians in the relevant technical field can reasonably determine the specific meanings of the above terms in this application based on the specific content of the technical solution.
[0049] In the description of the present application, the description with reference to the terms "one embodiment", "some embodiments", "illustrative embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials, or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0050] First, some nouns involved in this application are analyzed:
[0051] Logical address to physical address: logical_to_physical, referred to as L2P, the L2P table is a mapping table used to map the logical address (LBA) used by the upper file system or application layer to the physical address inside the flash memory. Each logical address corresponds to one or more physical addresses, depending on the mapping strategy and the usage of the flash memory.
[0052] Physical address to logical address: physical_to_logical, referred to as P2L, the P2L table is an optional mapping table used to map physical addresses back to logical addresses. Although it is not required for all flash systems, it may be very useful in some scenarios (such as data recovery, debugging, or optimization). When an SSD or other storage device fails and causes the loss of some logical address to physical address mapping, the P2L table can be used to help recover data. By reversely looking up the logical address corresponding to the physical address, part or all of the file system structure can be rebuilt.
[0053] Logical data block: refers to a set of information that is logically organized together to represent and process data. These data blocks are logically related to each other and together constitute a higher-level data structure or data model. They are not necessarily stored in a physically continuous manner, but are logically treated as a whole for processing.
[0054] SSD (Solid State Drive): SSD consists of multiple components, including NAND flash memory chips, SSD controllers, DRAM cache, connectors, etc. NAND flash memory is the basic storage unit of SSD, and these units are organized into pages and blocks. In NAND flash memory, regarding the mapping of logical data blocks to physical addresses, NAND devices (or the NAND flash memory part in SSD) use one or more mapping tables to manage the conversion of logical addresses to physical addresses. This mapping mechanism is an important part of the internal storage management of NAND flash memory (or SSD), which ensures that the operating system and file system can efficiently access the data stored in NAND flash memory.
[0055] When a logical data block performs a write operation, it will generate P2L mapping information. However, the P2L mapping information of the logical data block will be updated to the P2L mapping table only when the physical address pages used in the write operation reach a preset number. If a power outage occurs when the physical address pages used in the write operation do not reach a certain number, although the flash memory will quickly perform an emergency data backup, it can only back up part of the data and cannot back up the P2L mapping information of all logical data blocks. The P2L mapping information of the logical data block will still be lost. When the power is restored, each physical address corresponding to the logical data block needs to be read to restore the P2L mapping information. When there are many logical data blocks, the recovery time is very long.
[0056] Based on this, the embodiments of the present application provide a method, device, electronic device and storage medium for recovering an address mapping relationship, which can shorten the recovery time of P2L mapping information.
[0057] The method for recovering the address mapping relationship of the embodiment of the present application can be applied to a terminal. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a router, a programmable switch, a network card, etc.; in one embodiment, the method for recovering the address mapping relationship can be applied to a server. The server can be configured as an independent physical server, or as a server cluster or a distributed system composed of multiple physical servers. It can also be configured as a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application that implements the method for recovering the address mapping relationship, etc., but is not limited to the above forms.
[0058] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific services or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which services are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0059] In the first aspect of this application, reference is made to Figure 1 , Figure 1 The following is a schematic diagram of the steps of the method for restoring the address mapping relationship according to the embodiment of the present application. The method for restoring the address mapping relationship according to the embodiment of the present application includes but is not limited to steps S110 to S140.
[0060] Step S110, when responding to the preset condition for the first time, storing the first P2L mapping information of each logical data block in a preset information storage block and recording the number of physical address page usages of each logical data block; when responding to the preset condition for the second time and thereafter, updating the first P2L mapping information stored in the information storage block based on the number of physical address page usages;
[0061] In step S110 of one embodiment, the preset condition is: the number of physical address pages used by any logical data block reaches a preset number. In the related art, when the number of physical address pages used by a certain logical data block reaches a certain value, the P2L mapping information of the logical data block will be maintained, but the P2L mapping information of other logical data blocks will not be saved. If a power outage occurs, the P2L mapping information of other logical data blocks will be lost. In the present application, when the number of physical address pages used by any logical data block reaches a preset number, the first P2L mapping information of each logical data block is stored in a pre-set information storage block and the number of physical address pages used by each logical data block is recorded. If a power outage occurs, the first P2L mapping information of each logical data block is stored, which can reduce the amount of lost information. In the subsequent recovery process when the terminal is powered on again, less P2L mapping information needs to be restored, thereby improving the recovery speed.
[0062] In step S110 of another embodiment, the preset condition is that the current time is a preset time, and there may be multiple preset times. In this way, the first P2L mapping information of each logical data block can be periodically stored in a preset information storage block and the number of physical address pages used by each logical data block can be recorded to avoid the loss of P2L mapping information due to power failure.
[0063] It is worth noting that when step S110 is executed for the first time, the first P2L mapping information of each logical data block is stored in a pre-set information storage block and the number of physical address pages used by each logical data block is recorded; when step S110 is executed for the second time and thereafter, the first P2L mapping information corresponding to the logical data block in the information storage block is updated based on the number of physical address pages used by the logical data block.
[0064] It is worth noting that flash memory usually has multiple logical data blocks. Flash memory allocates a certain number of physical address pages to each logical data block. When writing data, the logical data block uses the physical address in the physical address page to store the data, so that the logical address of the data corresponds to the physical address one by one. The number of used physical address pages refers to the number of physical address pages that have stored data.
[0065] Step S120, when it is detected that the terminal is powered on again after being powered off, determining the latest written physical address of the first P2L mapping information of each logical data block from the information storage block;
[0066] It should be noted that the latest written physical address of the first P2L mapping information refers to the latest storage address of the first P2L mapping information.
[0067] Step S130, obtaining first P2L mapping information based on the latest written physical address;
[0068] Step S140, determining the end physical address based on the first P2L mapping information, and reading the second P2L mapping information from the corresponding logical data block based on the end physical address; the second P2L mapping information is the P2L mapping information not stored in the information storage block.
[0069] In step S140 of an embodiment, the first P2L mapping information includes a physical address and a logical address, and the physical address corresponds to the logical address one by one. After acquiring the first P2L mapping information, the physical address included in the first P2L mapping information is determined, and the physical address at the very end is determined as the last physical address. After determining the last physical address, within the physical address range corresponding to the logical data block, the information stored after the last physical address is read step by step based on the last physical address, and the logical address of the information is read from the corresponding logical data block, so as to determine the mapping relationship between the physical address after the last physical address and the logical address, so as to obtain the second P2L mapping information.
[0070] The embodiment of the present application, through the above steps S110 to S140, when responding to the preset condition for the first time, stores the first P2L mapping information of each logical data block in a preset information storage block and records the number of physical address pages used by each logical data block; when responding to the preset condition for the second time and thereafter, the first P2L mapping information stored in the information storage block is updated based on the number of physical address pages used. When the terminal loses power, since the first P2L mapping information has been stored in the information storage block, the first P2L mapping information will not be lost. When the power is restored, the latest written physical address of the first P2L mapping information of each logical data block is determined from the information storage block. Based on the latest written physical address, the first P2L mapping information can be directly obtained. Since the second P2L mapping information is not stored in the information storage block, it is lost when the power is restored. After the power is restored, the last physical address in the first P2L mapping information is determined, and then based on the last physical address, data is read one by one from the last physical address in the logical data block corresponding to the first P2L mapping information to form the second P2L mapping information. In this way, the recovery of the P2L mapping information of the logical data block is completed. During the recovery process, the first P2L mapping information does not need to be read one by one physically, only the second P2L mapping information needs to be read one by one physically, which can reduce the number of physical addresses read, thereby speeding up the recovery speed of the P2L mapping information and shortening the recovery time of the P2L mapping information.
[0071] It can be understood that after step S110, the following steps are also included:
[0072] A mapping information table is formed based on the first P2L mapping information, and the mapping information table is stored in an information storage block; wherein, in the mapping information table, each logical data block corresponds to M table entries, M=(X+N-1) / N, X is the number of available physical address pages of the logical data block, and N is a preset number; each table entry includes a table entry number and address information, the table entry number corresponds to the address information one-to-one, the table entry number is used to represent the number of updates of the first P2L mapping information of the logical data block; the address information is used to represent the write physical address of the first P2L mapping information corresponding to the table entry number.
[0073] It is worth noting that referring to Figure 2 and Figure 3 , Figure 2 Schematic diagram of the storage format of the first P2L mapping information in the information storage block. Figure 3 A schematic diagram of mapping information tables in information storage blocks. Figure 2 and Figure 3 It also shows the update process. Figure 2 The three tables and Figure 3 The three tables are one-to-one corresponding. For details, refer to Figure 3 , the table entry number includes the table entry name and the number value. For example, if a table entry number is "P2L number A+1", the table entry name is "P2L number A" and the number value is 1; if a table entry number is "P2L number A", the table entry name is "P2L number A" and the number value is 0. If a table entry code is "P2L number B+M-1", the table entry name is "P2L number B" and the number value is M-1. And, when not written, the address information is "invalid". For details, refer to Figure 2 The information storage block also records the storage order of the first P2L mapping information of each logical data block, wherein the content corresponding to the "WRITE ORDER" column is the storage order of the first P2L mapping information of each logical data block. The write physical address refers to the storage address of the first P2L mapping information.
[0074] It should be noted that those skilled in the art can freely set the values of X and N and make M a positive integer.
[0075] It is worth noting that the flash memory allocates a certain number of physical address pages to each logical data block, and this number is the number of available physical address pages.
[0076] It is understandable that, referring to Figure 4 , Figure 4 for Figure 1 A specific flow chart of step S110 in FIG. Updating the first P2L mapping information stored in the information storage block based on the number of physical address page usages includes the following steps:
[0077] Step S410, detecting the current number of physical address pages used by the target logical data block;
[0078] Step S420, when it is detected that the current number of physical address pages used is greater than the number of physical address pages used corresponding to the target logical data block recorded in the information storage block, the first P2L mapping information corresponding to the target logical data block in the information storage block is updated based on the current first P2L mapping information of the target logical data block.
[0079] It is worth noting that if the current number of physical address pages in use is greater than the number of physical address pages in use corresponding to the target logical data block recorded in the information storage block, it means that after the last update, new data has been written to the target logical data block, and new first P2L mapping information has been generated. Therefore, it is necessary to store the newly generated first P2L mapping information in the information storage block to update the first P2L mapping information corresponding to the target logical data block in the information storage block, and synchronously update the number of physical address pages in use corresponding to the target logical data block recorded in the information storage block. If the current number of physical address pages in use is less than or equal to the number of physical address pages in use corresponding to the target logical data block recorded in the information storage block, it means that after the last update, no new data has been written to the target logical data block, and no new first P2L mapping information has been generated, and no update is required.
[0080] It is understandable that, referring to Figure 5 , Figure 5 This is another step flow chart of the method for recovering the address mapping relationship according to an embodiment of the present application. Figure 5 The illustrated steps include:
[0081] Step S510, determining a write physical address for the updated first P2L mapping information;
[0082] Step S520, determining the unfilled entry number of the M entry numbers corresponding to the target logical data block in the mapping information table, which has no address information filled in, and determining the target entry number with the smallest number value from the unfilled entry numbers;
[0083] Step S530: write the physical address as the address information corresponding to the target entry number.
[0084] Specifically, when updating, first update Figure 2 The INFO information in the data block includes the latest written physical address of the first P2L mapping information of each logical data block. Figure 3 After the INFO information is updated, the physical address of the first P2L mapping information of logical block 0 (in the mapping information table, the logical data block is referred to as the logical block) is written to 0x1009, such as Figure 3As shown in the table above, the mapping information table is not updated temporarily. At this time, the unfilled table item number corresponding to the unfilled address information of the logical block 0 is determined, that is, P2L label A+1 to P2L label A+n, and the target table item number with the smallest number value is determined, that is, "P2L label A+1" is the target table item number, and then the physical address is written as the address information corresponding to the target table item number, that is, 0x1009 is used as the address information of "P2L label A+1", as shown in Figure 3 The table in the middle shows.
[0085] It should be noted that the target logical data block is one of the multiple logical data blocks.
[0086] It is understandable that, referring to Figure 6 , Figure 6 for Figure 1 Determining the latest written physical address of the first P2L mapping information of each logical data block from the information storage block includes the following steps:
[0087] Step S610, determining the filled entry number of the M entry numbers corresponding to the target logical data block in the mapping information table, in which the address information has been filled;
[0088] Step S620, determining the target table entry number with the largest number value from the filled table entry numbers;
[0089] Step S630: Use the address information corresponding to the target entry number as the latest written physical address.
[0090] For example, Figure 3 As shown in the table below, the filled-in table entry number of the address information of logical block 3 is "P2L label D". Since there is only one filled-in table entry number, the target table entry number with the largest number value is "P2L label D". The address information corresponding to the target table entry number is used as the latest written physical address, that is, 0x1012 is used as the latest written physical address of logical block 3.
[0091] In another embodiment, the latest written physical address of the first P2L mapping information of each logical data block may be determined from the INFO information.
[0092] It is understandable that after step S140, the method further includes: obtaining L2P mapping information based on the first P2L mapping information and the second P2L mapping information. Since the first P2L mapping information and the second P2L mapping information are mapping relationships between physical addresses and logical addresses, the mapping relationship between logical addresses and physical addresses, i.e., L2P mapping information, can be obtained.
[0093] Reference Figure 7 , Figure 7A schematic diagram of the structure of an address mapping relationship recovery device according to an embodiment of the present application. A second aspect of the present application provides an address mapping relationship recovery device, which is applied to a terminal, and the device includes:
[0094] The storage or update module 710 is used to store the first P2L mapping information of each logical data block in a preset information storage block and record the number of physical address page usage of each logical data block when responding to the preset condition for the first time; and update the first P2L mapping information stored in the information storage block based on the number of physical address page usage when responding to the preset condition for the second time and thereafter;
[0095] The address determination module 720 is used to determine the latest written physical address of the first P2L mapping information of each logical data block from the information storage block when it is detected that the terminal is powered on again after being powered off;
[0096] An acquisition module 730, configured to acquire first P2L mapping information based on the latest written physical address;
[0097] The reading module 740 is used to determine the last physical address based on the first P2L mapping information, and read the second P2L mapping information from the corresponding logical data block based on the last physical address; the second P2L mapping information is the P2L mapping information not stored in the information storage block.
[0098] The device for recovering the address mapping relationship is used to execute the method for recovering the address mapping relationship of the first embodiment of the present application. When executing the method, when responding to the preset condition for the first time, the first P2L mapping information of each logical data block is stored in a preset information storage block and the number of physical address pages used of each logical data block is recorded; when responding to the preset condition for the second time and thereafter, the first P2L mapping information stored in the information storage block is updated based on the number of physical address pages used. When the terminal loses power, since the first P2L mapping information has been stored in the information storage block, the first P2L mapping information will not be lost. When the power is restored, the latest written physical address of the first P2L mapping information of each logical data block is determined from the information storage block. Based on the latest written physical address, the first P2L mapping information can be directly obtained. Since the second P2L mapping information is not stored in the information storage block, it is lost when the power is restored. After the power is restored, the last physical address in the first P2L mapping information is determined, and then based on the last physical address, data is read one by one from the last physical address in the logical data block corresponding to the first P2L mapping information to form the second P2L mapping information. In this way, the recovery of the P2L mapping information of the logical data block is completed. During the recovery process, the first P2L mapping information does not need to be read one by one physically, only the second P2L mapping information needs to be read one by one physically, which can reduce the number of physical addresses read, thereby speeding up the recovery speed of the P2L mapping information and shortening the recovery time of the P2L mapping information.
[0099] Reference Figure 8 , Figure 8 This is a schematic diagram of the structure of an electronic device according to an embodiment of the third aspect of the present application. The electronic device includes:
[0100] The processor 801 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;
[0101] The memory 802 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 802 can store an operating system and other applications. When the technical solution provided in the embodiment of this specification is implemented by software or firmware, the relevant program code is stored in the memory 802, and the processor 801 calls and executes the address mapping relationship recovery method of the embodiment of the present application;
[0102] Input / output interface 803, used to implement information input and output;
[0103] The communication interface 804 is used to realize the communication interaction between the device and other devices. The communication can be realized through wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.);
[0104] A bus 805 that transmits information between various components of the device (e.g., the processor 801, the memory 802, the input / output interface 803, and the communication interface 804);
[0105] The processor 801 , the memory 802 , the input / output interface 803 and the communication interface 804 are connected to each other in communication within the device via a bus 805 .
[0106] The fourth aspect of the present application is a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the method for recovering the address mapping relationship of any one of the first aspect embodiments is implemented.
[0107] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0108] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0109] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.
[0110] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0111] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.
[0112] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0113] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the mapping relationship of the mapping objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the previous and next mapping objects are in an "or" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0114] In the several embodiments provided in the present application, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the system embodiments described above are merely schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0115] The units described above 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 distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0116] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0117] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.
[0118] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.
Claims
1. A method for recovering an address mapping relationship, characterized in that: Applied to a terminal, the method comprises: When responding to the preset condition for the first time, storing the first physical address to logical address P2L mapping information of each logical data block in a preset information storage block and recording the number of physical address page usages of each logical data block; when responding to the preset condition for the second time and thereafter, updating the first P2L mapping information stored in the information storage block based on the number of physical address page usages; When it is detected that the terminal is powered on again after being powered off, determining the latest written physical address of the first P2L mapping information of each logical data block from the information storage block; Based on the latest written physical address, acquiring the first P2L mapping information; Determine the end physical address based on the first P2L mapping information, and read the second P2L mapping information from the corresponding logical data block based on the end physical address; the second P2L mapping information is the P2L mapping information not stored in the information storage block; The preset conditions are: The number of used physical address pages of any logical data block reaches a preset number; After storing the first P2L mapping information of each logical data block in a preset information storage block, the method includes: A mapping information table is formed based on the first P2L mapping information, and the mapping information table is stored in the information storage block; wherein, in the mapping information table, each logical data block corresponds to M table entries, M=(X+N-1) / N, X is the number of available physical address pages of the logical data block, and N is the preset number; each table entry includes a table entry number and address information, the table entry number corresponds to the address information one-to-one, the table entry number is used to represent the update times of the first P2L mapping information of the logical data block; the address information is used to represent the write physical address of the first P2L mapping information corresponding to the table entry number; The updating of the first P2L mapping information stored in the information storage block based on the number of physical address page usages includes: Detect the current number of physical address pages used by the target logical data block; When it is detected that the current number of physical address pages in use is greater than the number of physical address pages in use corresponding to the target logical data block recorded in the information storage block, the first P2L mapping information corresponding to the target logical data block in the information storage block is updated based on the current first P2L mapping information of the target logical data block.
2. The method for recovering the address mapping relationship according to claim 1, characterized in that: After the first P2L mapping information corresponding to the target logical data block in the information storage block is updated, the method further includes: Determine the write physical address of the first P2L mapping information after update; Determine an unfilled table entry number in which the address information is not filled in among the M table entry numbers corresponding to the target logical data block in the mapping information table, and determine a target table entry number with the smallest number value from the unfilled table entry numbers; The written physical address is used as the address information corresponding to the target table entry number.
3. The method for recovering the address mapping relationship according to claim 2, characterized in that: The determining, from the information storage block, a latest written physical address of the first P2L mapping information of each logical data block comprises: Determine a filled entry number in which the address information has been filled in among the M entry numbers corresponding to the target logical data block in the mapping information table; Determine the target table entry number with the largest number value from the filled table entry numbers; The address information corresponding to the target entry number is used as the latest written physical address.
4. The method for recovering the address mapping relationship according to claim 1, characterized in that: After reading the second P2L mapping information from the corresponding logical data block based on the last physical address, the method further includes: Logical address to physical address L2P mapping information is obtained based on the first P2L mapping information and the second P2L mapping information.
5. A device for recovering an address mapping relationship, characterized in that: Applied to a terminal, the device comprises: A storage or update module, configured to store the first P2L mapping information of each logical data block in a preset information storage block and record the number of physical address page usages of each logical data block when responding to the preset condition for the first time; and update the first P2L mapping information stored in the information storage block based on the number of physical address page usages when responding to the preset condition for the second time and thereafter; An address determination module, configured to determine, when detecting that the terminal is powered on again after being powered off, a latest written physical address of the first P2L mapping information of each logical data block from the information storage block; An acquisition module, configured to acquire the first P2L mapping information based on the latest written physical address; a reading module, configured to determine an end physical address based on the first P2L mapping information, and read second P2L mapping information from a corresponding logical data block based on the end physical address; the second P2L mapping information is P2L mapping information not stored in the information storage block; The preset conditions are: The number of used physical address pages of any logical data block reaches a preset number; After storing the first P2L mapping information of each logical data block in a preset information storage block, the method includes: A mapping information table is formed based on the first P2L mapping information, and the mapping information table is stored in the information storage block; wherein, in the mapping information table, each logical data block corresponds to M table entries, M=(X+N-1) / N, X is the number of available physical address pages of the logical data block, and N is the preset number; each table entry includes a table entry number and address information, the table entry number corresponds to the address information one-to-one, the table entry number is used to represent the update times of the first P2L mapping information of the logical data block; the address information is used to represent the write physical address of the first P2L mapping information corresponding to the table entry number; The updating of the first P2L mapping information stored in the information storage block based on the number of physical address page usages includes: Detect the current number of physical address pages used by the target logical data block; When it is detected that the current number of physical address pages in use is greater than the number of physical address pages in use corresponding to the target logical data block recorded in the information storage block, the first P2L mapping information corresponding to the target logical data block in the information storage block is updated based on the current first P2L mapping information of the target logical data block.
6. An electronic device, characterized in that: The electronic device comprises a memory and a processor, the memory stores a computer program, and the processor implements the method for recovering the address mapping relationship according to any one of claims 1 to 4 when executing the computer program.
7. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method for recovering the address mapping relationship described in any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
Storage device including memory controller and operating method thereof
US20230305712A1
Storage device managing map information and method of operating the storage device
US20240193094A1
