Data migration method and device for solid state disk, equipment and storage medium
By setting interval transfer rules in solid-state drives, the write performance jitter problem caused by unbalanced distribution of effective data in physical blocks is solved, and the effect of improving the stability of random write performance is achieved.
Patent Information
- Application Number
- CN202411364868.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-27
- Publication Date
- 2025-02-07
AI Technical Summary
In solid-state drives, when the effective data is distributed unevenly within the physical block, garbage collection (Gc) may cause continuous migration of invalid data and valid data when moving data, resulting in write performance jitter and affecting random write performance.
By obtaining the data information of the physical block to be moved, setting interval transfer rules according to the data information, and moving valid data to the idle physical block to be received according to the interval transfer rules. The method includes dividing multiple zones and setting a moving order for each zone to ensure balanced moving of effective data.
It effectively solves the problem of Gc write rate fluctuation caused by uneven distribution of effective data in physical blocks, and improves the stability of random write performance.
Smart Images

Figure CN119396334A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of storage technology, and in particular to a data migration method, device, equipment and storage medium for a solid state hard disk. Background Art
[0002] With the development of modern computer systems, memory management has become a key issue. In order to optimize memory usage and improve system performance, the garbage collection (GC) mechanism is widely used in various programming languages and runtime environments.
[0003] The main goal of GC is to automatically detect and reclaim memory space that is no longer in use. GC also plays a key role in SSDs (such as NAND Flash-based storage devices). To ensure that the SSD has sufficient free space, GC deletes invalid data in NAND Flash and moves valid data to new blocks.
[0004] However, when valid data is unevenly distributed within the block, if GC moves data in the order of page numbers, invalid data and valid data may be moved continuously. This may cause jitter in GC write performance, thereby affecting the overall system random write performance. Summary of the invention
[0005] In order to solve the above technical problems, the embodiments of the present disclosure provide a method, device, equipment and storage medium for migrating data of a solid state drive.
[0006] In a first aspect, an embodiment of the present disclosure provides a method for migrating data from a solid state drive, comprising:
[0007] Determine a physical block to be moved for which valid data is to be moved from a plurality of physical blocks included in the solid state drive; wherein the physical block to be moved includes a plurality of pages, and the plurality of pages store invalid data and / or valid data;
[0008] Acquire data information of the physical block to be moved; wherein the data information represents the distribution of the multiple pages in the physical block to be moved;
[0009] Setting an interval migration rule according to the data information; wherein the interval migration rule represents a migration order for the plurality of pages;
[0010] The valid data in the multiple pages are moved to idle physical blocks to be received among the multiple physical blocks according to the interval moving rule.
[0011] Optionally, setting an interval migration rule according to the data information includes:
[0012] Dividing the plurality of pages into a plurality of regions according to the data information; wherein each region includes at least one page, and each region has no intersection;
[0013] A first migration order between the plurality of zones and a second migration order between at least one page in each zone are set to generate an interval migration rule.
[0014] Optionally, dividing the plurality of pages into a plurality of regions according to the data information includes:
[0015] Determine, according to the data information, a plurality of target pages in which the amount of valid data or the amount of invalid data stored is within a set amount range, and count the maximum number of consecutive numbers in the plurality of target pages;
[0016] The plurality of pages are divided into a plurality of regions based on the maximum contiguous number.
[0017] Optionally, setting a first migration order between the plurality of zones and a second migration order between at least one page in each zone to generate an interval migration rule includes:
[0018] Setting a first migration order between the plurality of zones to: random migration or migration in order of zone numbers of the plurality of zones, until all valid data of the plurality of zones are migrated;
[0019] Set the second migration order between at least one page in each zone at each migration;
[0020] An interval moving rule is generated according to the first moving sequence and the second moving sequence.
[0021] Optionally, the second migration order between at least one page in each zone is:
[0022] The Nth page that has not been moved; or,
[0023] Randomly moved; or
[0024] Move in the order of page numbers of the at least one page; or,
[0025] At least one page in the first zone is moved in a page number sequence, and at least one page in the second zone is moved randomly; wherein the plurality of zones include the first zone and the second zone.
[0026] Optionally, setting an interval migration rule according to the data information includes:
[0027] Determine a writing mode according to the logical block addresses when the plurality of pages are written with data, wherein the writing mode includes sequential writing and random writing;
[0028] Dividing the plurality of pages into a plurality of zones based on the writing mode, and setting a distribution type for each zone; wherein the distribution type includes sequential distribution and random distribution, and the writing mode corresponding to at least one page in each zone is the same;
[0029] Setting a first migration order between the plurality of zones as follows: alternately migrating zones according to the distribution type corresponding to each zone, or migrating all zones of other distribution types after migrating all zones of the target distribution type;
[0030] Setting a second migration order between at least one page in each zone as follows: sequential migration between at least one page in each zone in the sequential distribution and random migration between at least one page in each zone in the random distribution;
[0031] An interval moving rule is generated according to the first moving sequence and the second moving sequence.
[0032] Optionally, before the valid data in the multiple pages are moved to the idle physical blocks to be received in the multiple physical blocks according to the interval moving rule, the method further includes:
[0033] Determining a target migration rule in the random migration rule and the interval migration rule; wherein the random migration rule refers to randomly and non-repeatedly migrating valid data;
[0034] If the random migration rule is selected as the target migration rule, the valid data in the multiple pages are randomly and non-repetitively moved to the idle physical blocks to be received in the multiple physical blocks; or,
[0035] The moving of valid data in the multiple pages to the idle physical blocks to be received among the multiple physical blocks according to the interval moving rule includes: if the interval moving rule is selected as the target moving rule, the moving of valid data in the multiple pages to the physical blocks to be received according to the interval moving rule.
[0036] In a second aspect, an embodiment of the present disclosure provides a data migration device for a solid state hard disk, comprising:
[0037] A determination unit, configured to determine a physical block to be moved for which valid data is to be moved from a plurality of physical blocks included in the solid state drive; wherein the physical block to be moved includes a plurality of pages, and the plurality of pages store invalid data and / or valid data;
[0038] An acquisition unit, configured to acquire data information of the physical block to be moved; wherein the data information represents the distribution of the plurality of pages in the physical block to be moved;
[0039] A setting unit, configured to set an interval moving rule according to the data information; wherein the interval moving rule represents a moving order for the plurality of pages;
[0040] A moving unit is used to move the valid data in the multiple pages to the idle physical blocks to be received in the multiple physical blocks according to the interval moving rule.
[0041] In a third aspect, an embodiment of the present disclosure provides an electronic device, including:
[0042] Memory;
[0043] Processor; and
[0044] Computer programs;
[0045] The computer program is stored in the memory and is configured to be executed by the processor to implement the data migration method of the solid state drive as described above.
[0046] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the steps of the method for migrating data from a solid state drive as described above are implemented.
[0047] The data migration method of the solid-state hard disk provided by the present disclosure includes: determining a physical block to be migrated for effective data migration among multiple physical blocks included in the solid-state hard disk; wherein the physical block to be migrated includes multiple pages, and the multiple pages store invalid data and / or effective data; obtaining data information of the physical block to be migrated; wherein the data information represents the distribution of multiple pages in the physical block to be migrated; setting an interval migration rule according to the data information; wherein the interval migration rule represents the migration order for multiple pages; and migrating the effective data in the multiple pages to the idle physical blocks to be received in the multiple physical blocks according to the interval migration rule. The method provided by the present application solves the problem of fluctuations in the garbage collection write rate caused by the uneven distribution of effective data inside the physical block, and improves the stability of random write performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0049] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0050] Figure 1 A schematic diagram of a data migration principle provided by an embodiment of the present disclosure;
[0051] Figure 2 A schematic diagram of write performance fluctuation during data migration provided by an embodiment of the present disclosure;
[0052] Figure 3 A schematic diagram of a flow chart of a method for moving data of a solid state drive provided in an embodiment of the present disclosure;
[0053] Figure 4 A structural diagram of another data migration principle provided by an embodiment of the present disclosure;
[0054] Figure 5 A schematic diagram of another write performance fluctuation during data migration provided by an embodiment of the present disclosure;
[0055] Figure 6 A structural schematic diagram of a data migration device for a solid state hard disk provided in an embodiment of the present disclosure;
[0056] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0057] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.
[0058] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.
[0059] Specifically, Nand Flash (NAND flash memory) is a non-volatile storage device with the advantages of large capacity, small size, and low power consumption. The write unit of Nand Flash is page, and the erase unit is a block (physical block) composed of multiple pages. A page must be erased before writing. This feature requires the use of the Gc (garbage collection) function to move the valid data distributed inside the block to the new block, thereby releasing more free space. The above-mentioned move before writing is determined by the physical characteristics of Nand Flash. The storage unit of Nand Flash is read and written in pages, and the erase operation is moved in blocks. Due to this characteristic of Nand Flash, the programming brings the side effect of write amplification, that is, an erase operation is required before each data is written, which increases the complexity and cost of the write operation.
[0060] When writing data randomly through the host, for example, when the host writes data to a new Block, Gc will move the valid data in the selected Block and write it to a new Block. The amount of data written by the Host and the amount of data written by Gc maintain a specific ratio, which can ensure the stability of the free space size. This function can be understood as flow control (FlowCtrl). Usually, flow control will release the corresponding amount of Host write data according to the number of Gc writes. Therefore, it can be seen that the write performance of the host is proportional to the write performance of Gc. Gc moves the write data based on the valid data in the scanned and moved Block. When Gc scans and moves Blocks, it usually moves them in order from small to large according to the page number. However, the valid data in the Block is unevenly distributed. If the valid data is unevenly distributed in the Block, it will cause the write performance of Gc to jitter when moving a Block, thereby affecting the jitter of the host write performance.
[0061] For example, see Figure 1 , Figure 1A structural diagram of a data migration principle provided by an embodiment of the present disclosure, wherein a Block includes multiple pages, and the pages are numbered from page 0 to page max, and the effective data is not evenly distributed within the Block. Specifically, near the beginning of the migration sequence, page 0 to page k basically does not contain effective data, that is, page 0 to page k do not include effective data, and are all invalid data. Near the middle of the migration sequence, page k+1 to page m has less effective data, that is, page k+1 to page m includes less effective data and more invalid data. Near the end of the migration sequence, page m+1 to page max has more effective data, that is, page m+1 to page max includes more effective data and less invalid data. In the traditional design, when Gc is migrated, it is migrated from page 0 to page max according to the page number. The migration of Gc includes three steps. During the entire migration process, if the effective data is unevenly distributed, the difference in the amount of effective data migrated before and after is relatively large. The three steps of Gc migration include: 1) reading valid data; 2) comparing the mapping table to confirm that the data is valid; 3) writing the valid data into a new Block.
[0062] exist Figure 1 Based on the example, the host write performance during GC migration is divided into three stages:
[0063] Phase 1 page 0 to page k: The page does not contain valid data, all of which are invalid data. Therefore, the Gc migration only includes steps 1) and 2) (reading valid data and comparing the mapping table), and there is no step 3) to write valid data. At this time, the performance of Gcwrite (write) is 0, and the corresponding host write performance is also 0.
[0064] Phase 2: Page k+1 to page m: The page contains less valid data. The Gc migration includes steps 1) and 2) as well as a small amount of step 3). The amount of data written is relatively small. At this time, the Gc write performance is low, and the corresponding host write performance is also low.
[0065] Stage 3: Page m+1 to page max: The page contains more valid data. The Gc migration includes steps 1), 2), and a large number of steps 3). A lot of data is written. At this time, the Gc write performance is higher, and the corresponding host write performance is also higher.
[0066] In the traditional migration process, the valid data of the three stages are executed in the order of page numbers. Therefore, when performing host write performance testing, it can be found that the host write performance is basically 0 when migrating page 0-page k. After this part of the migration is completed, the host write performance between page k+1-page m has improved to a certain extent, but it is still low. When it comes to page m+1-page max, the host write performance has been improved again, and the host write performance is higher than the average. In the end, the random write performance fluctuates greatly. Figure 2 As shown in the figure, when the pages are moved sequentially according to the page numbers, the write performance fluctuates greatly and the stability is relatively poor.
[0067] In view of the above technical problems, the disclosed embodiment provides a method for data migration of a solid state drive. According to the distribution of valid data in the page inside the Block, an interval migration rule is set, that is, the valid data in the page is moved at a certain interval. The write performance of a single page does not affect the rate of the Gc. Only when multiple consecutive pages are valid data or invalid data will performance jitter occur. Therefore, the interval migration method can effectively solve the problem of fluctuations in the Gc write rate caused by the uneven distribution of valid data inside the Block, and improve the stability of the host write performance. Detailed description is given through one or more of the following embodiments.
[0068] The data migration method of the solid-state hard disk provided in the embodiment of the present disclosure can be applied to the scenario where Gc migrates valid data in a Block. The method can be executed by a data migration device of a solid-state hard disk, which can be implemented by software and / or hardware, and the device can be integrated in an electronic device. Among them, the electronic device can include but is not limited to mobile terminals such as smart phones, laptops, digital broadcast receivers, personal digital assistants (PDA), tablet computers (Tablet Personal Computer, Tablet PC), PMP (portable multimedia player), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), wearable devices, etc., and fixed terminals such as digital televisions, desktop computers, smart home devices, etc.
[0069] Figure 2 A flow chart of a method for moving data from a solid state drive provided in an embodiment of the present disclosure, specifically comprising: Figure 2 The following steps are shown:
[0070] S201. Determine a physical block to be moved for effective data migration among a plurality of physical blocks included in a solid state drive.
[0071] The physical block to be moved includes a plurality of pages, and the plurality of pages store invalid data and / or valid data.
[0072] It is understandable that the solid-state drive includes multiple physical blocks (Blocks), and the multiple physical blocks include physical blocks to be moved to which valid data is to be moved and physical blocks to be received to which valid data is to be received, that is, the valid data in the physical blocks to be moved is written into the physical blocks to be received through Gc, wherein the physical blocks to be received are idle physical blocks, and idle means that no data movement or other data processing operations are required. The physical blocks to be moved to which valid data is to be moved are determined from the multiple physical blocks. Specifically, the physical blocks can issue garbage collection requests, and the physical blocks to be moved are determined according to the garbage collection requests, wherein garbage collection in the solid-state drive refers to moving the valid data in the physical blocks to be moved to the physical blocks to be received, and then deleting the physical blocks to be moved or deleting the data in the physical blocks to be moved.
[0073] It is understandable that the physical block to be moved includes multiple pages. The physical block stores and reads data by pages, and erases data by blocks. Among them, multiple pages store invalid data and / or valid data, that is, the data types stored in multiple pages can be divided into valid data and invalid data. For example, Figure 1 In the pages shown, page 0 stores all invalid data, and page max stores more valid data and less invalid data, which means that the data type stored in each page is not a completely single type.
[0074] S202: Acquire data information of the physical block to be moved.
[0075] The data information represents the distribution of the multiple pages in the physical block to be moved.
[0076] It is understandable that, based on the above S201, data information of the physical block to be moved is obtained, and the data information represents the distribution of multiple pages in the physical block to be moved, and can also represent the inclusion of valid data in each page, for example, Figure 1 As shown in the distribution, the first type of pages containing invalid data are distributed in the first half of the physical block, the second type of pages containing less valid data are distributed in the middle part of the physical block, and the third type of pages containing more valid data are distributed in the second half of the physical block.
[0077] S203: Setting interval migration rules according to the data information.
[0078] The interval migration rule represents the migration order of the plurality of pages according to the set interval.
[0079] It can be understood that on the basis of the above S202, the interval migration rule is set according to the data information. The interval migration rule represents the migration order when multiple pages are moved according to the set interval. The interval migration rule stipulates that the internal movement of the physical block to be moved is not moved in sequence / sequentially according to the page number, but is moved at a certain interval to reduce the impact of the uneven distribution of valid data on the write performance. The host write performance of a single page will not affect the write rate of the entire Gc, thereby avoiding performance jitter caused by continuous movement of valid data or invalid data.
[0080] Optionally, the interval migration rule is set according to the data information, which can be implemented by the following steps:
[0081] The multiple pages are divided into multiple zones according to the data information; each zone includes at least one page, and there is no intersection between the zones; a first migration order between the multiple zones and a second migration order between at least one page in each zone are set to generate an interval migration rule.
[0082] It is understandable that, according to the inclusion of valid data in multiple pages and the distribution of multiple pages, multiple pages are divided into multiple zones, each zone includes at least one page, and each zone does not have an intersection, that is, each zone does not have a duplicate page, and the number of at least one page included in each zone may be the same or different. Specifically, dividing multiple pages into multiple zones means dividing multiple pages into multiple zones based on the order of multiple pages in the physical block to be moved, and the overall order of multiple pages in the physical block to be moved is not modified. For example, before the zone division, page 0 refers to the first page in the physical block to be moved, and after the zone division, page 0 refers to the first page in the first zone in the physical block to be moved, so that the multiple pages can be subsequently partitioned and moved, that is, multiple pages are moved at intervals in units of zones. After the multiple pages are divided into multiple zones, a first migration order between multiple zones and a second migration order between at least one page in a single page are set, and an interval migration rule is generated accordingly, wherein the first migration order refers to the migration order between zones, and the second migration order refers to the migration order between pages.
[0083] Optionally, dividing the multiple pages into multiple regions according to the data information may be implemented by the following steps:
[0084] According to the data information, multiple target pages whose stored valid data amount or invalid data amount is within a set amount range are determined in the multiple pages, and the maximum continuous number of consecutive numbers in the multiple target pages is counted; based on the maximum continuous number, the multiple pages are divided into multiple zones.
[0085] Understandably, the amount of valid data or invalid data stored / contained in each page is counted, and multiple target pages whose amount of valid data or invalid data is within a set amount range are determined among multiple pages. The amount of valid data refers to the proportion or degree of valid data contained in each page. For example, page 0 contains more valid data, and its amount of valid data is relatively large (80%), and its amount of invalid data is relatively small (20%). In this case, the target page can be determined as the page with a similar amount of valid data or invalid data and within the set amount range (80%-85%). After determining the target page, the maximum continuous number of consecutive numbers in multiple target pages is counted, or the maximum continuous number of sequentially connected target pages is counted. For example, the number of pages included in the current Block is 4176. If the amount of valid data of more than 100 consecutive pages is within the range of 80%-85%, and the amount of invalid data of the next 100 pages is also within the range of 80%-85%, then the maximum continuous number can be determined as 100. The transfer of such a large amount of continuous valid data and a large amount of continuous invalid data will cause performance jitter. After determining the maximum continuous number, the set interval is calculated according to the ratio of the number of pages to the maximum continuous number, and the multiple pages are divided into multiple zones according to the set interval. Based on the above example, the set interval is 4176 / 100=42 (that is, by rounding, the interval is 42), and the multiple pages are divided into multiple zones according to the set interval, each zone including 42 pages. Alternatively, the set interval can be preset, and the multiple pages are directly divided into multiple zones according to the preset set interval.
[0086] It is understandable that when the effective data is subsequently moved based on the interval migration rule, the set interval can also be adjusted in real time according to the migration situation.
[0087] For example, see Figure 3 , Figure 3 A structural diagram of another data migration principle provided for an embodiment of the present disclosure, wherein a Block includes M pages numbered from 0 to max, an interval is set to N, and each zone is divided into N pages, so that M / N zones can be divided, which are recorded as zone 0-zone j.
[0088] Optionally, the above setting of the first migration order between the multiple zones and the second migration order between at least one page in each zone to generate the interval migration rule can be specifically implemented by the following steps:
[0089] A first migration order between the multiple zones is set to: randomly migrate or migrate in order of the zone numbers of the multiple zones until all valid data of the multiple zones are migrated; a second migration order between at least one page in each zone is set each time the migration occurs; and an interval migration rule is generated according to the first migration order and the second migration order.
[0090] It is understandable that the first migration order between multiple zones is set as: random migration or migration in the order of zone numbers of multiple zones until the valid data of all zones are migrated, wherein the random migration between multiple zones refers to the random and non-repetitive migration of a certain page between multiple zones in one migration, and one migration refers to the migration of a page in multiple zones in the same cycle; the zone number refers to the above-mentioned zone 0-zone j, and migration in the order of zone numbers of multiple zones refers to the sequential migration of the valid data of a page in zone 0-zone j until the valid data of all zones are completely migrated, that is, each zone will be migrated periodically. The second migration order between at least one page in each zone is set at each migration. For the same zone, the second migration order set at each migration can be the same or different. For example, in the process from the first migration to the tenth migration, at least one page in the first zone is randomly migrated, and after the tenth migration, at least one page in the first zone is migrated in the order of page numbers. After the first moving order and the second moving order are set, the interval moving rule is generated according to the first moving rule and the second moving rule, that is, the two moving rules are integrated to generate the final interval moving rule.
[0091] Optionally, the second migration order between at least one page in each zone is:
[0092] The Nth page that has not been moved; or, randomly moved; or, moved in the order of page numbers of the at least one page; or, at least one page in the first zone is moved in the order of page numbers, and at least one page in the second zone is randomly moved; wherein the multiple zones include the first zone and the second zone.
[0093] It is understandable that the second migration order between at least one page in each interval is: the Nth page that has not been moved, with the Nth page as an interval, random migration, migration in the order of page numbers, or different migration methods for each area / part of the area. Specifically, based on the above example, the order of Gc migration is: 0→N→2N→3N→4N.....→1→(1+N)→(1+2N)→(1+3N)........, that is, in the first migration, the first page in each area is moved, in the second migration, the second page in each area is moved, and so on, to complete the migration of valid data on all pages. Figure 3As shown in the figure, the order of Gc moving pages for sequential migration between multiple zones and sequential migration between at least one page in each zone is: page 0, page k+1, page m+1..., where page 0 belongs to zone 0, page k+1 belongs to zone n, and page m+1 belongs to zone i. Furthermore, page 0 has no valid data, page k+1 contains less valid data, and page m+1 contains more valid data. In the final migration, the uneven distribution of valid data within the Block is solved, making the data migration rate more balanced during the entire migration process, thereby avoiding jitter in random write performance. Random migration means randomly selecting a page in each zone for migration. The order of Gc moving pages is: randomly selecting a page in each zone for migration. In addition, different migration methods can be selected in each zone, or some zones can adopt the first migration method and other zones can adopt the second migration method. For example, the first zone adopts a random migration method and the second zone adopts a sequential migration method. The order in which Gc moves pages is: zone 0-zone n adopts a method in which a page is randomly selected within the zone for migration, and zonei-zone j adopts a method in which pages are sequentially selected within the zone for migration.
[0094] Optionally, the interval migration rule is set according to the data information, which can be implemented by the following steps:
[0095] Determine a write mode according to a logical block address when data is written to the multiple pages, the write mode including sequential write and random write; divide the multiple pages into multiple zones based on the write mode, and set a distribution type for each zone; wherein the distribution type includes sequential distribution and random distribution, and the write mode corresponding to at least one page in each zone is the same; set a first migration order between the multiple zones to: alternately migrate according to the distribution type corresponding to each zone, or migrate all zones of other distribution types after all zones of the target distribution type are migrated; set a second migration order between at least one page in each zone to: sequentially migrate at least one page in each zone of the sequential distribution, and randomly migrate at least one page in each zone of the random distribution; generate an interval migration rule according to the first migration order and the second migration order.
[0096] It is understandable that when data is written to a physical block, it can determine whether each page is written sequentially or randomly according to the logical block address (LogicalBlock Address, LBA) of the written data. The logical block addresses when data is written to multiple pages are obtained, and the writing mode of each page is determined according to the logical block addresses. The writing modes include random writing and sequential writing. After determining the writing mode of each page, the multiple pages are divided into multiple zones according to the writing mode, and a distribution type is set for each zone. The distribution type includes random distribution and sequential distribution. The writing mode corresponding to at least one page in each zone is the same. Specifically, at least one continuous page with the same writing mode is divided into one zone. For example, page 0-page 10 has the same writing mode and is a continuous page, so page 0-page 10 is divided into zone 0, page 11-page 15 has the same writing mode and is a continuous page, so page 11-page 15 is divided into zone 1, and the writing modes of zone 0 and zone 1 are different. In addition, the number of all pages that have the same writing method and are continuous pages can be counted, and they can be divided into different zones again at intervals of a preset number. For example, the preset number is 5, and page 0-page 10 in the above example is divided into 2 zones. After completing the division of multiple zones, set a first migration order between multiple zones and a second migration order between at least one page in each zone. Specifically, the first migration order is: alternate migration according to the distribution type corresponding to each zone, or after all zones of the target distribution type are migrated, all zones of other distribution types are migrated. Alternating migration of distribution types means first migrating a first zone of sequential distribution, then migrating a second zone of random distribution, and then migrating a third zone of sequential distribution, and so on; the second migration order is: sequential migration between at least one page in each zone of sequential distribution, and random migration between at least one page in each zone of random distribution. For example, for the sequentially distributed zone 0, the page is first selected sequentially within the zone for migration. After the sequentially distributed zone 0 is completely written, a page is randomly selected within the randomly distributed zone 1 for migration. That is, for the sequentially written zone, the migration method of sequentially reading valid data is maintained, and for the randomly written zone, the migration method of randomly reading valid data across zones is executed.
[0097] S204: Move valid data in the multiple pages to idle physical blocks to be received among the multiple physical blocks according to the interval migration rule.
[0098] It can be understood that, based on the above S203, according to the first migration rule between multiple zones and the second migration rule between at least one page in each zone in the above-determined interval migration rules, the valid data in multiple pages are moved to the physical block to be received. The specific interval migration rules can be found in the above embodiment and will not be elaborated here.
[0099] Optionally, the valid data in the multiple pages are moved before the idle physical blocks to be received in the multiple physical blocks according to the interval moving rule, and the method further includes:
[0100] A target moving rule is determined between the random moving rule and the interval moving rule; wherein the random moving rule refers to random and non-repetitive moving of valid data; if the random moving rule is selected as the target moving rule, the valid data in the multiple pages are randomly and non-repetitively moved to the idle physical blocks to be received in the multiple physical blocks; or, if the interval moving rule is selected as the target moving rule, the valid data in the multiple pages are moved to the physical blocks to be received according to the interval moving rule.
[0101] Understandably, after determining the physical block to be moved, you can also directly use the random move rule to move valid data in multiple pages to the physical block to be received. The random move rule refers to the random move method. Generally, valid data is randomly distributed in different pages within the Block, but in some special scenarios, for example, all valid data is concentrated in page 0-page1000, and page 1001-page 4175 is all invalid data. According to the traditional move method based on the numbering sequence, from page 0 to page 4175, when moving page 0 to page1000, Gc can move all valid data, but when moving page 1001-page 4175, there is no valid data. This situation will cause Gc to move valid data in page 0-page1000 at a fast move rate, and when moving valid data in page 1001-page 4175, the move rate is slow or even 0, which will cause write performance jitter. The random migration method means changing the original migration order of page 0-page 4175 to a random migration order from page 0-page 4175 without duplication. Because the number of the migrated pages is random, in the above scenario, after migrating a page, whether the next page to be moved has more valid data or more invalid data is randomized. The performance of a single page will not affect the rate of GC. Only when multiple consecutive pages (for example, more than 100 pages) are all invalid data or all valid data, will performance jitter occur.
[0102] It is understandable that a target moving rule can also be selected from the random moving rule and the above-generated interval moving rule. If the random moving rule is selected as the target moving rule, the valid data in multiple pages are randomly and non-repetitively moved to the physical block to be received; or, if the interval moving rule is selected as the target moving rule, the valid data in multiple pages are moved to the physical block to be received according to the interval moving rule. The specific moving order of the interval moving rule can be found in the above embodiment and will not be repeated here.
[0103] For example, see Figure 5 , Figure 5 Another schematic diagram of write performance fluctuation during data migration provided by the present disclosure is compared with Figure 2 When the effective data is written into the new block by using the interval migration method, the write performance fluctuates less, there is almost no jitter, and the write stability is also better.
[0104] A method for data migration of a solid-state hard disk provided by an embodiment of the present disclosure can generate an interval migration rule according to the distribution of valid data in the physical block to be moved after determining the physical block to be moved. The interval migration rule means that the internal movement of the physical block to be moved is not carried out in sequence from 0 to max according to the page number, but the pages are moved according to the set interval. For example, the valid data is moved in units of zones. A random migration rule can also be directly adopted, that is, the migration order of multiple pages is randomized. This interval migration method and random migration time effectively solve the problem that the uneven distribution of valid data in the physical block causes the Gc migration performance to fluctuate, thereby affecting the random write performance, and further optimizes the stability of the random write performance.
[0105] Figure 6 The structure diagram of a data migration device for a solid state hard disk provided in an embodiment of the present disclosure is shown in FIG. The data migration device for a solid state hard disk provided in an embodiment of the present disclosure can execute the processing flow provided in an embodiment of a data migration method for a solid state hard disk, such as Figure 6 As shown, the data migration device 600 of the solid state hard disk includes a determination unit 601, an acquisition unit 602, a setting unit 603 and a migration unit 604, wherein:
[0106] The determining unit 601 is used to determine a physical block to be moved for valid data migration from a plurality of physical blocks included in the solid state drive; wherein the physical block to be moved includes a plurality of pages, and the plurality of pages store invalid data and / or valid data;
[0107] The acquisition unit 602 is used to acquire data information of the physical block to be moved; wherein the data information represents the distribution of the multiple pages in the physical block to be moved;
[0108] A setting unit 603 is used to set an interval migration rule according to the data information; wherein the interval migration rule represents the migration order of the multiple pages;
[0109] The moving unit 604 is used to move the valid data in the multiple pages to the idle physical blocks to be received in the multiple physical blocks according to the interval moving rule.
[0110] Optionally, the setting unit 603 is used to:
[0111] Dividing the plurality of pages into a plurality of regions according to the data information; wherein each region includes at least one page, and each region has no intersection;
[0112] A first migration order between the plurality of zones and a second migration order between at least one page in each zone are set to generate an interval migration rule.
[0113] Optionally, the setting unit 603 is used to:
[0114] Determine, according to the data information, a plurality of target pages in which the amount of valid data or the amount of invalid data stored is within a set amount range, and count the maximum number of consecutive numbers in the plurality of target pages;
[0115] The plurality of pages are divided into a plurality of regions based on the maximum contiguous number.
[0116] Optionally, the setting unit 603 is used to:
[0117] Setting a first migration order between the plurality of zones to: random migration or migration in order of zone numbers of the plurality of zones, until all valid data of the plurality of zones are migrated;
[0118] Set the second migration order between at least one page in each zone at each migration;
[0119] An interval moving rule is generated according to the first moving sequence and the second moving sequence.
[0120] Optionally, the second migration order between at least one page in each zone is:
[0121] The Nth page that has not been moved; or,
[0122] Randomly moved; or
[0123] Move in the order of page numbers of the at least one page; or,
[0124] At least one page in the first zone is moved in a page number sequence, and at least one page in the second zone is moved randomly; wherein the plurality of zones include the first zone and the second zone.
[0125] Optionally, the setting unit 603 is used to:
[0126] Determine a writing mode according to the logical block addresses when the plurality of pages are written with data, wherein the writing mode includes sequential writing and random writing;
[0127] Dividing the plurality of pages into a plurality of zones based on the writing mode, and setting a distribution type for each zone; wherein the distribution type includes sequential distribution and random distribution, and the writing mode corresponding to at least one page in each zone is the same;
[0128] Setting a first migration order between the plurality of zones as follows: alternately migrating zones according to the distribution type corresponding to each zone, or migrating all zones of other distribution types after migrating all zones of the target distribution type;
[0129] Setting a second migration order between at least one page in each zone as follows: sequential migration between at least one page in each zone in the sequential distribution and random migration between at least one page in each zone in the random distribution;
[0130] An interval moving rule is generated according to the first moving sequence and the second moving sequence.
[0131] Optionally, the data migration device 600 of the solid state hard disk is also used for:
[0132] Determining a target migration rule in the random migration rule and the interval migration rule; wherein the random migration rule refers to randomly and non-repeatedly migrating valid data;
[0133] If the random migration rule is selected as the target migration rule, the valid data in the multiple pages are randomly and non-repetitively moved to the idle physical blocks to be received in the multiple physical blocks; or,
[0134] The moving of valid data in the multiple pages to the idle physical blocks to be received among the multiple physical blocks according to the interval moving rule includes: if the interval moving rule is selected as the target moving rule, the moving of valid data in the multiple pages to the physical blocks to be received according to the interval moving rule.
[0135] Figure 6 The data migration device of the solid state hard disk of the illustrated embodiment can be used to execute the technical solution of the above method embodiment, and its implementation principle and technical effect are similar and will not be repeated here.
[0136] Figure 7 This is a schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure. Figure 7, which shows a schematic diagram of the structure of an electronic device 700 suitable for implementing the embodiment of the present disclosure. The electronic device 700 in the embodiment of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle terminals (such as vehicle navigation terminals), wearable electronic devices, etc., and fixed terminals such as digital TVs, desktop computers, smart home devices, etc. Figure 7 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0137] like Figure 7 As shown, the electronic device 700 may include a processing device 701 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage device 708 into a random access memory (RAM) 703 to implement the data migration method of the solid-state hard disk of the embodiment described in the present disclosure. In the RAM 703, various programs and data required for the operation of the electronic device 700 are also stored. The processing device 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0138] Typically, the following devices may be connected to the I / O interface 705: an input device 706 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 707 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 708 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 709. The communication device 709 may allow the electronic device 700 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 7 The electronic device 700 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0139] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains a program code for executing the method shown in the flowchart, thereby implementing the data migration method of the solid-state hard disk as described above. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 709, or installed from the storage device 708, or installed from the ROM 702. When the computer program is executed by the processing device 701, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0140] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0141] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0142] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0143] Optionally, when the above one or more programs are executed by the electronic device, the electronic device may also execute other steps described in the above embodiments.
[0144] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0145] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0146] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the name of a unit does not, in some cases, limit the unit itself.
[0147] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0148] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0149] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or gateway that includes a series of elements includes not only those elements, but also other elements that are not explicitly listed, or also includes elements inherent to such process, method, article or gateway. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or gateway that includes the elements.
[0150] The above description is only a specific embodiment of the present disclosure, so that those skilled in the art can understand or implement the present disclosure. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for migrating data from a solid state drive, characterized in that: include: Determine a physical block to be moved for which valid data is to be moved from a plurality of physical blocks included in the solid state drive; wherein the physical block to be moved includes a plurality of pages, and the plurality of pages store invalid data and / or valid data; Acquire data information of the physical block to be moved; wherein the data information represents the distribution of the multiple pages in the physical block to be moved; Setting an interval migration rule according to the data information; wherein the interval migration rule represents a migration order for the plurality of pages; The valid data in the multiple pages are moved to idle physical blocks to be received among the multiple physical blocks according to the interval moving rule.
2. The method according to claim 1, characterized in that The step of setting the interval migration rule according to the data information includes: Dividing the plurality of pages into a plurality of regions according to the data information; wherein each region includes at least one page, and each region has no intersection; A first migration order between the plurality of zones and a second migration order between at least one page in each zone are set to generate an interval migration rule.
3. The method according to claim 2, characterized in that The dividing the plurality of pages into a plurality of regions according to the data information comprises: Determine, according to the data information, a plurality of target pages in which the amount of valid data or the amount of invalid data stored is within a set amount range, and count the maximum number of consecutive numbers in the plurality of target pages; The plurality of pages are divided into a plurality of regions based on the maximum contiguous number.
4. The method according to claim 2, characterized in that: The step of setting a first migration order between the plurality of zones and a second migration order between at least one page in each zone to generate an interval migration rule includes: Setting a first migration order between the plurality of zones to: random migration or migration in order of zone numbers of the plurality of zones, until all valid data of the plurality of zones are migrated; Setting a second migration order between at least one page in each zone during each migration; An interval moving rule is generated according to the first moving sequence and the second moving sequence.
5. The method according to claim 3, characterized in that: The second migration order between at least one page in each zone is: The Nth page that has not been moved; or, Randomly moved; or Move in the order of page numbers of the at least one page; or, At least one page in the first zone is moved in a page number sequence, and at least one page in the second zone is moved randomly; wherein the plurality of zones include the first zone and the second zone.
6. The method according to claim 1, characterized in that The step of setting the interval migration rule according to the data information includes: Determining a writing mode according to the logical block addresses when the plurality of pages are written with data, the writing mode including sequential writing and random writing; Dividing the plurality of pages into a plurality of zones based on the writing mode, and setting a distribution type for each zone; wherein the distribution type includes sequential distribution and random distribution, and the writing mode corresponding to at least one page in each zone is the same; Setting a first migration order between the plurality of zones as follows: alternately migrating zones according to the distribution type corresponding to each zone, or migrating all zones of other distribution types after migrating all zones of the target distribution type; Setting a second migration order between at least one page in each zone as follows: sequential migration between at least one page in each zone in the sequential distribution and random migration between at least one page in each zone in the random distribution; An interval moving rule is generated according to the first moving sequence and the second moving sequence.
7. The method according to claim 1, characterized in that Before the valid data in the multiple pages are moved to the idle physical blocks to be received in the multiple physical blocks according to the interval moving rule, the method further includes: Determining a target migration rule in the random migration rule and the interval migration rule; wherein the random migration rule refers to randomly and non-repeatedly migrating valid data; If the random migration rule is selected as the target migration rule, the valid data in the multiple pages are randomly and non-repetitively moved to the idle physical blocks to be received in the multiple physical blocks; or, The moving of valid data in the multiple pages to the idle physical blocks to be received among the multiple physical blocks according to the interval moving rule includes: if the interval moving rule is selected as the target moving rule, the moving of valid data in the multiple pages to the physical blocks to be received according to the interval moving rule.
8. A data migration device for a solid state hard disk, characterized in that: include: A determination unit, configured to determine a physical block to be moved for which valid data is to be moved from a plurality of physical blocks included in the solid state drive; wherein the physical block to be moved includes a plurality of pages, and the plurality of pages store invalid data and / or valid data; An acquisition unit, configured to acquire data information of the physical block to be moved; wherein the data information represents the distribution of the plurality of pages in the physical block to be moved; A setting unit, configured to set an interval moving rule according to the data information; wherein the interval moving rule represents a moving order for the plurality of pages; A moving unit is used to move the valid data in the multiple pages to the idle physical blocks to be received in the multiple physical blocks according to the interval moving rule.
9. An electronic device, characterized in that: include: Memory; processor; as well as Computer programs; The computer program is stored in the memory and is configured to be executed by the processor to implement the data migration method of the solid state drive as described in any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method for migrating data from a solid state drive as described in any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Solid state disk garbage collection method and device, electronic equipment and storage medium
CN120353724A