Data Management Method, Intelligent Terminal, and Computer-Readable Storage Medium
By constructing mapping relationship logs and dirty map block tables in the cache area, using the combination of hash tables and extended tables, the problems of poor read and write performance of DRAM-less storage devices and slow mapping table query are solved, and the random write performance of storage devices and mapping table update speed are improved.
Patent Information
- Application Number
- CN202111056765.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-09
- Publication Date
- 2025-08-01
- Estimated Expiration
- 2041-09-09
AI Technical Summary
In the absence of DRAM, existing storage devices have poor read and write performance, especially poor random read and write performance, and slow query and update speed of mapping tables, which affects the user experience.
The mapping relationship log and dirty mapping block table are constructed in the cache area. Through the combination of hash table and extended table, the mapping relationship to be updated is stored in a classified manner, reducing the number of accesses to flash memory and improving query and update speed.
By classifying storage and quickly finding mapping relationships, the number of accesses to flash memory is reduced, the random write performance of storage devices and the update speed of mapping tables is improved, and the user experience is improved.
Smart Images

Figure CN115793954B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of Internet technologies, and in particular, to a data management method, a smart terminal, and a computer-readable storage medium. Background Art
[0002] Currently, mainstream flash-based storage devices, such as SSD (Solid State Disk), UFS (Universal Flash Storage), eMMC (embedded Multi Media Card), etc., usually adopt a page mapping method for their FTL (Flash Translation Layer). Compared with the traditional block mapping method, the storage device adopting the page mapping method has better random write performance, but the disadvantage is that the storage space occupied by the corresponding mapping table is usually very large, generally 1 / 1024 of the storage device capacity. For example, for a 1TB storage device, the mapping table size is 1GB.
[0003] Traditional SSDs generally come with a corresponding size of DRAM (Dynamic Random Access Memory) to store the mapping table during operation. However, in some consumer-grade SSDs and mobile storage devices (such as UFS, eMMC), due to considerations such as cost and power consumption, they often do not configure DRAM, but instead adopt a DRAM-less firmware architecture in software design for replacement.
[0004] Currently, the performance of mainstream mobile phone CPUs (central processing units) is usually relatively powerful, and DRAM resources are rich (generally in the range of 4GB - 12GB). Their performance bottlenecks are often limited by the performance of their storage devices. The lag that users experience during mobile phone use is often caused by the delay in accessing the storage device. It can be said that the performance of the storage device determines the user experience. Therefore, improving the performance of the storage device helps to improve the user experience of mobile phone users.
[0005] However, compared with storage devices with DRAM, the existing DRAM-less storage devices need to access the flash more times when obtaining user data, so their read and write performance is much worse, especially in terms of random read and write performance. And when updating the mapping table, there are usually problems such as slow query and slow mapping table update, which seriously affect the random write performance. Summary of the Invention
[0006] The main technical problem to be solved by this application is to provide a data management method, an intelligent terminal and a computer-readable storage medium, so as to solve the problems in the prior art that the data management method of the storage device has poor read and write performance, and when updating the mapping table, the query is slow and the mapping table update is slow, thus seriously affecting the random write performance.
[0007] To solve the above problems, a first aspect of this application provides a data management method for a storage device. Among them, the data management method includes: writing the mapping relationship to be updated into the mapping relationship log in the cache area; obtaining the mapping block number corresponding to each mapping relationship to be updated in the dirty mapping block table of the cache area based on the logical address of each mapping relationship to be updated in the mapping relationship log; writing each mapping relationship to be updated into the mapping relationship linked list corresponding to its corresponding mapping block number in sequence.
[0008] Among them, after writing the mapping relationship to be updated into the mapping relationship log in the cache area and before obtaining the mapping block number corresponding to each mapping relationship to be updated in the dirty mapping block table of the cache area based on the logical address of each mapping relationship to be updated in the mapping relationship log, it further includes: constructing a dirty mapping block table with a set length including a hash table and an extension table in the cache area.
[0009] Among them, after obtaining the mapping block number corresponding to each mapping relationship to be updated in the dirty mapping block table of the cache area based on the logical address of each mapping relationship to be updated in the mapping relationship log and before writing each mapping relationship to be updated into the mapping relationship linked list corresponding to its corresponding mapping block number in sequence, it further includes: obtaining the index number of each mapping relationship to be updated in the dirty mapping block table based on the mapping block number and the length of the hash table; writing each mapping relationship to be updated into the mapping relationship linked list corresponding to its corresponding mapping block number in sequence, including: writing each mapping relationship to be updated into the mapping relationship linked list corresponding to its corresponding mapping block number in sequence. Among them, when the index number corresponding to the currently to-be-written mapping relationship to be updated is the same as the index number corresponding to the previously written mapping relationship to be updated, but the mapping block numbers are different, writing the mapping block number corresponding to the currently to-be-written mapping relationship to be updated into the extension table; writing the currently to-be-written mapping relationship to be updated into the mapping relationship linked list corresponding to its corresponding mapping block number in the extension table.
[0010] Among them, after writing the currently to-be-written mapping relationship to be updated into the mapping relationship linked list corresponding to its corresponding mapping block number in the extension table, it further includes: obtaining the logical address to be read; obtaining the read mapping block number and the read index number corresponding to it in the dirty mapping block table based on the logical address to be read; judging whether the storage position corresponding to the read index number in the dirty mapping block table is empty; if the storage position corresponding to the read index number in the dirty mapping block table is empty, determining that there is no mapping relationship to be updated corresponding to the logical address to be read in the mapping relationship log, and ending the current read operation.
[0011] Among them, if the storage location corresponding to the read index number in the dirty mapping block table is not empty, it is determined whether the read mapping block number is the same as the mapping block number currently stored at the storage location; if the read mapping block number is the same as the mapping block number currently stored at the storage location, it is checked whether there is a to-be-updated mapping relationship corresponding to the to-be-read logical address in the mapping relationship linked list corresponding to the read mapping block number.
[0012] Among them, if the read mapping block number is different from the mapping block number currently stored at the storage location, it is checked whether there is a mapping block number in the extension table that is the same as the read mapping block number; if there is a mapping block number in the extension table that is the same as the read mapping block number, it is checked whether there is a to-be-updated mapping relationship corresponding to the to-be-read logical address in the mapping relationship linked list corresponding to the read mapping block number in the extension table.
[0013] Among them, the length of the hash table is a positive integer multiple of 4 times the length of the extension table.
[0014] Among them, after sequentially writing each to-be-updated mapping relationship into the mapping relationship linked list of its corresponding mapping block number, it further includes: based on the mapping relationship linked list of each mapping block number, finding each to-be-updated mapping block in the mapping table of the flash memory area, and loading each to-be-updated mapping block into the cache area; updating the to-be-updated mapping block according to each to-be-updated mapping relationship in the mapping relationship linked list corresponding to the mapping block number of each to-be-updated mapping block, and writing the updated to-be-updated mapping block into the mapping table.
[0015] To solve the above problems, a second aspect of the present application provides a data management device, where the data management device includes: a writing module for writing the to-be-updated mapping relationship into the mapping relationship log in the cache area; a processing module for obtaining the mapping block number corresponding to each to-be-updated mapping relationship in the dirty mapping block table of the cache area based on the logical address of each to-be-updated mapping relationship in the mapping relationship log; where the writing module is further configured to sequentially write each to-be-updated mapping relationship into the mapping relationship linked list of its corresponding mapping block number.
[0016] To solve the above problems, a third aspect of the present application provides an intelligent terminal, where the intelligent terminal includes a memory and a processor that are coupled to each other, and the memory stores program data; the processor is configured to execute the program data to implement the data management method described in any one of the above.
[0017] To solve the above problems, a fourth aspect of the present application provides a computer-readable storage medium, on which program instructions are stored, and when the program instructions are executed by a processor, the data management method described in any one of the above is implemented.
[0018] The beneficial effects of the present invention are as follows: Different from the prior art, the data management method of this application writes the mapping relationships to be updated into the mapping relationship log in the cache area, and based on the logical addresses of each mapping relationship to be updated in the mapping relationship log, obtains the mapping block numbers corresponding to each mapping relationship to be updated in the dirty mapping block table of the cache area, so as to be able to write each mapping relationship to be updated into the mapping relationship linked list corresponding to its mapping block number in turn. This is equivalent to classifying and storing multiple mapping relationships to be updated in the mapping relationship log according to the logical addresses of each mapping relationship to be updated, so that the mapping relationships to be updated can be found more quickly and classified from the dirty mapping block table, and the number of times of accessing the mapping relationship log can be effectively reduced. Therefore, when obtaining user data from the flash memory of the storage device, the number of times of accessing the flash memory can be effectively reduced, and when updating the mapping table, the number of times of traversing the cache is also less, so that the corresponding storage device is faster in data query and update, and the random write performance of the storage device is thus better. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 It is a schematic diagram of writing the mapping relationships to be updated into the mapping relationship log in the cache area of the storage device;
[0020] Figure 2 It is a schematic diagram of updating the mapping relationships to be updated by the storage device in the prior art;
[0021] Figure 3 It is a schematic flowchart of the first embodiment of the data management method of this application;
[0022] Figure 4 It is a schematic diagram of storing the mapping relationships to be updated by this application;
[0023] Figure 5 It is a schematic flowchart of the second embodiment of the data management method of this application;
[0024] Figure 6 It is a schematic flowchart of the third embodiment of the data management method of this application;
[0025] Figure 7 It is a schematic flowchart of the fourth embodiment of the data management method of this application;
[0026] Figure 8 It is a schematic framework diagram of an embodiment of the intelligent terminal of this application;
[0027] Figure 9 It is a schematic framework diagram of an embodiment of the computer-readable storage medium of this application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0028] After long-term research, the inventors found that in current mainstream flash-based storage devices (such as SSDs, UFSs, eMMCs, etc.), their FTLs all adopt the page mapping method. Compared with the traditional block mapping method, storage devices using the page mapping method have better random write performance. However, the disadvantage is that the corresponding mapping table (used to store the physical addresses of logical blocks in the flash memory) usually occupies a large amount of storage space, generally 1 / 1024 of the storage device capacity. For example, for a 1TB storage device, the mapping table size is 1GB.
[0029] Among them, traditional SSDs generally come with a corresponding amount of DRAM to store the mapping table during operation. However, in some consumer-grade SSDs and mobile storage devices (such as UFSs, eMMCs), due to factors such as cost and power consumption, they often do not have DRAM configured and adopt a DRAM-less firmware architecture in software design. Specifically, the vast majority of the mapping table is stored in the flash memory of the storage device. When the storage device is running, the mapping table data will be loaded into the mapping table cache (usually SRAM with a size of dozens to hundreds of KB, Static Random-Access Memory) as needed. For example, when a logical block (Logical Block Address, LBA) needs to be read, the firmware will first search the mapping table cache. If a hit occurs, the physical address (Physical address, PPA) of the logical block can be directly obtained, and then the flash memory area of the storage device can be read according to this physical address to obtain the final user data. However, since the mapping table cache is usually very small, there is a high probability that the cache will not be hit, and it is necessary to temporarily load the mapping table data from the flash memory into the cache and then read the user data according to the physical address. Therefore, compared with storage devices with DRAM, DRAM-less storage devices need to access the flash memory more times, and thus their read and write performance is much worse, especially in terms of random read and write performance.
[0030] Among them, the logical block is a general mechanism for describing the data block location on a computer storage device and is generally used in auxiliary memory devices such as hard disks. LBA can mean the address of a data block or the data block pointed to by an address. A so-called logical block on a modern computer is usually 512 or 1024 bytes. And the physical address is specifically the actual address corresponding to the storage unit in the network card physical address memory, corresponding to the logical address. The physical address of the network card is usually written into the network card's EPROM (Erasable Programmable Read-Only Memory) by the network card manufacturer, and it stores the addresses of the computer that actually sends the data and the host that receives the data when transmitting data.
[0031] Furthermore, for DRAM-less storage devices, updating the mapping table is also a problem. When user data is written, erased (such as Trim), or garbage collected within the device, it will cause the mapping relationship to be updated. For storage devices with DRAM, updating the mapping table only requires updating the mapping table in the DRAM. However, for DRAM-less storage devices, since the mapping table is in the flash memory, it is impossible to load the corresponding mapping relationship from the flash memory every time a mapping relationship is generated, update it, and then write it back to the flash memory. Otherwise, the write performance (especially the random write performance) will be very poor.
[0032] To solve the problem of mapping table update, as Figure 1 shown, Figure 1 is a schematic diagram of writing the mapping relationship to be updated into the mapping relationship log in the cache area of the storage device. DRAM-less storage devices often use the log method, that is, the generated mapping relationships (LBA, PPA) are first recorded in the mapping relationship log in the SRAM, and then updated collectively after reaching a certain number.
[0033] When the mapping table is updated, as Figure 2 shown, Figure 2 is a schematic diagram of a storage device in the prior art updating the mapping relationship to be updated. According to the mapping relationship log, the corresponding mapping block (the basic unit for loading and updating mapping table data, usually 2KB or 4KB) can be loaded into the cache, the old mapping relationship can be replaced with the new mapping relationship, and then written back to the flash memory after the update is completed. This way of delaying batch update avoids frequent loading and updating of the flash memory, and improves the performance and lifespan of the storage device.
[0034] However, this method also has two problems: First, the query is slow. When a read command comes, the firmware first needs to search the mapping relationship log to detect whether the mapping relationship of the LBA to be read is in the log. Since the mapping relationships in the log are not sorted, when the log is large, searching the log is a time-consuming operation, seriously affecting the read performance; if the log is sorted when inserting mapping relationships, although the problem of slow query can be solved (binary search can be used), the insertion operation will become slower. In the worst case, when inserting a mapping relationship, all the previously inserted mapping relationships need to be moved backward. Second, the mapping table update is slow. When updating the mapping table, when loading a mapping block into the cache, the entire log needs to be traversed to find all the mapping relationships belonging to that mapping block. Suppose N mapping blocks need to be updated and the log size is M mapping relationships. Updating these mapping blocks requires accessing the log N*M times. When the writes are relatively random (N is relatively large) and the log M is relatively large, this overhead is very large and will seriously affect the random write performance.
[0035] In order to improve the read and write performance of a storage device, and enhance the query speed and the mapping table update speed when updating the mapping table, the present application provides a data management method for a storage device. The following will further describe the present application in detail in conjunction with the accompanying drawings and embodiments. It should be specifically noted that the following embodiments are only used to illustrate the present application, but do not limit the scope of the present application. Similarly, the following embodiments are only partial embodiments of the present application rather than all embodiments. All other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the scope of protection of the present application.
[0036] Referring to "embodiment" in the present application means that the specific features, structures or characteristics described in connection with the embodiment may be included in at least one embodiment of the present application. The phrase appears at various positions in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment mutually exclusive with other embodiments. Those skilled in the art explicitly and implicitly understand that the embodiments described herein may be combined with other embodiments.
[0037] Please refer to Figure 3 and Figure 4 , where Figure 3 is a schematic flowchart of the first embodiment of the data management method of the present application, Figure 4 is a schematic diagram of storing the mapping relationship to be updated in the present application. Specifically, the following steps may be included:
[0038] S11: Write the mapping relationship to be updated into the mapping relationship log in the cache area.
[0039] ) With the rapid development of the storage device industry, especially the development of DRAM-less storage devices, due to their advantages in factors such as cost and power consumption, they are increasingly favored by the market. Among them, for storage devices, when reading logical blocks and querying and updating the corresponding mapping tables, how to effectively reduce the number of accesses to the flash memory and enhance the query speed and the mapping table update speed when updating the mapping table is a key point affecting the read and write performance of the storage device, and also a key factor affecting whether the storage device can be accepted by the market. In this embodiment, the data management method specifically corresponds to any reasonable data processing method for reading, querying, writing, and updating the mapping table of the data in the storage device, and can be applied to any reasonable storage device, such as SSD, UFS, eMMC, etc., especially DRAM-less storage devices.
[0040] Among them, the flash memory area of the storage device stores a mapping table integrating all mapping relationships, so as to be able to perform processing such as randomly writing and reading data in the storage device according to the mapping table; and a mapping relationship log is correspondingly constructed in its cache area, so as to be able to record each newly generated mapping relationship (LBA, PPA), and after aggregating to a certain number, the previously stored mapping relationships in the mapping table are updated collectively.
[0041] Specifically, as Figure 4 shown, when it is necessary to update the mapping table in the storage device, first, each mapping relationship to be updated generated in sequence, for example, a, b, c,... z, is written into the mapping relationship log in the cache area of the storage device in sequence, so as to aggregate the data of the mapping relationships to be updated in the mapping relationship log.
[0042] S12: Based on the logical address of each mapping relationship to be updated in the mapping relationship log, obtain the mapping block number corresponding to each mapping relationship to be updated in the dirty mapping block table of the cache area.
[0043] It can be understood that each mapping relationship to be updated corresponds to a pair (LBA, PPA), and this LBA is the logical address of this mapping relationship to be updated, and for different mapping relationships to be updated, the corresponding mapping blocks may be the same. As Figure 2 shown, there is usually a situation in the mapping relationship log where multiple mapping relationships to be updated correspond to the same mapping block, and the logical addresses of these multiple mapping relationships to be updated are the same, while the physical addresses are different.
[0044] From this, it can be seen that in order to reduce the total number of accesses to the mapping relationship log when updating the mapping relationship subsequently, all the mapping relationships to be updated in the mapping relationship log can be classified according to the logical address, that is, the mapping relationships to be updated with the same logical address are grouped into one category for unified storage. For example, a dirty mapping block table is constructed in the cache area of the storage device to store each category of mapping relationships to be updated in partitions, and for the convenience of subsequent classified queries, a mapping block number can be set correspondingly in the dirty mapping block table to establish an association with each category of mapping relationships to be updated.
[0045] Specifically, based on the logical address of each mapping relationship to be updated in the mapping relationship log, the mapping block number corresponding to each mapping relationship to be updated in the dirty mapping block table of the cache area is calculated through a set function or logical comparison relationship.
[0046] S13: Write each mapping relationship to be updated into the mapping relationship linked list corresponding to its mapping block number in sequence.
[0047] It is understandable that the dirty mapping block table is specifically constructed based on the mapping relationship log to record which mapping blocks have generated new mapping relationships. To establish an association between different pending update mapping relationships that belong to the same category with consistent logical addresses, the pending update mapping relationships in the mapping relationship log that belong to the same mapping block number can also be linked by a linked list, so that each sequentially generated pending update mapping relationship can be sequentially written into the mapping relationship linked list corresponding to the mapping block number in the dirty mapping block table.
[0048] Among them, a linked list is a non - continuous and non - sequential storage structure in physical storage units. The logical order of data elements is realized through the link order of pointers in the linked list. A linked list consists of a series of nodes (each element in the linked list is called a node), and nodes can be dynamically generated during runtime. Each node includes two parts: one is the data field for storing data elements, and the other is the pointer field for storing the address of the next node. Using the linked list structure can overcome the disadvantage that an array linked list needs to know the data size in advance. The linked list structure can make full use of the computer memory space to achieve flexible dynamic memory management. The most obvious advantage of a linked list is that the way of arranging related items in a conventional array may be different from the order of these data items in memory or on disk, and the access to data often needs to be converted among different arrangement orders. A linked list allows inserting and removing nodes at any position on the list, but does not allow random access. There are many different types of linked lists: singly - linked lists, doubly - linked lists, and circular linked lists. Linked lists can be implemented in many programming languages.
[0049] Among them, for ease of understanding, in one embodiment, as Figure 1 and Figure 4 shown, taking the newly generated pending update mapping relationships as a(LBA1, PPA1), b(LBA2, PPA2), c(LBA3, PPA3),... l(LBA12, PPA12) in sequence as an example, it can be known that each newly generated pending update mapping relationship (assuming the mapping relationship b in Figure 4 ) will first be sequentially added to the mapping relationship log. Further, according to LBA2 of the mapping relationship b, it is calculated that the mapping block it belongs to in the dirty mapping block table is Y, then the mapping relationship b is added to the linked list belonging to the mapping block number Y.
[0050] As the mapping relationships continue to be added, when adding the mapping relationship g(LBA7, PPA7), it will also first be added to the mapping relationship log. And according to its LBA7, it is calculated that the mapping block it belongs to is also Y. Therefore, the mapping relationship g will also be added to the mapping relationship linked list of the mapping block number Y.
[0051] By analogy, the mapping relationship i will also be added to the mapping relationship linked list of the mapping block number Y. Similarly, it can be obtained that the mapping relationships a, c, e, and j will be sequentially added to the mapping relationship linked lists of other mapping block numbers, while the mapping relationships d, f, h, k, and l will be sequentially added to the mapping relationship linked lists of yet another mapping block number, which will not be elaborated here.
[0052] In the above solution, by establishing a mapping relationship linked list in the dirty mapping block table of the cache area according to the mapping block number corresponding to each mapping relationship to be updated, it is possible to further classify and store multiple mapping relationships to be updated in the mapping relationship log according to the logical address of each mapping relationship to be updated. Thus, it is possible to more quickly search for the mapping relationships to be updated by category in the dirty mapping block table, and effectively reduce the number of times of accessing the mapping relationship log. Therefore, it is possible to effectively reduce the number of times of accessing the flash memory when obtaining user data from the flash memory of the storage device, and when updating the mapping table, the number of times of traversing the cache is also less, so that the corresponding storage device has a faster speed and faster update when querying data, and the random write performance of the storage device is thus better.
[0053] Further, in an embodiment, after S11 and before S12 (or before S11), it may specifically further include: constructing a dirty mapping block table with a set length including a hash table and an extension table in the cache area.
[0054] It can be understood that before calculating the mapping block number corresponding to each mapping relationship to be updated in the dirty mapping block table, it is necessary to first construct a dirty mapping block table with a set length in the cache area. Among them, the set length of the dirty mapping block table can be determined according to the number of mapping block numbers corresponding to the mapping relationships to be updated that may be generated under normal circumstances in the actual scenario, and this application does not limit this.
[0055] Among them, to facilitate subsequent indexing of the mapping relationships to be updated in the dirty mapping block table, so as to be able to address the dirty mapping block table in a hash manner, the dirty mapping block table specifically includes a hash table and an extension table that does not use the hash method.
[0056] Among them, the hash table (also called a hash table), is a data structure that directly accesses data according to the key value. That is to say, it accesses records by mapping the key value to a position in the table to speed up the search. This mapping function is called a hash function, and the array storing the records is called a hash table.
[0057] For example, given a table M, there exists a function f(key). For any given keyword value key, if the address of the record containing the keyword in the table can be obtained after substituting it into the function, then the table M is called a Hash table, and the function f(key) is called a Hash function.
[0058] Please refer to Figure 5 , Figure 5 which is a schematic flowchart of the second embodiment of the data management method of this application. The data management method of this embodiment is Figure 3 a schematic flowchart of a refined embodiment of the data management method in
[0059] S21: Write the mapping relationship to be updated into the mapping relationship log in the cache area.
[0060] S22: Based on the logical address of each mapping relationship to be updated in the mapping relationship log, obtain the mapping block number corresponding to each mapping relationship to be updated in the dirty mapping block table of the cache area.
[0061] Among them, S21 and S22 are the same as Figure 3 S11 and S12 in
[0062] S23: Based on the mapping block number and the length of the hash table, obtain the index number of each mapping relationship to be updated in the dirty mapping block table.
[0063] It can be understood that for the convenience of indexing the mapping relationships to be updated in the dirty mapping block table, after establishing a dirty mapping block table including a hash table in the cache area, the mapping block number corresponding to each mapping relationship to be updated in the dirty mapping block table can be obtained first based on the logical address of each mapping relationship to be updated in the mapping relationship log. And after obtaining the mapping block number, the index number of each mapping relationship to be updated in the dirty mapping block table can be further obtained based on the mapping block number and the length of the hash table, so that when querying a certain mapping relationship subsequently, the corresponding mapping block number and the corresponding mapping relationship linked list can be found according to the index number.
[0064] S24: Write each mapping relationship to be updated into the mapping relationship linked list corresponding to its mapping block number in turn. Among them, when the index number corresponding to the mapping relationship to be written currently is the same as that of the mapping relationship to be updated written previously, but the mapping block numbers are different, write the mapping block number corresponding to the mapping relationship to be written currently into the extension table.
[0065] It is understandable that, to avoid mapping the mapping relationships to be updated with different LBAs to the same index, based on the hash table, the dirty mapping block table further includes an extended table for storing the mapping relationships to be updated that have the same index but belong to different mapping block numbers. And the extended table does not use the hashing method but directly performs insertion and query.
[0066] Specifically, each mapping relationship to be updated in the mapping relationship log is sequentially written into the mapping relationship linked list corresponding to its mapping block number. And when the index number corresponding to the currently to-be-written mapping relationship to be updated is the same as that of the previously written mapping relationship to be updated, but the mapping block numbers are different, the mapping block number corresponding to the currently to-be-written mapping relationship to be updated needs to be directly written into the extended table to avoid the situation of unclear pointers when querying a certain mapping relationship later.
[0067] Optionally, as Figure 4 shown, to ensure a reasonable number of mapping relationship linked lists belonging to the hash table, the length M of the hash table is specifically a positive integer multiple of 4 of the length N of the extended table. For example, any reasonable multiple such as 4 times, 8 times, or 16 times, etc. This application does not make a limitation on this.
[0068] S25: Write the mapping relationship to be updated currently to be written into the mapping relationship linked list corresponding to its mapping block number in the extended table.
[0069] Further, after writing the mapping block number corresponding to the mapping relationship to be updated currently to be written into the extended table, it is then necessary to write the mapping relationship to be updated currently to be written into the mapping relationship linked list corresponding to its mapping block number in the extended table.
[0070] Further, in an embodiment, the above S22 may specifically further include: using a set function Y(=LBA>>10) to calculate the mapping block number corresponding to each mapping relationship to be updated in the dirty mapping block table.
[0071] Wherein, LBA represents each mapping relationship to be updated in the mapping relationship log, and Y is the mapping block number to which it belongs. Y(=LBA>>10) can be specifically understood as Y = LBA / 1024.
[0072] Further, in an embodiment, the above S23 may specifically further include: using a set function X(=Y%M) to calculate the index number of each mapping relationship to be updated in the dirty mapping block table.
[0073] Wherein, Y represents the calculated mapping block number, M is the length of the hash table, and X is the index number of each mapping relationship to be updated in the dirty mapping block table. X(=Y%M) can be specifically understood as X is the remainder of Y divided by M.
[0074] Similarly, for ease of understanding, in one embodiment, as Figure 1 and Figure 4 shown, taking the newly generated mapping relationships to be updated in sequence as a(LBA1, PPA1), b(LBA2, PPA2), c(LBA3, PPA3),... z(LBA26, PPA26) as an example, it can be known that each newly generated mapping relationship to be updated (assuming the mapping relationship b in Figure 4 ) will first be added to the mapping relationship log in sequence. Further, according to the LBA of the mapping relationship b, the mapping block number it belongs to in the dirty mapping block table is calculated as Y, and the index of the dirty mapping block table is calculated, assuming it is X. It is found that the corresponding position is empty, so it will occupy this position in the dirty mapping block table X and record the mapping block number as Y to add the mapping relationship b to the mapping relationship linked list belonging to this mapping block number Y.
[0075] As the mapping relationships continue to be added, when adding the mapping relationship g(LBA7, PPA7), it will also first be added to the mapping relationship log. And according to its LBA7, the mapping block number it belongs to is calculated as Y, and the index of the dirty mapping block table is calculated as X. It is found that this position has been allocated and is occupied by the mapping block number Y to which it belongs, so the mapping relationship g will also be added to the mapping relationship linked list of the mapping block number Y.
[0076] If a certain mapping relationship z is added to the mapping relationship log, and according to its LBA26, the index of this dirty mapping block is also calculated as X, but it belongs to the mapping block number Z. Since this position has been occupied by the mapping block number Y, it will find a position in the extended table part of the dirty mapping block to add it.
[0077] And so on, the mapping relationship i will also be added to the mapping relationship linked list of the mapping block number Y, and similarly, it can be obtained that the mapping relationships a, c, e, j will be added to the mapping relationship linked lists of another mapping block number in sequence, while the mapping relationships d, f, h, k, l will be added to the mapping relationship linked lists of yet another mapping block number in sequence, which will not be elaborated here.
[0078] Please refer to Figure 6 , Figure 6 which is the schematic flowchart of the third embodiment of the data management method of this application. The data management method of this embodiment is Figure 5 the schematic flowchart of a refined embodiment of the data management method in
[0079] S**31**: Write the mapping relationship to be updated into the mapping relationship log in the cache area.
[0080] S32: Obtain the mapping block number in the dirty mapping block table corresponding to each to-be-updated mapping relationship in the mapping relationship log based on the logical address of each to-be-updated mapping relationship.
[0081] S33: Based on the mapping block number and the length of the hash table, obtain the index number of each to-be-updated mapping relationship in the dirty mapping block table.
[0082] S34: Write each to-be-updated mapping relationship into the mapping relationship linked list corresponding to its mapping block number in sequence. Among them, when the index number corresponding to the currently to-be-written to-be-updated mapping relationship is the same as that of the previously written to-be-updated mapping relationship, but the mapping block numbers are different, write the mapping block number corresponding to the currently to-be-written to-be-updated mapping relationship into the extension table.
[0083] S35: Write the currently to-be-written to-be-updated mapping relationship into the mapping relationship linked list corresponding to its mapping block number in the extension table.
[0084] Among them, S31, S32, S33, S34, and S35 are the same as Figure 5 S21, S22, S23, S24, and S25 in, for specific details, please refer to S21, S22, S23, S24, and S25 and their related textual descriptions, which will not be elaborated here.
[0085] S36: Obtain the to-be-read logical address.
[0086] It is understandable that when the storage device reads a certain logical address through the dirty mapping block table, first obtain the corresponding to-be-read logical address.
[0087] S37: Based on the to-be-read logical address, obtain the read mapping block number and read index number corresponding to it in the dirty mapping block table.
[0088] Furthermore, based on the to-be-read logical address, for example, using the above functions Y(=LBA>>10) and X(=Y%M), calculate in sequence to obtain the read mapping block number and read index number corresponding to this to-be-read logical address in the dirty mapping block table.
[0089] S38: Determine whether the storage location corresponding to the read index number in the dirty mapping block table is empty.
[0090] It is understandable that each index number uniquely corresponds to a storage location in the dirty mapping block table, and this storage location is used to store the mapping block number to further establish the corresponding mapping relationship linked list.
[0091] After obtaining the read mapping block number and the read index number corresponding to the to-be-read logical address in the dirty mapping block table, it is further determined whether the storage location corresponding to the read index number in the dirty mapping block table is empty, that is, it is detected whether there is an index number corresponding to the to-be-updated mapping relationship that is the same as the read index number, and the mapping relationship linked list of the mapping block number pre-stored in this storage location.
[0092] Among them, if the storage location corresponding to the read index number in the dirty mapping block table is empty, then execute S39; if the storage location corresponding to the read index number in the dirty mapping block table is not empty, then execute S310.
[0093] S39: Determine that there is no to-be-updated mapping relationship corresponding to the to-be-read logical address in the mapping relationship log, and end the current read operation.
[0094] It can be understood that each to-be-updated mapping relationship in the mapping relationship log has been classified and stored in the mapping relationship linked list of the corresponding mapping block number in the dirty mapping block table according to its LBA. That is, when the storage location corresponding to the read index number in the dirty mapping block table is empty, it means that there is also no to-be-updated mapping relationship corresponding to the corresponding to-be-read logical address in the mapping relationship log, and the current read operation can be directly ended. In other embodiments, after determining that there is no to-be-updated mapping relationship corresponding to the to-be-read logical address in the mapping relationship log, the mapping table in the flash memory can also be loaded into the cache for further querying of the mapping table.
[0095] S310: Judge whether the read mapping block number is the same as the mapping block number currently stored in the storage location.
[0096] Among them, when it is determined that the storage location corresponding to the read index number in the dirty mapping block table is not empty, it means that a mapping block number and the corresponding mapping relationship linked list are stored at this storage location. Further, it is judged whether the read mapping block number is the same as the mapping block number currently stored in this storage location.
[0097] Among them, if the read mapping block number is the same as the mapping block number currently stored in this storage location, then execute S311; if the read mapping block number is not the same as the mapping block number currently stored in this storage location, then execute S312.
[0098] S311: Search whether there is a to-be-updated mapping relationship corresponding to the to-be-read logical address in the mapping relationship linked list corresponding to the read mapping block number.
[0099] It is understandable that each mapping block number in the dirty mapping block table uniquely corresponds to a mapping relationship linked list, and the logical block address (LBA) corresponding to each mapping relationship to be updated loaded into the mapping relationship linked list is the same. Therefore, when the corresponding read mapping block number is determined through the logical address to be read, it can be determined that there may be a mapping relationship to be updated that is the same as the logical address to be read in the mapping relationship linked list corresponding to the read mapping block number. Thus, it is possible to directly check whether there is a mapping relationship to be updated corresponding to the logical address to be read in the mapping relationship linked list corresponding to the read mapping block number, without having to address the mapping relationship linked lists of other mapping block numbers. That is, after obtaining the logical address to be read and calculating the read mapping block number through corresponding calculations, only one of the multiple mapping relationship linked lists established in advance according to the mapping block number needs to be queried, without having to query other mapping relationship linked lists, so as to effectively reduce the number of times of accessing the dirty mapping block table and the mapping relationship log.
[0100] S312: Check whether there is a mapping block number in the extended table that is the same as the read mapping block number.
[0101] Among them, when the read mapping block number is different from the mapping block number currently stored at this storage location, it is possible to further check whether there is a mapping block number in the extended table that is the same as the read mapping block number, so that when there is a mapping block number in the extended table that is the same as the read mapping block number, it is possible to check whether there is a mapping relationship to be updated corresponding to the logical address to be read in the mapping relationship linked list corresponding to the read mapping block number in the extended table.
[0102] Then it can be understood that when there is no mapping relationship to be updated corresponding to the logical address to be read in the mapping relationship linked list corresponding to the read mapping block number, and there is also no mapping relationship to be updated corresponding to the logical address to be read in the mapping relationship linked list corresponding to the read mapping block number in the extended table, it can be determined that there is no mapping relationship to be updated in the mapping relationship log that is the same as the corresponding logical address to be read, and the current read operation can be directly ended, or the mapping table in the flash memory can be loaded into the cache to further query the mapping table.
[0103] Among them, in one embodiment, for the convenience of understanding, assume that the mapping relationship to be read is LBA. Then it can be known that first, according to the LBA, the mapping block number to which it belongs can be calculated, assumed to be Y (= LBA >> 10), and the index number X of the dirty mapping block table can be calculated and obtained (X = Y % M).
[0104] Among them, if the position X in the dirty mapping block table is empty, it indicates that there is no mapping relationship for this LBA in the mapping relationship log, and no further operation is required; while if the storage position X in the dirty mapping block table is not empty and the mapping block number recorded at this storage position X is Y, then traverse the mapping relationship linked list of the mapping block number Y to find whether there is a mapping relationship for this LBA;
[0105] while if the mapping block number recorded at this position is not Y, then search in the extended table to see if there is a record of the mapping block number Y; among them, if there is in the extended table, then traverse the linked list corresponding to this mapping number to find the mapping relationship of this LBA; if there is no in the extended table, it means that there is no mapping relationship for this LBA in the mapping relationship log.
[0106] It can be seen from this that through the setting of the dirty mapping block table and the establishment of the mapping relationship linked list of the dirty mapping block table, when querying is needed, there is no need to search in the entire mapping relationship log, which makes the query simpler and faster, and thus can help improve the read and write performance of DRAM and DRAM-less storage devices.
[0107] Please refer to Figure 7 , Figure 7 which is the schematic flowchart of the fourth embodiment of the data management method of this application. The data management method of this embodiment is Figure 3 a schematic flowchart of a refined embodiment of the data management method in
[0108] S41: Write the mapping relationship to be updated into the mapping relationship log in the cache area.
[0109] S42: Based on the logical address of each mapping relationship to be updated in the mapping relationship log, obtain the mapping block number corresponding to each mapping relationship to be updated in the dirty mapping block table of the cache area.
[0110] S43: Write each mapping relationship to be updated into the mapping relationship linked list corresponding to its mapping block number in turn.
[0111] Among them, S41, S42 and S43 are the same as Figure 3 S11, S12 and S13 in
[0112] . For details, please refer to S11, S12 and S13 and their related textual descriptions, which will not be elaborated here.
[0113] Understandably, when it is necessary to update each mapping relationship to be updated in the mapping relationship log, each mapping block to be updated in the mapping table of the flash memory area can be found based on the mapping relationship linked list corresponding to each mapping block number, and only each corresponding mapping block to be updated is loaded into the cache area.
[0114] S45: Update the mapping block to be updated according to each mapping relationship to be updated in the mapping relationship linked list corresponding to the mapping block number of each mapping block to be updated, and write the updated mapping block to be updated into the mapping table.
[0115] Further, after each mapping block to be updated in the mapping table of the flash memory area is loaded into the cache area, each mapping block to be updated can be sequentially updated according to each mapping relationship to be updated in the mapping relationship linked list corresponding to the mapping block number of each mapping block to be updated, and the updated mapping block to be updated is written into the mapping table of the flash memory area.
[0116] It can be seen from this that compared with the solution with only the mapping relationship log, the method of setting the dirty mapping block table can quickly find out which mapping blocks need to be updated; and for a certain mapping block, it can quickly find out which mapping relationships need to be updated without traversing the entire mapping relationship log, thus greatly accelerating the update speed of the mapping table.
[0117] Please refer to Figure 8 , Figure 8 is a schematic framework diagram of an embodiment of the intelligent terminal of the present application. The intelligent terminal 51 includes a memory 511 and a processor 512 that are coupled to each other. The processor 512 is configured to execute program instructions stored in the memory 511 to implement the steps of any of the above data management method embodiments.
[0118] In a specific implementation scenario, the intelligent terminal 51 may include, but is not limited to, any reasonable terminal device including a flash-based storage device such as a solid-state drive, a mobile phone, a tablet computer, etc. The present application does not make any limitations in this regard.
[0119] Specifically, the processor 512 is used to control itself and the memory 511 to implement the steps of any of the above video display method embodiments. The processor 512 can also be referred to as a CPU (Central Processing Unit). The processor 512 may be an integrated circuit chip with signal processing capabilities. The processor 512 can also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. Additionally, the processor 512 can be implemented jointly by integrated circuit chips.
[0120] Please refer to Figure 9 , Figure 9 which is a schematic framework diagram of an embodiment of the computer-readable storage medium of the present application. The computer-readable storage medium 61 stores program instructions 611 that can be run by a processor, and the program instructions 611 are used to implement the steps of any of the above data management method embodiments.
[0121] In several embodiments provided in the present application, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of modules or units is only a logical function division. In actual implementation, there can be other division methods. For example, 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 displayed or discussed couplings or direct couplings or communication connections to each other can be through some interfaces. The indirect couplings or communication connections of the devices or units can be in electrical, mechanical, or other forms.
[0122] The units described as separate components may or may not be physically separated. The components shown as units may or may not be physical units, that is, they can be located in one place or distributed to network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0123] In addition, each functional unit in various embodiments of the present application may be integrated into one processing unit, may exist physically as individual units, or two or more units may be integrated into one unit. The above-mentioned integrated units may be implemented in the form of hardware or in the form of software functional units.
[0124] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it may be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, may be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor to execute all or part of the steps of the methods in various embodiments of the present application. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical discs that can store program codes.
Claims
1. A data management method for a storage device, characterized in that, The data management method includes: Writing the mapping relationship to be updated into the mapping relationship log in the cache area; Constructing a dirty mapping block table with a set length including a hash table and an extension table in the cache area; Based on the logical address of each mapping relationship to be updated in the mapping relationship log, obtaining the mapping block number corresponding to each mapping relationship to be updated in the dirty mapping block table of the cache area; Based on the mapping block number and the length of the hash table, obtaining the index number of each mapping relationship to be updated in the dirty mapping block table; Sequentially writing each mapping relationship to be updated into the mapping relationship linked list of its corresponding mapping block number. Wherein, when the index number corresponding to the currently to-be-written mapping relationship to be updated is the same as the index number corresponding to the previously written mapping relationship to be updated, but the mapping block numbers are different, writing the mapping block number corresponding to the currently to-be-written mapping relationship to be updated into the extension table; Writing the currently to-be-written mapping relationship to be updated into the mapping relationship linked list of its corresponding mapping block number in the extension table.
2. The data management method according to claim 1, characterized in that After writing the currently to-be-written mapping relationship to be updated into the mapping relationship linked list of its corresponding mapping block number in the extension table, it further includes: Obtaining the logical address to be read; Based on the logical address to be read, obtaining the read mapping block number and the read index number corresponding to it in the dirty mapping block table; Judging whether the storage position corresponding to the read index number in the dirty mapping block table is empty; If the storage position corresponding to the read index number in the dirty mapping block table is empty, determining that there is no mapping relationship to be updated corresponding to the logical address to be read in the mapping relationship log, and ending the current read operation.
3. The data management method according to claim 2, wherein: If the storage position corresponding to the read index number in the dirty mapping block table is not empty, judging whether the read mapping block number is the same as the mapping block number currently stored at the storage position; If the read mapping block number is the same as the mapping block number currently stored at the storage position, searching whether there is a mapping relationship to be updated corresponding to the logical address to be read in the mapping relationship linked list corresponding to the read mapping block number.
4. The data management method according to claim 3, wherein: If the read mapping block number is different from the mapping block number currently stored at the storage position, searching whether there is a mapping block number in the extension table that is the same as the read mapping block number; If there is a mapping block number in the extension table that is the same as the read mapping block number, searching whether there is a mapping relationship to be updated corresponding to the logical address to be read in the mapping relationship linked list corresponding to the read mapping block number in the extension table.
5. The data management method according to any one of claims 2-4, wherein: The length of the hash table is a positive integer multiple of 4 times the length of the extension table.
6. The data management method according to claim 1, wherein After writing the mapping relationship to be updated currently to the mapping relationship linked list of the corresponding mapping block number in the extension table, the following steps are further included: Based on the mapping relationship linked list of each mapping block number, each mapping block to be updated in the mapping table of the flash memory area is found, and each mapping block to be updated is loaded into the cache area; Each mapping block to be updated is updated according to each mapping relationship to be updated in the mapping relationship linked list of the mapping block number corresponding to each mapping block to be updated, and the updated mapping block to be updated is written into the mapping table.
7. An intelligent terminal, characterized in that, The intelligent terminal includes a memory and a processor which are coupled to each other; The memory stores program data; The processor is used to execute the program data to implement the data management method according to any one of claims 1-6.
8. A computer-readable storage medium having program instructions stored thereon, characterized in that, When the program instructions are executed by the processor, the data management method according to any one of claims 1-6 is implemented.
Citation Information
Patent Citations
Memory device and operating method of same
CN106055489A
Memory, control method thereof and storage system
CN112506814A