Solid state disk garbage collection optimization method, device and medium based on storage partition
By partitioning the solid-state drive (SSD) and performing alternating garbage collection, hot data is identified and backed up. The backup data is then used to redirect host requests, thus resolving the issue of garbage collection interfering with SSD performance and improving read and write efficiency.
Patent Information
- Application Number
- CN202511317598.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-16
- Publication Date
- 2026-01-16
- Estimated Expiration
- 2045-09-16
AI Technical Summary
In existing technologies, garbage collection operations during solid-state drive (SSD) garbage collection can interfere with host read and write requests, leading to performance degradation, especially when invalid data accumulates.
The solid-state drive's logical address space is divided into a primary logical area and a backup logical area, and the flash array is divided into multiple independent garbage collection areas, which are alternately executed for garbage collection. The backup data is used to redirect host requests, and hot data is identified and backed up through the address mapping table.
It effectively reduces the interference of garbage collection on the read and write performance of solid-state drives, improves read and write efficiency, and reduces the impact of garbage collection on host requests.
Smart Images

Figure CN120821441B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of solid state disk, and particularly relates to a solid state disk garbage collection optimization method based on storage partition, equipment and medium. BACKGROUND
[0002] The flash memory has the characteristic of erasing before writing, so the solid state disk based on the flash memory adopts the writing mode of off-site updating, needs to write the updating data into the new flash memory position and mark the old data as invalid, and meanwhile the garbage collection operation needs to be performed in the solid state disk to release the flash memory space occupied by the invalid data. The garbage collection contains the migration of valid data and the erasing of the flash memory block, which can interfere with the execution of the read and write requests issued by the host and reduce the read and write performance of the solid state disk.
[0003] For the garbage collection of the solid state disk, the prior art usually processes the host requests in priority through scheduling to reduce the interference of the garbage collection, but this can cause the accumulation of the garbage collection data migration requests, and when a large amount of invalid data accumulates in the solid state disk, the forced garbage collection can still have a great impact on the host requests.
[0004] Some practitioners propose to implement the RAID mechanism in the solid state disk, and when the data read by the host is blocked by the garbage collection, the required data is read out through the RAID redundant data degradation, but this kind of way can cause a large number of additional read requests, occupy the bandwidth of the solid state disk, and with the increase of the capacity of the solid state disk and the size of the RAID, the additional read request overhead caused by the degradation reading is also increased. SUMMARY
[0005] The technical problem to be solved by the present application is that in view of the above problems existing in the prior art, the present application provides a solid state disk garbage collection optimization method based on storage partition, which can identify the hot access data in the solid state disk and first perform backup redundancy in the two partitions by performing the garbage collection in the two or more partitions alternately, and then redirect the host request by using the backup data, so as to effectively reduce the interference of the garbage collection on the read and write performance of the solid state disk.
[0006] To solve the above technical problems, the technical scheme provided by the present application is as follows:
[0007] A solid state disk garbage collection optimization method based on storage partition, comprising:
[0008] Step S01. Storage partitioning: dividing the logical address space of the solid state disk into a main logical area and a backup logical area, the main logical area is used for storing main logical pages, and the backup logical area is used for storing backup logical pages to realize hot data backup;
[0009] Step S02. Alternating garbage collection configuration: the entire flash memory array of the solid state disk is divided into two or more independent garbage collection areas, the main logical pages and the corresponding backup logical pages are respectively mapped to the physical flash memory pages in different garbage collection areas, and the alternating garbage collection is performed in each garbage collection area, and only one garbage collection area is allowed to perform garbage collection at the same time period;
[0010] Step S03. Hot data backup: an address mapping table is maintained in each of the main logical area and the backup logical area to record the address mapping of the logical pages to the physical flash memory pages. During the reading and writing of the main logical pages and the garbage collection data migration operation, it is determined whether the current main logical page is a hot data page that needs to be backed up. If so, it is determined whether to perform data backup in the backup logical page according to the occupied state of the corresponding backup logical page of the current main logical page and update the corresponding address mapping table.
[0011] Step S04. Request redirection: during the process of reading the logical pages in the main logical area by the host software or updating the host data, the data is read and updated according to the backup data to realize the redirection of the host request.
[0012] Further, in step S01, the main logical area is configured as a user visible space, and the backup logical area is configured as only visible in the solid state disk. The logical page addresses of the main logical area and the backup logical area use a directly connected mapping mode. Among them, all logical pages in the main logical area that satisfy LPN%M=n are determined as hot data pages, and the nth page in the backup logical area is used to store backup data, where M is the total number of logical pages in the backup logical area, and n is an integer.
[0013] Further, in step S02, the free space and invalid data of the solid state disk and each garbage collection area are recorded, and a garbage collection token is maintained. The garbage collection token is circulated among the garbage collection areas. If the free space of the solid state disk is lower than a preset first threshold th1, a garbage collection operation is triggered, and the free space of the target garbage collection area holding the garbage collection token is determined. If the free space is lower than a preset second threshold th2 and the invalid data is higher than a preset third threshold th3, the target garbage collection area is selected to perform garbage collection. Otherwise, the garbage collection token is circulated to the next garbage collection area for further checking. If all garbage collection areas are not checked for garbage collection, the garbage collection token is passed to the garbage collection area with the most invalid data and a garbage collection operation is performed to realize alternating garbage collection.
[0014] Further, the address mapping table of the main logical area also uses identification information to identify whether each logical page has backup data, and also records read access times of each main logical page by the host software for judging whether the logical page is a hot data page needing backup, wherein if the read access times of the target logical page is greater than a preset threshold, the target logical page is determined as a hot data page needing backup, otherwise, it is determined as a cold data page not needing backup, and the access times of all records in the address mapping table of the main logical area are decayed at a specified time interval, the address mapping table of the backup logical area also records validity information of whether each backup logical page is used as backup data by the main logical page, wherein only one main logical page uses the corresponding backup logical page among all main logical pages sharing the same backup logical page.
[0015] Further, the step S03 comprises:
[0016] When a main logical page is initially written to the solid state disk and is determined as cold data and directly written to the main logical area, the address mapping table of the main logical area is updated, and the access times of the current main logical page are recorded subsequently;
[0017] When the current main logical page is read and written, garbage collection operation is performed, whether the current main logical page is a hot data page is judged according to the access times of the current main logical page, if yes, whether the corresponding backup logical page is occupied is checked;
[0018] If it is judged that the corresponding backup logical page is not occupied, it is determined to directly use the corresponding backup logical page to backup the current main logical page when the solid state disk is idle, and the backup identification bit of the main logical page and the validity identification bit of the backup logical page are modified;
[0019] If it is judged that the corresponding backup logical page is occupied, the address mapping table of the main logical area is checked to find other main logical pages using the corresponding backup logical page, and whether the found main logical page is a hot data page is judged, if not, the backup identification bit of the found main logical page is cleared, it is determined to use the corresponding backup logical page to backup the current main logical page when the solid state disk is idle, and the corresponding mapping information and identification bit are updated.
[0020] Further, when a write operation is performed on the current data page, and if it is a write data update operation, it is determined whether the current write data has backup data, and if it has, the corresponding backup data is invalidated, the address mapping table of the backup logical area is updated, it is determined whether the current write data is hot data, if it is not hot data, only the current main logical page is written, and the address mapping table of the main logical area is updated, if it is hot data, it is determined whether the corresponding backup logical page has been occupied, if not, the current write data is written into the current main logical page and the corresponding backup logical page, and the address mapping tables of the main logical area and the backup logical area are updated; if the backup logical page is occupied, it is determined whether the main logical page occupying the backup logical page is a hot data page, if the main logical page occupying the backup logical page is a hot data page, the current data is only written into the current main logical page, and the address mapping table of the main logical area is updated, if the main logical page occupying the backup logical page is a cold data page, the occupied backup data is invalidated, and the backup identification bit of the main logical page occupying the backup logical page is cleared, and then the current data is written into the current main logical page and the corresponding backup logical page, and the address mapping tables of the main logical area and the backup logical area are updated.
[0021] Further, when a garbage collection data migration operation is performed on the current data page, it is determined whether the data to be migrated is main logical data, if it is main logical data, it is checked whether the data to be migrated has backup data, if it has, the main logical data to be migrated is migrated to a garbage collection area different from the backup data, if it does not have, only the address mapping table of the main logical area is modified; if the data to be migrated is backup data, it is checked whether the corresponding main logical data is still hot data, if it is, the backup data to be migrated is migrated to a garbage collection area different from the main logical data, and the address mapping table of the backup logical area is modified, if it is not hot data, the current backup data is marked as invalid so that it does not need to be migrated, and the address mapping tables of the main logical area and the backup logical area are modified.
[0022] Further, step S04 comprises:
[0023] When the host software reads the main logical page in the main logical area, it is checked whether the garbage collection is currently being performed in the garbage collection area where the current main logical page is located, if the garbage collection is not currently being performed, the data of the current main logical page is directly read, if the garbage collection is currently being performed, it is checked whether the current main logical page has backup data, if it has, the backup data of the current main logical page is directly read, if it does not have, the data in the original garbage collection area is read.
[0024] When the host software writes the main logical page in the main logical area, the address is preferentially allocated in the garbage collection area which does not perform garbage collection to write data, wherein, if it is the first time to write the current main logical page or the current main logical page is cold data, only the main logical area data is written, and the address mapping table of the main logical area is modified; if it is update writing data, the writing data update operation is performed.
[0025] An electronic device comprising a processor and a memory for storing a computer program, the processor being configured to execute the computer program to perform the method as described above.
[0026] A computer readable storage medium storing a computer program, the computer program being executed by a processor to implement the method as described above.
[0027] Compared with the prior art, the beneficial effects of the present application are that: the present application divides the solid state disk logical address space into a main logical area and a backup logical area by storage partitioning, the main logical area is a user visible space, the backup logical area is only visible in the solid state disk, and the flash memory array of the entire solid state disk is divided into two or more independent garbage collection areas, each garbage collection area alternately performs garbage collection, an address mapping table is maintained in each of the main logical area and the backup logical area, the address mapping table records the address mapping of the logical page to the physical flash page, and during the reading and writing of the main logical page and the garbage collection data migration operation, the hot data page is backed up to the corresponding available backup logical page, so that the hot access data in the solid state disk can be simultaneously identified and first backed up redundantly in two or more partitions, and then the backup data is used to redirect the host request, which can effectively reduce the interference of garbage collection on the read and write performance of the solid state disk. BRIEF DESCRIPTION OF DRAWINGS
[0028] Figure 1 is a typical internal structure principle schematic diagram of a solid state disk.
[0029] Figure 2 is an implementation flowchart of the solid state disk garbage collection optimization method based on storage partitioning of the present embodiment.
[0030] Figure 3 is a principle schematic diagram of the solid state disk garbage collection optimization based on storage partitioning of the present embodiment. DETAILED DESCRIPTION
[0031] The present application is further described below in conjunction with the accompanying drawings and specific preferred embodiments, but the protection scope of the present application is not limited thereby.
[0032] For the convenience of understanding, first, the related technical background involved in the present application is exemplarily introduced.
[0033] The solid state disk based on flash memory adopts electronic devices to realize data access,Figure 1 A typical internal structure of a solid state disk is shown, mainly including the following components: ① host interface; ② built-in DRAM; ③ solid state disk controller; ④ flash memory array, composed of a plurality of flash memory wafers and channels connecting the flash memory wafers, to realize data transmission and storage functions. Different channels can simultaneously perform command / data transmission, and different flash memory wafers can simultaneously perform different flash memory operations. Each flash memory wafer is divided into a large number of flash memory blocks, and each flash memory block contains a plurality of flash memory pages. Among them, the page is the basic unit of flash memory read / write operation, and the block is the basic unit of flash memory erase operation.
[0034] A software layer, flash translation layer (FTL), is implemented inside the solid state disk to manage a plurality of flash memory chips, mask the underlying flash memory characteristics, and expose the solid state disk as a common block device for use. FTL mainly implements address mapping, garbage collection, wear leveling, request scheduling and other functions. Since flash memory needs to be erased before writing and the erase / write time is asymmetric, in order to avoid introducing time-consuming erase operations during writing, the solid state disk uses an off-site update method to write updated data to new flash memory pages and mark the flash memory pages storing old data as invalid. At the same time, FTL maintains a mapping table recording the mapping from host logical page number (LPN) to flash memory physical page number (PPN), and after data writing or updating, FTL synchronously updates the related address mapping information. As the solid state disk is continuously used, the update write operation generates a large amount of invalid data in the solid state disk, rapidly consuming the available space of the solid state disk, and FTL needs to perform garbage collection (GC) operation to release the flash memory space occupied by invalid data. During garbage collection, FTL migrates valid data in one or several flash memory blocks containing invalid data to other flash memory pages and updates the address mapping table, and then erases the selected flash memory block for subsequent use. However, garbage collection will occupy flash memory channels and block host read / write requests on the same flash memory wafer, reducing the read / write bandwidth of the solid state disk and increasing the request response time.
[0035] The application divides the solid state disk logical address space into a main logical area and a backup logical area by storage partitioning, the main logical area is used for storing main logical pages, and the backup logical area is used for storing backup logical pages to realize hot data backup and configuration, and the flash memory array of the whole solid state disk is divided into two or more independent garbage collection areas, garbage collection is alternately performed by each garbage collection area, an address mapping table is maintained in the main logical area and the backup logical area respectively, the address mapping from the logical page to the physical flash memory page is recorded, in the process of reading and writing the main logical page and garbage collection data migration operation, the hot data page is backed up to the corresponding available backup logical page, so that the hot access data in the solid state disk can be identified and first backed up redundantly in two or more partitions, and then the host request is redirected by using the backup data, which can effectively reduce the interference of garbage collection on the read and write performance of the solid state disk.
[0036] The application will be further described below in combination with specific embodiments.
[0037] As shown in the figure, the steps of the solid state disk garbage collection optimization method based on storage partitioning in the embodiment include: Figure 2
[0038] Step S01. Storage partitioning: the solid state disk logical address space is divided into a main logical area and a backup logical area, the main logical area is used for storing main logical pages, and the backup logical area is used for storing backup logical pages to realize hot data backup;
[0039] Step S02. Alternating garbage collection configuration: the flash memory array of the whole solid state disk is divided into two or more independent garbage collection areas, the main logical page and the corresponding backup logical page are respectively mapped to the physical flash memory page in different garbage collection areas, and the garbage collection is staggered in each garbage collection area, and garbage collection is only allowed in one garbage collection area at the same time;
[0040] Step S03. An address mapping table is maintained in the main logical area and the backup logical area respectively to record the address mapping from the logical page to the physical flash memory page, in the process of reading and writing the main logical page and garbage collection data migration operation, it is judged whether the current main logical page is a hot data page that needs to be backed up, if yes, it is determined whether data backup is performed in the backup logical page according to the occupied state of the corresponding backup logical page of the current main logical page and the corresponding address mapping table is updated;
[0041] Step S04. Request redirection: in the process of reading the logical page in the main logical area or writing the main logical page in the main logical area by the host software, data reading and data writing are performed according to the backup data to realize host request redirection.
[0042] As shown in the figure, the steps of the solid state disk garbage collection optimization method based on storage partitioning in the embodiment include: Figure 3 As shown, this embodiment divides the solid-state drive's logical address space into two regions: a primary logical region, which can be configured as a user-visible space exposed to upper-layer software; and a backup logical region, used for hot data backup, which can be configured to be visible only within the solid-state drive. The logical page addresses of the primary and backup logical regions are directly mapped. If any logical page in the primary logical region that satisfies LPN%M=n is determined to be a hot data page, the backup data is stored in the nth page of the backup logical region, where M is the total number of logical pages in the backup logical region and n is an integer.
[0043] Specifically, assuming the backup logical area has M logical pages, all logical pages in the main logical area that satisfy LPN%M=0 (i.e., page 0, page M, page 2M, etc.) can use page 0 in the backup logical area to store backup data if they are determined to be hot data. Hot data pages in the main logical area that satisfy LPN%M=1 (i.e., page 1, page M+1, page 2M+1, etc.) can use page 1 in the backup logical area, and so on. Here, LPN is the logical page number, i.e., the logical page address.
[0044] like Figure 3 As shown, this embodiment divides the entire solid-state drive's flash memory array into two independent garbage collection areas (e.g., according to flash memory channels or wafer partitions). Figure 3 The system is divided into two garbage collection zones: Garbage Collection Zone 1 and Garbage Collection Zone 2. Garbage collection is performed alternately in these two zones, with only one zone allowed to perform garbage collection at a time. The primary logical page and its corresponding backup logical page are mapped to physical flash pages in the two different zones. For example, if the primary logical page is allocated a flash page in Garbage Collection Zone 1, then the backup logical page for that data needs to be allocated a flash page in Garbage Collection Zone 2.
[0045] This embodiment, by employing the aforementioned storage partitioning and alternating garbage collection method, enables garbage collection to only interfere with the flash memory within a portion of the solid-state drive.
[0046] It is understandable that storage partitions are not limited to two partitions; they can also be divided into multiple areas. That is, there can be multiple backup data and multiple garbage collection areas. As long as the primary data and backup data are placed separately and garbage collection is performed alternately in multiple flash memory areas, the requirement of request redirection can be met.
[0047] To ensure that only one area performs garbage collection in the same time period and different areas are executed in a cycle, in step S02, the embodiment further includes recording the free space and invalid data of the solid state disk and each garbage collection area, and maintaining a garbage collection token, which is passed in a cycle among the garbage collection areas. If the free space of the solid state disk is lower than a preset first threshold th1, a garbage collection operation is triggered, and the free space of the target garbage collection area holding the garbage collection token is judged. If the free space is lower than a preset second threshold th2 and the invalid data is higher than a preset third threshold th3, the target garbage collection area is selected to perform garbage collection. Otherwise, the garbage collection token is passed to the next garbage collection area for continuous checking. If all the garbage collection areas are not executed, the garbage collection token is passed to the garbage collection area with the most invalid data to perform garbage collection, so as to realize alternate garbage collection. The preset first threshold th1, the second threshold th2 and the third threshold th3 can be configured according to actual needs.
[0048] Further, the data written can be dispersed in different garbage collection areas as evenly as possible under the premise that the data and the backup data are in different garbage collection areas, so as to avoid that the data written in a certain partition is too much to frequently trigger garbage collection.
[0049] In the embodiment, the address mapping table of the main logical area further uses identification information to identify whether each logical page has backup data, and further records the read access times information of each main logical page by the host software, so as to judge whether the logical page is a hot data page needing backup. If the read access times of the target logical page is greater than a preset threshold, the target logical page is determined as a hot data page needing backup, that is, it can be backed up. Otherwise, it is determined as a cold data page not needing backup, and the access times recorded in the address mapping table of the main logical area are decayed at a specified time interval. The address mapping table of the backup logical area further records the validity information of whether each backup logical page is used as backup data by the main logical page.
[0050] Specifically, the address mapping table of the main logical area uses 1 bit to identify whether the data of each logical page has backup data. Among all the main logical pages sharing the same backup logical page, only one main logical page can use the corresponding backup logical page. Meanwhile, the address mapping table of the main logical area records the read access times information Rcnt of each main logical page by the host software, so as to judge whether the logical page is a hot data page. Meanwhile, all the recorded access times are decayed (such as reduced to 1 / 2 of the original) at a fixed time interval, so as to consider the change of access hotness information over time and avoid data overflow. The address mapping table of the backup logical area records the validity of each backup logical page, that is, whether the logical page is used as backup data by a certain main logical page.
[0051] Referring to Figure 3 In the main logical area and the backup logical area, an address mapping table is maintained respectively. The address mapping table in the main logical area contains the mapping relationship between the logical address LPN and the physical address PPN, and contains the identification information of whether the logical page has backup data (0 represents no backup data, and 1 represents that there is backup data), and the read access times information Rcnt. The address mapping table in the backup logical area contains the mapping relationship between the logical address LPN and the physical address PPN, and the identification information of whether it is valid (1 represents valid, and 0 represents invalid). Taking L1 and L2 as examples in the main logical area in the figure, the corresponding PPN (physical page address) is P1 and P2 respectively, and the access times Rcnt corresponds to C1 and C2 respectively, and the backup data corresponding to L2 is identified as 1, that is, it needs to be backed up, and the backup data is stored in the backup logical area, and the mapping relationship between the logical address LPN and the physical address PPN of the backup data and the validity are stored in the address mapping table in the backup logical area, for example, the LPN is L3, the PPN is P3, and it is valid. When the garbage collection area is allocated, L1 is allocated to the garbage collection area 1, and L2 and L3 are allocated to the garbage collection area 1 and the garbage collection area 2 respectively.
[0052] In this embodiment, the specific steps of step S03 include:
[0053] When a main logical page is written into the solid state disk for the first time and is determined to be cold data and is directly written into the main logical area, the address mapping table of the main logical area is updated, and then the access times of the current main logical page are recorded;
[0054] When the current main logical page is read and written, the garbage collection operation is performed, and whether the current main logical page is a hot data page is determined according to the access times of the current logical page, if it is, whether the corresponding backup logical page is occupied is checked;
[0055] If it is determined that the corresponding backup logical page is not occupied, it is determined that the corresponding backup logical page is directly used to back up the current main logical page when the solid state disk is idle, and the backup identification bit of the main logical page and the valid identification bit of the backup logical page are modified;
[0056] If it is determined that the corresponding backup logical page is occupied, the address mapping table of the main logical area is checked, other main logical pages using the corresponding backup logical page are found, and whether the found main logical page is a hot data page is determined, if it is not, the backup identification bit of the found main logical page is cleared, it is determined that the corresponding backup logical page is used to back up the current main logical page when the solid state disk is idle, and the corresponding mapping information and identification bit are updated.
[0057] Specifically, one main logical page is determined as cold data direct writing when first writing the solid state disk, and the access times of the logical page are recorded, and then it is determined whether the logical page is hot data when reading, writing, and garbage collection migration of the logical page. If a data page is determined as hot data and needs to be backed up, first check whether the corresponding backup logical address is occupied, if not, directly use the backup logical page to write backup data, and modify the backup identification bit of the main logical page and the valid identification bit of the backup logical page; if it is occupied, check the main logical area mapping table, find the main logical page using the backup logical page and check whether it is still hot data, if not, clear the backup identification bit of the main logical page, backup the current logical page and update the related mapping information and identification bit. For backup data writing, it can be written when the solid state disk is idle to reduce the impact on the host read-write request.
[0058] In the embodiment, when performing a write operation on the current data page, if it is a first write operation, the write data is considered as cold data and is directly written into the main logical area, and the address mapping table of the main logical area is updated. If it is a write data update operation, it is determined whether the current write data has backup data, if yes, the corresponding backup data is invalidated, the address mapping table of the backup logical area is updated, it is determined whether the current write data is hot data, if not, only the current main logical page is written, and the address mapping table of the main logical area is updated, if yes, it is further determined whether the corresponding backup logical page is occupied, if not, the current write data is written into the current main logical page and the corresponding backup logical page respectively, and the address mapping tables of the main logical area and the backup logical area are updated; if the backup logical page is occupied, it is determined whether the main logical page occupying the backup logical page is a hot data page, if yes, the current data is only written into the current main logical page, and the address mapping table of the main logical area is updated, if not, the occupied backup data is invalidated, and the backup identification bit of the main logical page occupying the backup logical page is cleared, and then the current data is written into the current main logical page and the corresponding backup logical page respectively, and the address mapping tables of the main logical area and the backup logical area are updated.
[0059] In the specific application embodiment, the detailed steps for generating and processing backup data during a write operation are as follows:
[0060] Step S311. It is determined whether it is a first write operation, if yes, the write data is considered as cold data and is directly written into the main logical area, and the address mapping table (LPN->PPN mapping) of the main logical area is updated, otherwise, it is indicated that it is a write update operation, and step S312 is entered;
[0061] Step S312. It is determined whether the data has backup data, if yes, the backup data is invalidated, the backup area address mapping table is updated, and step S313 is entered;
[0062] Step S313. Determine whether the current write data is hot data. If not, only write to the primary area and update the primary area address mapping table. If yes, go to step S314.
[0063] Step S314. Determine whether the backup area corresponding to the logical address is occupied, i.e., whether it is available. If the backup area is available, write the primary logical area data and the backup data, and update the address mapping table of the primary logical area and the backup logical area. If the backup area is not available, go to step S315.
[0064] Step S315. Determine whether the primary logical data occupying the backup area is hot data. If the primary logical data is hot data, write the current data only to the primary logical area and update the address mapping table of the primary logical area. If the primary logical data is already cold data (the access count will decay), go to step S316.
[0065] Step S316. Inactivate the occupied backup data, clear the backup identification bit of the primary logical data, and then write the current data to the primary logical area and the backup logical area, and update the address mapping table of the primary logical area and the backup logical area.
[0066] Correspondingly, if it is a read operation, the access count of the data will be updated, it is determined whether the current data is hot data that needs to be backed up and whether there is backup data. If it is hot data that needs to be backed up and there is no backup, it is determined whether the backup logical area is available. The remaining steps are the same as those in the write operation.
[0067] In the embodiment, when the garbage collection data migration operation is performed on the current data page, the detailed steps of backup data generation and processing include:
[0068] Step S321. Determine the type of data to be migrated.
[0069] Step S322. If the data to be migrated is the primary logical data, check whether there is backup data of the data to be migrated. If there is, migrate the primary logical data to be migrated to a garbage collection area different from the backup data. If there is not, only modify the address mapping table of the primary logical area.
[0070] Step S323. If the data to be migrated is the backup data, check whether the corresponding primary logical data is still hot data. If yes, migrate the backup data to be migrated to a garbage collection area different from the primary logical data, and modify the address mapping table of the backup logical area. If not, mark the current backup data as invalid, i.e., not needing to be migrated, and simultaneously modify the address mapping table of the primary logical area and the backup logical area.
[0071] It can be understood that the hot data identification method can not be limited to using the read access times of the host software, and can be implemented using other methods, such as using the time interval between the last two accesses, a least recently used (LRU) linked list, or a bloom filter method, as long as the purpose of hot data identification is achieved.
[0072] In this embodiment, the specific steps of step S04 include:
[0073] When the host software reads the main logic page in the main logic area, it is checked whether the garbage collection is currently being performed in the garbage collection area where the current main logic page is located. If the garbage collection is not currently performed, the data of the current main logic page is directly read. If the garbage collection is currently performed, it is checked whether the backup data of the current main logic page exists. If the backup data exists, the backup data of the current main logic page is directly read. If the backup data does not exist, the data in the original garbage collection area is read, and the subsequent processing flow of the read operation is entered.
[0074] When the host software writes the main logic page in the main logic area, the address in the garbage collection area where the garbage collection is not performed is preferentially allocated to write the data. If it is the first time to write the current main logic page or the current main logic page is cold data, only the data in the main logic area is written, and the address mapping table of the main logic area is modified. If it is the update write data, the above-mentioned write data update operation is performed.
[0075] Specifically, when the host software reads a certain logic page in the main area, if the flash page mapped by the logic page is not affected by the garbage collection or the logic page has no backup, the flash page mapped by the logic page is directly read. If the storage area corresponding to the logic page is performing the garbage collection and the logic page has backup data, the backup data of the logic page is directly read, which can eliminate the influence of the garbage collection on the read operation. For the host data write operation, the address in the garbage collection area where the garbage collection is not performed is preferentially allocated to write the data. If it is the first time to write the current main logic page or the current main logic page is cold data, only the data in the main logic area is written, and the address mapping table of the main logic area is correspondingly modified. If it is the update write data, the host data update is performed according to the above-mentioned steps S312~step S316.
[0076] By using the above-mentioned hot data backup and request redirection, the interference of the garbage collection on the host read and write requests can be effectively reduced.
[0077] The embodiment further provides an electronic device including a processor and a memory. The memory is configured to store a computer program. The processor is configured to execute the computer program to perform the above-mentioned method.
[0078] It can be understood that the above method of the embodiment can be executed by a single device, such as a computer or a server, or can be applied to a distributed scenario and completed by multiple devices in cooperation. In the distributed scenario, one of the multiple devices can only execute one or more steps in the above method of the embodiment, and the multiple devices interact to complete the above method. The processor can be implemented in a general-purpose CPU, a microprocessor, an application-specific integrated circuit, or one or more integrated circuits, and is configured to execute a related program to implement the above method of the embodiment. The memory can be implemented in a read-only memory (ROM), a random access memory (RAM), a static storage device, and a dynamic storage device. The memory can store an operating system and other application programs. When the above method of the embodiment is implemented by software or firmware, the related program code is stored in the memory and executed by the processor.
[0079] The embodiment further provides a computer readable storage medium storing a computer program, which, when executed by a processor, implements the above method.
[0080] Those skilled in the art should understand that the above-mentioned embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can be in the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can be in the form of a computer program product implemented on one or more computer readable storage media (including, but not limited to, disk storage, CD-ROMs, optical storage devices, etc.) containing computer usable program code. The present application is described with reference to flowcharts and / or block diagrams of the methods, apparatus (systems), and computer program products according to embodiments of the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, as well as combinations of flows and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing apparatus to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing apparatus produce a device that implements the functions specified in the flowcharts and / or block diagrams. Figure 1 one or more flows and / or blocks Figure 1 an apparatus with a function specified in one or more flows and / or blocks. These computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing apparatus to work in a specific manner, so that the instructions stored in the computer readable memory produce a manufactured product including an instruction apparatus that implements the functions specified in the flowcharts and / or block diagrams. Figure 1 one or more flows and / or blocks Figure 1The computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart block or blocks. Figure 1 The computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart block or blocks. Figure 1 The computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart block or blocks.
[0081] The above merely preferred embodiments of the present application and not intended to limit the present application in any form. Although the present application has been disclosed with the preferred embodiments as above, it is not intended to limit the present application. Therefore, any simple modification, equivalent change and modification of the above embodiments according to the technical essence of the present application without departing from the technical solution of the present application shall fall within the scope of protection of the technical solution of the present application.
Claims
1. A method for optimizing garbage collection of a solid state disk based on storage partition, characterized in that, Comprise: Step S01. Storage partition: divide the solid state disk logical address space into a main logical area and a backup logical area, the main logical area is used to store the main logical page, and the backup logical area is used to store the backup logical page to realize hot data backup; Step S02. Alternating garbage collection configuration: divide the flash memory array of the entire solid state disk into two or more independent garbage collection areas, the main logical page and the corresponding backup logical page are respectively mapped to the physical flash memory page in different garbage collection areas, and the garbage collection areas are staggered for garbage collection, and only one garbage collection area is allowed to perform garbage collection at the same time; Step S03. Hot data backup: maintain an address mapping table in the main logical area and the backup logical area respectively, to record the address mapping of the logical page to the physical flash memory page, during the reading and writing of the main logical page and the garbage collection data migration operation, determine whether the current main logical page is a hot data page that needs to be backed up, if so, determine whether to backup data in the backup logical page according to the occupied state of the corresponding backup logical page of the current main logical page and update the corresponding address mapping table; Step S04. Request redirection: during the process of reading the logical page in the main logical area or writing the main logical page in the main logical area by the host software, read and write data according to the backup data to realize host request redirection.
2. The method of claim 1, wherein, In step S01, the main logical area is configured as a user visible space, and the backup logical area is configured as only visible in the solid state disk, the logical page addresses of the main logical area and the backup logical area adopt a directly connected mapping mode, wherein all logical pages in the main logical area that satisfy LPN%M=n are determined as hot data pages, and the nth page in the backup logical area is used to store backup data, wherein M is the total number of logical pages in the backup logical area, LPN is the logical address, and n is an integer. 3.The method of claim 1, wherein, In step S02, the free space and invalid data of the solid state disk and each garbage collection area are also recorded, and a garbage collection token is maintained, the garbage collection token is circulated among the garbage collection areas, if the free space of the solid state disk is lower than a preset first threshold th1, the garbage collection operation is triggered, and the free space of the target garbage collection area holding the garbage collection token is judged, if the free space is lower than a preset second threshold th2 and the invalid data is higher than a preset third threshold th3, the target garbage collection area is selected to perform garbage collection, otherwise the garbage collection token is circulated to the next garbage collection area for further checking, if all garbage collection areas are not checked for garbage collection, the garbage collection token is passed to the garbage collection area with the most invalid data and the garbage collection operation is performed, to realize alternating garbage collection.
4. The method of claim 1, wherein, The address mapping table of the main logical area also uses identification information to identify whether each logical page has backup data, and also records read access times information of each main logical page by the host software for judging whether the logical page is a hot data page needing backup, wherein if the read access times of the target logical page is greater than a preset threshold, the target logical page is determined as a hot data page needing backup, otherwise, it is determined as a cold data page not needing backup, and the access times recorded in the address mapping table of the main logical area is decayed at a specified time interval, the address mapping table of the backup logical area also records validity information of whether each backup logical page is used as backup data by the main logical page, wherein only one main logical page uses the corresponding backup logical page among all main logical pages sharing the same backup logical page.
5. The method of claim 1, wherein, Step S03 comprises: When a main logical page is initially written to the solid state disk, it is determined as cold data and directly written to the main logical area, and the address mapping table of the main logical area is updated, and then the access times of the current main logical page is recorded; When the current main logical page is read and written, garbage collection operation is performed, whether the current main logical page is a hot data page is judged according to the access times of the current main logical page, if yes, whether the corresponding backup logical page is occupied is checked; If it is judged that the corresponding backup logical page is not occupied, it is determined that the corresponding backup logical page is directly used to backup the current main logical page when the solid state disk is idle, and the backup identification bit of the main logical page and the validity identification bit of the backup logical page are modified; If it is judged that the corresponding backup logical page is occupied, the address mapping table of the main logical area is checked, other main logical pages using the corresponding backup logical page are found, and whether the found main logical page is a hot data page is judged, if not, the backup identification bit of the found main logical page is cleared, the corresponding backup logical page is determined to be used to backup the current main logical page when the solid state disk is idle, and the corresponding mapping information and identification bit are updated.
6. The method of claim 5, wherein, When the current data page is written, and if it is a write data update operation, whether the current write data has backup data is judged, if yes, the corresponding backup data is invalidated, the address mapping table of the backup logical area is updated, whether the current write data is hot data is judged, if not, only the current main logical page is written, and the address mapping table of the main logical area is updated, if yes, whether the corresponding backup logical page is occupied is judged, if not, the current write data is written to the current main logical page and the corresponding backup logical page respectively, and the address mapping table of the main logical area and the backup logical area is updated, if the backup logical page is occupied, whether the main logical page occupying the backup logical page is a hot data page is judged, if yes, the current data is only written to the current main logical page, and the address mapping table of the main logical area is updated, if the main logical page occupying the backup logical page is a cold data page, the occupied backup data is invalidated, and the backup identification bit of the main logical page occupying the backup logical page is cleared, then the current data is written to the current main logical page and the corresponding backup logical page respectively, and the address mapping table of the main logical area and the backup logical area is updated.
7. The method of claim 5, wherein the garbage collection optimization is performed by a storage partition based solid state disk. When the garbage collection data migration operation is performed on the current data page, the type of data to be migrated is determined, if the data to be migrated is the main logic data, it is checked whether the backup data exists, if the backup data exists, the main logic data to be migrated is migrated to the garbage collection area different from the backup data, if the backup data does not exist, only the address mapping table of the main logic area is modified; if the data to be migrated is the backup data, it is checked whether the corresponding main logic data is still hot data, if yes, the backup data to be migrated is migrated to the garbage collection area different from the main logic data, and the address mapping table of the backup logic area is modified, if not, the current backup data is marked as invalid so that it is not necessary to migrate, and the address mapping tables of the main logic area and the backup logic area are modified.
8. The method according to any one of claims 1 to 7, wherein, Step S04 comprises: When the host software reads the main logic page in the main logic area, it is checked whether the garbage collection is currently being performed in the garbage collection area where the current main logic page is located, if the garbage collection is not currently performed, the data of the current main logic page is directly read, if the garbage collection is currently performed, it is checked whether the backup data of the current main logic page exists, if yes, the backup data of the current main logic page is directly read, if no, the data in the original garbage collection area is read; When the host software writes the main logic page in the main logic area, the address in the garbage collection area where the garbage collection is not performed is preferentially allocated to write the data, wherein, if the current main logic page is written for the first time or the current main logic page is cold data, only the main logic area data is written, and the address mapping table of the main logic area is modified; if the data is updated, the data update operation is performed.
9. An electronic device comprising a processor and a memory for storing a computer program, characterized in that The processor is configured to execute the computer program to perform the method of any one of claims 1-8.
10. A computer readable storage medium storing a computer program, characterized in that, The computer program is executed by the processor to implement the method of any one of claims 1-8.
Citation Information
Patent Citations
Data write-in method, memorizer control circuit unit and memorizer storage device
CN104793891A
Garbage collection in a storage system
US20130346720A1