A method and device for mapping solid state hard disk addresses
By dynamically updating the address mapping table of the solid state drive, using the appropriate size of the mapping granularity according to the actual situation of the write request, and resetting it when the memory reaches the threshold, it solves the problem of poor flexibility of the solid state drive address mapping table and improves the read and write efficiency and performance.
Patent Information
- Application Number
- CN202110998016.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-27
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2041-08-27
AI Technical Summary
Due to the fixed and small mapping granularity of the existing solid-state drive address mapping table, the read and write efficiency is low, and the flexibility is poor, which affects performance when the mapping table size is larger than the memory capacity.
By obtaining the write request from the host side, the physical block address PBA is updated in the address mapping table based on the logical block address LBA and the current LBA interval mapping granularity, and when the memory reaches the threshold, it is determined whether to use different conditions according to the continuous situation of the PBA distribution. Range offset to reduce memory usage and even reset the address map table.
It improves the read and write efficiency and flexibility of solid-state drives, reduces the memory space occupied by address mapping tables, and significantly improves performance.
Smart Images

Figure CN113704140B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer storage, and in particular to a solid state hard disk address mapping method and device. Background Art
[0002] With the continuous improvement of flash memory (NAND) technology, the capacity of solid-state drives (SSDs) is also growing, and accordingly, the address mapping table of SSDs is also getting larger. The address mapping table of SSDs is used to maintain the mapping from logical block address (LBA) to physical block address (PBA).
[0003] In the prior art, the host sends the data to be written and the corresponding LBA to the SSD; the SSD searches for an idle flash memory physical block and a corresponding physical block address; further, the SSD writes the data sent by the host into the physical block and associates the LBA of the data with the PBA.
[0004] However, the address mapping table of the above SSD generally adopts a fixed and small mapping granularity, which has poor flexibility, and the read and write efficiency is low when the mapping table size is larger than the memory capacity. Summary of the invention
[0005] The present application provides a solid state drive address mapping method and device to solve the problem that the prior art adopts a fixed and small mapping granularity, has poor flexibility, and has low read and write efficiency when the mapping table size is larger than the memory capacity.
[0006] In a first aspect, the present application provides a solid-state hard disk address mapping method, the method comprising: obtaining a write request sent by a host, the write request carrying data to be written; after writing the data to be written into the solid-state hard disk, updating the physical block address PBA corresponding to the LBA contained in the write request in the address mapping table according to the logical block address LBA corresponding to the write request and the size of the current LBA interval mapping granularity; when the memory occupied by the address mapping table corresponding to a certain LBA interval reaches a corresponding threshold, determining whether the address mapping table of the LBA interval can use different range offsets to reduce memory occupancy according to the continuity of the PBA distribution in the address mapping table of the LBA interval, and if so, resetting the address mapping table corresponding to the LBA interval.
[0007] In one possible implementation, the PBA corresponding to the LBA included in the write request is updated in the address mapping table according to the LBA corresponding to the write request and the size of the current LBA interval mapping granularity, including: determining the LBA interval in the address mapping table corresponding to the LBA included in this write request and the mapping granularity corresponding to the LBA interval; for at least part of the LBAs of the mapping granularity that covers a complete number in the write request, directly updating the corresponding mapping table entries in the address mapping table according to the at least part of the LBAs; for the remaining LBAs in the write request, or when the LBA of the write request cannot completely cover the complete mapping granularity, using a finer mapping granularity to update the corresponding mapping table entries; after the address mapping table is updated, the statistical information of the corresponding LBA interval is updated according to the first address of the LBA of the write request; wherein the statistical information is used to represent the continuity of the PBA distribution in the LBA interval address mapping table.
[0008] In one possible implementation, each LBA interval in the address mapping table corresponds to a statistical information, which is a bit map, and each bit in the bit map corresponds to an LBA in the LBA interval; after the address mapping table is updated, the statistical information of the corresponding LBA interval is updated according to the starting address of the LBA of the write request, including: after the address mapping table is updated, it is determined whether the PBA corresponding to the starting address of the LBA of the write request and the PBA corresponding to the previous LBA of the starting address of the LBA are continuous; if they are continuous, there is no need to adjust the bit map, and if they are not continuous, the bit corresponding to the starting address of the LBA of the write request is set to "1".
[0009] In one possible implementation, when the memory occupied by the address mapping table corresponding to a certain LBA interval reaches a corresponding threshold, it is determined whether the address mapping table of the LBA interval can use a range offset to reduce the memory occupancy according to the continuity of the PBA distribution in the LBA interval mapping table. If so, the address mapping table corresponding to the LBA interval is reset, including: if the memory occupied by the address mapping table corresponding to a certain LBA interval reaches a corresponding threshold, then according to the position of "1" in the bit map corresponding to the LBA interval, the memory occupied when the initial mapping granularity is used is calculated under different range offsets; if the range offset corresponding to the address mapping table when the memory occupancy is minimum is the range offset currently being used by the LBA interval, the address mapping table corresponding to the LBA interval does not need to be changed; if the range offset corresponding to the address mapping table when the memory occupancy is minimum is not equal to the range offset currently being used by the LBA interval, the address mapping table of the LBA interval is reset using the range offset corresponding to the minimum memory occupancy and the initial mapping granularity.
[0010] In one possible implementation, the method further includes: obtaining a data read request for reading a solid state drive, the data read request carrying the LBA of the data to be read; querying the PBA corresponding to the LBA stored in the address mapping table; and reading the data to be read from the corresponding PBA.
[0011] In one possible implementation, the method also includes: dividing the address mapping table into several LBA intervals, initializing the mapping granularity and range offset of each LBA interval; during the operation stage of the solid-state hard disk, each LBA interval records the continuity of the PBA within the LBA interval through statistical information, and records the mapping granularity and range offset currently used by the LBA interval.
[0012] In the second aspect, the present application provides a solid-state hard disk address mapping device, including: an acquisition module, used to acquire a write request sent by a host end, the write request carrying data to be written; an update module, used to update the physical block address PBA corresponding to the LBA contained in the write request in the address mapping table after the data to be written is written to the solid-state hard disk, according to the logical block address LBA corresponding to the write request and the size of the current LBA interval mapping granularity; a determination and processing module, used to determine whether the address mapping table of a certain LBA interval can use different range offsets to reduce memory occupancy when the memory occupied by the address mapping table corresponding to the LBA interval reaches a corresponding threshold, according to the continuity of the PBA distribution in the address mapping table of the LBA interval, and if so, reset the address mapping table corresponding to the LBA interval.
[0013] In a third aspect, the present application provides an electronic device comprising: a processor, a memory, and a computer program; wherein the computer program is stored in the memory and is configured to be executed by the processor, and the computer program includes instructions for executing the solid-state hard drive address mapping method as described in any one of the first aspects.
[0014] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the solid-state hard disk address mapping method as described in any one of the first aspects.
[0015] In a fifth aspect, the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the solid-state hard disk address mapping method as described in any one of the first aspects.
[0016] In summary, the present application provides a method and device for address mapping of a solid-state hard disk, which can obtain a write request sent by a host, and the write request carries data to be written; further, after the data to be written is written to the solid-state hard disk, the physical block address PBA corresponding to the LBA contained in the write request can be updated in the address mapping table according to the logical block address LBA corresponding to the write request and the size of the current LBA interval mapping granularity; when the memory occupied by the address mapping table corresponding to a certain LBA interval reaches the corresponding threshold, according to the continuity of the PBA distribution in the address mapping table of the LBA interval, it is further determined whether the address mapping table of the LBA interval can use different range offsets to reduce the memory occupancy, and if so, the address mapping table corresponding to the LBA interval can be reset. In this way, a mapping granularity of appropriate size can be used according to the actual situation of the write request, thereby fully reducing the memory space occupied by the address mapping table, improving flexibility, and greatly improving performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0018] Figure 1 A schematic diagram of an application scenario of a solid state drive address mapping method provided in an embodiment of the present application;
[0019] Figure 2 A schematic diagram of a flow chart of a solid state drive address mapping method provided in an embodiment of the present application;
[0020] Figure 3 A schematic diagram of an address mapping table interval provided in an embodiment of the present application using two mapping granularities of 16KB and 4KB;
[0021] Figure 4 A schematic diagram of an address mapping table interval provided in an embodiment of the present application using a 32KB mapping granularity and an LBA range offset of 0;
[0022] Figure 5 A schematic diagram of an address mapping table interval provided in an embodiment of the present application using a 32KB mapping granularity and an LBA range offset of -1;
[0023] Figure 6 A schematic diagram of the structure of a solid state drive address mapping device provided in an embodiment of the present application;
[0024] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
[0025] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0026] In order to facilitate the clear description of the technical solutions of the embodiments of the present application, in the embodiments of the present application, the words "first", "second" and the like are used to distinguish the same items or similar items with substantially the same functions and effects. For example, the first device and the second device are only used to distinguish different devices, and their order is not limited. Those skilled in the art can understand that the words "first", "second" and the like do not limit the quantity and execution order, and the words "first", "second" and the like do not necessarily limit them to be different.
[0027] It should be noted that, in this application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in this application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.
[0028] In the present application, "at least one" means one or more, and "plurality" means two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can mean: a, b, c, ab, ac, bc, or abc, where a, b, c can be single or multiple.
[0029] The embodiments of the present application are introduced below with reference to the accompanying drawings. Figure 1 This is a schematic diagram of an application scenario of a solid state drive address mapping method provided in an embodiment of the present application. The solid state drive address mapping method provided in the present application can be applied to: Figure 1In the application scenario shown. The application scenario includes: user 101, terminal device 102 and host end 103 (the solid state drive end is located in the host end 103). In this application scenario, when user 101 needs to store a document, the terminal device 102 can perform related storage operations, and the terminal device 102 establishes a connection with the host end 103. Further, the host end 103 sends a write request to the solid state drive end. Correspondingly, the solid state drive end receives the write request and completes the data storage according to the write request.
[0030] If user 101 needs to view a document stored in the solid-state hard disk, he can perform relevant viewing operations on the terminal device 102, and the terminal device 102 establishes a connection with the host end 103. Further, the host end 103 sends a read request to the solid-state hard disk. Correspondingly, the solid-state hard disk receives the read request and completes the data reading according to the read request. In this way, user 101 can view the document content in the solid-state hard disk through the terminal device 102.
[0031] It is understandable that the terminal device may also be referred to as a terminal, user equipment (UE), mobile station (MS), mobile terminal (MT), etc. The terminal device may be a mobile phone, a smart TV, a wearable device, a smart speaker, a smart security device, a smart gateway, a tablet computer (Pad), a computer with a wireless transceiver function, a virtual reality (VR) terminal device, an augmented reality (AR) terminal device, a wireless terminal in industrial control, a wireless terminal in self-driving, a wireless terminal in remote medical surgery, a wireless terminal in smart grid, a wireless terminal in transportation safety, a wireless terminal in smart city, a wireless terminal in smart home, etc., and the embodiments of the present application do not specifically limit this.
[0032] In one possible implementation, the host sends the data to be written and the corresponding LBA to the SSD; the SSD searches for an idle flash memory physical block and the corresponding physical block address; further, the SSD writes the data sent by the host into the physical block and associates the LBA of the data with the PBA.
[0033] However, the mapping granularity of the address mapping table of the above SSD is generally fixed and small, such as 4KB. As the capacity of the SSD increases, the address mapping table space also increases linearly. If the address mapping table cannot be completely accommodated in the memory, the read and write efficiency will be reduced, thereby affecting the performance of the SSD.
[0034] Therefore, the embodiment of the present application provides a solid-state hard disk address mapping method, which can obtain a write request sent by the host end, and the write request carries the data to be written; further, after the data to be written is written to the solid-state hard disk, the physical block address PBA corresponding to the LBA contained in the write request can be updated in the address mapping table according to the logical block address LBA corresponding to the write request and the size of the current LBA interval mapping granularity; when the memory occupied by the address mapping table corresponding to a certain LBA interval reaches the corresponding threshold, according to the continuity of the PBA distribution in the address mapping table of the LBA interval, it is further determined whether the address mapping table of the LBA interval can use different range offsets to reduce the memory occupancy, and if so, the address mapping table corresponding to the LBA interval can be reset. In this way, the mapping granularity of appropriate size can be used according to the actual situation of the write request, thereby fully reducing the memory space occupied by the address mapping table, improving flexibility, and greatly improving performance.
[0035] For example, Figure 2 A flowchart of a solid state drive address mapping method provided in an embodiment of the present application is shown in FIG. Figure 2 As shown, the method of the embodiment of the present application includes:
[0036] S201. Obtain a write request sent by a host, wherein the write request carries data to be written.
[0037] For example, in Figure 1 In the application scenario, a write request sent by the host end 103 can be obtained, and the write request carries the data to be written.
[0038] S202. After writing the data to be written into the solid state drive, the physical block address PBA corresponding to the LBA included in the write request is updated in the address mapping table according to the logical block address LBA corresponding to the write request and the size of the current LBA interval mapping granularity.
[0039] In an embodiment of the present application, the logical block address LBA may also be called a relative address, which may refer to the sequential addressing of each target module with 0 as the base address when data is stored; the physical block address PBA may also be called an absolute address, which may refer to the sequential addressing of the addresses of each physical storage unit in the storage medium from a unified base address, which is the actual storage address of the data in the storage medium.
[0040] Among them, the address mapping table can refer to the basic unit of reading and writing. The address mapping is responsible for converting all LBAs issued by the file system into PBAs recognizable by NAND, and establishing a certain mapping relationship between LBA and PBA. The mapping relationship will be stored in the address mapping table for subsequent query and modification.
[0041] Exemplarily, after writing the data to be written to the solid-state hard disk, the solid-state hard disk can update the physical block address PBA corresponding to the LBA contained in the write request in the address mapping table according to the logical block address LBA corresponding to the write request and the size of the current LBA interval mapping granularity. For example, taking a larger mapping granularity of 16KB as an example, if the write request contains several complete and aligned 16KB, the mapping table entries corresponding to these 16KB are directly updated in the address mapping table, that is, the physical block address PBA corresponding to the LBA. If the write request contains an incomplete 16KB, a pointer is used to point to another small memory area, that is, the mapping table entry of the second layer, which is equivalent to the mapping table entry of the first layer being a complete 16KB. The mapping table entry of the second layer records the relevant mapping information with a mapping granularity of 4KB. The physical block address PBA corresponding to the LBA contained in the write request can be updated in the address mapping table according to the mapping table entries of the first layer and the mapping table entries of the second layer.
[0042] S203. When the memory occupied by the address mapping table corresponding to a certain LBA interval reaches the corresponding threshold, determine whether the address mapping table of the LBA interval can use different range offsets to reduce memory occupancy based on the continuity of PBA distribution in the address mapping table of the LBA interval. If so, reset the address mapping table corresponding to the LBA interval.
[0043] In an embodiment of the present application, the threshold may refer to a value used to determine whether the memory usage is too large. For example, the threshold may be 1KB or 2KB. The threshold may be a system-set threshold or a manually-set threshold. The embodiment of the present application does not limit the specific numerical value of the threshold.
[0044] Exemplarily, when the memory occupied by the address mapping table corresponding to a certain LBA interval reaches the corresponding threshold, i.e., 1KB, the memory occupancy under different range offsets can be calculated in turn according to the continuity of the PBA distribution in the address mapping table of the LBA interval. The same mapping granularity as that during initialization can be used, for example, a mapping granularity of 16KB and a range offset of 0 can be used to check whether the range offset at the minimum memory occupancy is equal to the range offset currently being used by the current LBA interval. If not, the address mapping table corresponding to the LBA interval can be reset using a new range offset.
[0045] It should be noted that the embodiment of the present application does not limit the specific numerical value of the range offset, which can be an integer, a negative number, or 0. The numerical value only expresses the number of range offsets.
[0046] Therefore, the solid-state hard disk address mapping method provided in the embodiment of the present application can use a mapping granularity of appropriate size according to the actual situation of the write request, thereby fully reducing the memory space occupied by the address mapping table, improving flexibility, and greatly improving performance.
[0047] For example, Figure 3 The address mapping table interval provided in the embodiment of the present application adopts two mapping granularities of 16KB and 4KB; Figure 3 As shown, the size of an LBA is 4KB (the same applies to the embodiments of the present application below), and the address mapping table interval adopts two mapping granularities of 16KB and 4KB. Because the write corresponding to LBA4 to LBA7 is a random write of 4KB, the LBA4~LBA7 range requires a mapping granularity of 4KB, wherein the portion of the mapping table corresponding to the 4KB mapping granularity can be indicated by the table entry corresponding to the 16KB mapping granularity, that is, the memory address of the portion of the mapping table corresponding to the 4KB mapping granularity can be saved in the table entry corresponding to the 16KB mapping granularity; in this way, the address mapping table can be updated using two mapping granularities within one interval to reduce the amount of memory occupied.
[0048] For example, Figure 4 The address mapping table interval provided in the embodiment of the present application adopts a 32KB mapping granularity and the LBA range offset is 0; Figure 4 As shown, the address mapping table interval uses two mapping granularities of 32KB and 8KB. Because the write corresponding to LBA8 to LBA15 is 8KB random write, the LBA8~LBA15 range requires an 8KB mapping granularity. At this time, the 32KB write request is aligned with the 32KB mapping granularity, such as LBA0~7, LBA16~23. After the 32KB mapping granularity is used in the address mapping interval, the LBA range offset is 0. In this way, two mapping granularities can be used in one interval and the LBA range offset is 0 to update the address mapping table, thereby reducing the amount of memory occupied.
[0049] For example, Figure 5 The address mapping table interval provided in the embodiment of the present application adopts a 32KB mapping granularity and an LBA range offset of -1; Figure 5As shown, if the LBA range corresponding to the write request is LBA0~LBA31, the address mapping table interval uses two mapping granularities of 32KB and 8KB. Because the write corresponding to LBA7 to LBA14 is a random write of 8KB, the LBA7~LBA14 range requires a mapping granularity of 8KB. At this time, if there is a write request of LBA-1~LBA6 before the write request, this write request spans two consecutive address mapping intervals. Therefore, in the interval of LBA0~LBA31, if the mapping granularity of 32KB is used, then this mapping is not aligned according to 32KB. The range of the write request falling into the mapping interval of LBA0~LBA31 is LBA0~LBA6. Therefore, it can be considered that the range offset is (7-8=-1), then the write request can be regarded as missing 1 LBA at the beginning. In this way, the address mapping table can be updated using two mapping granularities and an LBA range offset of -1 in this interval to reduce the amount of memory occupied.
[0050] It is understandable that the above situation may also occur in multiple intervals divided by the address mapping table, and each interval may correspond to mapping granularities of different sizes, which will not be described in detail in the embodiments of the present application.
[0051] Therefore, the address mapping table is updated according to the number of mapping granularities, the mapping granularity size and the range offset, and different range offsets can be used to reduce memory occupancy. There are many situations combined with different actual situations, which are highly flexible and greatly improve performance.
[0052] In one possible implementation, the PBA corresponding to the LBA included in the write request is updated in the address mapping table according to the LBA corresponding to the write request and the size of the current LBA interval mapping granularity, including: determining the LBA interval in the address mapping table corresponding to the LBA included in this write request and the mapping granularity corresponding to the LBA interval; for at least part of the LBAs of the mapping granularity that covers a complete number in the write request, directly updating the corresponding mapping table entries in the address mapping table according to the at least part of the LBAs; for the remaining LBAs in the write request, or when the LBA of the write request cannot completely cover the complete mapping granularity, using a finer mapping granularity to update the corresponding mapping table entries; after the address mapping table is updated, the statistical information of the corresponding LBA interval is updated according to the first address of the LBA of the write request; wherein the statistical information is used to represent the continuity of the PBA distribution in the LBA interval address mapping table.
[0053] In an embodiment of the present application, statistical information can be used to indicate the continuity of PBA distribution in an LBA interval address mapping table, and each address mapping table interval corresponds to one statistical information.
[0054] Exemplarily, the solid-state drive can determine the LBA interval in the address mapping table corresponding to the LBA included in the current write request and the mapping granularity corresponding to the LBA interval; for at least part of the LBAs of the mapping granularity that covers a complete number in the write request, directly update the corresponding mapping table entries in the address mapping table according to the at least part of the LBAs; for example, two write requests are received in the first LBA interval, corresponding to 4 to 7KB and 16 to 32KB, and the mapping granularity used in the LBA interval is 16KB, then at least part of the LBAs of the mapping granularity that covers a complete number in the second write request are 16 to 31KB, and further, the corresponding mapping table entries in the address mapping table are directly updated according to the PBA corresponding to the 16 to 31KB data.
[0055] Furthermore, if the LBA of the write request cannot completely cover the complete mapping granularity, i.e., 4 to 7KB, a finer mapping granularity, such as 4KB, can be used to update the corresponding mapping table entry; or, if there are remaining LBAs in the write request, such as the 32KB of data in the second write request mentioned above, a finer mapping granularity, such as 4KB, can be used to update the corresponding mapping table entry; after the address mapping table is updated, the statistical information of the corresponding LBA interval can be updated according to the starting address of the LBA of the write request. For example, if the starting address of the write request is LBA4, the statistical information of the corresponding LBA interval can be updated.
[0056] Therefore, the PBA corresponding to the LBA contained in the write request can be updated in the address mapping table according to the LBA corresponding to the write request in actual situation and the size of the current LBA interval mapping granularity. Different mapping granularities can be used within the LBA interval to improve flexibility and reduce memory usage.
[0057] In one possible implementation, each LBA interval in the address mapping table corresponds to a statistical information, which is a bit map, and each bit in the bit map corresponds to an LBA in the LBA interval; after the address mapping table is updated, the statistical information of the corresponding LBA interval is updated according to the starting address of the LBA of the write request, including: after the address mapping table is updated, it is determined whether the PBA corresponding to the starting address of the LBA of the write request and the PBA corresponding to the previous LBA of the starting address of the LBA are continuous; if they are continuous, there is no need to adjust the bit map, and if they are not continuous, the bit corresponding to the starting address of the LBA of the write request is set to "1".
[0058] In the embodiments of the present application, the bit map may also be referred to as a bit pattern, which may refer to a combination format of binary bits "0" and "1". If there are n bits, there are 2 to the power of n combinations, where a bit is a unit of measurement for the amount of information in the computer field, and the information contained in one bit of a binary number is 1 bit.
[0059] Exemplarily, taking a bitmap representing the LBA in the interval as an example, each LBA corresponds to a bit in a bitmap. After the address mapping table is updated, check whether the PBA corresponding to the LBA first address of the write request is continuous with the PBA corresponding to the previous LBA. If continuous, there is no need to adjust the bitmap. If not, the bit of the LBA interval bitmap corresponding to the LBA first address of the write request can be set to "1". For example, the bitmap 100010001000 after setting the bit corresponding to the first address of the LBA of the write request to "1", where 1000 represents a 16KB, the bitmap 100010001000 represents three discontinuous 16KB, but each 16KB is continuous inside; or the bitmap is 101000100000, which represents three data blocks of 8KB, 16KB and 24KB. The data blocks are discontinuous, but each data block is continuous inside.
[0060] In this way, after the address mapping table is updated, the continuity of the PBA in the LBA interval can be determined from the position of "1" in the bit map, thereby increasing the speed and accuracy of identifying continuity and greatly improving performance.
[0061] In one possible implementation, when the memory occupied by the address mapping table corresponding to a certain LBA interval reaches a corresponding threshold, it is determined whether the address mapping table of the LBA interval can use a range offset to reduce the memory occupancy according to the continuity of the PBA distribution in the LBA interval mapping table. If so, the address mapping table corresponding to the LBA interval is reset, including: if the memory occupied by the address mapping table corresponding to a certain LBA interval reaches a corresponding threshold, then according to the position of "1" in the bit map corresponding to the LBA interval, the memory occupied when the initial mapping granularity is used is calculated under different range offsets; if the range offset corresponding to the address mapping table when the memory occupancy is minimum is the range offset currently being used by the LBA interval, the address mapping table corresponding to the LBA interval does not need to be changed; if the range offset corresponding to the address mapping table when the memory occupancy is minimum is not equal to the range offset currently being used by the LBA interval, the address mapping table of the LBA interval is reset using the range offset corresponding to the minimum memory occupancy and the initial mapping granularity.
[0062] For example, if the memory occupied by the address mapping table corresponding to a certain LBA interval reaches a corresponding threshold, such as 1KB, the memory occupied when the initial mapping granularity is used under different range offsets can be calculated according to the position of "1" in the bit map corresponding to the LBA interval. Taking a bit map of 10100010001000100010 as an example, the initial mapping granularity is 16KB, and the range offset is 0, then each mapping table entry needs to point to another memory area with a mapping granularity of 4KB. For example, 1010 represents a 16KB, and in the mapping table entry In the corresponding 16KB range, the PBA is not completely continuous, because in the 16KB range corresponding to each mapping table entry in the bitmap, the PBA is not completely continuous; it is necessary to modify the address mapping table corresponding to the LBA interval. By calculating that when the range offset is 2, the middle 4 mapping table entries can still use the mapping granularity of 16KB, and only the two table entries at the beginning need to point to the memory area of 4KB mapping granularity. Therefore, when the range offset is 2, the memory occupied is less than when the range offset is 0. Therefore, the address mapping table of the LBA interval is reset using the range offset 2 corresponding to the minimum memory occupancy.
[0063] Therefore, when the memory occupied by the address mapping table corresponding to a certain LBA interval reaches the corresponding threshold, it can be determined whether the LBA interval address mapping table can use range offset to reduce memory occupancy, and further reset the address mapping table corresponding to the LBA interval to reduce memory occupancy and improve the performance of the solid-state drive.
[0064] In one possible implementation, a data read request for reading a solid state drive is obtained, the data read request carrying the LBA of the data to be read; a PBA corresponding to the LBA stored in the address mapping table is queried; and the data to be read is read from the corresponding PBA.
[0065] Exemplarily, when the file system needs to perform a read operation on a specified logical block address, it needs to generate a data read request for reading the solid-state drive, and the data read request carries the LBA of the data to be read; further, the corresponding mapping relationship is queried in the address mapping table, and the PBA corresponding to the NAND is found according to the mapping relationship, and then the data to be read is read from the corresponding PBA.
[0066] In this way, when reading the data to be read in the solid-state drive, the mapping relationship between LBA and PBA can be queried in the address mapping table. If the address mapping table uses a larger mapping granularity, the PBA corresponding to all LBAs can be restored through the continuity of LBA and PBA, thereby saving memory.
[0067] In one possible implementation, the address mapping table is divided into several LBA intervals, and the mapping granularity and range offset of each LBA interval are initialized; during the operation stage of the solid-state hard disk, each LBA interval records the continuity of the PBA within the LBA interval through statistical information, and records the mapping granularity and range offset currently used by the LBA interval.
[0068] In the embodiments of the present application, initialization may refer to the practice of assigning initial values to data objects or variables.
[0069] Exemplarily, the address mapping table can be divided into several LBA intervals, each LBA interval is initialized to a larger mapping granularity, and the initialization range offset is 0. If the previous existing mapping granularity is 4KB, each LBA interval can be initialized to a mapping granularity of 16KB or 32KB. The embodiment of the present application does not specifically limit the size of the initialization to a larger mapping granularity, but the size of the initialized mapping granularity is relatively larger than the previous one.
[0070] Furthermore, during the operation stage of the solid-state hard disk, each LBA interval records the continuity of the PBA within the LBA interval through statistical information, and can record the mapping granularity and range offset currently used by the LBA interval, and can update the information in the statistical information in real time. For example, during the operation stage, there is random write in a certain LBA interval, and the mapping granularity used is 16KB and 4KB and the range offset is 2, then the above information can be recorded in the statistical information.
[0071] It can be understood that the specific circumstances of the mapping granularity and range offset of the SSD initialization can be set in advance by the system or preset manually, and the embodiments of the present application do not make specific limitations on this. The specific circumstances of updating statistical information of the SSD can be changed according to actual conditions, and the embodiments of the present application do not make specific limitations on this. The above is only an example.
[0072] Therefore, the solid-state drive can divide the address mapping table into several intervals, and the mapping granularity and range offset of each LBA interval in the address mapping table can be updated in real time, which can not only reduce memory usage but also improve flexibility and storage performance.
[0073] In the above embodiments, the solid-state hard disk address mapping method provided by the embodiments of the present application is introduced. In order to realize the functions in the method provided by the embodiments of the present application, the electronic device as the execution subject may include a hardware structure and / or a software module, and the above functions are realized in the form of a hardware structure, a software module, or a hardware structure plus a software module. Whether one of the above functions is executed in the form of a hardware structure, a software module, or a hardware structure plus a software module depends on the specific application and design constraints of the technical solution.
[0074] For example, Figure 6 A structural diagram of a solid state hard disk address mapping device provided in an embodiment of the present application is shown in FIG. Figure 6 As shown, the device comprises:
[0075] An acquisition module 610 is used to acquire a write request sent by a host, wherein the write request carries data to be written; an update module 620 is used to update, in the address mapping table, the physical block address PBA corresponding to the LBA contained in the write request, according to the logical block address LBA corresponding to the write request and the size of the current LBA interval mapping granularity after the data to be written is written into the solid-state hard disk; a determination and processing module 630 is used to determine, when the memory occupied by the address mapping table corresponding to a certain LBA interval reaches a corresponding threshold, whether the address mapping table of the LBA interval can use different range offsets to reduce the memory occupancy, according to the continuity of the PBA distribution in the address mapping table of the LBA interval, and if so, reset the address mapping table corresponding to the LBA interval.
[0076] In one possible implementation, the update module 620 is specifically used to determine the LBA interval in the address mapping table corresponding to the LBA included in this write request and the mapping granularity corresponding to the LBA interval; for at least part of the LBAs that cover a complete number of mapping granularities in the write request, directly update the corresponding mapping table entries in the address mapping table based on the at least part of the LBAs; for the remaining LBAs in the write request, or when the LBAs of the write request cannot completely cover the complete mapping granularity, use a finer mapping granularity to update the corresponding mapping table entries; after the address mapping table is updated, the statistical information of the corresponding LBA interval is updated according to the first address of the LBA of the write request; wherein the statistical information is used to represent the continuity of the PBA distribution in the LBA interval address mapping table.
[0077] In one possible implementation, each LBA interval in the address mapping table corresponds to a statistical information, which is a bit map, and each bit in the bit map corresponds to an LBA in the LBA interval; the update module 620 is specifically used to determine whether the PBA corresponding to the first address of the LBA of the write request and the PBA corresponding to the previous LBA of the first address of the LBA are continuous after the address mapping table is updated; if they are continuous, there is no need to adjust the bit map; if they are not continuous, the bit corresponding to the first address of the LBA of the write request is set to "1".
[0078] In one possible implementation, the determination and processing module 630 is specifically used to, if the memory occupied by the address mapping table corresponding to a certain LBA interval reaches a corresponding threshold, then according to the position of "1" in the bit map corresponding to the LBA interval, calculate the memory occupied when using the initial mapping granularity under different range offsets; if the range offset corresponding to the address mapping table when the memory occupancy is minimum is the range offset currently being used by the LBA interval, then the address mapping table corresponding to the LBA interval does not need to be changed; if the range offset corresponding to the address mapping table when the memory occupancy is minimum is not equal to the range offset currently being used by the LBA interval, then the address mapping table of the LBA interval is reset using the range offset corresponding to the minimum memory occupancy and the initial mapping granularity.
[0079] In one possible implementation, the acquisition module 610 is also used to obtain a data read request for reading a solid state drive, wherein the data read request carries the LBA of the data to be read; the determination and processing module 630 is also used to query the PBA corresponding to the LBA stored in the address mapping table; and read the data to be read from the corresponding PBA.
[0080] In one possible implementation, the determination and processing module 630 is also used to divide the address mapping table into several LBA intervals and initialize the mapping granularity and range offset of each LBA interval; during the operation stage of the solid-state hard disk, each LBA interval records the continuity of the PBA within the LBA interval through statistical information, and records the mapping granularity and range offset currently used by the LBA interval.
[0081] The present application also provides a schematic diagram of the structure of an electronic device. Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown in FIG. Figure 7 As shown, the electronic device may include: a memory 701 and a processor 702; the memory 701 stores a computer program; the processor 702 executes the computer program stored in the memory 701, so that the processor 702 executes the method described in any of the above embodiments.
[0082] The memory 701 and the processor 702 may be connected via a bus 703 .
[0083] The specific implementation principle and effect of the solid-state hard disk address mapping device provided in the embodiment of the present application can be found in the relevant description and effects corresponding to the above embodiment, and will not be elaborated here.
[0084] An embodiment of the present application also provides a computer-readable storage medium, which stores computer program execution instructions. When the computer execution instructions are executed by a processor, they are used to implement a solid-state hard disk address mapping method as described in any of the aforementioned embodiments of the present application.
[0085] An embodiment of the present application also provides a chip for executing instructions, which is used to execute the solid-state hard disk address mapping method executed by an electronic device in any of the aforementioned embodiments of the present application.
[0086] An embodiment of the present application also provides a computer program product, which includes a computer program. When the computer program is executed by a processor, it can implement a solid-state hard disk address mapping method performed by an electronic device in any of the aforementioned embodiments of the present application.
[0087] In the several embodiments provided in the present application, 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 modules is only a logical function division. There may be other division methods in actual implementation, such as multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or modules, which can be electrical, mechanical or other forms.
[0088] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to implement the solution of this embodiment.
[0089] In addition, each functional module in each embodiment of the present application can be integrated into one processing unit, or each module can exist physically separately, or two or more modules can be integrated into one unit. The above-mentioned module-composed unit can be implemented in the form of hardware or in the form of hardware plus software functional units.
[0090] The above-mentioned integrated module implemented in the form of a software function module can be stored in a computer-readable storage medium. The above-mentioned software function module is stored in a storage medium, including a number of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to perform some steps of the method described in each embodiment of the present application.
[0091] It should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or the processor may be any conventional processor, etc. The steps of the method disclosed in the application may be directly implemented as being executed by a hardware processor, or may be implemented by a combination of hardware and software modules in the processor.
[0092] The memory may include high-speed random access memory (RAM), and may also include non-volatile memory (NVM), such as at least one disk memory, and may also be a USB flash drive, a mobile hard disk, a read-only memory, a disk or an optical disk, etc.
[0093] The bus can be an industry standard architecture (ISA) bus, a peripheral component interconnect (PCI) bus, or an extended industry standard architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of this application is not limited to only one bus or one type of bus.
[0094] The above storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The storage medium can be any available medium that can be accessed by a general or special purpose computer.
[0095] An exemplary storage medium is coupled to a processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an application specific integrated circuit (ASIC). Of course, the processor and the storage medium can also exist as discrete components in an electronic device or a main control device.
[0096] The above is only a specific implementation of the embodiment of the present application, but the protection scope of the embodiment of the present application is not limited thereto, and any changes or replacements within the technical scope disclosed in the embodiment of the present application should be included in the protection scope of the embodiment of the present application. Therefore, the protection scope of the embodiment of the present application should be based on the protection scope of the claims.
Claims
1. A solid state hard disk address mapping method, characterized in that: include: Obtaining a write request sent by the host, wherein the write request carries data to be written; After the data to be written is written into the solid state hard disk, the physical block address PBA corresponding to the LBA included in the write request is updated in the address mapping table according to the logical block address LBA corresponding to the write request and the size of the current LBA interval mapping granularity; When the memory occupied by the address mapping table corresponding to a certain LBA interval reaches a corresponding threshold, determine whether the address mapping table of the LBA interval can use different range offsets to reduce the memory occupation according to the continuity of the PBA distribution in the address mapping table of the LBA interval, and if so, reset the address mapping table corresponding to the LBA interval; According to the LBA corresponding to the write request and the size of the current LBA interval mapping granularity, updating the PBA corresponding to the LBA included in the write request in the address mapping table includes: Determine the LBA interval in the address mapping table corresponding to the LBA included in this write request and the mapping granularity corresponding to the LBA interval; For at least part of the LBAs of the mapping granularity that covers a complete number in the write request, directly update the corresponding mapping table entries in the address mapping table according to the at least part of the LBAs; for the remaining LBAs in the write request, or when the LBAs of the write request cannot completely cover the complete mapping granularity, use a finer mapping granularity to update the corresponding mapping table entries; After the address mapping table is updated, the statistical information of the corresponding LBA interval is updated according to the first address of the LBA of the write request; wherein the statistical information is used to indicate the continuity of the PBA distribution in the LBA interval address mapping table; Each LBA interval in the address mapping table corresponds to a piece of statistical information, and the statistical information is a bit map, and each bit in the bit map corresponds to an LBA in the LBA interval; after the address mapping table is updated, the statistical information of the corresponding LBA interval is updated according to the first address of the LBA of the write request, including: After the address mapping table is updated, determine whether the PBA corresponding to the first address of the LBA of the write request and the PBA corresponding to the previous LBA of the first address of the LBA are continuous; if they are continuous, there is no need to adjust the bit map; if they are not continuous, set the bit corresponding to the first address of the LBA of the write request to "1"; When the memory occupied by the address mapping table corresponding to a certain LBA interval reaches a corresponding threshold, according to the continuity of the PBA distribution in the address mapping table of the LBA interval, it is determined whether the address mapping table of the LBA interval can use different range offsets to reduce the memory occupation, and if so, the address mapping table corresponding to the LBA interval is reset, including: If the memory occupied by the address mapping table corresponding to a certain LBA interval reaches a corresponding threshold, the memory occupied when the initial mapping granularity is used is calculated respectively under different range offsets according to the position of "1" in the bitmap corresponding to the LBA interval; If the range offset corresponding to the address mapping table when the memory occupancy is minimum is the range offset currently used by the LBA interval, then the address mapping table corresponding to the LBA interval does not need to be changed; if the range offset corresponding to the address mapping table when the memory occupancy is minimum is not equal to the range offset currently used by the LBA interval, then the range offset corresponding to the minimum memory occupancy and the initial mapping granularity are used to reset the address mapping table for the LBA interval.
2. The method according to claim 1, characterized in that Also includes: Obtaining a data read request for reading a solid state drive, wherein the data read request carries an LBA of data to be read; Query the PBA corresponding to the LBA stored in the address mapping table; The to-be-read data is read from the corresponding PBA.
3. The method according to claim 1, characterized in that Also includes: Divide the address mapping table into several LBA intervals, and initialize the mapping granularity and range offset of each LBA interval; During the operation phase of the solid-state drive, each LBA interval records the continuity of the PBA in the LBA interval through statistical information, and records the mapping granularity and range offset currently used by the LBA interval.
4. A solid state hard disk address mapping device, characterized in that: include: An acquisition module, used for acquiring a write request sent by a host end, wherein the write request carries data to be written; An update module, configured to update the physical block address PBA corresponding to the LBA included in the write request in the address mapping table according to the logical block address LBA corresponding to the write request and the size of the current LBA interval mapping granularity after the data to be written is written into the solid state hard disk; A determination and processing module, used to determine whether the address mapping table of a certain LBA interval can use different range offsets to reduce the memory occupation when the memory occupied by the address mapping table corresponding to a certain LBA interval reaches a corresponding threshold, according to the continuity of the PBA distribution in the address mapping table of the LBA interval, and if so, reset the address mapping table corresponding to the LBA interval; The update module is specifically used to determine the LBA interval in the address mapping table corresponding to the LBA included in this write request and the mapping granularity corresponding to the LBA interval; for at least part of the LBAs of the mapping granularity covering a complete number in the write request, directly update the corresponding mapping table entries in the address mapping table according to the at least part of the LBAs; for the remaining LBAs in the write request, or when the LBA of the write request cannot completely cover the complete mapping granularity, use a finer mapping granularity to update the corresponding mapping table entries; after the address mapping table is updated, according to the first address of the LBA of the write request, update the statistical information of the corresponding LBA interval; wherein the statistical information is used to indicate the continuity of the PBA distribution in the LBA interval address mapping table; Each LBA interval in the address mapping table corresponds to a piece of statistical information, and the statistical information is a bit map, and each bit in the bit map corresponds to an LBA in the LBA interval; the update module is specifically used to determine whether the PBA corresponding to the first address of the LBA of the write request and the PBA corresponding to the previous LBA of the first address of the LBA are continuous after the address mapping table is updated; if they are continuous, there is no need to adjust the bit map, and if they are not continuous, the bit corresponding to the first address of the LBA of the write request is set to "1"; The determination and processing module is specifically used to calculate the memory occupied when using the initial mapping granularity under different range offsets according to the position of "1" in the bit map corresponding to the LBA interval if the memory occupied by the address mapping table corresponding to a certain LBA interval reaches a corresponding threshold; if the range offset corresponding to the address mapping table when the memory occupancy is minimum is the range offset currently being used by the LBA interval, the address mapping table corresponding to the LBA interval does not need to be changed; if the range offset corresponding to the address mapping table when the memory occupancy is minimum is not equal to the range offset currently being used by the LBA interval, the range offset corresponding to the minimum memory occupancy and the initial mapping granularity are used to reset the address mapping table of the LBA interval.
5. An electronic device, characterized in that: include: A processor, a memory and a computer program; wherein the computer program is stored in the memory and is configured to be executed by the processor, and the computer program includes instructions for executing the solid-state hard disk address mapping method as described in any one of claims 1-3.
6. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the solid-state hard disk address mapping method as described in any one of claims 1 to 3.
7. A computer program product, characterized in that It comprises a computer program, which, when executed by a processor, implements the solid state hard disk address mapping method described in any one of claims 1 to 3.
