SSD mapping management method and device based on double mapping, equipment and medium
By constructing fine-grained secondary mapping tables in HMB and storing coarse-grained secondary mapping tables in RAM, the performance bottlenecks and dirty data loss problems of traditional SSD mapping management methods when dealing with large-scale data and frequent data updates, achieving efficient data management and performance improvement.
Patent Information
- Application Number
- CN202510015245.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-06
- Publication Date
- 2025-04-25
AI Technical Summary
Traditional SSD mapping management methods have performance bottlenecks when handling large-scale data and frequent data updates, and lack effective dynamic management mechanisms, resulting in the risk of dirty data loss.
Using the SSD mapping management method based on dual mapping, the efficient management and recovery of data is achieved by building a fine-grained secondary mapping table in HMB and storing coarse-grained secondary mapping table in RAM.
Improve the read and write performance of SSD, ensure the accessibility and integrity of data, ensure the timely write back of dirty cache shards, and avoid data loss.
Smart Images

Figure CN119883958A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of SSD mapping management technology, and in particular to an SSD mapping management method, device, equipment and medium based on dual mapping. Background Art
[0002] In the field of solid-state drive (SSD) technology, efficient data mapping management is crucial to improving the read and write performance of storage devices. Traditional SSD mapping management methods usually use a single mapping table structure, such as a coarse-grained mapping table, to record the correspondence between logical addresses and physical addresses. However, with the rapid growth of data volume and the diversification of data access patterns, the single mapping table structure gradually exposes performance bottlenecks, especially when dealing with frequent data updates and accesses, which easily leads to increased mapping lookup delays, thereby affecting the overall performance of the SSD.
[0003] In addition, traditional mapping management methods often lack effective dynamic management mechanisms when dealing with dirty data (data that has been modified but not yet written back to the SSD). Dirty data is usually stored in the cache. If the cache space is insufficient or there is an abnormal situation such as power failure, the dirty data that is not written back in time may be lost, thus threatening the integrity and accessibility of the data. Summary of the invention
[0004] The purpose of the present invention is to overcome the deficiencies of the prior art and provide an SSD mapping management method, device, equipment and medium based on dual mapping.
[0005] In order to solve the above technical problems, the present invention adopts the following technical solutions:
[0006] In a first aspect, this embodiment provides an SSD mapping management method based on dual mapping, comprising the following steps:
[0007] Get a dirty cache shard containing several dirty sub-shards from the cache;
[0008] Determine whether there is a complete old fine-grained secondary mapping table corresponding to the dirty cache slice in the HMB;
[0009] If the old fine-grained secondary mapping table does not exist in the HMB, restoring the old fine-grained secondary mapping table according to the old coarse-grained secondary mapping table in the RAM;
[0010] If the old fine-grained secondary mapping table exists in the HMB, the dirty sub-shards are allocated and written to the secondary physical addresses in sequence according to the old fine-grained secondary mapping table to form new sub-shards and corresponding new secondary mapping relationships;
[0011] Storing all the new secondary mapping relationships in the old fine-grained secondary mapping table to form a new fine-grained secondary mapping table;
[0012] The last formed new secondary mapping relationship is stored as a new coarse-grained secondary mapping relationship in the old coarse-grained secondary mapping table to form a new coarse-grained secondary mapping table.
[0013] A further technical solution is: after the step of storing the last formed new secondary mapping relationship as a new coarse-grained secondary mapping relationship in the old coarse-grained secondary mapping table to form a new coarse-grained secondary mapping table, the method further comprises:
[0014] Determine whether there are still dirty cache fragments in the cache;
[0015] If there are still dirty cache shards in the cache, continue to obtain dirty cache shards containing several dirty sub-shards from the cache;
[0016] If there are no dirty cache shards in the cache, stop obtaining dirty cache shards containing several dirty sub-shards from the cache.
[0017] A further technical solution is: before the step of obtaining a dirty cache slice containing a plurality of dirty sub-slices from the cache, the step includes:
[0018] The user data is obtained, and the primary mapping relationship corresponding to the user data is stored in the old sub-shard in the old cache shard to form the dirty cache shard and the dirty sub-shard.
[0019] A further technical solution is: before the step of obtaining user data and storing the primary mapping relationship corresponding to the user data in the old sub-shard in the old cache shard to form the dirty cache shard and the dirty sub-shard, it includes:
[0020] Load the complete old coarse-grained L2 mapping table from NAND into RAM.
[0021] A further technical solution is: if the old fine-grained secondary mapping table does not exist in the HMB, the step of restoring the old fine-grained secondary mapping table according to the old coarse-grained secondary mapping table in the RAM includes:
[0022] Acquire an old coarse-grained secondary mapping relationship corresponding to the old cache slice from the old coarse-grained secondary mapping table;
[0023] Reading the old cache shard according to the old coarse-grained secondary mapping relationship to obtain and extract the old secondary mapping relationship corresponding to all the old sub-shards;
[0024] All the old secondary mapping relationships are stored in the HMB to restore the old fine-grained secondary mapping table in the HMB.
[0025] A further technical solution is: after the step of storing all the old secondary mapping relationships in the HMB to restore the old fine-grained secondary mapping table in the HMB, the method further comprises:
[0026] In the fine-grained mapping bitmap table, the bitmap corresponding to the old fine-grained secondary mapping table is marked as restored.
[0027] A further technical solution is: after the step of storing the last formed new secondary mapping relationship as a new coarse-grained secondary mapping relationship in the old coarse-grained secondary mapping table to form a new coarse-grained secondary mapping table, the method further comprises:
[0028] Obtaining a read instruction of the user data;
[0029] Acquire the corresponding new secondary mapping relationship from the new fine-grained secondary mapping table according to the read instruction;
[0030] Read the corresponding new sub-shard according to the new secondary mapping relationship to obtain the primary mapping relationship corresponding to the user data;
[0031] The user data is read according to the primary mapping relationship.
[0032] In a second aspect, an embodiment of the present invention further provides an SSD mapping management device based on dual mapping, comprising: a first acquisition unit, a first judgment unit, a recovery unit, an allocation and writing unit, a first storage unit and a second storage unit;
[0033] The first acquisition unit is used to acquire a dirty cache slice containing a plurality of dirty sub-slices from the cache;
[0034] The first determination unit is used to determine whether there is a complete old fine-grained secondary mapping table corresponding to the dirty cache fragment in the HMB;
[0035] The restoring unit is configured to restore the old fine-grained secondary mapping table according to the old coarse-grained secondary mapping table in the RAM if the old fine-grained secondary mapping table does not exist in the HMB;
[0036] The allocation and writing unit is used to allocate and write the dirty sub-shards to the secondary physical addresses in sequence according to the old fine-grained secondary mapping table if the old fine-grained secondary mapping table exists in the HMB, so as to form new sub-shards and corresponding new secondary mapping relationships;
[0037] The first storage unit is used to store all the new secondary mapping relationships in the old fine-grained secondary mapping table to form a new fine-grained secondary mapping table;
[0038] The second storage unit is used to store the last formed new secondary mapping relationship as a new coarse-grained secondary mapping relationship in the old coarse-grained secondary mapping table to form a new coarse-grained secondary mapping table. In a third aspect, this embodiment provides a computer device, the computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the SSD mapping management method based on dual mapping as described above when executing the computer program.
[0039] In a fourth aspect, the present embodiment provides a storage medium storing a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the SSD mapping management method based on dual mapping as described above can be implemented.
[0040] Compared with the prior art, the beneficial effects of the present invention are as follows: by constructing a fine-grained secondary mapping table in the HMB, additional cache space is provided for the SSD, thereby improving the read and write performance of the SSD; and by using the RAM to store the coarse-grained secondary mapping table, when the fine-grained secondary mapping table is missing, the secondary mapping relationship in the fine-grained secondary mapping table can be restored based on the coarse-grained secondary mapping table, thereby ensuring data accessibility and integrity; and by managing dirty cache shards and dirty sub-shards, ensuring that data is written back to the SSD in a timely manner to avoid data loss, ensuring dynamic processing of dirty cache shards, and thus being able to quickly adapt to data changes.
[0041] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0043] Figure 1 A schematic diagram of a flow chart of a SSD mapping management method based on dual mapping provided by an embodiment of the present invention;
[0044] Figure 2 A schematic diagram of an application scenario of the SSD mapping management method based on dual mapping provided by an embodiment of the present invention;
[0045] Figure 3 A schematic block diagram of an SSD mapping management device based on dual mapping provided by an embodiment of the present invention;
[0046] Figure 4 A schematic block diagram of a computer device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0047] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0048] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.
[0049] It should also be understood that the terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0050] It should be further understood that the term "and / or" used in the present description and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0051] See also Figure 1 to Figure 2 In the specific embodiment shown, the present invention discloses a SSD mapping management method based on dual mapping, comprising the following steps:
[0052] S1. Obtain a dirty cache shard containing several dirty sub-shards from the cache.
[0053] Specifically, in an SSD storage system, the cache is used to temporarily store data to improve read and write performance. A dirty cache shard refers to a data fragment that has been updated in the memory but has not yet been written back to the storage medium (SSD), and it is usually a collection of larger data blocks. By scanning the cache area in the memory, the modified data blocks will be marked as dirty cache shards, so that the data that needs to be updated can be processed later, thereby ensuring that all modified data can eventually be written back to the SSD in time to avoid data loss. The dirty cache shards will be further subdivided into smaller units, which are dirty sub-shards. The division of dirty sub-shards is performed according to a pre-set sharding rule. For example, the obtained dirty cache shards can be disassembled into smaller dirty sub-shards according to a fixed size, a specific data type range, or a logical grouping. In a specific embodiment, each dirty cache shard includes a number of data pages, and each dirty sub-shard can be 1 data page, so that data updates can be managed in a more fine-grained manner, so that data updates can be processed more targeted, avoiding operations on the entire cache shard, and improving the accuracy of operations and the performance and resource utilization efficiency of the system.
[0054] S2. Determine whether there is a complete old fine-grained secondary mapping table corresponding to the dirty cache fragment in the HMB.
[0055] Specifically, HMB stands for Host Memory Buffer, which is a host memory buffer technology. The principle of the technology is to reserve a cache area in the host's memory for SSD use; this area only occupies a small part of the PC's memory space (generally within 128MB), and the memory reserves sufficient space to coordinate the data exchange between the CPU and the hard disk. The SSD (solid state drive) can completely apply for the PC's "HMB space" for its own use when its own cache is insufficient. The fine-grained secondary mapping table is used to record the secondary mapping relationship of the sub-shards, reflecting the physical location corresponding to the sub-shards. By judging whether there is a complete old fine-grained secondary mapping table (unupdated fine-grained secondary mapping table) corresponding to the dirty cache shard in the HMB, the next operation process can be determined based on this judgment result. If there is no complete old fine-grained secondary mapping table in the HMB, it is restored to its original state based on the old coarse-grained secondary mapping table (unupdated coarse-grained secondary mapping table) in the RAM to ensure that the mapping table information required for subsequent operations is complete and available. This can avoid data operation errors caused by incomplete mapping tables. If a complete old fine-grained secondary mapping table exists in the HMB, subsequent allocation and writing operations can be performed directly based on the mapping table to improve the efficiency of the operation. Through the above-mentioned step S2, it is ensured that when processing dirty cache slices, operations can be performed correctly according to the old secondary mapping relationship (non-updated secondary mapping relationship), avoiding problems such as data loss, erroneous overwriting or inability to find the corresponding physical address due to missing or incomplete mapping table information; and when a complete old fine-grained secondary mapping table exists in the HMB, the complete old fine-grained secondary mapping table in the HMB is directly used to avoid the additional operation of restoring the mapping table from RAM, reducing unnecessary operations, thereby saving time and system resources, and improving the performance and efficiency of the storage system. Because restoring the mapping table from RAM may involve more data transmission and processing, using the existing information in the HMB can speed up the entire update process.
[0056] S3. If the old fine-grained secondary mapping table does not exist in the HMB, restore the old fine-grained secondary mapping table according to the old coarse-grained secondary mapping table in the RAM.
[0057] Specifically, RAM (Random Access Memory) is the main memory of a computer, where data can be read and written randomly and quickly. In this solution, it is used to store a coarse-grained secondary mapping table so that the macro mapping information therein can be quickly obtained when needed to assist in restoring a more detailed mapping relationship. The coarse-grained secondary mapping table is used to record the coarse-grained secondary mapping relationship corresponding to each cache shard, reflecting the physical location of each cache shard in the cache. In this embodiment, the coarse-grained secondary mapping table uses the secondary mapping relationship of the last sub-shard in each cache shard as the coarse-grained secondary mapping relationship corresponding to each cache shard. When it is necessary to operate a cache shard as a whole or obtain its general information, the corresponding SSD area range can be quickly determined based on the coarse-grained secondary mapping relationship and the cache shard can be read without traversing the entire fine-grained secondary mapping table, which greatly improves the initial positioning speed during large-scale data processing. When the fine-grained secondary mapping table is partially damaged or loses information, the coarse-grained secondary mapping relationship recorded in the coarse-grained secondary mapping table becomes an important clue for restoring the fine-grained mapping. Because it can provide a key reference point for each cache shard, based on which the approximate mapping of other sub-shards within the cache shard can be gradually calculated, so as to restore the fine-grained mapping relationship as completely as possible and ensure the accessibility and integrity of the data. For example, when the system encounters a sudden power outage or other failure that causes part of the data in the fine-grained secondary mapping table to be lost, the coarse-grained secondary mapping relationship of each cache shard in the coarse-grained secondary mapping table can be used, combined with the storage logic order of the data and some feature information, to gradually rebuild the fine-grained secondary mapping table, reducing the risk of data loss or erroneous access due to mapping loss. Step S3 solves the problem of missing fine-grained secondary mapping tables, supplements necessary mapping records, and lays the foundation for the subsequent formation of a complete and accurate new fine-grained secondary mapping table.
[0058] Furthermore, step S3 includes the following sub-steps:
[0059] An old coarse-grained secondary mapping relationship corresponding to the old cache slice is obtained from the old coarse-grained secondary mapping table.
[0060] Specifically, the design principle of this step is to use the global information provided by the coarse-grained L2 mapping table to locate the old cache slice corresponding to the dirty cache slice. Since the old coarse-grained L2 mapping table records the old coarse-grained L2 mapping relationship corresponding to the old cache slice (in this embodiment, the L2 mapping relationship of the last old sub-slice), it can be used to quickly locate the location of the old cache slice in the physical memory, thereby improving the search efficiency.
[0061] The old cache slices are read according to the old coarse-grained L2 mapping relationship to obtain and extract the old L2 mapping relationships corresponding to all the old sub-slices.
[0062] Specifically, the entire old cache shard is read through the old coarse-grained secondary mapping relationship (the old secondary mapping relationship of the last old sub-shard), thereby ensuring that the old secondary mapping relationships of all old sub-shards in the entire old cache shard are effectively extracted, avoiding the situation where old sub-shards are missed.
[0063] All the old secondary mapping relationships are stored in the old fine-grained secondary mapping table in the HMB.
[0064] Specifically, by re-storing all the extracted old secondary mapping relationships into the old fine-grained secondary mapping table, the old fine-grained secondary mapping table can restore the complete secondary mapping relationship through the coarse-grained secondary mapping table, reducing the problem of data inability to be stored correctly or read and write errors due to mapping loss, thereby ensuring the reliability of data storage and the stability of the system.
[0065] In addition, the step S3 further includes the following steps: marking the bitmap corresponding to the old fine-grained secondary mapping table as restored in the fine-grained mapping bitmap table.
[0066] Specifically, the fine-grained mapping bitmap table is a data structure used to quickly mark and query the status of the fine-grained secondary mapping table. In this embodiment, if it is detected in step S2 that there is no complete old fine-grained secondary mapping table in the HMB, the fine-grained mapping bitmap table marks the bitmap corresponding to the old fine-grained secondary mapping table as unrestored, and if it is detected in step S2 that there is a complete old fine-grained secondary mapping table in the HMB or after the old fine-grained secondary mapping table is fully restored through step S3, the fine-grained mapping bitmap table will mark the bitmap corresponding to the old fine-grained secondary mapping table as restored. Through the above steps, it can be ensured that the system can accurately track the recovery status of the old fine-grained secondary mapping table. In this embodiment, by marking the bitmap corresponding to the old fine-grained secondary mapping table as unrestored or restored according to the recovery status of the old fine-grained secondary mapping table, it can be quickly determined whether the old fine-grained secondary mapping table has completed the recovery operation according to the fine-grained mapping bitmap table, thereby avoiding the problem of repeated recovery or missed recovery, simplifying the management operation of the old fine-grained secondary mapping table, and reducing management costs.
[0067] S4. If the old fine-grained L2 mapping table exists in the HMB, the dirty sub-shards are allocated and written to the L2 physical addresses in sequence according to the old fine-grained L2 mapping table to form new sub-shards and corresponding new L2 mapping relationships.
[0068] Specifically, the new secondary mapping relationship (updated secondary mapping relationship) records the mapping relationship between the new sub-slice (updated sub-slice) and the secondary physical address. Step S4 includes the following sub-steps:
[0069] The dirty sub-shard is extracted, and it is identified whether there is an old secondary mapping relationship that is valid and corresponds to the dirty sub-shard in the old fine-grained secondary mapping table.
[0070] If there is an old secondary mapping relationship that is valid and corresponds to the dirty sub-shard in the old fine-grained secondary mapping table, the secondary physical address allocated to the dirty sub-shard is consistent with the original secondary physical address corresponding to the old secondary mapping relationship, and the dirty sub-shard is written to the original secondary physical address, thereby forming a new sub-shard and the corresponding new secondary mapping relationship.
[0071] By reusing the valid L2 physical address in the old L2 mapping relationship, unnecessary resource allocation can be reduced, thereby improving resource utilization efficiency, simplifying the mapping update process, and improving system operation efficiency.
[0072] If there is no valid old secondary mapping relationship corresponding to the dirty sub-shard in the old fine-grained secondary mapping table, a blank secondary physical address is allocated to the dirty sub-shard, and the dirty sub-shard is written to the blank secondary physical address. This blank secondary physical address is different from all the original secondary physical addresses corresponding to all the old secondary mapping relationships, thereby forming a new sub-shard and the corresponding new secondary mapping relationship, thereby ensuring the integrity and consistency of the data.
[0073] Furthermore, after completing the allocation write of each dirty sub-slice, step S5 also includes the following content: determining whether there are still dirty sub-slices in the dirty cache slice, repeatedly extracting the dirty sub-slices in the dirty cache slice, and performing the above-mentioned allocation write operation on the dirty sub-slice, until there are no dirty sub-slices in the dirty cache slice, and the dirty cache slice forms a new cache slice (updated cache slice) corresponding to the dirty cache slice, and then entering step S5, thereby ensuring that each dirty sub-slice is allocated and written to the secondary physical address, ensuring the consistency and integrity of the data.
[0074] S5. Store all the new secondary mapping relationships into the old fine-grained secondary mapping table to form a new fine-grained secondary mapping table.
[0075] Specifically, through the above step S5, the old fine-grained secondary mapping table is updated, thereby obtaining a new fine-grained secondary mapping table (updated fine-grained secondary mapping table), so that in subsequent operations, data can be accessed quickly and accurately through the new fine-grained secondary mapping table, thereby improving data access efficiency and consistency.
[0076] S6. Store the last formed new secondary mapping relationship as a new coarse-grained secondary mapping relationship in the old coarse-grained secondary mapping table to form a new coarse-grained secondary mapping table.
[0077] Specifically, through the above-mentioned step S6, in subsequent operations, the user can access the entire new cache shard based on the new coarse-grained secondary mapping relationship (updated coarse-grained secondary mapping relationship) in the new coarse-grained secondary mapping table (updated fine-grained secondary mapping table), thereby maintaining the validity and relevance of the new coarse-grained secondary mapping table. Through the collaborative work between the new coarse-grained secondary mapping table and the new fine-grained secondary mapping table, the management requirements of data mapping from macro to micro in different scenarios are met, the mapping architecture of the entire SSD storage system is optimized, and the flexibility and applicability of storage management are improved.
[0078] Furthermore, after step S6, the following steps are also included:
[0079] Determine whether there are still dirty cache fragments in the cache; if there are still dirty cache fragments in the cache, repeatedly obtain the dirty cache fragments; if there are no dirty cache fragments in the cache, end the acquisition of dirty cache fragments.
[0080] Specifically, through the above steps, it is ensured that all dirty cache slices are processed. Since the data in the SSD storage system changes dynamically, new dirty cache slices may be continuously generated during the processing process. Therefore, by determining whether there are unprocessed dirty cache slices, it is avoided to omit unprocessed dirty cache slices, thereby ensuring the integrity and accuracy of data updates.
[0081] Furthermore, before step S1, the following steps are also included:
[0082] Load the complete old coarse-grained L2 mapping table from NAND into RAM.
[0083] Specifically, when the power is off, NAND flash memory is the core storage medium of the SSD. It stores data in the form of a large-scale storage cell array based on the principle of non-volatile storage. It has the characteristic of not losing data after power failure, which is the key guarantee for the long-term and stable storage of data by the SSD. The storage unit of NAND flash memory usually uses pages as the basic read and write units, and multiple pages form blocks. The organization and management of data in these storage units directly affects the performance and reliability of the SSD. At the moment when the SSD starts or the recovery process starts, by loading the complete old coarse-grained secondary mapping table in NAND into RAM, subsequent mapping management operations can quickly and conveniently access the key information contained therein, providing strong support for the precise positioning and management of data.
[0084] The user data is obtained, and the primary mapping relationship corresponding to the user data is stored in the old sub-shard in the old cache shard to form the dirty cache shard and the dirty sub-shard.
[0085] Specifically, the method of acquiring user data includes writing user data and updating user data.
[0086] When writing user data, the first-level mapping relationship corresponding to the user data will be stored in the blank old sub-shard, that is, the dirty sub-shard formed by the blank old sub-shard does not have a corresponding and valid old second-level mapping relationship in the old fine-grained second-level mapping table. Therefore, the dirty sub-shard will be allocated and written to the blank second-level physical address subsequently, thereby forming the corresponding new dirty sub-shard and new second-level mapping relationship.
[0087] When updating user data, the first-level mapping relationship corresponding to the user data will be stored in the non-blank old sub-shard, that is, the data in the non-blank old sub-shard is updated, thereby forming a corresponding dirty sub-shard. The dirty sub-shard has a corresponding and valid old second-level mapping relationship in the old fine-grained second-level mapping table. Therefore, the dirty sub-shard will also be written to the original second-level physical address accordingly, thereby forming a corresponding new dirty sub-shard and a new second-level mapping relationship.
[0088] Furthermore, after step S6, the following steps are also included:
[0089] Obtain a read instruction for the user data.
[0090] Specifically, the read instruction can contain a variety of information, such as the name, address, type, etc. of the data, so that the system can accurately locate the required data. This step is the starting point of the data reading process. Its design principle is to respond to external data needs and trigger subsequent data search and reading operations by receiving read instructions.
[0091] The corresponding new secondary mapping relationship is obtained from the new fine-grained secondary mapping table according to the read instruction.
[0092] Specifically, by parsing the information in the read instruction, such as the identification or location information of the data, the corresponding new secondary mapping relationship is then searched in the new fine-grained secondary mapping table. The new fine-grained secondary mapping table is used to quickly locate the location of the data in the physical storage. The new fine-grained secondary mapping table records the mapping relationship between the new sub-shard and the secondary physical address, so the corresponding new secondary mapping relationship can be searched by reading the information in the instruction. This step realizes the rapid location of data and improves the efficiency of data reading.
[0093] The corresponding new sub-shard is read according to the corresponding new secondary mapping relationship to obtain the primary mapping relationship corresponding to the user data.
[0094] Specifically, according to the secondary physical address in the new secondary mapping relationship, the corresponding new sub-shard is read from the SSD. Then, the primary mapping relationship corresponding to the user data is searched and extracted in the new sub-shard. This step realizes the accurate extraction of the primary mapping relationship corresponding to the user data, which provides a basis for subsequent data reading.
[0095] The user data is read according to the primary mapping relationship corresponding to the user data.
[0096] Specifically, according to the primary mapping relationship, user data can be directly located and read. The primary mapping relationship provides a direct correspondence between user data and user data storage units, so user data can be directly obtained through it, thereby achieving accurate reading of user data and meeting external data requirements.
[0097] This embodiment can store a smaller-grained but more space-consuming fine-grained secondary mapping table in the HMB. When reading user data, the user data mapping can be obtained directly through one HMB access and one SSD access, thereby reducing one SSD access (the access latency of the HMB is lower than that of the SSD, and it can be executed simultaneously with the SSD operation). That is, this embodiment constructs secondary mapping tables of different granularities, the coarse-grained secondary mapping table is maintained in the smaller RAM inside the SSD, and the fine-grained secondary mapping table is maintained in the HMB, thereby reducing the latency of obtaining the user data mapping and improving the performance, thereby greatly improving the large-scale random read performance of the SSD.
[0098] The present invention provides the above-mentioned SSD mapping management method based on dual mapping, and provides additional cache space for the SSD by constructing a fine-grained secondary mapping table in the HMB, thereby improving the read and write performance of the SSD, and uses the RAM to store the coarse-grained secondary mapping table, so that when the fine-grained secondary mapping table is missing, the secondary mapping relationship in the fine-grained secondary mapping table can be restored according to the coarse-grained secondary mapping table, thereby ensuring the accessibility and integrity of the data, and through the management of dirty cache slices and dirty sub-shards, ensuring that data is written back to the SSD in time to avoid data loss, ensuring the dynamic processing of dirty cache slices, so as to quickly adapt to data changes.
[0099] See also Figure 3 As shown, the present invention also discloses an SSD mapping management device based on dual mapping, comprising: a first acquisition unit 10, a first judgment unit 20, a recovery unit 30, an allocation write unit 40, a first storage unit 50 and a second storage unit 60;
[0100] The first acquisition unit 10 is used to acquire a dirty cache slice containing a plurality of dirty sub-slices from the cache;
[0101] The first determination unit 20 is used to determine whether there is a complete old fine-grained secondary mapping table corresponding to the dirty cache fragment in the HMB;
[0102] The restoring unit 30 is configured to restore the old fine-grained secondary mapping table according to the old coarse-grained secondary mapping table in the RAM if the old fine-grained secondary mapping table does not exist in the HMB;
[0103] The allocation and writing unit 40 is used to allocate and write the dirty sub-shards to the secondary physical addresses in sequence according to the old fine-grained secondary mapping table if the old fine-grained secondary mapping table exists in the HMB, so as to form new sub-shards and corresponding new secondary mapping relationships;
[0104] The first storage unit 50 is used to store all the new secondary mapping relationships into the old fine-grained secondary mapping table to form a new fine-grained secondary mapping table;
[0105] The second storage unit 60 is used to store the last formed new secondary mapping relationship as a new coarse-grained secondary mapping relationship in the old coarse-grained secondary mapping table to form a new coarse-grained secondary mapping table.
[0106] In a specific embodiment, the SSD mapping management device based on dual mapping further includes: a second judgment unit, a second acquisition unit and a stop unit;
[0107] A second determination unit, used to determine whether there are still dirty cache fragments in the cache;
[0108] A second acquisition unit is used for continuing to acquire dirty cache slices containing a plurality of dirty sub-slices from the cache if there are still dirty cache slices in the cache;
[0109] The stopping unit is used for stopping obtaining a dirty cache slice containing a plurality of dirty sub-slices from the cache if no dirty cache slice exists in the cache.
[0110] In a specific embodiment, the SSD mapping management device based on dual mapping further includes: acquiring a storage unit;
[0111] The acquisition storage unit is used to acquire user data and store the primary mapping relationship corresponding to the user data in the old sub-shard in the old cache shard to form the dirty cache shard and the dirty sub-shard.
[0112] In a specific embodiment, the SSD mapping management device based on dual mapping further includes: a loading unit;
[0113] The loading unit is used to load the complete old coarse-grained secondary mapping table from the NAND into the RAM.
[0114] In a specific embodiment, the SSD mapping management device based on dual mapping further includes: a marking unit;
[0115] The marking unit is used to mark the bitmap corresponding to the old fine-grained secondary mapping table as restored in the fine-grained mapping bitmap table.
[0116] In a specific embodiment, the SSD mapping management device based on dual mapping further includes: a third acquisition unit, a fourth acquisition unit, a read acquisition unit, and a read unit;
[0117] The third acquisition unit is used to acquire a read instruction of the user data;
[0118] The fourth acquisition unit is used to acquire the corresponding new secondary mapping relationship from the new fine-grained secondary mapping table according to the read instruction;
[0119] The reading and obtaining unit is used to read the corresponding new sub-shard according to the new secondary mapping relationship to obtain the primary mapping relationship corresponding to the user data;
[0120] The reading unit is used to read the user data according to the first-level mapping relationship.
[0121] It should be noted that technicians in the relevant field can clearly understand that the specific implementation process of the above-mentioned SSD mapping management device based on dual mapping and each unit can refer to the corresponding description in the aforementioned method embodiment, and for the convenience and conciseness of the description, it will not be repeated here.
[0122] See also Figure 4 , Figure 4 is a schematic block diagram of a computer device provided in an embodiment of the present application; the computer device 500 may be a terminal or a server, wherein the terminal may be an electronic device with communication functions such as a smart phone, a tablet computer, a laptop computer, a desktop computer, a personal digital assistant, and a wearable device. The server may be an independent server or a server cluster composed of multiple servers.
[0123] See also Figure 4 The computer device 500 includes a processor 502 , a memory and a network interface 505 connected via a system bus 501 , wherein the memory may include a non-volatile storage medium 503 and an internal memory 504 .
[0124] The non-volatile storage medium 503 can store an operating system 5031 and a computer program 5032. The computer program 5032 includes program instructions, and when the program instructions are executed, the processor 502 can execute a SSD mapping management method based on dual mapping.
[0125] The processor 502 is used to provide computing and control capabilities to support the operation of the entire computer device 500 .
[0126] The internal memory 504 provides an environment for the operation of the computer program 5032 in the non-volatile storage medium 503. When the computer program 5032 is executed by the processor 502, the processor 502 can execute an SSD mapping management method based on dual mapping.
[0127] The network interface 505 is used to communicate with other devices over the network. Figure 4 The structure shown in the figure is merely a block diagram of a portion of the structure related to the solution of the present application, and does not constitute a limitation on the computer device 500 to which the solution of the present application is applied. The specific computer device 500 may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0128] The processor 502 is used to run the computer program 5032 stored in the memory to implement the following steps:
[0129] Obtain a dirty cache slice containing several dirty sub-slices from the cache; determine whether there is a complete old fine-grained secondary mapping table corresponding to the dirty cache slice in the HMB; if the old fine-grained secondary mapping table does not exist in the HMB, restore the old fine-grained secondary mapping table according to the old coarse-grained secondary mapping table in the RAM; if the old fine-grained secondary mapping table exists in the HMB, allocate and write the dirty sub-slices to the secondary physical addresses in turn according to the old fine-grained secondary mapping table to form new sub-slices and corresponding new secondary mapping relationships; store all the new secondary mapping relationships in the old fine-grained secondary mapping table to form a new fine-grained secondary mapping table; store the last formed new secondary mapping relationship as a new coarse-grained secondary mapping relationship in the old coarse-grained secondary mapping table to form a new coarse-grained secondary mapping table.
[0130] It should be understood that in the embodiment of the present application, the processor 502 may be a central processing unit (CPU), and the processor 502 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0131] It can be understood by those skilled in the art that all or part of the processes in the method for implementing the above embodiment can be completed by instructing the relevant hardware through a computer program. The computer program includes program instructions, and the computer program can be stored in a storage medium, which is a computer-readable storage medium. The program instructions are executed by at least one processor in the computer system to implement the process steps of the embodiment of the above method.
[0132] Therefore, the present invention also provides a storage medium. The storage medium may be a computer-readable storage medium. The storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the above-mentioned SSD mapping management method based on dual mapping can be implemented. The storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the above-mentioned method can be implemented. The program instructions include the following steps:
[0133] Obtain a dirty cache slice containing several dirty sub-slices from the cache; determine whether there is a complete old fine-grained secondary mapping table corresponding to the dirty cache slice in the HMB; if the old fine-grained secondary mapping table does not exist in the HMB, restore the old fine-grained secondary mapping table according to the old coarse-grained secondary mapping table in the RAM; if the old fine-grained secondary mapping table exists in the HMB, allocate and write the dirty sub-slices to the secondary physical addresses in turn according to the old fine-grained secondary mapping table to form new sub-slices and corresponding new secondary mapping relationships; store all the new secondary mapping relationships in the old fine-grained secondary mapping table to form a new fine-grained secondary mapping table; store the last formed new secondary mapping relationship as a new coarse-grained secondary mapping relationship in the old coarse-grained secondary mapping table to form a new coarse-grained secondary mapping table.
[0134] The storage medium may be a USB flash drive, a mobile hard disk, a read-only memory (ROM), a magnetic disk, or an optical disk, etc., which are computer-readable storage media that can store program codes.
[0135] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0136] In the several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of each unit is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or skipped.
[0137] The steps in the method of the embodiment of the present invention can be adjusted in order, combined and deleted according to actual needs. The units in the device of the embodiment of the present invention can be combined, divided and deleted according to actual needs. In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0138] 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 storage medium. Based on this understanding, the technical solution of the present invention is essentially 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 a number of instructions for a computer device (which can be a personal computer, terminal, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention.
[0139] The above embodiments are preferred implementation schemes of the present invention. In addition, the present invention may also be implemented in other ways. Any obvious replacement without departing from the concept of the present technical solution is within the protection scope of the present invention.
Claims
1. The SSD mapping management method based on dual mapping is characterized in that: The following steps are involved: Get a dirty cache shard containing several dirty sub-shards from the cache; Determine whether there is a complete old fine-grained secondary mapping table corresponding to the dirty cache slice in the HMB; If the old fine-grained secondary mapping table does not exist in the HMB, restoring the old fine-grained secondary mapping table according to the old coarse-grained secondary mapping table in the RAM; If the old fine-grained secondary mapping table exists in the HMB, the dirty sub-shards are allocated and written to the secondary physical addresses in sequence according to the old fine-grained secondary mapping table to form new sub-shards and corresponding new secondary mapping relationships; Storing all the new secondary mapping relationships in the old fine-grained secondary mapping table to form a new fine-grained secondary mapping table; The last formed new secondary mapping relationship is stored as a new coarse-grained secondary mapping relationship in the old coarse-grained secondary mapping table to form a new coarse-grained secondary mapping table.
2. The SSD mapping management method based on dual mapping according to claim 1, characterized in that: After the step of storing the last formed new secondary mapping relationship as a new coarse-grained secondary mapping relationship in the old coarse-grained secondary mapping table to form a new coarse-grained secondary mapping table, the method further comprises: Determine whether there are still dirty cache fragments in the cache; If there are still dirty cache shards in the cache, continue to obtain dirty cache shards containing several dirty sub-shards from the cache; If there are no dirty cache shards in the cache, stop obtaining dirty cache shards containing several dirty sub-shards from the cache.
3. The SSD mapping management method based on dual mapping according to claim 1, characterized in that: Before the step of obtaining a dirty cache shard containing a plurality of dirty sub-shards from the cache, the method further comprises: The user data is obtained, and the primary mapping relationship corresponding to the user data is stored in the old sub-shard in the old cache shard to form the dirty cache shard and the dirty sub-shard.
4. The SSD mapping management method based on dual mapping according to claim 3, characterized in that: Before the step of acquiring the user data and storing the primary mapping relationship corresponding to the user data in the old sub-shard in the old cache shard to form the dirty cache shard and the dirty sub-shard, the method includes: Load the complete old coarse-grained L2 mapping table from NAND into RAM.
5. The SSD mapping management method based on dual mapping according to claim 3, characterized in that: If the old fine-grained secondary mapping table does not exist in the HMB, the step of restoring the old fine-grained secondary mapping table according to the old coarse-grained secondary mapping table in the RAM includes: Acquire an old coarse-grained secondary mapping relationship corresponding to the old cache slice from the old coarse-grained secondary mapping table; Reading the old cache shards according to the old coarse-grained secondary mapping relationship to obtain and extract the old secondary mapping relationships corresponding to all the old sub-shards; All the old secondary mapping relationships are stored in the HMB to restore the old fine-grained secondary mapping table in the HMB.
6. The SSD mapping management method based on dual mapping according to claim 5, characterized in that: After the step of storing all the old secondary mapping relationships in the HMB to restore the old fine-grained secondary mapping table in the HMB, the method further comprises: In the fine-grained mapping bitmap table, the bitmap corresponding to the old fine-grained secondary mapping table is marked as restored.
7. The SSD mapping management method based on dual mapping according to claim 3, characterized in that: After the step of storing the last formed new secondary mapping relationship as a new coarse-grained secondary mapping relationship in the old coarse-grained secondary mapping table to form a new coarse-grained secondary mapping table, the method further comprises: Obtaining a read instruction for the user data; Acquire the corresponding new secondary mapping relationship from the new fine-grained secondary mapping table according to the read instruction; Read the corresponding new sub-shard according to the new secondary mapping relationship to obtain the primary mapping relationship corresponding to the user data; The user data is read according to the primary mapping relationship.
8. The SSD mapping management device based on dual mapping is characterized in that: include: A first acquisition unit, a first determination unit, a recovery unit, an allocation and writing unit, a first storage unit, and a second storage unit; The first acquisition unit is used to acquire a dirty cache slice containing a plurality of dirty sub-slices from the cache; The first determination unit is used to determine whether there is a complete old fine-grained secondary mapping table corresponding to the dirty cache fragment in the HMB; The restoring unit is configured to restore the old fine-grained secondary mapping table according to the old coarse-grained secondary mapping table in the RAM if the old fine-grained secondary mapping table does not exist in the HMB; The allocation and writing unit is used to allocate and write the dirty sub-shards to the secondary physical addresses in sequence according to the old fine-grained secondary mapping table if the old fine-grained secondary mapping table exists in the HMB, so as to form new sub-shards and corresponding new secondary mapping relationships; The first storage unit is used to store all the new secondary mapping relationships in the old fine-grained secondary mapping table to form a new fine-grained secondary mapping table; The second storage unit is used to store the last formed new secondary mapping relationship as a new coarse-grained secondary mapping relationship in the old coarse-grained secondary mapping table to form a new coarse-grained secondary mapping table.
9. A computer device, characterized in that: The computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the SSD mapping management method based on dual mapping as described in any one of claims 1 to 7 when executing the computer program.
10. A storage medium, characterized in that: The storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the SSD mapping management method based on dual mapping as described in any one of claims 1 to 7 is implemented.