A method and related equipment for creating an effective data bitmap
By periodically traversing the logical-physical mapping table, memory space is dynamically allocated for superblocks containing valid data and bitmaps are recorded, solving the problem of low memory space utilization of solid-state drives and achieving more efficient memory space utilization and data reclamation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-10
- Publication Date
- 2026-03-06
AI Technical Summary
Solid-state drives (SSDs) have low memory utilization because they pre-allocate memory space for each superblock instead of storing valid data in each superblock, resulting in unnecessary storage resource consumption.
The logical-physical mapping table is periodically traversed to determine the physical address of valid data. Memory space is allocated only for the superblock containing valid data, and a valid data bitmap is recorded and dynamically built.
It improves the memory space utilization of solid-state drives and the flexibility of building effective data bitmaps, avoids superblocks that do not contain effective data occupying memory space, and improves data recycling efficiency.
Smart Images

Figure CN115291805B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method and related equipment for creating an effective data bitmap. Background Technology
[0002] With the continuous development of technology, more and more devices are using solid-state drives (SSDs) to provide storage services. SSDs can improve storage space utilization by creating effective data bitmaps to reclaim data.
[0003] In related technologies, the method for establishing an effective data bitmap is to pre-allocate a memory space for each superblock stored in the solid-state drive. When effective data is stored in multiple data blocks associated with the superblock, the storage location of the effective data can be recorded in the corresponding content space to obtain the corresponding effective data bitmap.
[0004] However, the storage resources of a device are limited. When a large number of superblocks are stored in the solid-state drive, the device needs to allocate a significant amount of memory space in advance. However, not all data blocks associated with each superblock contain valid data, resulting in a large amount of storage resources being unnecessarily occupied and low memory space utilization.
[0005] It is evident that among related technologies, solid-state drives (SSDs) have relatively low memory space utilization. Summary of the Invention
[0006] This application provides a method, apparatus, computer device, and storage medium for establishing an effective data bitmap, which addresses the problem of low memory space utilization in solid-state drives.
[0007] Firstly, a method for establishing a valid data bitmap is provided, applied to a solid-state drive (SSD), wherein the SSD stores multiple superblocks and multiple data blocks associated with each superblock, each superblock stores metadata of the associated multiple data blocks, and each data block stores valid data, including:
[0008] Periodically, within a preset time period, traverse the logical-physical mapping table and determine the physical address of each valid data item in turn; after determining the physical address of each valid data item, perform the following operations:
[0009] Obtain the bitmap identifier of the target superblock that matches the physical address of the valid data, wherein the bitmap identifier is used to characterize whether the target superblock is associated with a valid data bitmap and the establishment status of the valid data bitmap;
[0010] When it is determined that the bitmap identifier represents that no valid data bitmap is associated with it, a corresponding memory space is allocated to the target superblock, and the storage location of the valid data in the target superblock is recorded in the memory space in the format of a valid data bitmap.
[0011] The bitmap identifier is updated to indicate that the target superblock has been associated with a valid data bitmap, and the establishment status is incomplete. This continues until the logical-physical mapping table is traversed, at which point the bitmap identifier is updated to indicate that the target superblock has been associated with a valid data bitmap, and the establishment status is completed.
[0012] Optionally, before periodically traversing the logical-physical mapping table and sequentially determining the physical address of each valid data point within a preset time period, the method further includes:
[0013] The solid-state drive is powered on;
[0014] The bitmap identifiers of the multiple superblocks are initialized to indicate that the corresponding superblock is not associated with a valid data bitmap.
[0015] Optionally, after obtaining the bitmap identifier of the target superblock that matches the physical address of the valid data, the method further includes:
[0016] When the bitmap identifier represents the valid data bitmap associated with the setting, and the establishment status is incomplete, the physical address of the memory space allocated for the valid data bitmap associated with the target superblock is determined based on the logical-physical mapping table.
[0017] Based on the physical address of the memory space, the storage location of the valid data in the target superblock is recorded in the memory space in the format of a valid data bitmap.
[0018] Optionally, after recording the storage location of the valid data in the target superblock within the memory space, the method further includes:
[0019] When it is determined that the traversal of the logical-physical mapping table is complete, the bitmap identifier is updated to indicate that the target superblock has been associated with a valid data bitmap, and the establishment status is completed.
[0020] Optionally, after updating the bitmap identifier to indicate that the target superblock has been associated with a valid data bitmap and the establishment status is incomplete, the method further includes:
[0021] When it is determined that multiple target data blocks associated with the target superblock do not contain valid data, the bitmap identifier of the target superblock is obtained;
[0022] When it is determined that the bitmap identifier indicates that the target superblock has been associated with a valid data bitmap, the memory space allocated to the target superblock will be released;
[0023] Update the bitmap identifier to indicate that the target superblock is not associated with a valid data bitmap.
[0024] Optionally, after updating the bitmap identifier to indicate that the target superblock has been associated with a valid data bitmap and the establishment status is completed, the method further includes:
[0025] Upon receiving a data reclamation instruction for the target superblock, obtain the bitmap identifier of the target superblock;
[0026] When the bitmap identifier indicates that the target superblock has been associated with a valid data bitmap and the establishment status is established, the storage location of the valid data contained in the multiple target data blocks associated with the target superblock is determined based on the valid data bitmap of the target superblock.
[0027] Based on the storage location of the obtained valid data, data reclamation is performed on the target superblock.
[0028] Secondly, an apparatus for establishing a valid data bitmap is provided, applied to a solid-state drive (SSD), wherein the SSD is used to store multiple superblocks and multiple data blocks associated with each superblock, each superblock is used to store metadata of the associated multiple data blocks, and each data block is used to store valid data, including:
[0029] Acquisition module: Used to periodically traverse the logical-physical mapping table within a preset time period and determine the physical address of each valid data in turn;
[0030] For each valid data physical address determined, perform the following operations:
[0031] The acquisition module is further configured to: acquire the bitmap identifier of the target superblock that matches the physical address of the valid data, wherein the bitmap identifier is used to characterize whether the target superblock is associated with a valid data bitmap and the establishment status of the valid data bitmap;
[0032] Processing module: When the bitmap identifier represents that no valid data bitmap is associated with it, it allocates corresponding memory space for the target superblock and records the storage location of the valid data in the target superblock in the memory space in the recording format of the valid data bitmap;
[0033] The processing module is further configured to: update the bitmap identifier to indicate that the target superblock has been associated with a valid data bitmap and the establishment status is incomplete, until the logical physical mapping table is traversed, update the bitmap identifier to indicate that the target superblock has been associated with a valid data bitmap and the establishment status is completed.
[0034] Optionally, the processing module is further configured to:
[0035] Before periodically traversing the logical-physical mapping table and sequentially determining the physical address of each valid data within the preset time period, the solid-state drive is powered on.
[0036] The bitmap identifiers of the multiple superblocks are initialized to indicate that the corresponding superblock is not associated with a valid data bitmap.
[0037] Optionally, the processing module is further configured to:
[0038] After obtaining the bitmap identifier of the target superblock that matches the physical address of the valid data, and determining that the bitmap identifier represents the associated valid data bitmap, and when the establishment status is incomplete, the physical address of the memory space allocated for the associated valid data bitmap of the target superblock is determined based on the logical physical mapping table.
[0039] Based on the physical address of the memory space, the storage location of the valid data in the target superblock is recorded in the memory space in the format of a valid data bitmap.
[0040] Optionally, the processing module is further configured to:
[0041] After recording the storage location of the valid data in the target superblock in the memory space, when it is determined that the traversal of the logical-physical mapping table is complete, the bitmap identifier is updated to indicate that the target superblock has been associated with a valid data bitmap, and the establishment status is completed.
[0042] Optionally, the processing module is further configured to:
[0043] After the bitmap identifier is updated to indicate that the target superblock has been associated with a valid data bitmap and the establishment status is incomplete, when it is determined that the multiple target data blocks associated with the target superblock do not contain valid data, the bitmap identifier of the target superblock is obtained.
[0044] When it is determined that the bitmap identifier indicates that the target superblock has been associated with a valid data bitmap, the memory space allocated to the target superblock will be released;
[0045] Update the bitmap identifier to indicate that the target superblock is not associated with a valid data bitmap.
[0046] Optionally, the processing module is further configured to:
[0047] After updating the bitmap identifier to indicate that the target superblock has been associated with a valid data bitmap and the establishment status is completed, the bitmap identifier of the target superblock is obtained after receiving a data reclamation instruction for the target superblock.
[0048] When the bitmap identifier indicates that the target superblock has been associated with a valid data bitmap and the establishment status is established, the storage location of the valid data contained in the multiple target data blocks associated with the target superblock is determined based on the valid data bitmap of the target superblock.
[0049] Based on the storage location of the obtained valid data, data reclamation is performed on the target superblock.
[0050] Thirdly, a computer program product is provided, including a computer program that, when executed by a processor, implements the method described in the first aspect.
[0051] Fourthly, a computer device is provided, comprising:
[0052] Memory, used to store program instructions;
[0053] A processor is configured to invoke program instructions stored in the memory and execute the method described in the first aspect according to the obtained program instructions.
[0054] Fifthly, a computer-readable storage medium is provided, the computer-readable storage medium storing computer-executable instructions for causing a computer to perform the method as described in the first aspect.
[0055] In this embodiment, the logical-physical mapping table is traversed periodically within a preset time period to determine the physical address of each valid data in turn. During the traversal process, the valid data bitmap of each superblock is established, realizing the process of dynamically establishing the valid data bitmap and improving the flexibility of establishing the valid data bitmap.
[0056] Furthermore, only when the target superblock is determined to contain valid data and the bitmap identifier of the target superblock is not associated with a valid data bitmap will the corresponding memory space be allocated to the target superblock, instead of pre-allocating the corresponding memory space for all superblocks stored on the solid-state drive. This avoids the situation where superblocks that do not contain valid data occupy a large amount of memory space, thereby improving the memory space utilization of the solid-state drive.
[0057] Furthermore, by setting bitmap identifiers for each superblock, it is possible to quickly determine whether the corresponding superblock is associated with a valid data bitmap and the establishment status of the valid data bitmap. This allows for efficient determination of whether to allocate memory space for the target superblock to establish a valid data bitmap, thereby improving the efficiency of dynamically establishing valid data bitmaps. Attached Figure Description
[0058] Figure 1 This is one application scenario of the method for creating a valid data bitmap provided in the embodiments of this application;
[0059] Figure 2 A flowchart illustrating a method for creating a valid data bitmap provided in an embodiment of this application. Figure 1 ;
[0060] Figure 3 A flowchart illustrating a method for creating a valid data bitmap provided in an embodiment of this application. Figure 2 ;
[0061] Figure 4 A schematic diagram of the structure of an apparatus for creating a valid data bitmap provided in an embodiment of this application. Figure 1 ;
[0062] Figure 5 A schematic diagram of the structure of an apparatus for creating a valid data bitmap provided in an embodiment of this application. Figure 2 . Detailed Implementation
[0063] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings.
[0064] It should be noted that in the embodiments of this application, data such as bitmap identifiers are involved. When the above embodiments of this application are applied to specific products or technologies, user permission or consent is required each time data is acquired, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0065] The application areas of the method for creating a valid data bitmap provided in the embodiments of this application will be briefly introduced below.
[0066] With the continuous development of technology, more and more devices are using solid-state drives (SSDs) to provide storage services. SSDs can improve storage space utilization by creating effective data bitmaps to reclaim data.
[0067] For example, the vast majority of solid-state drives (SSDs) currently use NAND flash memory as their storage medium. Therefore, the working principle of SSDs is largely based on the characteristics of flash memory. Data recycling is based on the "erase before write" characteristic of flash memory.
[0068] In related technologies, the method for establishing an effective data bitmap is to pre-allocate a memory space for each superblock stored in the solid-state drive. When effective data is stored in multiple data blocks associated with the superblock, the storage location of the effective data can be recorded in the corresponding content space to obtain the corresponding effective data bitmap.
[0069] However, the storage resources of a device are limited. When a large number of superblocks are stored in the solid-state drive, the device needs to allocate a significant amount of memory space in advance. However, not all data blocks associated with each superblock contain valid data, resulting in a large amount of storage resources being unnecessarily occupied and low memory space utilization.
[0070] For example, when recording the storage location of valid data, a Valid Bit Map (VBM) can be used. This allows for SSD data reclamation based on the VBM. Therefore, each Super Block (SPB) can correspond to a VBM, facilitating the recording of valid data storage locations and enabling rapid retrieval and relocation of valid data during reclamation. However, device computing resources are limited. When the SSD pre-allocates memory space for each Super Block using the aforementioned method of establishing a valid bit map, some Super Blocks that do not contain valid data will consume a significant amount of storage resources, resulting in low SSD memory space utilization.
[0071] It is evident that among related technologies, solid-state drives (SSDs) have relatively low memory space utilization.
[0072] To address the issue of low memory space utilization in solid-state drives (SSDs), this application proposes a method for establishing an effective data bitmap. This method is applied to an SSD used to store multiple superblocks and multiple data blocks associated with each superblock. Each superblock stores metadata for the associated data blocks, and each data block stores valid data.
[0073] Periodically, within a preset time period, traverse the logical-physical mapping table and determine the physical address of each valid data item in turn; after determining the physical address of each valid data item, perform the following operations:
[0074] Obtain the bitmap identifier of the target superblock that matches the physical address of the valid data. The bitmap identifier indicates whether the target superblock is associated with a valid data bitmap and the establishment status of the valid data bitmap. If the bitmap identifier indicates that a valid data bitmap is not associated, allocate corresponding memory space for the target superblock and record the storage location of the valid data in the target superblock in the memory space using the record format of a valid data bitmap. Update the bitmap identifier to indicate that the target superblock is associated with a valid data bitmap and the establishment status is incomplete. This process continues until the logical-physical mapping table is traversed, at which point the bitmap identifier is updated to indicate that the target superblock is associated with a valid data bitmap and the establishment status is complete.
[0075] In this embodiment, the logical-physical mapping table is traversed periodically within a preset time period to determine the physical address of each valid data in turn. During the traversal process, the valid data bitmap of each superblock is established, realizing the process of dynamically establishing the valid data bitmap and improving the flexibility of establishing the valid data bitmap.
[0076] Furthermore, only when the target superblock is determined to contain valid data and the bitmap identifier of the target superblock is not associated with a valid data bitmap will the corresponding memory space be allocated to the target superblock, instead of pre-allocating the corresponding memory space for all superblocks stored on the solid-state drive. This avoids the situation where superblocks that do not contain valid data occupy a large amount of memory space, thereby improving the memory space utilization of the solid-state drive.
[0077] Furthermore, by setting bitmap identifiers for each superblock, it is possible to quickly determine whether the corresponding superblock is associated with a valid data bitmap and the establishment status of the valid data bitmap. This allows for efficient determination of whether to allocate memory space for the target superblock to establish a valid data bitmap, thereby improving the efficiency of dynamically establishing valid data bitmaps.
[0078] The following describes the application scenarios of the method for creating valid data bitmaps provided in this application.
[0079] Please refer to Figure 1 This is a schematic diagram illustrating an application scenario of the method for establishing a valid data bitmap provided in this application. The application scenario includes a client 101 and a server 102. The client 101 and the server 102 can communicate with each other. The communication method can be wired, such as through a network cable or serial cable; or wireless, such as through Bluetooth or Wi-Fi. No specific limitation is imposed.
[0080] Client 101 generally refers to a device that can send instructions or display data to server 102, such as a terminal device, a third-party application accessible to the terminal device, or a webpage accessible to the terminal device. Terminal devices include, but are not limited to, mobile phones, computers, intelligent transportation equipment, and smart appliances. Server 102 generally refers to a device that can establish a valid data bitmap, such as a terminal device or a server. Servers include, but are not limited to, cloud servers, local servers, or associated third-party servers. Both client 101 and server 102 can use cloud computing to reduce the consumption of local computing resources; similarly, they can also use cloud storage to reduce the consumption of local storage resources.
[0081] As one embodiment, the client 101 and the server 102 can be the same device. For example, this embodiment can be implemented using only the client 101 or only the server 102, etc., without any specific limitation. In this embodiment, the client 101 and the server 102 are described as different devices.
[0082] The following is based on Figure 1 Taking server 102 as an example, the method for establishing a valid data bitmap provided in this application embodiment will be described in detail. Please refer to... Figure 2 This is a flowchart illustrating a method for creating a valid data bitmap provided in an embodiment of this application.
[0083] S201 periodically traverses the logical-physical mapping table within a preset time period to determine the physical address of each valid data in turn.
[0084] The Logical to Physical Mapping Table (L2P) is periodically traversed within a preset time period. The L2P table records the physical addresses of each valid data item. Following the record order in the L2P table, the physical addresses of each valid data item are determined sequentially. For example, this process could be performed daily between 1 AM and 4 AM, or weekly during a preset time period when the device's computing resource utilization is below a threshold. This process of traversing the L2P table to build a valid data bitmap can be flexibly performed when the device is idle, avoiding situations where the traversal process consumes excessive computing resources, preventing other tasks from executing.
[0085] If the logical-physical mapping table is not completely traversed within the preset time period of the current cycle, the remaining logical-physical mapping table can be traversed within the preset time period of the next cycle, without any specific restrictions.
[0086] When traversing the logical-physical mapping table and determining the physical address of each valid data in turn, after determining the physical address of each valid data, the subsequent process of building a valid data bitmap can be performed for that valid data. Thus, when the logical-physical mapping table is completed, the valid data bitmaps of all superblocks stored on the solid-state drive can be built simultaneously, realizing the process of dynamically building valid data bitmaps.
[0087] The following is an example of the process of creating a valid data bitmap based on the physical address of a valid data. The processing of each valid data is similar and will not be repeated here. Please refer to S202 to S204.
[0088] S202, Obtain the bitmap identifier of the target superblock that matches the physical address of the valid data.
[0089] Based on the physical address of the valid data, the target data block corresponding to that physical address is determined. This target data block is the data block that stores the valid data. Therefore, based on the target data block, the associated target superblock can be determined. After determining the target superblock, its bitmap identifier can be obtained.
[0090] Bitmap identifiers are used to indicate whether a valid data bitmap is associated with a target superblock, and the establishment status of the valid data bitmap. When a valid data bitmap is associated with a target superblock, the valid data bitmap can be in an incomplete state of being established, or in a completed state of being established. The valid data bitmap is used to represent the storage location of valid data stored in multiple target data blocks associated with the target superblock within the target superblock.
[0091] As one example, when using a solid-state drive for the first time, the bitmap identifiers of all superblocks stored in the solid-state drive can be initialized to unassociated valid data bitmaps. Then, when creating valid data bitmaps periodically, the bitmap identifiers of the superblocks can be continuously updated to achieve the purpose of dynamically creating valid data bitmaps.
[0092] As one implementation, the bitmap identifier can be represented numerically. For example, 0 indicates that the corresponding superblock has not been associated with a valid data bitmap; 1 indicates that the corresponding superblock has been associated with a valid data bitmap, and the establishment status of the valid data bitmap is incomplete; 2 indicates that the corresponding superblock has been associated with a valid data bitmap, and the establishment status of the valid data bitmap is complete, etc. There are no specific limitations. Therefore, after the solid-state drive is powered on, the bitmap identifier of each superblock can be initialized to 0.
[0093] S203, when it is determined that the bitmap identifier represents that no valid data bitmap is associated with it, allocate corresponding memory space for the target superblock, and record the storage location of the valid data in the target superblock in the memory space in the recording format of the valid data bitmap.
[0094] After obtaining the bitmap identifier of the target superblock, it can be determined whether the bitmap identifier indicates that no valid data bitmap is associated. If the bitmap identifier indicates that no valid data bitmap is associated, then memory space can be allocated for the target superblock based on the size of the target superblock. The memory space is used to store the valid data bitmap of the target superblock.
[0095] As one embodiment, after the solid-state drive is powered on for the first time, during the first preset time period of the first cycle, the bitmap identifiers of each superblock all indicate that no valid data bitmaps are associated with them. Therefore, each superblock can be used as a target superblock in turn, and memory space can be allocated to each target superblock in turn. During the preset time periods of other cycles, the bitmap identifiers of each superblock may be updated differently, and therefore the allocated memory space will also be updated accordingly.
[0096] After allocating memory space for the target superblock, the storage location of valid data within the target superblock is recorded in memory space using a valid data bitmap recording format. For example, valid data is marked as valid on the corresponding bit of the valid data bitmap (e.g., 0 indicates invalid, 1 indicates invalid), enabling updates to the valid data bitmap of the target superblock based on this valid data. The purpose of establishing the valid data bitmap can include organizing valid data and deleting invalid data from multiple target data blocks, freeing up storage space for subsequent use of other valid data, thereby improving the utilization rate of the solid-state drive's storage space.
[0097] As one embodiment, after obtaining the bitmap identifier of the target superblock that matches the physical address of the valid data, if the bitmap identifier indicates that the associated valid data bitmap is set and the setup status is incomplete, it means that memory space has already been allocated for the target superblock, and memory space will not be allocated again for the target superblock. Since the logical-physical mapping table also stores the physical addresses of the memory space of the valid data bitmaps of each superblock, the physical address of the memory space allocated for the valid data bitmap associated with the target superblock can be determined based on the logical-physical mapping table. Based on the physical address of the memory space, the storage location of the valid data in the target superblock is recorded in the memory space in the recording format of the valid data bitmap.
[0098] As one embodiment, when it is determined that the bitmap identifier represents a valid data bitmap associated with the target superblock and the establishment status is incomplete, based on the physical address of the target superblock's memory space, and using the recording format of a valid data bitmap, after recording the storage location of the valid data in the target superblock in the memory space, the bitmap identifier can be updated to represent that the target superblock has been associated with a valid data bitmap and the establishment status is complete when it is determined that the traversal of the logical-physical mapping table is complete. When it is determined that the traversal of the logical-physical mapping table is complete, it means that all valid data recorded in the logical-physical mapping table has been processed, so the bitmap identifier can be updated to represent that the target superblock has been associated with a valid data bitmap and the establishment status is complete.
[0099] S204, update the bitmap identifier to indicate that the target superblock has been associated with a valid data bitmap and the establishment status is incomplete, until the logical physical mapping table is traversed, then update the bitmap identifier to indicate that the target superblock has been associated with a valid data bitmap and the establishment status is completed.
[0100] After determining that the bitmap identifier represents a valid data bitmap that has not been associated with the target superblock, allocating the corresponding memory space for the target superblock, and recording the storage location of the valid data in the target superblock in the memory space in the format of a valid data bitmap, since a valid data bitmap has already been associated with the target superblock, the bitmap identifier can be updated to represent that the target superblock has been associated with a valid data bitmap, and the establishment status is incomplete. This continues until the logical-physical mapping table is traversed, indicating that all valid data recorded in the logical-physical mapping table has been processed. At this point, the bitmap identifier can be updated to represent that the target superblock has been associated with a valid data bitmap, and the establishment status is complete.
[0101] Once a valid data bitmap has been associated with the target superblock and its creation status is complete, the valid data bitmap will be updated as the valid data contained in the multiple target data blocks associated with the target superblock is updated. The valid data bitmap is updated and maintained in real time on the solid-state drive. For example, when the storage location of the valid data contained in a target data block changes, or when valid data is added to a target data block, the valid data bitmap will also be updated in real time.
[0102] As one embodiment, for a superblock whose bitmap identifier indicates that a valid data bitmap has been associated with it and whose establishment status is "completed," if it is determined that multiple data blocks associated with the superblock do not contain valid data, the memory space allocated to the superblock can be released to avoid unnecessary memory space occupation, and the bitmap identifier of the superblock can be updated to indicate that the superblock is not associated with a valid data bitmap. Therefore, in this embodiment, even if memory space is allocated for a superblock that does not contain valid data, the memory space will be released promptly and will not be occupied indefinitely, thus improving the utilization rate of the solid-state drive's memory space.
[0103] Taking a target superblock as an example, after updating the bitmap identifier of the target superblock to indicate that the target superblock has been associated with a valid data bitmap and the setup status is completed, if it is determined, through methods such as receiving instructions that multiple target data blocks associated with the target superblock do not contain valid data, that the multiple target data blocks associated with the target superblock do not contain valid data, the bitmap identifier of the target superblock is retrieved. If it is determined that the bitmap identifier indicates that the target superblock has been associated with a valid data bitmap, the memory space allocated to the target superblock is released. The bitmap identifier is then updated to indicate that the target superblock has not been associated with a valid data bitmap. Therefore, the solid-state drive only stores valid data bitmaps for superblocks containing valid data, instead of pre-setting a valid data bitmap for all superblocks, avoiding unnecessary storage resource consumption.
[0104] For example, a NAND flash memory contains 32 superblocks (SPBs), each SPB contains 8 data blocks, each block contains 16 data pages, each page contains 4 data manipulation units (cells), and each cell is 4KB in size. In the valid data bitmap, one bit is used to indicate whether a cell is valid. Therefore, the space occupied by the valid data bitmap for each superblock is (8*16*4) / 8 = 256 bits / 8 = 32 bytes. If a valid data bitmap is pre-set for all superblocks, it will consume 32*32 bytes of storage space. If only 2 of the 32 superblocks contain valid data in their data blocks, then only 2*32 bytes of storage space are actually needed.
[0105] As one embodiment, after updating the bitmap identifier to indicate that the target superblock has been associated with a valid data bitmap and the establishment status is incomplete, and updating the bitmap identifier to indicate that the target superblock has been associated with a valid data bitmap and the establishment status is complete when the logical-physical mapping table is traversed, if a data reclamation instruction for the target superblock is received, data reclamation of the target superblock can be performed directly based on the pre-established dynamic valid data bitmap to improve the efficiency of data reclamation.
[0106] After obtaining the bitmap identifier of the target superblock, the server can determine whether the target superblock is associated with a valid data bitmap and the establishment status of the valid data bitmap. If the bitmap identifier indicates that the target superblock is associated with a valid data bitmap and the establishment status of the valid data bitmap is complete, then the storage location of the valid data contained in the multiple target data blocks associated with the target superblock can be directly determined based on the valid data bitmap. If the bitmap identifier indicates that the target superblock is not associated with a valid data bitmap, then it is necessary to traverse the multiple target data blocks associated with the target superblock and determine the valid data contained in the multiple target data blocks and the storage location of the valid data in real time.
[0107] After obtaining the storage locations of the valid data contained in multiple target data blocks, data reclamation can be performed on the target superblock based on the storage locations of the valid data.
[0108] The following is an example of the method for creating a valid data bitmap provided in the embodiments of this application. Please refer to [link / reference]. Figure 3 .
[0109] The server can pre-set three bitmap flags. When the flag is 0, it means that the superblock has not been associated with a valid data bitmap. When the flag is 1, it means that the superblock has been associated with a valid data bitmap and the establishment status of the valid data bitmap is incomplete. When the flag is 2, it means that the superblock has been associated with a valid data bitmap and the establishment status of the valid data bitmap is complete.
[0110] After the S301 SSD is successfully powered on for the first time, the flag of all superblocks stored on the SSD is initialized to 0.
[0111] S302, Set a timer to periodically traverse the L2P table within a preset time period, and determine the physical address of each valid data in the L2P table in turn. After determining the physical address of each valid data, perform the following operations, please refer to S303 to S307.
[0112] S303, the valid data is stored in the superblock with logical address x, and the physical address of the superblock is determined to be m through the L2P table.
[0113] S304: Obtain the flag of the superblock, determine whether the bitmap identifier of superblock m is associated with a valid data bitmap, and the establishment status of the valid data bitmap. When flag is 0, execute S305-S307; when flag is 1, execute S306; when flag is 2, traverse the next superblock.
[0114] In S305, when the flag of the superblock is 0, a memory space of size 32 bytes is allocated from the memory of the solid-state drive for the superblock. Each bit in the valid data bitmap is initialized to 0, and the execution continues to S306~S307.
[0115] S306, the storage location of a valid data item within the superblock is recorded in the valid data bitmap. If a data block contains multiple data pages, and each data page contains multiple data operation units, then the physical address of the data block can be represented as block = i, page = j, cell = k. Each data operation unit in each data page of each data block is arranged sequentially, and different bits in the valid data bitmap correspond to different data operation units. When a data operation unit is determined to be valid data, the corresponding bit in the valid data bitmap is marked as 1, indicating that the data operation unit at that position is valid.
[0116] S307, update the bitmap identifier of the superblock to 1.
[0117] The bitmap identifier of the superblock is updated to 2 when the L2P table traversal is complete.
[0118] During the traversal process, if the end time of the preset time period set by the timer is reached before all the valid data stored in the L2P table has been traversed, the traversal process is paused. When the start time of the preset time period of the next cycle set by the timer is reached, the unfinished traversal process continues. This is to prevent the device from having its computing resources occupied for a long time during the traversal process, which could cause other tasks to fail to execute or to malfunction.
[0119] For superblocks with a valid data bitmap set in the associated configuration and whose valid data bitmap creation status is "completed," the valid data bitmap is updated and maintained in real time in the SSD's memory as the data stored in the data block is updated. When each bit of the valid data bitmap becomes 0 during the continuous data updates of the superblock, indicating that the superblock does not contain valid data, the superblock's flag is updated from 2 to 0, and the memory space occupied by its valid data bitmap is released.
[0120] S308, after receiving the data reclamation instruction for superblock n, obtains the flag of superblock n.
[0121] S309, when flag is determined to be 2, obtain the valid data bitmap associated with superblock n, and reclaim data from superblock n based on the storage location of the valid data represented by the valid data bitmap.
[0122] If flag is not 2, iterate through superblock n, determine each valid data it contains, record the storage location of the valid data, and then reclaim data from superblock n based on the recorded storage location of the valid data.
[0123] In this embodiment, the dynamic creation of a valid data bitmap is implemented. By dynamically creating the valid data bitmap, the problem of the valid data bitmap occupying flash memory, HMB, and other space for a long time is avoided. After power-on, SSD memory resources are dynamically allocated to the valid data bitmap that needs to be created, reducing the waste of flash memory, HMB, and other resources, speeding up the access speed of the valid data bitmap, and improving the efficiency of data recycling.
[0124] Based on the same inventive concept, embodiments of this application provide an apparatus for establishing a valid data bitmap, capable of realizing the functions corresponding to the aforementioned method for establishing a valid data bitmap. Please refer to... Figure 4 The device includes an acquisition module 401 and a processing module 402, wherein:
[0125] Module 401: Used to periodically traverse the logical-physical mapping table within a preset time period and determine the physical address of each valid data in turn;
[0126] For each valid data physical address determined, perform the following operations:
[0127] The acquisition module 401 is also used to: acquire the bitmap identifier of the target superblock that matches the physical address of the valid data, wherein the bitmap identifier is used to characterize whether the target superblock is associated with a valid data bitmap and the establishment status of the valid data bitmap;
[0128] Processing module 402: When determining that the bitmap identifier represents a valid data bitmap that is not associated with a set of valid data bitmaps, it allocates corresponding memory space for the target superblock and records the storage location of the valid data in the target superblock in the memory space in the recording format of the valid data bitmap;
[0129] The processing module 402 is further configured to: update the bitmap identifier to indicate that the target superblock has been associated with a valid data bitmap and the establishment status is incomplete, until the logical physical mapping table is traversed, and then update the bitmap identifier to indicate that the target superblock has been associated with a valid data bitmap and the establishment status is complete.
[0130] In one possible embodiment, the processing module 402 is further configured to:
[0131] Before periodically traversing the logical-physical mapping table and determining the physical address of each piece of valid data within a preset time period, the solid-state drive is powered on.
[0132] Initialize the bitmap identifiers of multiple superblocks to represent the corresponding superblocks that are not associated with valid data bitmaps.
[0133] In one possible embodiment, the processing module 402 is further configured to:
[0134] After obtaining the bitmap identifier of the target superblock that matches the physical address of the valid data, and determining that the bitmap identifier represents the valid data bitmap associated with the setting, and when the establishment status is incomplete, the physical address of the memory space allocated for the valid data bitmap associated with the target superblock is determined based on the logical-physical mapping table.
[0135] Based on the physical address of the memory space, and using the recording format of a valid data bitmap, the storage location of valid data in the target superblock is recorded in the memory space.
[0136] In one possible embodiment, the processing module 402 is further configured to:
[0137] After recording the storage location of valid data in the target superblock in the memory space, when it is determined that the logical-physical mapping table has been traversed, the bitmap identifier is updated to indicate that the target superblock has been associated with a valid data bitmap and the establishment status is completed.
[0138] In one possible embodiment, the processing module 402 is further configured to:
[0139] After updating the bitmap identifier to indicate that the target superblock has been associated with a valid data bitmap and the establishment status is incomplete, if it is determined that multiple target data blocks associated with the target superblock do not contain valid data, the bitmap identifier of the target superblock is obtained.
[0140] Once it is determined that the bitmap identifier represents that the target superblock has been associated with a valid data bitmap, the memory space allocated to the target superblock will be released;
[0141] Update the bitmap identifier to represent a valid data bitmap that is not associated with the target superblock.
[0142] In one possible embodiment, the processing module 402 is further configured to:
[0143] After updating the bitmap identifier to indicate that the target superblock has been associated with a valid data bitmap and the establishment status is completed, the bitmap identifier of the target superblock is obtained after receiving the data reclamation instruction for the target superblock.
[0144] When the bitmap identifier indicates that the target superblock has been associated with a valid data bitmap and the establishment status is established, the storage location of the valid data contained in the multiple target data blocks associated with the target superblock is determined based on the valid data bitmap of the target superblock.
[0145] Based on the storage location of the obtained valid data, data reclamation is performed on the target superblock.
[0146] Please refer to Figure 5 The aforementioned apparatus for establishing a valid data bitmap can run on a computer device 500. The current and historical versions of the data storage program, as well as the application software corresponding to the data storage program, can be installed on the computer device 500, which includes a processor 580 and a memory 520. In some embodiments, the computer device 500 may include a display unit 540, which includes a display panel 541 for displaying a user-interactive interface, etc.
[0147] In one possible embodiment, the display panel 541 may be configured in the form of a liquid crystal display (LCD) or an organic light-emitting diode (OLED).
[0148] The processor 580 is used to read a computer program and then execute the methods defined by the computer program. For example, the processor 580 reads a data storage program or file, thereby running the data storage program on the computer device 500 and displaying the corresponding interface on the display unit 540. The processor 580 may include one or more general-purpose processors, and may also include one or more DSPs (Digital Signal Processors) for performing related operations to implement the technical solutions provided in the embodiments of this application.
[0149] The memory 520 generally includes main memory and secondary storage. Main memory can be random access memory (RAM), read-only memory (ROM), and cache, etc. Secondary storage can be a hard disk, optical disk, USB flash drive, floppy disk, or tape drive, etc. The memory 520 is used to store computer programs and other data. The computer programs include applications corresponding to each client, and other data may include data generated after the operating system or applications are run, including system data (e.g., operating system configuration parameters) and user data. In this embodiment, program instructions are stored in the memory 520, and the processor 580 executes the program instructions in the memory 520 to implement any of the methods described in the preceding figures.
[0150] The aforementioned display unit 540 is used to receive input digital information, character information, or contact touch operations / non-contact gestures, and to generate signal inputs related to user settings and function control of the computer device 500. Specifically, in this embodiment, the display unit 540 may include a display panel 541. The display panel 541, for example, is a touch screen, which can collect touch operations performed by the user on or near it (such as operations performed by the user using a finger, stylus, or any suitable object or accessory on or on the display panel 541), and drive corresponding connection devices according to a pre-set program.
[0151] In one possible embodiment, the display panel 541 may include two parts: a touch detection device and a touch controller. The touch detection device detects the player's touch position and the signal generated by the touch operation, and transmits the signal to the touch controller. The touch controller receives touch information from the touch detection device, converts it into touch point coordinates, and sends it to the processor 580. It can also receive and execute commands from the processor 580.
[0152] The display panel 541 can be implemented using various types such as resistive, capacitive, infrared, and surface acoustic wave. In addition to the display unit 540, in some embodiments, the computer device 500 may also include an input unit 530. The input unit 530 may include an image input device 531 and other input devices 532, wherein the other input devices may include, but are not limited to, one or more of the following: a physical keyboard, function keys (such as volume control buttons, power buttons, etc.), a trackball, a mouse, and a joystick.
[0153] In addition to the above, the computer device 500 may also include a power supply 590 for powering other modules, an audio circuit 560, a near-field communication module 570, and an RF circuit 510. The computer device 500 may also include one or more sensors 550, such as an accelerometer, a light sensor, and a pressure sensor. The audio circuit 560 specifically includes a speaker 561 and a microphone 562, for example, the computer device 500 can use the microphone 562 to collect the user's voice and perform corresponding operations.
[0154] As one embodiment, the number of processors 580 can be one or more, and the processors 580 and the memory 520 can be coupled together or relatively independent.
[0155] As one example, Figure 5 The processor 580 in the system can be used to implement, for example Figure 4 The functions of the acquisition module 401 and the processing module 402 in the process.
[0156] As one example, Figure 5The processor 580 in the document can be used to implement the functions of the server or terminal devices discussed above.
[0157] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0158] Alternatively, if the integrated units of this invention are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of this invention, or the parts that contribute to the prior art, can be embodied in the form of software products, for example, through a computer program product. This computer program product is stored in a storage medium and includes several instructions to cause a computer device to execute all or part of the methods of the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, ROM, RAM, magnetic disks, or optical disks.
[0159] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.
Claims
1. A method of building an active data bitmap, characterized by, The application is applied to a solid state disk used for storing a plurality of super blocks and a plurality of data blocks associated with each super block, each super block is used for storing metadata of the associated plurality of data blocks, and each data block is used for storing valid data, comprising: Periodically traversing a logical-physical mapping table within a preset time period to sequentially determine the physical addresses of each valid data; and performing the following operations after determining the physical address of each valid data: Obtaining a bitmap identifier of a target super block matched with the physical address of the valid data, wherein the bitmap identifier is used to represent whether the target super block is associated with a valid data bitmap, and the establishment state of the valid data bitmap; When the bitmap identifier represents that the target super block is not associated with the valid data bitmap, allocating a corresponding memory space for the target super block, and recording the storage position of the valid data in the target super block in the memory space in the record format of the valid data bitmap; Updating the bitmap identifier to represent that the target super block is associated with the valid data bitmap, and the establishment state is not completed, until the traversal of the logical-physical mapping table is completed, updating the bitmap identifier to represent that the target super block is associated with the valid data bitmap, and the establishment state is completed.
2. The method of claim 1, wherein, Before the periodically traversing the logical-physical mapping table within the preset time period to sequentially determine the physical addresses of each valid data, further comprising: Powering on the solid state disk; Initializing the bitmap identifiers of the plurality of super blocks to represent that the corresponding super blocks are not associated with the valid data bitmap, respectively.
3. The method of claim 1, wherein, After the obtaining the bitmap identifier of the target super block matched with the physical address of the valid data, further comprising: When the bitmap identifier represents that the target super block is associated with the valid data bitmap, and the establishment state is not completed, determining the physical address of the memory space allocated for the valid data bitmap associated with the target super block based on the logical-physical mapping table; Recording the storage position of the valid data in the target super block in the memory space in the record format of the valid data bitmap based on the physical address of the memory space.
4. The method of claim 3, wherein, After the recording the storage position of the valid data in the target super block in the memory space in the record format of the valid data bitmap based on the physical address of the memory space, further comprising: Determining to update the bitmap identifier to represent that the target super block is associated with the valid data bitmap, and the establishment state is completed when the traversal of the logical-physical mapping table is completed.
5. The method according to any one of claims 1 to 4, characterized in that, After the updating the bitmap identifier to represent that the target super block is associated with the valid data bitmap, and the establishment state is not completed, further comprising: When the bitmap identifier represents that the target super block is associated with the valid data bitmap, obtaining the bitmap identifier of the target super block; When the bitmap identifier represents that the target super block is associated with the valid data bitmap, releasing the memory space allocated for the target super block; Updating the bitmap identifier to represent that the target super block is not associated with the valid data bitmap.
6. The method of claim 1, wherein, After the bitmap identifier is updated to represent that the target super block has associatedly set the valid data bitmap, and the establishment state is completed, the method further comprises: After receiving a data recycling instruction for the target super block, obtaining a bitmap identifier of the target super block; When the bitmap identifier represents that the target super block has associatedly set the valid data bitmap, and the establishment state is established, determining storage locations of valid data contained in a plurality of target data blocks associated with the target super block based on the valid data bitmap of the target super block; Based on the obtained storage locations of valid data, performing data recycling on the target super block.
7. An apparatus for establishing an active data bitmap, the apparatus comprising: The application is applied to a solid state disk, and the solid state disk is used for storing a plurality of super blocks and a plurality of data blocks associated with each super block. Each super block is used for storing metadata of the associated plurality of data blocks, and each data block is used for storing valid data. The application comprises: An obtaining module is used for periodically traversing a logical-physical mapping table within a preset time period, and sequentially determining physical addresses of each valid data; After determining the physical address of one valid data, the following operations are performed: The obtaining module is further used for obtaining a bitmap identifier of a target super block matched with the physical address of the valid data, wherein the bitmap identifier is used for representing whether the target super block has associatedly set a valid data bitmap and an establishment state of the valid data bitmap; A processing module is used for determining that the bitmap identifier represents that the target super block has not associatedly set the valid data bitmap, allocating a corresponding memory space for the target super block, and recording storage locations of the valid data in the target super block in the memory space in a record format of the valid data bitmap; The processing module is further used for updating the bitmap identifier to represent that the target super block has associatedly set the valid data bitmap, and the establishment state is not completed, until the logical-physical mapping table is traversed, the bitmap identifier is updated to represent that the target super block has associatedly set the valid data bitmap, and the establishment state is completed.
8. A computer program product comprising a computer program, characterized in that, The computer program is executed by a processor to implement the method in any one of claims 1-6.
9. A computer device, comprising: Comprise: a memory for storing program instructions; a processor for calling the program instructions stored in the memory, and executing the method in any one of claims 1-6 according to the obtained program instructions.
10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer executable instructions, and the computer executable instructions are used for causing a computer to execute the method in any one of claims 1-6.
Citation Information
Patent Citations
Universal F2FS file system analyzing method, terminal equipment and storage medium
CN108090168A
Effective data bitmap creation method and device, storage medium and electric equipment
CN112379830A