WO2024148874A1 - Wear leveling method and apparatus, and electronic device and storage medium - Google Patents
Wear leveling method and apparatus, and electronic device and storage medium Download PDFInfo
- Publication number
- WO2024148874A1 WO2024148874A1 PCT/CN2023/122278 CN2023122278W WO2024148874A1 WO 2024148874 A1 WO2024148874 A1 WO 2024148874A1 CN 2023122278 W CN2023122278 W CN 2023122278W WO 2024148874 A1 WO2024148874 A1 WO 2024148874A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- target
- physical storage
- storage area
- frequency
- wear
- Prior art date
Links
- 238000000034 method Methods 0.000 title claims abstract description 72
- 239000007787 solid Substances 0.000 claims description 49
- 238000004590 computer program Methods 0.000 claims description 19
- 238000013517 stratification Methods 0.000 claims description 15
- 238000012546 transfer Methods 0.000 claims description 15
- 238000012545 processing Methods 0.000 abstract description 7
- 238000013403 standard screening design Methods 0.000 description 12
- 238000010586 diagram Methods 0.000 description 11
- 230000008569 process Effects 0.000 description 11
- 238000005516 engineering process Methods 0.000 description 7
- 239000002699 waste material Substances 0.000 description 6
- 238000011161 development Methods 0.000 description 5
- 230000009471 action Effects 0.000 description 3
- 238000004364 calculation method Methods 0.000 description 3
- 230000006870 function Effects 0.000 description 3
- 238000004422 calculation algorithm Methods 0.000 description 2
- 238000013500 data storage Methods 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 230000001960 triggered effect Effects 0.000 description 2
- 101001121408 Homo sapiens L-amino-acid oxidase Proteins 0.000 description 1
- 101000827703 Homo sapiens Polyphosphoinositide phosphatase Proteins 0.000 description 1
- 102100026388 L-amino-acid oxidase Human genes 0.000 description 1
- 102100023591 Polyphosphoinositide phosphatase Human genes 0.000 description 1
- 101100012902 Saccharomyces cerevisiae (strain ATCC 204508 / S288c) FIG2 gene Proteins 0.000 description 1
- 101100233916 Saccharomyces cerevisiae (strain ATCC 204508 / S288c) KAR5 gene Proteins 0.000 description 1
- 230000008859 change Effects 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000005265 energy consumption Methods 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 238000010606 normalization Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000000750 progressive effect Effects 0.000 description 1
- 238000013519 translation Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
- G06F12/06—Addressing a physical block of locations, e.g. base addressing, module addressing, memory dedication
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Definitions
- the present application relates to the field of data processing technology, and in particular to a wear leveling method, device, electronic device and storage medium.
- solid-state drives are becoming more and more widespread, and the requirements for the performance and capacity of solid-state drives are getting higher.
- flash memory technology the improvement of the performance of the main control chip
- the relevant technologies of solid-state drives are constantly updated to meet the needs of applications as much as possible.
- a wear leveling method, device, electronic device and storage medium are proposed to overcome the above problems or at least partially solve the above problems, including:
- a wear leveling method comprising:
- the data in the first physical storage area is transferred to the second physical storage area for storage.
- obtaining the erase and write frequency of each logical address in the target solid state drive includes:
- the erasing and writing frequency of each logical address segment is determined, and the erasing and writing frequency of the logical address segment is used as the erasing and writing frequency of each logical address included in the logical address segment.
- determining the erasing frequency of each logical address segment includes:
- the erasure frequency of each logical address segment is calculated according to the segment erasure number and the total erasure number.
- the method further includes:
- the total erase and write times and the segment erase and write times are cleared, and the total erase and write times of the target solid state drive and the segment erase and write times of each logical address segment are counted again.
- the method further includes:
- the frequency level of each logical address segment is determined according to the erase and write frequency of each logical address segment
- a corresponding third physical storage area is determined, and the target data is written into the third physical storage area.
- the method further includes:
- the erase and write frequencies of each logical address segment are cleared, and the erase and write frequencies of each logical address segment are recalculated.
- judging whether the data in the target solid-state drive meets the preset tiering condition according to the erase and write frequency of each logical address segment includes:
- the frequency level of each logical address segment is determined according to the erase and write frequency of each logical address segment, including:
- a frequency rank of the logical address segments is determined.
- determining the corresponding third physical storage area according to the frequency level of the target logical address segment includes:
- a third physical storage area having a wear level matching the frequency level of the target logical address segment is determined.
- determining a third physical storage area whose wear level matches the frequency level of the target logical address segment includes:
- a physical storage area having a target wear level is used as the third physical storage area.
- determining a target erase/write frequency of the first physical storage area according to erase/write frequencies of a plurality of logical addresses corresponding to the first physical storage area includes:
- a target erasing frequency of the first physical storage area is determined according to the target sum value and the target quantity.
- determining a target erase/write frequency of the first physical storage area according to the target value and the target quantity includes:
- a second ratio of the first ratio to the target number is calculated, and the second ratio is used as the target erase frequency.
- a target wear degree is determined based on the first wear deviation.
- determining a first wear deviation of a first physical storage area according to the number of wear times of each physical storage area includes:
- a first wear deviation is determined based on a ratio of the first difference to the second difference.
- determining whether the target erase frequency and the target wear degree meet a preset matching condition includes:
- the matching degree between the target erasing frequency and the target wear degree exceeds a second threshold, it is determined that the target erasing frequency and the target wear degree meet a preset matching condition.
- determining the matching degree between the target erase frequency and the target wear degree includes:
- the matching degree between the target erasing frequency and the target wear degree is determined according to the third ratio.
- determining the matching degree between the target erase frequency and the target wear degree includes:
- the matching degree between the target write-erase frequency and the target wear degree is determined.
- the method further includes:
- the write-erase frequencies of the first physical storage area and the second physical storage area are updated according to the transferred data.
- the embodiment of the present application also provides a wear leveling device, the device comprising:
- a first judgment module is used to judge whether the target erasure frequency and the target wear degree meet a preset matching condition
- a first determination module is used to determine a second physical storage area that meets the preset matching condition with the target erasing frequency from other physical storage areas except the first physical storage area when the target erasing frequency and the target wear degree do not meet the preset matching condition;
- the transfer module is used to transfer the data in the first physical storage area to the second physical storage area for storage.
- the first acquisition module is used to count the total number of erase and write times of the target solid-state hard disk, and the number of segment erase and write times of each logical address segment; when the total number of erase and write times exceeds the first threshold, the erase and write frequency of each logical address segment is calculated based on the segment erase and write times and the total erase and write times.
- the device further includes:
- the first clearing module is used to clear the total erase and write times and the segment erase and write times, and restart counting the total erase and write times of the target solid state drive and the segment erase and write times of each logical address segment.
- a write module is used to determine whether the data in the target solid-state hard disk meets the preset stratification conditions according to the write-erasing frequency of each logical address segment; when the data in the target solid-state hard disk meets the preset stratification conditions, determine the frequency level of each logical address segment according to the write-erasing frequency of each logical address segment; for the target data to be written into the physical storage area, determine the target logical address segment corresponding to the target data; determine the corresponding third physical storage area according to the frequency level of the target logical address segment, and write the target data into the third physical storage area.
- the device further includes:
- the second clearing module is used to clear the write-erase frequency of each logical address segment and restart the calculation of the write-erase frequency of each logical address segment when the data in the target solid state drive does not meet the preset stratification condition.
- the write module is used to sort the logical address segments according to the magnitude of the erase and write frequency of each logical address; and determine the frequency level of each logical address segment based on the sorting of the logical address segments.
- a write module is used to sort each physical storage area according to the degree of wear; determine the wear level of each physical storage area based on the sorting of each physical storage area; and determine a third physical storage area whose wear level matches the frequency level of the target logical address segment.
- the second acquisition module is used to determine the plurality of logical locations corresponding to the first physical storage area. determining a target number of logical addresses corresponding to the first physical storage area; and determining a target erasing frequency of the first physical storage area according to the target sum and the target number.
- the second acquisition module is used to calculate a first ratio of the target sum value to the target quantity; calculate a second ratio of the first ratio to the target quantity, and use the second ratio as the target erase frequency.
- the second acquisition module is used to obtain the number of wear times of each physical storage area; determine the first wear deviation of the first physical storage area based on the number of wear times of each physical storage area; and determine the target wear degree based on the first wear deviation.
- the second acquisition module is used to determine an extreme wear count, an average wear count, and the wear count of the first physical storage area from the wear counts of each physical storage area; determine a first difference between the wear count and the extreme wear count of the first physical storage area, and a second difference between the average wear count and the extreme wear count; and determine a first wear deviation based on the ratio of the first difference to the second difference.
- the first judgment module is used to determine the matching degree between the target erasure frequency and the target wear degree; when the matching degree between the target erasure frequency and the target wear degree exceeds a second threshold, it is determined that the target erasure frequency and the target wear degree meet a preset matching condition.
- the first judgment module is used to determine a third ratio of the target erase frequency to the target wear degree; and determine the matching degree of the target erase frequency and the target wear degree based on the third ratio.
- a first judgment module is used to sort each physical storage area according to the erase and write frequency of each physical storage area, and determine the frequency level of each physical storage area based on the sorting of each physical storage area; sort each physical storage area according to the degree of wear, and determine the wear level of each physical storage area based on the sorting of each physical storage area; determine the matching degree of the target erase and write frequency and the target wear level according to the wear level and frequency level corresponding to the first physical storage area.
- the device further includes:
- An embodiment of the present application also provides an electronic device, including a processor, a memory, and a computer program stored in the memory and capable of running on the processor, and the computer program implements the above wear leveling method when executed by the processor.
- An embodiment of the present application further provides a non-volatile readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the above-mentioned wear leveling method is implemented.
- the write-erase frequency of each logical address in the target solid-state hard disk can be obtained first; then, according to the write-erase frequency of multiple logical addresses corresponding to the first physical storage area, the target write-erase frequency of the first physical storage area is determined, and the target wear degree of the first physical storage area is obtained; then, it is determined whether the target write-erase frequency and the target wear degree meet the preset matching condition; if the target write-erase frequency and the target wear degree do not meet the preset matching condition, then a second physical storage area that meets the preset matching condition with the target write-erase frequency is determined from other physical storage areas except the first physical storage area, and the data in the first physical storage area is transferred to the second physical storage area for storage.
- FIG1 is a flowchart of a wear leveling method according to an embodiment of the present application.
- FIG2 is a flowchart of another wear leveling method according to an embodiment of the present application.
- FIG3 is a schematic diagram of a solid state drive according to an embodiment of the present application.
- FIG4 is a flowchart of a data writing step according to an embodiment of the present application.
- FIG5 is a schematic diagram of the structure of a wear leveling device according to an embodiment of the present application.
- FIG6 is a schematic diagram of the structure of an electronic device according to an embodiment of the present application.
- FIG. 7 is a schematic diagram of the structure of a non-volatile readable storage medium according to an embodiment of the present application.
- wear leveling can be triggered when the degree of wear of each physical storage area differs; specifically, data in a physical storage area with less wear can be restored to other physical storage areas.
- wear leveling needs to be triggered.
- the data in blockA with less wear can be moved to blockB with greater wear, and then blockA can be erased and used again to increase the wear of blockA and reduce the gap between the minimum wear degree and the average and maximum values.
- the embodiment of the present application provides a wear leveling method; it no longer determines wear leveling based only on the degree of wear, but determines whether wear leveling is needed based on the overall erase and write frequency of the physical storage area and the relationship between the corresponding degree of wear.
- the overall erase and write frequency of the physical storage area can represent the total erase and write frequency of all data stored in the physical storage area; the erase and write frequency is the frequency of erasing and writing.
- the overall write-erase frequency of a physical storage area does not match the corresponding degree of wear, it can be considered that wear leveling is required for the physical storage area; at this time, the data in the physical storage area can be transferred to another physical storage area whose wear degree matches the overall write-erase frequency of the physical storage area for storage; by focusing on the relationship between the overall write-erase frequency of the physical storage area and the corresponding degree of wear to perform wear leveling, the problems existing in the prior art of only focusing on the degree of wear to perform wear leveling can be avoided, thereby improving the efficiency of wear leveling and avoiding waste of the life of the solid-state hard drive.
- Step 101 Obtain the write/erasure frequency of each logical address in the target solid-state hard disk, where the target solid-state hard disk includes multiple physical storage devices. Storage area.
- the logical address may refer to the address of a memory unit, a storage unit, or a network host from the perspective of an application program
- the physical storage area may refer to a physical storage area in a target solid state drive for data storage.
- the logical address may correspond to a piece of data, and the data may be written in a physical storage area of the target solid state drive; a plurality of pieces of data may be stored in one physical storage area.
- the embodiments of the present application can focus on the overall erase frequency of the physical storage area and the corresponding degree of wear; thus, wear leveling is performed based on the relationship between the overall erase frequency of the physical storage area and the corresponding degree of wear.
- each physical storage area stores multiple data, and the data has a one-to-one correspondence with the logical address in the target solid state drive, the write-erase frequency of each logical address in the target solid state drive can be obtained first.
- the erasure frequency of each logical address may be counted in advance; specifically, the erasure frequency of data corresponding to the logical address may be counted in advance, and then the erasure frequency of the logical address may be determined based on the erasure frequency of the data corresponding to the logical address.
- the erase and write frequency of the data when counting the erase and write frequency of the data corresponding to the logical address, can be determined based on the ratio of the number of erase and write times of the data to the total number of erase and write times of the target solid-state hard disk; further, the erase and write frequency of the logical address corresponding to the data can be determined based on the erase and write frequency of the data.
- Step 102 Determine a target write/erase frequency of the first physical storage area according to the write/erase frequencies of a plurality of logical addresses corresponding to the first physical storage area, and obtain a target wear degree of the first physical storage area.
- the target erasing frequency of the first physical storage area may be determined according to the acquired erasing frequency of the logical address.
- each physical storage area stores multiple data and each data corresponds to a logical address
- the multiple logical addresses corresponding to the multiple data corresponding to the first physical storage area can be determined first.
- the target write-erase frequency of the first physical storage area can be calculated based on the write-erase frequencies of the multiple logical addresses corresponding to the multiple data corresponding to the first physical storage area.
- the sum of the write-erase frequencies of the multiple logical addresses can be used as the target write-erase frequency, or the average of the write-erase frequencies of the multiple logical addresses can be used as the target write-erase frequency, which is not limited in the embodiments of the present application.
- the target wear degree of the first physical storage area can also be obtained.
- the target wear degree can be used to represent the wear condition of the first physical storage area.
- the target wear degree can be determined based on the number of wear times of the first physical storage area, or based on the number of wear times of the first physical storage area and the number of wear times of other physical storage areas in the target solid state drive except the first physical storage area.
- Step 103 Determine whether the target erasing frequency and the target wear degree meet a preset matching condition.
- the higher the target write-erase frequency the higher the write-erase frequency of the data stored in the first physical storage area; the lower the target write-erase frequency, the lower the write-erase frequency of the data stored in the first physical storage area.
- data with a low write-erase frequency data with a high write-erase frequency will cause a high degree of wear on the physical storage area, which may lead to earlier damage to the physical storage area, thereby affecting the overall life of the target solid-state drive.
- the embodiment of the present application can It is determined whether the target write-erase frequency of the first physical storage area and the target wear degree of the first physical storage area meet a preset matching condition.
- the target wear degree of the first physical storage area is high, it may indicate that the first physical storage area may be damaged earlier than other physical storage areas in the target solid state drive.
- the target write-erase frequency is high, it may indicate that the write-erase frequency of the data stored in the first physical storage area is high, which may cause the first physical storage area to be damaged faster. In this case, it can be determined that the target write-erase frequency and the target wear degree do not meet the preset matching condition.
- step 104 may be continued to be executed to perform wear leveling on the first physical storage area.
- step 101 can be performed for another physical storage area, and the embodiment of the present application does not limit this.
- Step 104 When the target write-erase frequency and the target wear degree do not satisfy a preset matching condition, a second physical storage area that satisfies a preset matching condition with the target write-erase frequency is determined from other physical storage areas except the first physical storage area.
- the degree of wear corresponding to these other physical storage areas can be determined, and based on the degree of wear of each other physical storage area, a second physical storage area that meets the preset matching conditions with the target erase frequency can be determined; the second physical storage area can refer to a physical storage area whose degree of wear meets the preset matching conditions with the target erase frequency.
- the second physical storage area when determining the second physical storage area, it is possible to determine one by one whether the degree of wear of other physical storage areas matches the target erase frequency; if the degree of wear of another physical storage area and the target erase frequency meet the preset matching conditions, then the other physical storage area can be used as the second physical storage area.
- Step 105 Transfer the data in the first physical storage area to the second physical storage area for storage.
- the data in the first physical storage area may be transferred to the determined second physical storage area for storage.
- the above-mentioned wear leveling process can be simultaneously performed on all physical storage areas in the target solid-state hard disk; that is, when transferring data from the first physical storage area to the second physical storage area, it is also possible to transfer data from the second physical storage area to the third physical storage area, and transfer data from the third physical storage area to the first physical storage area; thereby, the degree of wear of each physical storage area and the erase and write frequency corresponding to each physical storage area meet the preset matching conditions.
- first and second are only for distinction and do not specifically refer to a certain physical storage address.
- Step 201 segment all logical addresses in the target solid state drive to obtain a plurality of logical address segments, each logical address segment including at least one logical address.
- the embodiment of the present application can pre-segment all logical addresses in the target solid-state drive to obtain multiple logical address scores; wherein each logical address segment can include at least one logical address, and of course, can also include multiple logical addresses, and the embodiment of the present application does not limit this.
- the target solid state drive includes 1000 logical addresses.
- the 100 logical addresses are divided into 100 segments, and each logical address segment may include 10 logical addresses.
- logical address segment 1 includes logical address 1 and logical address 2
- logical address segment 2 includes logical address 3 and logical address 4 .
- Step 202 determine the erasing and writing frequency of each logical address segment, and use the erasing and writing frequency of the logical address segment as the erasing and writing frequency of each logical address included in the logical address segment.
- the erasure frequency of each logical address segment can be determined respectively; the erasure frequency of a logical address segment can be determined based on the erasure status of data corresponding to all logical addresses in the logical address segment.
- logical address segment 1 includes logical address 1 and logical address 2; logical address segment 2 includes logical address 3 and logical address 4; when the data corresponding to logical address 1 is erased or written, the erase frequency of logical address segment 1 can be updated; at the same time, the updated erase frequency of logical address segment 1 is used as the erase frequency of logical address 1 and logical address 2.
- the erasing frequency of each logical address segment can be determined by the following sub-steps:
- Sub-step 11 Count the total number of erase/write times of the target solid state drive and the number of segment erase/write times of each logical address segment.
- the total number of erasures and writes of the target SSD may be counted based on the erasure and write operations of the user on the target SSD; the total number of erasures and writes may be the sum of the number of erasures and writes of all data stored in the target SSD.
- the segment erase count of each logical address segment can be counted according to the user's erase and write operations on the target solid state drive; the segment erase count can be the sum of the erase and write counts of data corresponding to all logical addresses in a logical address segment.
- the target SSD includes logical address segment 1 and logical address segment 2; logical address segment 1 includes logical address 1 and logical address 2; logical address segment 2 includes logical address 3 and logical address 4.
- the segment erase count of logical address segment 1 can be increased by one; the total erase count of the target SSD can be increased by one.
- the number of erase and write times is increased by one, and this embodiment of the present application does not impose any limitation on this.
- Sub-step 12 When the total number of erasures exceeds the first threshold, the erasure frequency of each logical address segment is calculated according to the segment erasure number and the total erasure number.
- the embodiment of the present application first determines whether the total number of erase and write times of the target solid-state hard disk exceeds the first threshold.
- the first threshold can be determined according to actual conditions, for example: 10M.
- the total number of erasures and writes of the target solid state drive does not exceed the first threshold, the total number of erasures and writes and the number of segment erasures and writes continue to be counted.
- the erasure frequency of each logical address segment may be calculated according to the segment erasure number and the total erasure number.
- a write Ratio Stat data can be constructed, which stores the erase and write frequency of each logical address segment, the number of segment erase and write times, and the total erase and write times of the target solid state drive.
- the data may change in real time. For example, the data that was frequently erased last month may be rarely erased this month.
- the following steps may be included:
- the total erase and write times and the segment erase and write times are cleared, and the total erase and write times of the target solid state drive and the segment erase and write times of each logical address segment are counted again.
- the total erase and write times of the target solid-state hard disk and the segment erase and write times of each logical address segment are cleared; then, the total erase and write times of the target solid-state hard disk and the segment erase and write times of each logical address segment are counted again.
- Step 203 Determine a target write-erase frequency of the first physical storage area according to the write-erase frequencies of the plurality of logical addresses corresponding to the first physical storage area, and obtain a target wear degree of the first physical storage area.
- the target erasing frequency of the first physical storage area may be determined according to the erasing frequency of the logical address.
- each physical storage area stores multiple data and each data corresponds to a logical address
- the multiple logical addresses corresponding to the multiple data corresponding to the first physical storage area can be determined first.
- the target erasing frequency of the first physical storage area may be calculated based on the erasing frequencies of the plurality of logical addresses corresponding to the plurality of data corresponding to the first physical storage area.
- the target wear degree of the first physical storage area can also be obtained.
- the target erase frequency can be determined by the following sub-steps:
- Sub-step 21 Determine the target and value of the erase and write frequency of multiple logical addresses corresponding to the first physical storage area.
- the logical addresses corresponding to the multiple data stored in the first physical storage area can be determined; then, the erasing frequency of the multiple logical addresses can be determined; the erasing frequency of the multiple logical addresses is the erasing frequency of the logical address segments corresponding to the multiple logical addresses.
- the multiple data stored in the first physical storage area correspond to logical address 1, logical address 3 and logical address 9 respectively; logical address 1 is located in logical address segment 1, logical address 3 is located in logical address segment 2, and logical address 9 is located in logical address segment 5.
- the erase frequency of logical address segment 1, the erase frequency of logical address segment 2, and the erase frequency of logical address segment 5 can be determined; the erase frequency of logical address segment 1 is the erase frequency of logical address 1, the erase frequency of logical address segment 2 is the erase frequency of logical address 3, and the erase frequency of logical address 5 is the erase frequency of logical address 5.
- the target and value of the erasing and writing frequencies of the plurality of logical addresses may be calculated.
- the sum of the erase frequencies of logical address 1, logical address 3, and logical address 9 can be calculated and used as the target sum.
- Sub-step 22 Determine the target number of logical addresses corresponding to the first physical storage area.
- a target number of logical addresses corresponding to the first physical storage area may also be determined.
- the target number can also be determined based on the number of data stored in the first physical storage area, and the embodiments of the present application are not limited to this.
- Sub-step 23 Determine a target erasing frequency of the first physical storage area according to the target sum value and the target quantity.
- the target erasure frequency of the first physical storage area can be determined based on the target sum value and the target quantity. For example, the ratio of the target sum value and the target quantity can be used as the target erasure frequency of the first physical storage area.
- the data of logical address 1 and logical address 3 are stored in physical storage area 1, and the data of logical address 2 and logical address 4 are stored in physical storage area 2; the erase frequency of physical storage area 1 can be calculated based on the erase frequency of logical address segment 1 and logical address segment 2.
- sub-step 23 can be implemented in the following manner:
- a first ratio of the target sum value to the target quantity is calculated; a second ratio of the first ratio to the target quantity is calculated, and the second ratio is used as the target erase frequency.
- the target wear degree can be obtained through the following sub-steps:
- Sub-step 31 Obtain the number of wear times of each physical storage area.
- the number of wear times of each physical storage area may be obtained.
- Sub-step 32 determining a first wear deviation of a first physical storage area according to the number of wears of each physical storage area.
- a first wear deviation of the number of wear times of the first physical storage area compared to the number of wear times of other physical storage areas in the target solid state drive may be determined.
- sub-step 32 can be implemented in the following manner:
- an extreme wear count and a wear count of the first physical storage area may be determined; the extreme wear count may be a maximum wear count or a minimum wear count.
- the average wear count of all physical storage areas may be calculated according to the wear count of each physical storage area.
- a first wear deviation of the number of wear times of the first physical storage area compared to the number of wear times of other physical storage areas in the target solid state drive can be determined based on the ratio of the first difference and the second difference.
- first wear deviation first difference / second difference.
- Sub-step 33 determining a target wear degree according to the first wear deviation.
- the target solid-state hard disk stores data 1, data 2, and data 3; the erase frequency of data 1 is 20%, the erase frequency of data 2 is 50%, and the erase frequency of data 3 is 30%; then the first physical storage area is suitable for storing data 3; if the data stored in the first physical storage area is data 1, wear leveling can be performed to transfer data 1 to other physical storage areas for storage, and transfer data 3 to the first physical storage area for storage, and the embodiments of the present application are not limited to this.
- Step 204 Determine whether the target erase frequency and the target wear degree meet a preset matching condition.
- the target write/erase frequency and the target wear degree of the first physical storage area After obtaining the target write/erase frequency and the target wear degree of the first physical storage area, it can be determined whether the target write/erase frequency of the first physical storage area and the target wear degree of the first physical storage area meet a preset matching condition.
- the target wear degree of the first physical storage area may mean that the first physical storage area may be damaged earlier than other physical storage areas in the target solid state drive.
- the target erase frequency is high, it may mean that the erase frequency of the data stored in the first physical storage area is high, which may cause the first physical storage area to be damaged faster. In this case, it can be determined that the target erase frequency and the target wear degree do not meet the preset matching condition.
- step 205 may be continued to be executed to perform wear leveling on the first physical storage area.
- the target wear degree of the first physical storage area is high and the target erasure frequency is low, it can be determined that the target erasure frequency and the target wear degree meet the preset matching condition.
- step 201 can be performed for another physical storage area, and this embodiment of the present application does not limit this.
- the following sub-steps may be used to determine whether the target erase frequency and the target wear degree meet the preset matching condition:
- Sub-step 41 Determine the matching degree between the target erasing frequency and the target wear degree.
- the matching degree between the target erasure frequency and the target wear degree may be calculated; the matching degree may be determined based on the numerical value of the target erasure frequency and the numerical value of the target wear degree.
- sub-step 41 can be implemented in the following manner:
- a third ratio of the target erase frequency to the target wear degree is determined; and a matching degree of the target erase frequency to the target wear degree is determined based on the third ratio.
- the third ratio of the target erase frequency to the target wear degree can be directly calculated as follows: target erase frequency/target wear degree.
- the degree of match between the target erase frequency and the target wear degree can be determined based on the third ratio; for example: if the third ratio deviates greatly from a preset value, it means that the degree of match between the target erase frequency and the target wear degree is smaller; if the third ratio deviates less from the preset value, it means that the degree of match between the target erase frequency and the target wear degree is higher.
- sub-step 41 can also be implemented in the following manner:
- the physical storage areas are sorted according to their erase and write frequencies, and the frequency level of each physical storage area is determined based on the sorting; the physical storage areas are sorted according to their wear levels, and the wear level of each physical storage area is determined based on the sorting; and the matching degree of the target erase and write frequency and the target wear level is determined based on the wear level and frequency level corresponding to the first physical storage area.
- the physical storage area segments may be sorted according to the magnitude of the erasing and writing frequencies of the physical storage areas; and the frequency level of each logical address segment may be determined based on the position of each logical address segment in the sorting.
- the physical storage areas may be sorted according to the degree of wear of the physical storage areas; and the wear level of each physical storage area may be determined based on the position of each physical storage area in the sorting.
- the frequency level corresponding to the target write-erase frequency of the first physical storage area may be determined, and the wear level corresponding to the target wear degree of the first physical storage area may be determined.
- the matching degree between the target write-erase frequency and the target wear degree may be determined based on the wear level and frequency level corresponding to the first physical storage area.
- the wear level is divided into high, medium and low; the higher the wear level, the more serious the wear of the physical storage area.
- the frequency level is divided into high, medium and low; the higher the frequency level, the more frequently the data in the physical storage area is erased and written. If the wear level corresponding to the first physical storage area is high and the frequency level is low, a higher value of the matching degree can be determined; and if the wear level corresponding to the first physical storage area is high and the frequency level is high, a lower value of the matching degree can be determined, and the embodiments of the present application do not limit this.
- a second threshold may be set for the matching degree, and the second threshold may be set according to actual conditions.
- step 205 may be continued to perform wear leveling.
- step 201 can be re-executed, and the embodiment of the present application does not limit this.
- Step 205 When the target write-erase frequency and the target wear degree do not satisfy a preset matching condition, determine a second physical storage area that satisfies a preset matching condition with the target write-erase frequency from other physical storage areas except the first physical storage area.
- the degree of wear corresponding to these other physical storage areas can be determined, and based on the degree of wear of each other physical storage area, a second physical storage area that meets the preset matching conditions with the target erase frequency can be determined; the second physical storage area can refer to a physical storage area whose degree of wear meets the preset matching conditions with the target erase frequency.
- the second physical storage area when determining the second physical storage area, it is possible to determine one by one whether the degree of wear of other physical storage areas matches the target erase frequency; if the degree of wear of another physical storage area and the target erase frequency meet the preset matching conditions, then the other physical storage area can be used as the second physical storage area.
- Step 206 Transfer the data in the first physical storage area to the second physical storage area for storage.
- the data in the first physical storage area may be transferred to the determined second physical storage area for storage.
- the above-mentioned wear leveling process can be simultaneously performed on all physical storage areas in the target solid-state hard disk; that is, when transferring data from the first physical storage area to the second physical storage area, it is also possible to transfer data from the second physical storage area to the third physical storage area, and transfer data from the third physical storage area to the first physical storage area; thereby, the degree of wear of each physical storage area and the erase and write frequency corresponding to each physical storage area meet the preset matching conditions.
- Step 207 After transferring the data in the first physical storage area to the second physical storage area for storage, update the write-erase frequency of the first physical storage area and the second physical storage area according to the transferred data.
- the data in the first physical storage area is transferred to the second physical storage area for storage
- the data in the first physical storage area and the second physical storage area are changed; at this time, the data in the first physical storage area can be transferred to the second physical storage area for storage according to the transferred data (that is, the data transferred from the first physical storage area to the second physical storage area).
- the erase and write frequency of each physical storage area may be updated, but the embodiments of the present application do not limit this.
- all logical addresses in the target solid-state hard disk may be segmented to obtain a plurality of logical address segments, each logical address segment including at least one logical address; then, the erase and write frequencies of each logical address segment are determined, and the erase and write frequencies of the logical address segments are used as the erase and write frequencies of each logical address included in the logical address segment; thereafter, the target erase and write frequency of the first physical storage area is determined according to the erase and write frequencies of the plurality of logical addresses corresponding to the first physical storage area, and the target degree of wear of the first physical storage area is obtained, and it is determined whether the target erase and write frequency and the target degree of wear meet a preset matching condition; when the target erase and write frequency and the target degree of wear do not meet the preset matching condition, a second physical storage area that meets the preset matching condition with the target erase and write frequency is determined from other physical storage areas except the first physical storage area; the data in the first physical storage area is transferred to the second physical storage area for storage; after
- the physical storage area and the second physical storage area are updated in erasing and writing frequency.
- the amount of data required for wear leveling of the solid state drive is reduced, so that the solid state drive can use fewer resources to store the data required for wear leveling.
- FIG. 4 a flowchart of a data writing step in an embodiment of the present application is shown, which may include the following steps:
- Step 401 Determine whether the data in the target solid state drive meets a preset tiering condition based on the write-erase frequency of each logical address segment.
- the logical address segments in the target SSD may be stratified; for example, the total erase frequency of 20% of the logical address segments is 80%, while the total erase frequency of the other 80% of the logical address segments is 20%.
- the total erase frequency of 20% of the logical address segments is 80%
- the total erase frequency of the other 80% of the logical address segments is 20%.
- the embodiment of the present application can determine in advance whether the data stored in the target solid-state drive meets the preset tiering conditions according to the erase and write frequencies of each logical address segment.
- the following sub-steps may be used to determine whether the data in the target solid-state drive meets the preset tiering condition:
- Sub-step 51 determining the first M logical address segments with the highest erasure frequency, and calculating the total erasure frequency of the first M logical address segments with the highest erasure frequency, where M is a positive integer.
- the first M logical address segments with the highest erasure frequency can be determined from all logical address segments; M can be a preset positive integer, for example, when there are 100 logical address segments, M can be set to 25.
- the erasure frequencies of these logical address segments can be determined, and based on the erasure frequencies of these logical address segments, the total erasure frequency of the first M logical address segments with the highest erasure frequencies can be calculated.
- Sub-step 52 When the total erase/write frequency of the current M logical address segments is greater than a third threshold, it is determined that the data in the target solid state drive meets a preset tiering condition.
- the third threshold can be set according to actual conditions, for example: 60%.
- step 402 can be executed.
- step 405 If the total erasure frequency of the first M logical address segments with the highest erasure frequency is not greater than the third threshold, it can be determined that the data in the target solid state drive does not meet the preset tiering condition; at this time, step 405 is executed.
- Step 402 When the data in the target solid state drive meets the preset tiering condition, the frequency level of each logical address segment is determined according to the write-erase frequency of each logical address segment.
- the frequency level of each logical address segment can be determined based on the write-erase frequency of each logical address segment.
- the frequency level of each logical address segment may be determined by the following sub-steps:
- Sub-step 61 sorting the logical address segments according to the erase and write frequencies of the logical addresses.
- the logical address segments can be sorted according to the erase and write frequency of each logical address; the sorting can be arranged in order from large to small, or in order from small to high, and the embodiment of the present application does not limit this.
- Sub-step 62 Determine the frequency level of each logical address segment based on the ranking of each logical address segment.
- the frequency level of a logical address segment may be determined based on the position of the logical address segment in the ranking.
- Step 403 for the target data to be written into the physical storage area, determine the target logical address segment corresponding to the target data.
- the target logical address fractional segment into which the target data is written may be determined first.
- Step 404 Determine a corresponding third physical storage area according to the frequency level of the target logical address segment, and write the target data into the third physical storage area.
- the frequency level corresponding to the target logical address segment can be determined; after determining the frequency level corresponding to the target logical address segment, a third physical storage area can be determined according to the frequency level corresponding to the target logical address segment.
- the frequency level of the logical address segment includes high, medium and low. The higher the frequency level, the more frequently the data corresponding to the logical address segment is erased and written.
- the FTL can apply to write the target data into a physical storage area with a lower wear level; this physical storage area is the third physical storage area.
- the frequency levels corresponding to the logical address segments can also be simply divided into high and low; then, the first N logical address segments with the highest erase frequency can be selected, and the frequency levels of these N logical address segments can be set to high, and the frequency levels of other logical address segments can be set to low; wherein, the sum of the erase frequencies of these N logical address segments needs to be greater than or equal to a third threshold, and N is a positive integer.
- the target data can be written into the third physical storage area; compared with randomly writing the target data into the physical storage area, the embodiment of the present application can determine the corresponding third physical storage area by the frequency level of the target logical address segment in which the target data is written; thereby storing the target data in a more suitable physical storage area, thereby avoiding writing data that is frequently erased and written into a physical storage area with a higher degree of wear.
- the wear degree and erase frequency corresponding to the third physical storage area can be updated; wherein, when the third physical storage area is full, the erase frequency of the third physical storage area can be saved in the data structure of the third physical storage area.
- the third physical storage area may be determined by the following sub-steps:
- Sub-step 71 sort the physical storage areas according to the degree of wear.
- the physical storage areas may be sorted according to the degree of wear of the physical storage areas.
- Sub-step 72 Determine the wear level of each physical storage area based on the ranking of each physical storage area.
- the wear level of each physical storage area may be determined based on the position of each physical storage area in the sort.
- Sub-step 73 Determine a third physical storage area whose wear level matches the frequency level of the target logical address segment.
- a physical storage area whose wear level matches the frequency level of the target logical address segment may be determined and used as the third physical storage area.
- sub-step 73 is implemented in the following manner:
- a correspondence between the frequency level and the wear level of the logical address segment is established in advance; from the correspondence, a target wear level corresponding to the frequency level of the target logical address segment is determined; and a physical storage area having the target wear level is used as a third physical storage area.
- a correspondence between the frequency level and the wear level of the logical address segment can be established in advance; this correspondence can ensure that data with a high frequency level can be stored in a physical storage area with a low wear level, and that data with a low frequency level can be stored in a physical storage area with a high wear level; thereby reducing the wear leveling operation on the target solid state drive.
- Step 405 When the data in the target solid state drive does not meet the preset tiering condition, the erase and write frequencies of each logical address segment are cleared, and the erase and write frequencies of each logical address segment are recalculated.
- the erase frequency of each logical address segment can be cleared; then, the erase frequency of each logical address segment can be recalculated based on the number of segment erases of each logical address segment and the total number of erases of the target solid-state drive.
- the erase frequency of the previously erased logical address segment can be used as a reference; for example: the erase frequency of each logical address segment can be calculated based on the old erase frequency and the new erase frequency of the logical address segment, and the embodiments of the present application do not limit this.
- the erasing frequency of each logical address segment it is possible to determine in advance whether the data in the target solid-state hard disk meets the preset stratification conditions according to the erasing frequency of each logical address segment; when the data in the target solid-state hard disk meets the preset stratification conditions, the frequency level of each logical address segment is determined according to the erasing frequency of each logical address segment; for the target data to be written into the physical storage area, the target logical address segment corresponding to the target data can be determined; according to the frequency level of the target logical address segment, the corresponding third physical storage area is determined, and the target data is written into the third physical storage area; and when the data in the target solid-state hard disk does not meet the preset stratification conditions, the erasing frequency of each logical address segment is cleared, and the erasing frequency of each logical address segment is recalculated.
- FIG. 5 a schematic diagram of the structure of a wear leveling device according to an embodiment of the present application is shown, which may include the following modules:
- a first acquisition module 501 is used to acquire the erase and write frequency of each logical address in a target solid state drive, where the target solid state drive includes multiple physical storage areas;
- a second acquisition module 502 is used to determine a target write/erase frequency of the first physical storage area according to the write/erase frequencies of the plurality of logical addresses corresponding to the first physical storage area, and to acquire a target wear degree of the first physical storage area;
- the first judgment module 503 is used to judge whether the target erasure frequency and the target wear degree meet the preset matching condition
- a first determination module 504 is used to determine, from other physical storage areas except the first physical storage area, a second physical storage area that meets the preset matching condition with the target erasure frequency when the target erasure frequency and the target wear degree do not meet the preset matching condition;
- the transfer module 505 is used to transfer the data in the first physical storage area to the second physical storage area for storage.
- the first acquisition module 501 is used to segment all logical addresses in the target solid-state hard disk to obtain multiple logical address segments, each logical address segment includes at least one logical address; determine the erase and write frequency of each logical address segment, and use the erase and write frequency of the logical address segment as the erase and write frequency of each logical address included in the logical address segment.
- the first acquisition module 501 is used to count the total number of erase and write times of the target solid-state hard disk, and the number of segment erase and write times of each logical address segment; when the total number of erase and write times exceeds the first threshold, the erase and write frequency of each logical address segment is calculated based on the segment erase and write times and the total erase and write times.
- the device further includes:
- the first clearing module is used to clear the total erase and write times and the segment erase and write times, and restart counting the total erase and write times of the target solid state drive and the segment erase and write times of each logical address segment.
- the device further includes:
- a write module is used to determine whether the data in the target solid-state hard disk meets the preset stratification conditions according to the erase and write frequencies of each logical address segment; when the data in the target solid-state hard disk meets the preset stratification conditions, determine the frequency level of each logical address segment according to the erase and write frequencies of each logical address segment; for the target data to be written into the physical storage area, determine the target logical address segment corresponding to the target data; determine the corresponding third physical storage area according to the frequency level of the target logical address segment, and write the target data into the third physical storage area.
- the device further includes:
- the second clearing module is used to clear the write-erase frequency of each logical address segment and restart the calculation of the write-erase frequency of each logical address segment when the data in the target solid state drive does not meet the preset stratification condition.
- the write module is used to determine the top M logical address segments with the highest erase frequency, and calculate the total erase frequency of the top M logical address segments with the highest erase frequency, where M is a positive integer; when the total erase frequency of the current M logical address segments is greater than a third threshold, it is determined that the data in the target solid-state drive meets the preset stratification conditions.
- the write module is used to sort the logical address segments according to the magnitude of the erase and write frequency of each logical address; and determine the frequency level of each logical address segment based on the sorting of the logical address segments.
- a write module is used to sort each physical storage area according to the degree of wear; determine the wear level of each physical storage area based on the sorting of each physical storage area; and determine a third physical storage area whose wear level matches the frequency level of the target logical address segment.
- a write module is used to pre-establish a correspondence between the frequency level and the wear level of the logical address segment; from the correspondence, determine the target wear level corresponding to the frequency level of the target logical address segment; and use the physical storage area with the target wear level as the third physical storage area.
- the second acquisition module 502 is used to determine the target and value of the erase and write frequencies of multiple logical addresses corresponding to the first physical storage area; determine the target number of logical addresses corresponding to the first physical storage area; and determine the target erase and write frequency of the first physical storage area based on the target and value and the target number.
- the second acquisition module 502 is used to calculate a first ratio of the target sum value to the target quantity; calculate a second ratio of the first ratio to the target quantity, and use the second ratio as the target erase frequency.
- the second acquisition module 502 is used to obtain the number of wear times of each physical storage area; determine the first wear deviation of the first physical storage area based on the number of wear times of each physical storage area; and determine the target wear degree based on the first wear deviation.
- the second acquisition module 502 is used to determine an extreme wear count, an average wear count, and the wear count of the first physical storage area from the wear counts of each physical storage area; determine a first difference between the wear count and the extreme wear count of the first physical storage area, and a second difference between the average wear count and the extreme wear count; and determine a first wear deviation based on the ratio of the first difference to the second difference.
- the first judgment module 503 is used to determine the matching degree between the target erasure frequency and the target wear degree; when the matching degree between the target erasure frequency and the target wear degree exceeds a second threshold, it is determined that the target erasure frequency and the target wear degree meet a preset matching condition.
- the first judgment module 503 is used to determine a third ratio of the target erase frequency to the target wear degree; and determine the matching degree of the target erase frequency and the target wear degree according to the third ratio.
- the first judgment module 503 is used to sort each physical storage area according to the erase and write frequency of each physical storage area, and determine the frequency level of each physical storage area based on the sorting of each physical storage area; sort each physical storage area according to the degree of wear, and determine the wear level of each physical storage area based on the sorting of each physical storage area; determine the matching degree of the target erase and write frequency and the target wear level according to the wear level and frequency level corresponding to the first physical storage area.
- the device further includes:
- the update module is used to update the erasing frequency of the first physical storage area and the second physical storage area according to the transferred data after transferring the data in the first physical storage area to the second physical storage area for storage.
- the write-erase frequency of each logical address in the target solid-state hard disk can be obtained first; then, according to the write-erase frequency of multiple logical addresses corresponding to the first physical storage area, the target write-erase frequency of the first physical storage area is determined, and the target wear degree of the first physical storage area is obtained; then, it is determined whether the target write-erase frequency and the target wear degree meet the preset matching condition; if the target write-erase frequency and the target wear degree do not meet the preset matching condition, then a second physical storage area that meets the preset matching condition with the target write-erase frequency is determined from other physical storage areas except the first physical storage area, and the data in the first physical storage area is transferred to the second physical storage area for storage.
- An embodiment of the present application also provides an electronic device, as shown in FIG6 , the electronic device 6 includes a processor 601, a memory 602, and a computer program stored in the memory 602 and capable of running on the processor, and the computer program implements the above wear leveling method when executed by the processor.
- the embodiment of the present application further provides a non-volatile readable storage medium, as shown in FIG. 7 , the non-volatile readable storage medium 7 stores a computer program 701 , and the computer program 701 implements the above wear leveling method when executed by a processor.
- the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
- the embodiments of the present application may be provided as methods, devices, or computer program products. Therefore, the embodiments of the present application may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present application may take the form of a computer program implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code. The form of the sequence product.
- each process and/or box in the flowchart and/or block diagram, and the combination of the process and/or box in the flowchart and/or block diagram can be realized 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 terminal device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device produce a device for realizing the function specified in one process or multiple processes in the flowchart and/or one box or multiple boxes in the block diagram.
- These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device that implements the functions specified in one or more processes in the flowchart and/or one or more boxes in the block diagram.
- These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce computer-implemented processing, so that the instructions executed on the computer or other programmable terminal device provide steps for implementing the functions specified in one or more processes in the flowchart and/or one or more boxes in the block diagram.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Human Computer Interaction (AREA)
- Techniques For Improving Reliability Of Storages (AREA)
- Memory System (AREA)
Abstract
A wear leveling method and apparatus, and an electronic device and a storage medium, which relate to the technical field of data processing. The method comprises: acquiring an erase/program frequency of each logical address in a target solid-state disk (101); according to erase/program frequencies of a plurality of logical addresses corresponding to a first physical storage area, determining a target erase/program frequency of the first physical storage area, and acquiring a target degree of wear of the first physical storage area (102); determining whether the target erase/program frequency and the target degree of wear satisfy a preset matching condition (103); if the target erase/program frequency and the target degree of wear do not satisfy the preset matching condition, determining, from among the physical storage areas other than the first physical storage area, a second physical storage area, the degree of wear of which satisfies the preset matching condition with the target erase/program frequency (104); and transferring data in the first physical storage area to the second physical storage area for storage (105). Wear leveling is performed on the basis of the relationship between the overall erase/program frequency of a physical storage area and a corresponding degree of wear, thereby improving the efficiency of wear leveling.
Description
相关申请的交叉引用CROSS-REFERENCE TO RELATED APPLICATIONS
本申请要求于2023年01月09日提交中国专利局,申请号为202310029810.9,申请名称为“一种磨损均衡的方法、装置、电子设备和存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application filed with the China Patent Office on January 9, 2023, with application number 202310029810.9 and application name “A wear leveling method, device, electronic device and storage medium”, all contents of which are incorporated by reference in this application.
本申请涉及数据处理技术领域,特别是涉及一种磨损均衡的方法、装置、电子设备和存储介质。The present application relates to the field of data processing technology, and in particular to a wear leveling method, device, electronic device and storage medium.
随着互联网、云计算、物联网、大数据等技术的发展及广泛应用,在人类生活中,时时刻刻都会产生海量的数据,这些海量的数据需要进行处理和存储,信息技术的高速发展对存储系统的性能提出了更高的要求。固态硬盘因为其读写速度快、能耗低,而被广泛的应用。With the development and widespread application of technologies such as the Internet, cloud computing, the Internet of Things, and big data, massive amounts of data are generated all the time in human life. These massive amounts of data need to be processed and stored. The rapid development of information technology has put forward higher requirements on the performance of storage systems. Solid-state drives are widely used because of their fast read and write speeds and low energy consumption.
当前固态硬盘的使用变得越来越广泛,对固态硬盘的性能、容量的要求都更高,随着闪存技术的发展、主控芯片的性能提高,固态硬盘的相关技术不断更新,使得能够尽可能满足应用的需求。Currently, the use of solid-state drives is becoming more and more widespread, and the requirements for the performance and capacity of solid-state drives are getting higher. With the development of flash memory technology and the improvement of the performance of the main control chip, the relevant technologies of solid-state drives are constantly updated to meet the needs of applications as much as possible.
随着固态硬盘及NVMe(Non Volatile Memory Host Controller Interface Specification,非易失性内存主机控制器接口规范)技术的发展,存储系统、互联网应用对于固态硬盘提出了更高的要求,需要更高的性能,更好的寿命,当前影响固态硬盘寿命的关键点在于闪存介质寿命及FTL(Flash Translation Layer,闪存转换层)的磨损均衡算法,闪存介质本身的寿命取决于闪存介质技术的发展及厂商的能力,对于固态硬盘厂商来说,提供高效的磨损均衡算法是提升寿命的关键。With the development of SSD and NVMe (Non Volatile Memory Host Controller Interface Specification) technology, storage systems and Internet applications have put forward higher requirements for SSDs, requiring higher performance and better lifespan. Currently, the key points affecting the lifespan of SSDs are the lifespan of flash media and the wear-leveling algorithm of FTL (Flash Translation Layer). The lifespan of the flash media itself depends on the development of flash media technology and the capabilities of the manufacturer. For SSD manufacturers, providing an efficient wear-leveling algorithm is the key to prolonging lifespan.
发明内容Summary of the invention
鉴于上述问题,提出了以便提供克服上述问题或者至少部分地解决上述问题的一种磨损均衡的方法、装置、电子设备和存储介质,包括:In view of the above problems, a wear leveling method, device, electronic device and storage medium are proposed to overcome the above problems or at least partially solve the above problems, including:
一种磨损均衡的方法,方法包括:A wear leveling method, the method comprising:
获取目标固态硬盘中各逻辑地址的抹写频率,目标固态硬盘包括多个物理存储区域;Obtaining the write-erase frequency of each logical address in a target solid-state hard disk, where the target solid-state hard disk includes multiple physical storage areas;
根据第一物理存储区域所对应的多个逻辑地址的抹写频率,确定第一物理存储区域的目标抹写频率,并获取第一物理存储区域的目标磨损程度;Determine a target write-erase frequency of the first physical storage area according to the write-erase frequencies of the plurality of logical addresses corresponding to the first physical storage area, and obtain a target wear degree of the first physical storage area;
判断目标抹写频率与目标磨损程度是否满足预设匹配条件;Determine whether the target erasure frequency and the target wear degree meet the preset matching conditions;
当目标抹写频率与目标磨损程度不满足预设匹配条件时,从除第一物理存储区域外的其他物理存储区域中,确定一与目标抹写频率满足预设匹配条件的第二物理存储区域;When the target write-erase frequency and the target wear degree do not satisfy a preset matching condition, determining a second physical storage area that satisfies a preset matching condition with the target write-erase frequency from other physical storage areas except the first physical storage area;
将第一物理存储区域中的数据,转移至第二物理存储区域进行存储。The data in the first physical storage area is transferred to the second physical storage area for storage.
本申请一些实施例中,获取目标固态硬盘中各逻辑地址的抹写频率,包括:In some embodiments of the present application, obtaining the erase and write frequency of each logical address in the target solid state drive includes:
对目标固态硬盘中的所有的逻辑地址进行分段,得到多个逻辑地址分段,每段逻辑地址分段包括至少一个逻辑地址;
Segmenting all logical addresses in the target solid state drive to obtain a plurality of logical address segments, each logical address segment including at least one logical address;
确定各逻辑地址分段的抹写频率,并将逻辑地址分段的抹写频率,作为逻辑地址分段所包括的各逻辑地址的抹写频率。The erasing and writing frequency of each logical address segment is determined, and the erasing and writing frequency of the logical address segment is used as the erasing and writing frequency of each logical address included in the logical address segment.
本申请一些实施例中,确定各逻辑地址分段的抹写频率,包括:In some embodiments of the present application, determining the erasing frequency of each logical address segment includes:
统计目标固态硬盘的总抹写次数,以及各逻辑地址分段的段抹写次数;Count the total number of erase/write times of the target solid-state drive and the number of segment erase/write times of each logical address segment;
当总抹写次数超过第一阈值时,根据段抹写次数和总抹写次数,计算各逻辑地址分段的抹写频率。When the total erasure number exceeds the first threshold, the erasure frequency of each logical address segment is calculated according to the segment erasure number and the total erasure number.
本申请一些实施例中,方法还包括:In some embodiments of the present application, the method further includes:
对总抹写次数和段抹写次数进行清零处理,并重新开始统计目标固态硬盘的总抹写次数,以及各逻辑地址分段的段抹写次数。The total erase and write times and the segment erase and write times are cleared, and the total erase and write times of the target solid state drive and the segment erase and write times of each logical address segment are counted again.
本申请一些实施例中,方法还包括:In some embodiments of the present application, the method further includes:
根据各逻辑地址分段的抹写频率,判断目标固态硬盘中的数据是否满足预设分层条件;According to the write-erase frequency of each logical address segment, determining whether the data in the target solid state drive meets the preset tiering condition;
当目标固态硬盘中的数据满足预设分层条件时,根据各逻辑地址分段的抹写频率,确定各逻辑地址分段的频率等级;When the data in the target solid state drive meets the preset tiering condition, the frequency level of each logical address segment is determined according to the erase and write frequency of each logical address segment;
针对待写入物理存储区域的目标数据,确定目标数据对应的目标逻辑地址分段;For target data to be written into the physical storage area, determining a target logical address segment corresponding to the target data;
根据目标逻辑地址分段的频率等级,确定对应的第三物理存储区域,并将目标数据写入第三物理存储区域。According to the frequency level of the target logical address segment, a corresponding third physical storage area is determined, and the target data is written into the third physical storage area.
本申请一些实施例中,方法还包括:In some embodiments of the present application, the method further includes:
当目标固态硬盘中的数据不满足预设分层条件时,对各逻辑地址分段的抹写频率进行清零处理,并重新开始计算各逻辑地址分段的抹写频率。When the data in the target solid state drive does not meet the preset tiering condition, the erase and write frequencies of each logical address segment are cleared, and the erase and write frequencies of each logical address segment are recalculated.
本申请一些实施例中,根据各逻辑地址分段的抹写频率,判断目标固态硬盘中的数据是否满足预设分层条件,包括:In some embodiments of the present application, judging whether the data in the target solid-state drive meets the preset tiering condition according to the erase and write frequency of each logical address segment includes:
确定抹写频率最高的前M个逻辑地址分段,并计算抹写频率最高的前M个逻辑地址分段的总的抹写频率,M为正整数;Determine the first M logical address segments with the highest erasure frequency, and calculate the total erasure frequency of the first M logical address segments with the highest erasure frequency, where M is a positive integer;
当前M个逻辑地址分段的总的抹写频率大于第三阈值时,判定目标固态硬盘中的数据满足预设分层条件。When the total write-erase frequency of the current M logical address segments is greater than a third threshold, it is determined that the data in the target solid state drive meets the preset tiering condition.
本申请一些实施例中,根据各逻辑地址分段的抹写频率,确定各逻辑地址分段的频率等级,包括:In some embodiments of the present application, the frequency level of each logical address segment is determined according to the erase and write frequency of each logical address segment, including:
按照各逻辑地址的抹写频率的大小,对各逻辑地址分段进行排序;Sort the logical address segments according to the erase and write frequencies of the logical addresses;
基于各逻辑地址分段的排序,确定各逻辑地址分段的频率等级。Based on the ranking of the logical address segments, a frequency rank of the logical address segments is determined.
本申请一些实施例中,根据目标逻辑地址分段的频率等级,确定对应的第三物理存储区域,包括:In some embodiments of the present application, determining the corresponding third physical storage area according to the frequency level of the target logical address segment includes:
按照磨损程度的大小,对各物理存储区域进行排序;Sort each physical storage area according to the degree of wear;
基于各物理存储区域的排序,确定各物理存储区域的磨损等级;Determine the wear level of each physical storage area based on the ranking of each physical storage area;
确定磨损等级与目标逻辑地址分段的频率等级匹配的第三物理存储区域。A third physical storage area having a wear level matching the frequency level of the target logical address segment is determined.
本申请一些实施例中,确定磨损等级与目标逻辑地址分段的频率等级匹配的第三物理存储区域,包括:In some embodiments of the present application, determining a third physical storage area whose wear level matches the frequency level of the target logical address segment includes:
预先建立逻辑地址分段的频率等级与磨损等级的对应关系;Pre-establishing the correspondence between the frequency level and the wear level of the logical address segment;
从对应关系中,确定与目标逻辑地址分段的频率等级对应的目标磨损等级;From the corresponding relationship, determining a target wear level corresponding to the frequency level of the target logical address segment;
将具备目标磨损等级的物理存储区域作为第三物理存储区域。
A physical storage area having a target wear level is used as the third physical storage area.
本申请一些实施例中,根据第一物理存储区域所对应的多个逻辑地址的抹写频率,确定第一物理存储区域的目标抹写频率,包括:In some embodiments of the present application, determining a target erase/write frequency of the first physical storage area according to erase/write frequencies of a plurality of logical addresses corresponding to the first physical storage area includes:
确定第一物理存储区域所对应的多个逻辑地址的抹写频率的目标和值;Determine targets and values of erase and write frequencies of a plurality of logical addresses corresponding to the first physical storage area;
确定第一物理存储区域所对应的逻辑地址的目标数量;Determining a target number of logical addresses corresponding to the first physical storage area;
根据目标和值和目标数量,确定第一物理存储区域的目标抹写频率。A target erasing frequency of the first physical storage area is determined according to the target sum value and the target quantity.
本申请一些实施例中,根据目标和值和目标数量,确定第一物理存储区域的目标抹写频率,包括:In some embodiments of the present application, determining a target erase/write frequency of the first physical storage area according to the target value and the target quantity includes:
计算目标和值与目标数量的第一比值;calculating a first ratio of the target sum value to the target quantity;
计算第一比值与目标数量的第二比值,并将第二比值作为目标抹写频率。A second ratio of the first ratio to the target number is calculated, and the second ratio is used as the target erase frequency.
本申请一些实施例中,获取第一物理存储区域的目标磨损程度,包括:In some embodiments of the present application, obtaining a target wear level of the first physical storage area includes:
获取各物理存储区域的磨损次数;Get the number of wear times of each physical storage area;
根据各物理存储区域的磨损次数,确定第一物理存储区域的第一磨损偏差;Determining a first wear deviation of a first physical storage area according to the number of wears of each physical storage area;
根据第一磨损偏差,确定目标磨损程度。A target wear degree is determined based on the first wear deviation.
本申请一些实施例中,根据各物理存储区域的磨损次数,确定第一物理存储区域的第一磨损偏差,包括:In some embodiments of the present application, determining a first wear deviation of a first physical storage area according to the number of wear times of each physical storage area includes:
从各物理存储区域的磨损次数中,确定一极值磨损次数、一平均磨损次数,以及第一物理存储区域的磨损次数;Determine an extreme wear count, an average wear count, and a wear count of the first physical storage area from the wear counts of each physical storage area;
确定第一物理存储区域的磨损次数和极值磨损次数的第一差值,与平均磨损次数和极值磨损次数的第二差值;Determine a first difference between the number of wear times and the extreme number of wear times of the first physical storage area, and a second difference between the average number of wear times and the extreme number of wear times;
根据第一差值和第二差值的比值,确定第一磨损偏差。A first wear deviation is determined based on a ratio of the first difference to the second difference.
本申请一些实施例中,判断目标抹写频率与目标磨损程度是否满足预设匹配条件,包括:In some embodiments of the present application, determining whether the target erase frequency and the target wear degree meet a preset matching condition includes:
确定目标抹写频率与目标磨损程度的匹配度;Determine the matching degree between the target erase frequency and the target wear degree;
当目标抹写频率与目标磨损程度的匹配度超过第二阈值时,判定目标抹写频率与目标磨损程度满足预设匹配条件。When the matching degree between the target erasing frequency and the target wear degree exceeds a second threshold, it is determined that the target erasing frequency and the target wear degree meet a preset matching condition.
本申请一些实施例中,确定目标抹写频率与目标磨损程度的匹配度,包括:In some embodiments of the present application, determining the matching degree between the target erase frequency and the target wear degree includes:
确定目标抹写频率与目标磨损程度的第三比值;determining a third ratio of the target erase frequency to the target wear degree;
根据第三比值,确定目标抹写频率与目标磨损程度的匹配度。The matching degree between the target erasing frequency and the target wear degree is determined according to the third ratio.
本申请一些实施例中,确定目标抹写频率与目标磨损程度的匹配度,包括:In some embodiments of the present application, determining the matching degree between the target erase frequency and the target wear degree includes:
按照各物理存储区域的抹写频率的大小,对各物理存储区域进行排序,并基于各物理存储区域的排序,确定各物理存储区域的频率等级;Sort the physical storage areas according to the magnitude of the erase and write frequencies of the physical storage areas, and determine the frequency level of the physical storage areas based on the sorting of the physical storage areas;
按照磨损程度的大小,对各物理存储区域进行排序,并基于各物理存储区域的排序,确定各物理存储区域的磨损等级;Sort the physical storage areas according to the degree of wear, and determine the wear level of each physical storage area based on the sort of the physical storage areas;
根据第一物理存储区域对应的磨损等级和频率等级,确定目标抹写频率与目标磨损程度的匹配度。According to the wear level and frequency level corresponding to the first physical storage area, the matching degree between the target write-erase frequency and the target wear degree is determined.
本申请一些实施例中,在将第一物理存储区域中的数据,转移至第二物理存储区域进行存储后,方法还包括:In some embodiments of the present application, after transferring the data in the first physical storage area to the second physical storage area for storage, the method further includes:
根据所转移的数据,对第一物理存储区域和第二物理存储区域的抹写频率进行更新。The write-erase frequencies of the first physical storage area and the second physical storage area are updated according to the transferred data.
本申请实施例还提供了一种磨损均衡的装置,装置包括:The embodiment of the present application also provides a wear leveling device, the device comprising:
第一获取模块,用于获取目标固态硬盘中各逻辑地址的抹写频率,目标固态硬盘包括多
个物理存储区域;The first acquisition module is used to obtain the erase and write frequency of each logical address in the target solid-state hard disk. The target solid-state hard disk includes multiple physical storage area;
第二获取模块,用于根据第一物理存储区域所对应的多个逻辑地址的抹写频率,确定第一物理存储区域的目标抹写频率,并获取第一物理存储区域的目标磨损程度;A second acquisition module, configured to determine a target write-erase frequency of the first physical storage area according to the write-erase frequencies of a plurality of logical addresses corresponding to the first physical storage area, and to acquire a target wear degree of the first physical storage area;
第一判断模块,用于判断目标抹写频率与目标磨损程度是否满足预设匹配条件;A first judgment module is used to judge whether the target erasure frequency and the target wear degree meet a preset matching condition;
第一确定模块,用于当目标抹写频率与目标磨损程度不满足预设匹配条件时,从除第一物理存储区域外的其他物理存储区域中,确定一与目标抹写频率满足预设匹配条件的第二物理存储区域;A first determination module is used to determine a second physical storage area that meets the preset matching condition with the target erasing frequency from other physical storage areas except the first physical storage area when the target erasing frequency and the target wear degree do not meet the preset matching condition;
转移模块,用于将第一物理存储区域中的数据,转移至第二物理存储区域进行存储。The transfer module is used to transfer the data in the first physical storage area to the second physical storage area for storage.
本申请一些实施例中,第一获取模块,用于对目标固态硬盘中的所有的逻辑地址进行分段,得到多个逻辑地址分段,每段逻辑地址分段包括至少一个逻辑地址;确定各逻辑地址分段的抹写频率,并将逻辑地址分段的抹写频率,作为逻辑地址分段所包括的各逻辑地址的抹写频率。In some embodiments of the present application, a first acquisition module is used to segment all logical addresses in a target solid-state hard disk to obtain multiple logical address segments, each logical address segment including at least one logical address; determine the erase and write frequency of each logical address segment, and use the erase and write frequency of the logical address segment as the erase and write frequency of each logical address included in the logical address segment.
本申请一些实施例中,第一获取模块,用于统计目标固态硬盘的总抹写次数,以及各逻辑地址分段的段抹写次数;当总抹写次数超过第一阈值时,根据段抹写次数和总抹写次数,计算各逻辑地址分段的抹写频率。In some embodiments of the present application, the first acquisition module is used to count the total number of erase and write times of the target solid-state hard disk, and the number of segment erase and write times of each logical address segment; when the total number of erase and write times exceeds the first threshold, the erase and write frequency of each logical address segment is calculated based on the segment erase and write times and the total erase and write times.
本申请一些实施例中,装置还包括:In some embodiments of the present application, the device further includes:
第一清零模块,用于对总抹写次数和段抹写次数进行清零处理,并重新开始统计目标固态硬盘的总抹写次数,以及各逻辑地址分段的段抹写次数。The first clearing module is used to clear the total erase and write times and the segment erase and write times, and restart counting the total erase and write times of the target solid state drive and the segment erase and write times of each logical address segment.
本申请一些实施例中,装置还包括:In some embodiments of the present application, the device further includes:
写入模块,用于根据各逻辑地址分段的抹写频率,判断目标固态硬盘中的数据是否满足预设分层条件;当目标固态硬盘中的数据满足预设分层条件时,根据各逻辑地址分段的抹写频率,确定各逻辑地址分段的频率等级;针对待写入物理存储区域的目标数据,确定目标数据对应的目标逻辑地址分段;根据目标逻辑地址分段的频率等级,确定对应的第三物理存储区域,并将目标数据写入第三物理存储区域。A write module is used to determine whether the data in the target solid-state hard disk meets the preset stratification conditions according to the write-erasing frequency of each logical address segment; when the data in the target solid-state hard disk meets the preset stratification conditions, determine the frequency level of each logical address segment according to the write-erasing frequency of each logical address segment; for the target data to be written into the physical storage area, determine the target logical address segment corresponding to the target data; determine the corresponding third physical storage area according to the frequency level of the target logical address segment, and write the target data into the third physical storage area.
本申请一些实施例中,装置还包括:In some embodiments of the present application, the device further includes:
第二清零模块,用于当目标固态硬盘中的数据不满足预设分层条件时,对各逻辑地址分段的抹写频率进行清零处理,并重新开始计算各逻辑地址分段的抹写频率。The second clearing module is used to clear the write-erase frequency of each logical address segment and restart the calculation of the write-erase frequency of each logical address segment when the data in the target solid state drive does not meet the preset stratification condition.
本申请一些实施例中,写入模块,用于确定抹写频率最高的前M个逻辑地址分段,并计算抹写频率最高的前M个逻辑地址分段的总的抹写频率,M为正整数;当前M个逻辑地址分段的总的抹写频率大于第三阈值时,判定目标固态硬盘中的数据满足预设分层条件。In some embodiments of the present application, the write module is used to determine the top M logical address segments with the highest erase frequency, and calculate the total erase frequency of the top M logical address segments with the highest erase frequency, where M is a positive integer; when the total erase frequency of the current M logical address segments is greater than a third threshold, it is determined that the data in the target solid-state drive meets the preset stratification conditions.
本申请一些实施例中,写入模块,用于按照各逻辑地址的抹写频率的大小,对各逻辑地址分段进行排序;基于各逻辑地址分段的排序,确定各逻辑地址分段的频率等级。In some embodiments of the present application, the write module is used to sort the logical address segments according to the magnitude of the erase and write frequency of each logical address; and determine the frequency level of each logical address segment based on the sorting of the logical address segments.
本申请一些实施例中,写入模块,用于按照磨损程度的大小,对各物理存储区域进行排序;基于各物理存储区域的排序,确定各物理存储区域的磨损等级;确定磨损等级与目标逻辑地址分段的频率等级匹配的第三物理存储区域。In some embodiments of the present application, a write module is used to sort each physical storage area according to the degree of wear; determine the wear level of each physical storage area based on the sorting of each physical storage area; and determine a third physical storage area whose wear level matches the frequency level of the target logical address segment.
本申请一些实施例中,写入模块,用于预先建立逻辑地址分段的频率等级与磨损等级的对应关系;从对应关系中,确定与目标逻辑地址分段的频率等级对应的目标磨损等级;将具备目标磨损等级的物理存储区域作为第三物理存储区域。In some embodiments of the present application, a write module is used to pre-establish a correspondence between the frequency level and the wear level of the logical address segment; from the correspondence, determine the target wear level corresponding to the frequency level of the target logical address segment; and use the physical storage area with the target wear level as the third physical storage area.
本申请一些实施例中,第二获取模块,用于确定第一物理存储区域所对应的多个逻辑地
址的抹写频率的目标和值;确定第一物理存储区域所对应的逻辑地址的目标数量;根据目标和值和目标数量,确定第一物理存储区域的目标抹写频率。In some embodiments of the present application, the second acquisition module is used to determine the plurality of logical locations corresponding to the first physical storage area. determining a target number of logical addresses corresponding to the first physical storage area; and determining a target erasing frequency of the first physical storage area according to the target sum and the target number.
本申请一些实施例中,第二获取模块,用于计算目标和值与目标数量的第一比值;计算第一比值与目标数量的第二比值,并将第二比值作为目标抹写频率。In some embodiments of the present application, the second acquisition module is used to calculate a first ratio of the target sum value to the target quantity; calculate a second ratio of the first ratio to the target quantity, and use the second ratio as the target erase frequency.
本申请一些实施例中,第二获取模块,用于获取各物理存储区域的磨损次数;根据各物理存储区域的磨损次数,确定第一物理存储区域的第一磨损偏差;根据第一磨损偏差,确定目标磨损程度。In some embodiments of the present application, the second acquisition module is used to obtain the number of wear times of each physical storage area; determine the first wear deviation of the first physical storage area based on the number of wear times of each physical storage area; and determine the target wear degree based on the first wear deviation.
本申请一些实施例中,第二获取模块,用于从各物理存储区域的磨损次数中,确定一极值磨损次数、一平均磨损次数,以及第一物理存储区域的磨损次数;确定第一物理存储区域的磨损次数和极值磨损次数的第一差值,与平均磨损次数和极值磨损次数的第二差值;根据第一差值和第二差值的比值,确定第一磨损偏差。In some embodiments of the present application, the second acquisition module is used to determine an extreme wear count, an average wear count, and the wear count of the first physical storage area from the wear counts of each physical storage area; determine a first difference between the wear count and the extreme wear count of the first physical storage area, and a second difference between the average wear count and the extreme wear count; and determine a first wear deviation based on the ratio of the first difference to the second difference.
本申请一些实施例中,第一判断模块,用于确定目标抹写频率与目标磨损程度的匹配度;当目标抹写频率与目标磨损程度的匹配度超过第二阈值时,判定目标抹写频率与目标磨损程度满足预设匹配条件。In some embodiments of the present application, the first judgment module is used to determine the matching degree between the target erasure frequency and the target wear degree; when the matching degree between the target erasure frequency and the target wear degree exceeds a second threshold, it is determined that the target erasure frequency and the target wear degree meet a preset matching condition.
本申请一些实施例中,第一判断模块,用于确定目标抹写频率与目标磨损程度的第三比值;根据第三比值,确定目标抹写频率与目标磨损程度的匹配度。In some embodiments of the present application, the first judgment module is used to determine a third ratio of the target erase frequency to the target wear degree; and determine the matching degree of the target erase frequency and the target wear degree based on the third ratio.
本申请一些实施例中,第一判断模块,用于按照各物理存储区域的抹写频率的大小,对各物理存储区域进行排序,并基于各物理存储区域的排序,确定各物理存储区域的频率等级;按照磨损程度的大小,对各物理存储区域进行排序,并基于各物理存储区域的排序,确定各物理存储区域的磨损等级;根据第一物理存储区域对应的磨损等级和频率等级,确定目标抹写频率与目标磨损程度的匹配度。In some embodiments of the present application, a first judgment module is used to sort each physical storage area according to the erase and write frequency of each physical storage area, and determine the frequency level of each physical storage area based on the sorting of each physical storage area; sort each physical storage area according to the degree of wear, and determine the wear level of each physical storage area based on the sorting of each physical storage area; determine the matching degree of the target erase and write frequency and the target wear level according to the wear level and frequency level corresponding to the first physical storage area.
本申请一些实施例中,装置还包括:In some embodiments of the present application, the device further includes:
更新模块,用于在将第一物理存储区域中的数据,转移至第二物理存储区域进行存储后,根据所转移的数据,对第一物理存储区域和第二物理存储区域的抹写频率进行更新。The update module is used to update the erasing and writing frequencies of the first physical storage area and the second physical storage area according to the transferred data after transferring the data in the first physical storage area to the second physical storage area for storage.
本申请实施例还提供了一种电子设备,包括处理器、存储器及存储在存储器上并能够在处理器上运行的计算机程序,计算机程序被处理器执行时实现如上的磨损均衡的方法。An embodiment of the present application also provides an electronic device, including a processor, a memory, and a computer program stored in the memory and capable of running on the processor, and the computer program implements the above wear leveling method when executed by the processor.
本申请实施例还提供了一种非易失性可读存储介质,非易失性可读存储介质上存储计算机程序,计算机程序被处理器执行时实现如上的磨损均衡的方法。An embodiment of the present application further provides a non-volatile readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the above-mentioned wear leveling method is implemented.
本申请实施例具有以下优点:The embodiments of the present application have the following advantages:
本申请实施例中,可以先获取目标固态硬盘中各逻辑地址的抹写频率;然后根据第一物理存储区域所对应的多个逻辑地址的抹写频率,确定第一物理存储区域的目标抹写频率,并获取第一物理存储区域的目标磨损程度;之后,判断目标抹写频率与目标磨损程度是否满足预设匹配条件;如果目标抹写频率与目标磨损程度不满足预设匹配条件的话,则从除第一物理存储区域外的其他物理存储区域中,确定一与目标抹写频率满足预设匹配条件的第二物理存储区域,并将第一物理存储区域中的数据,转移至第二物理存储区域进行存储。通过关注物理存储区域的整体的抹写频率,和对应的磨损程度的关系,来进行磨损均衡,可以避免现有技术中仅关注磨损程度来进行磨损均衡所存在的问题,从而提高了磨损均衡的效率,避免了固态硬盘寿命的浪费。In the embodiment of the present application, the write-erase frequency of each logical address in the target solid-state hard disk can be obtained first; then, according to the write-erase frequency of multiple logical addresses corresponding to the first physical storage area, the target write-erase frequency of the first physical storage area is determined, and the target wear degree of the first physical storage area is obtained; then, it is determined whether the target write-erase frequency and the target wear degree meet the preset matching condition; if the target write-erase frequency and the target wear degree do not meet the preset matching condition, then a second physical storage area that meets the preset matching condition with the target write-erase frequency is determined from other physical storage areas except the first physical storage area, and the data in the first physical storage area is transferred to the second physical storage area for storage. By focusing on the relationship between the overall write-erase frequency of the physical storage area and the corresponding wear degree to perform wear leveling, the problem existing in the prior art of only focusing on the wear degree to perform wear leveling can be avoided, thereby improving the efficiency of wear leveling and avoiding the waste of the life of the solid-state hard disk.
为了更清楚地说明本申请的技术方案,下面将对本申请的描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solution of the present application, the drawings required for use in the description of the present application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
图1是本申请实施例的一种磨损均衡的方法的步骤流程图;FIG1 is a flowchart of a wear leveling method according to an embodiment of the present application;
图2是本申请实施例的另一种磨损均衡的方法的步骤流程图;FIG2 is a flowchart of another wear leveling method according to an embodiment of the present application;
图3是本申请实施例的一种固态硬盘的示意图;FIG3 is a schematic diagram of a solid state drive according to an embodiment of the present application;
图4是本申请实施例的一种数据写入的步骤流程图;FIG4 is a flowchart of a data writing step according to an embodiment of the present application;
图5是本申请实施例的一种磨损均衡的装置的结构示意图;FIG5 is a schematic diagram of the structure of a wear leveling device according to an embodiment of the present application;
图6是本申请实施例的一种电子设备的结构示意图;FIG6 is a schematic diagram of the structure of an electronic device according to an embodiment of the present application;
图7是本申请实施例的一种非易失性可读存储介质的结构示意图。FIG. 7 is a schematic diagram of the structure of a non-volatile readable storage medium according to an embodiment of the present application.
为使本申请的上述目的、特征和优点能够更加明显易懂,下面结合附图和具体实施方式对本申请作进一步详细的说明。显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。In order to make the above-mentioned purposes, features and advantages of the present application more obvious and easy to understand, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.
为了保证固态硬盘的使用寿命,可以在各物理存储区域的磨损程度出现差异时,触发磨损均衡;具体的,可以将磨损较小的物理存储区域中的数据重新存储到其他物理存储区域中。In order to ensure the service life of the solid-state drive, wear leveling can be triggered when the degree of wear of each physical storage area differs; specifically, data in a physical storage area with less wear can be restored to other physical storage areas.
例如:当所有block(即物理存储区域)的磨损程度中最大值、最小值与平均值相差较大时,就需要触发磨损均衡;此时,可以将磨损程度较小的blockA中的数据搬移到磨损较大的blockB中,然后将blockA擦除后使用,以达到增加blockA的磨损,缩小最小磨损程度与平均值和最大值间的差距。For example, when the maximum, minimum and average values of the wear degree of all blocks (i.e., physical storage areas) differ greatly, wear leveling needs to be triggered. At this time, the data in blockA with less wear can be moved to blockB with greater wear, and then blockA can be erased and used again to increase the wear of blockA and reduce the gap between the minimum wear degree and the average and maximum values.
以上方法的弊端在于:blockA的磨损程度增加后可能仍然是最小的,就需要将blockA中新写入的数据继续搬移到另外一个blockC中,总体上看,数据的存储结果只存在于blockB和blockC中,与直接将新写入blockA中的数据写入blockC效果基本一致;但是,反而在blockA上进行了一次无意义的擦除,这无疑浪费了固态硬盘的寿命。The disadvantage of the above method is that after the wear degree of blockA increases, it may still be the smallest, so the newly written data in blockA needs to be moved to another blockC. Overall, the data storage result only exists in blockB and blockC, which is basically the same as directly writing the newly written data in blockA to blockC; however, a meaningless erasure is performed on blockA, which undoubtedly wastes the life of the SSD.
为了提升磨损均衡的效果,避免出现反复磨损Block的情况,本申请实施例提供了一种磨损均衡的方法;其不再仅基于磨损程度来进行磨损均衡的判定,而是基于物理存储区域的整体的抹写频率,和对应的磨损程度的关系,来判定是否需要进行磨损均衡。其中,物理存储区域的整体的抹写频率可以表示该物理存储区域中所存储的所有数据的总的抹写频率;抹写频率即抹除和写入的频率。In order to improve the effect of wear leveling and avoid the situation of repeated wear of blocks, the embodiment of the present application provides a wear leveling method; it no longer determines wear leveling based only on the degree of wear, but determines whether wear leveling is needed based on the overall erase and write frequency of the physical storage area and the relationship between the corresponding degree of wear. Among them, the overall erase and write frequency of the physical storage area can represent the total erase and write frequency of all data stored in the physical storage area; the erase and write frequency is the frequency of erasing and writing.
当物理存储区域的整体的抹写频率,和对应的磨损程度的不匹配时,可以认为需要对该物理存储区域进行磨损均衡;此时,可以将该物理存储区域的数据转移至磨损程度与该物理存储区域的整体的抹写频率匹配的另一物理存储区域中进行存储;通过关注物理存储区域的整体的抹写频率,和对应的磨损程度的关系,来进行磨损均衡,可以避免现有技术中仅关注磨损程度来进行磨损均衡所存在的问题,从而提高了磨损均衡的效率,避免了固态硬盘寿命的浪费。When the overall write-erase frequency of a physical storage area does not match the corresponding degree of wear, it can be considered that wear leveling is required for the physical storage area; at this time, the data in the physical storage area can be transferred to another physical storage area whose wear degree matches the overall write-erase frequency of the physical storage area for storage; by focusing on the relationship between the overall write-erase frequency of the physical storage area and the corresponding degree of wear to perform wear leveling, the problems existing in the prior art of only focusing on the degree of wear to perform wear leveling can be avoided, thereby improving the efficiency of wear leveling and avoiding waste of the life of the solid-state hard drive.
参照图1,示出了本申请实施例的一种磨损均衡的方法的步骤流程图,可以包括如下步骤:1 , a flowchart of a wear leveling method according to an embodiment of the present application is shown, which may include the following steps:
步骤101、获取目标固态硬盘中各逻辑地址的抹写频率,目标固态硬盘包括多个物理存
储区域。Step 101: Obtain the write/erasure frequency of each logical address in the target solid-state hard disk, where the target solid-state hard disk includes multiple physical storage devices. Storage area.
其中,逻辑地址可以指应用程序角度看到的内存单元、存储单元、网络主机的地址。物理存储区域可以指目标固态硬盘中用于数据存储的物理存储区域。The logical address may refer to the address of a memory unit, a storage unit, or a network host from the perspective of an application program, and the physical storage area may refer to a physical storage area in a target solid state drive for data storage.
逻辑地址可以与一数据对应,该数据可以写在目标固态硬盘的一物理存储区域中;一个物理存储区域中可以存储多个数据。The logical address may correspond to a piece of data, and the data may be written in a physical storage area of the target solid state drive; a plurality of pieces of data may be stored in one physical storage area.
在实际应用中,为了避免出现因为仅关注磨损程度来进行磨损均衡而导致的问题,本申请实施例可以将注意力放在物理存储区域的整体的抹写频率,和对应的磨损程度上;从而,基于物理存储区域的整体的抹写频率,和对应的磨损程度的关系,来进行磨损均衡。In practical applications, in order to avoid the problems caused by only focusing on the degree of wear for wear leveling, the embodiments of the present application can focus on the overall erase frequency of the physical storage area and the corresponding degree of wear; thus, wear leveling is performed based on the relationship between the overall erase frequency of the physical storage area and the corresponding degree of wear.
具体的,由于每个物理存储区域中存储有多个数据,而数据又与目标固态硬盘中的逻辑地址存在一一对应的关系;因此,可以先获取目标固态硬盘中各逻辑地址的抹写频率。Specifically, since each physical storage area stores multiple data, and the data has a one-to-one correspondence with the logical address in the target solid state drive, the write-erase frequency of each logical address in the target solid state drive can be obtained first.
作为一示例,各逻辑地址的抹写频率可以是预先统计的;具体的,可以预先统计逻辑地址所对应的数据的抹写频率,然后基于逻辑地址所对应的数据的抹写频率,来确定逻辑地址的抹写频率。As an example, the erasure frequency of each logical address may be counted in advance; specifically, the erasure frequency of data corresponding to the logical address may be counted in advance, and then the erasure frequency of the logical address may be determined based on the erasure frequency of the data corresponding to the logical address.
其中,在统计逻辑地址所对应的数据的抹写频率时,可以基于一数据的抹写次数,和目标固态硬盘的总的抹写次数的比值,来确定该一数据的抹写频率;进而,可以基于该一数据的抹写频率,确定该一数据所对应的逻辑地址的抹写频率。Among them, when counting the erase and write frequency of the data corresponding to the logical address, the erase and write frequency of the data can be determined based on the ratio of the number of erase and write times of the data to the total number of erase and write times of the target solid-state hard disk; further, the erase and write frequency of the logical address corresponding to the data can be determined based on the erase and write frequency of the data.
步骤102、根据第一物理存储区域所对应的多个逻辑地址的抹写频率,确定第一物理存储区域的目标抹写频率,并获取第一物理存储区域的目标磨损程度。Step 102: Determine a target write/erase frequency of the first physical storage area according to the write/erase frequencies of a plurality of logical addresses corresponding to the first physical storage area, and obtain a target wear degree of the first physical storage area.
其中,第一物理存储区域可以是目标固态硬盘中的任一物理存储区域。The first physical storage area may be any physical storage area in the target solid state drive.
在需要判定第一物理存储区域是否需要进行磨损均衡的时候,可以先根据所获取的逻辑地址的抹写频率,确定第一物理存储区域的目标抹写频率。When it is necessary to determine whether the first physical storage area needs to be wear leveled, the target erasing frequency of the first physical storage area may be determined according to the acquired erasing frequency of the logical address.
具体的,由于每个物理存储区域中存储有多个数据,而每个数据又对应于一个逻辑地址;因此,在确定第一物理存储区域的目标抹写频率的时候,可以先确定第一物理存储区域所对应的多个数据所对应的多个逻辑地址。Specifically, since each physical storage area stores multiple data and each data corresponds to a logical address, when determining the target erase frequency of the first physical storage area, the multiple logical addresses corresponding to the multiple data corresponding to the first physical storage area can be determined first.
然后,可以基于第一物理存储区域所对应的多个数据所对应的多个逻辑地址的抹写频率,计算第一物理存储区域的目标抹写频率。例如:可以将该多个逻辑地址的抹写频率的总和作为目标抹写频率,也可以将该多个逻辑地址的抹写频率的平均值作为目标抹写频率,本申请实施例对此不作限制。Then, the target write-erase frequency of the first physical storage area can be calculated based on the write-erase frequencies of the multiple logical addresses corresponding to the multiple data corresponding to the first physical storage area. For example, the sum of the write-erase frequencies of the multiple logical addresses can be used as the target write-erase frequency, or the average of the write-erase frequencies of the multiple logical addresses can be used as the target write-erase frequency, which is not limited in the embodiments of the present application.
在计算第一物理存储区域的目标抹写频率的同时,还可以获取该第一物理存储区域的目标磨损程度。While calculating the target write-erase frequency of the first physical storage area, the target wear degree of the first physical storage area can also be obtained.
其中,目标磨损程度可以用于表示第一物理存储区域的磨损情况,目标磨损程度可以基于第一物理存储区域的磨损次数来确定,也可以基于第一物理存储区域的磨损次数,和目标固态硬盘中除第一物理存储区域外的其他物理存储区域的磨损次数来确定。Among them, the target wear degree can be used to represent the wear condition of the first physical storage area. The target wear degree can be determined based on the number of wear times of the first physical storage area, or based on the number of wear times of the first physical storage area and the number of wear times of other physical storage areas in the target solid state drive except the first physical storage area.
步骤103、判断目标抹写频率与目标磨损程度是否满足预设匹配条件。Step 103: Determine whether the target erasing frequency and the target wear degree meet a preset matching condition.
在实际应用中,目标抹写频率越高,则表示第一物理存储区域中存储的数据的抹写频率越高;目标抹写频率越低,则表示第一物理存储区域中存储的数据的抹写频率越低。相比于抹写频率低的数据来说,抹写频率高的数据将使得物理存储区域的磨损程度高,进而导致该物理存储区域可能更早的损坏,从而影响到目标固态硬盘的整体的寿命。In actual applications, the higher the target write-erase frequency, the higher the write-erase frequency of the data stored in the first physical storage area; the lower the target write-erase frequency, the lower the write-erase frequency of the data stored in the first physical storage area. Compared with data with a low write-erase frequency, data with a high write-erase frequency will cause a high degree of wear on the physical storage area, which may lead to earlier damage to the physical storage area, thereby affecting the overall life of the target solid-state drive.
因此,本申请实施例在得到第一物理存储区域的目标抹写频率和目标磨损程度后,可以
判断第一物理存储区域的目标抹写频率,与第一物理存储区域的目标磨损程度是否满足预设匹配条件。Therefore, after obtaining the target erasing frequency and target wear degree of the first physical storage area, the embodiment of the present application can It is determined whether the target write-erase frequency of the first physical storage area and the target wear degree of the first physical storage area meet a preset matching condition.
具体的,如果第一物理存储区域的目标磨损程度较高的话,则可以表示第一物理存储区域相比于目标固态硬盘中的其他物理存储区域来说,将可能更早的损坏。对于可能更早损坏的第一物理存储区域来说,如果目标抹写频率较高的话,可以表示该第一物理存储区域中所存储的数据的抹写频率较高,而这可能会导致第一物理存储区域更快地损坏。针对这种情况,可以判定目标抹写频率与目标磨损程度是不满足预设匹配条件的。Specifically, if the target wear degree of the first physical storage area is high, it may indicate that the first physical storage area may be damaged earlier than other physical storage areas in the target solid state drive. For the first physical storage area that may be damaged earlier, if the target write-erase frequency is high, it may indicate that the write-erase frequency of the data stored in the first physical storage area is high, which may cause the first physical storage area to be damaged faster. In this case, it can be determined that the target write-erase frequency and the target wear degree do not meet the preset matching condition.
当判定目标抹写频率与目标磨损程度是不满足预设匹配条件的时候,可以表示第一物理存储区域需要进行磨损均衡;此时,可以继续执行步骤104,以对第一物理存储区域进行磨损均衡。When it is determined that the target erasing frequency and the target wear degree do not meet the preset matching condition, it may indicate that the first physical storage area needs to be wear leveled. At this time, step 104 may be continued to be executed to perform wear leveling on the first physical storage area.
而如果第一物理存储区域的目标磨损程度较高,且目标抹写频率较低的话,可以判定目标抹写频率与目标磨损程度是满足预设匹配条件的。If the target wear degree of the first physical storage area is high and the target erasure frequency is low, it can be determined that the target erasure frequency and the target wear degree meet the preset matching condition.
当判定目标抹写频率与目标磨损程度是满足预设匹配条件的时候,可以表示第一物理存储区域不需要进行磨损均衡;此时,可以针对另一物理存储区域执行步骤101,本申请实施例对此不作限制。When it is determined that the target erase frequency and the target wear degree meet the preset matching conditions, it can be indicated that the first physical storage area does not need wear leveling; at this time, step 101 can be performed for another physical storage area, and the embodiment of the present application does not limit this.
步骤104、当目标抹写频率与目标磨损程度不满足预设匹配条件时,从除第一物理存储区域外的其他物理存储区域中,确定一与目标抹写频率满足预设匹配条件的第二物理存储区域。Step 104: When the target write-erase frequency and the target wear degree do not satisfy a preset matching condition, a second physical storage area that satisfies a preset matching condition with the target write-erase frequency is determined from other physical storage areas except the first physical storage area.
在实际应用中,当判定目标抹写频率与目标磨损程度不满足预设匹配条件的时候,可以先确定目标固态硬盘中,除第一物理存储区域外的其他物理存储区域。In practical applications, when it is determined that the target write-erase frequency and the target wear degree do not satisfy a preset matching condition, other physical storage areas except the first physical storage area in the target solid state drive may be determined first.
然后,可以确定这些其他物理存储区域分别对应的磨损程度,并基于各其他物理存储区域的磨损程度,确定一与目标抹写频率满足预设匹配条件的第二物理存储区域;第二物理存储区域可以指磨损程度与目标抹写频率满足预设匹配条件的物理存储区域。Then, the degree of wear corresponding to these other physical storage areas can be determined, and based on the degree of wear of each other physical storage area, a second physical storage area that meets the preset matching conditions with the target erase frequency can be determined; the second physical storage area can refer to a physical storage area whose degree of wear meets the preset matching conditions with the target erase frequency.
本申请一些实施例中,在确定第二物理存储区域的时候,可以逐个判断其他物理存储区域的磨损程度是否与目标抹写频率匹配;如果一其他物理存储区域的磨损程度与目标抹写频率满足预设匹配条件的话,则可以将该一其他物理存储区域作为第二物理存储区域。In some embodiments of the present application, when determining the second physical storage area, it is possible to determine one by one whether the degree of wear of other physical storage areas matches the target erase frequency; if the degree of wear of another physical storage area and the target erase frequency meet the preset matching conditions, then the other physical storage area can be used as the second physical storage area.
步骤105、将第一物理存储区域中的数据,转移至第二物理存储区域进行存储。Step 105: Transfer the data in the first physical storage area to the second physical storage area for storage.
在确定第二物理存储区域后,可以将第一物理存储区域中的数据转移至所确定的第二物理存储区域中进行存储。After the second physical storage area is determined, the data in the first physical storage area may be transferred to the determined second physical storage area for storage.
在实际应用中,上述磨损均衡的过程可以是同时针对目标固态硬盘中的所有的物理存储区域;也就是说,在将第一物理存储区域中的数据转移至第二物理存储区域中的时候,也可能将第二物理存储区域中的数据转移至第三物理存储区域中、将第三物理存储区域中的数据转移至第一物理存储区域中;从而,实现各物理存储区域的磨损程度,与各物理存储区域所对应的抹写频率都是满足预设匹配条件的。In actual applications, the above-mentioned wear leveling process can be simultaneously performed on all physical storage areas in the target solid-state hard disk; that is, when transferring data from the first physical storage area to the second physical storage area, it is also possible to transfer data from the second physical storage area to the third physical storage area, and transfer data from the third physical storage area to the first physical storage area; thereby, the degree of wear of each physical storage area and the erase and write frequency corresponding to each physical storage area meet the preset matching conditions.
需要说明的是,上述“第一”、“第二”仅是为了进行区分说明,并不是具体指某一物理存储地址。It should be noted that the above-mentioned “first” and “second” are only for distinction and do not specifically refer to a certain physical storage address.
本申请实施例中,可以先获取目标固态硬盘中各逻辑地址的抹写频率;然后根据第一物理存储区域所对应的多个逻辑地址的抹写频率,确定第一物理存储区域的目标抹写频率,并获取第一物理存储区域的目标磨损程度;之后,判断目标抹写频率与目标磨损程度是否满足
预设匹配条件;如果目标抹写频率与目标磨损程度不满足预设匹配条件的话,则从除第一物理存储区域外的其他物理存储区域中,确定一与目标抹写频率满足预设匹配条件的第二物理存储区域,并将第一物理存储区域中的数据,转移至第二物理存储区域进行存储。通过关注物理存储区域的整体的抹写频率,和对应的磨损程度的关系,来进行磨损均衡,可以避免现有技术中仅关注磨损程度来进行磨损均衡所存在的问题,从而提高了磨损均衡的效率,避免了固态硬盘寿命的浪费。In the embodiment of the present application, the write-erase frequency of each logical address in the target solid-state hard disk can be obtained first; then, according to the write-erase frequency of multiple logical addresses corresponding to the first physical storage area, the target write-erase frequency of the first physical storage area is determined, and the target wear degree of the first physical storage area is obtained; then, it is determined whether the target write-erase frequency and the target wear degree meet the requirements. Preset matching conditions; if the target write-erase frequency and the target wear degree do not meet the preset matching conditions, then determine a second physical storage area that meets the preset matching conditions with the target write-erase frequency from other physical storage areas except the first physical storage area, and transfer the data in the first physical storage area to the second physical storage area for storage. By focusing on the relationship between the overall write-erase frequency of the physical storage area and the corresponding wear degree to perform wear leveling, the problem existing in the prior art of only focusing on the wear degree to perform wear leveling can be avoided, thereby improving the efficiency of wear leveling and avoiding the waste of the life of the solid-state hard disk.
参照图2,示出了本申请实施例的另一种磨损均衡的方法的步骤流程图,可以包括如下步骤:2 , a flowchart of another wear leveling method according to an embodiment of the present application is shown, which may include the following steps:
步骤201、对目标固态硬盘中的所有的逻辑地址进行分段,得到多个逻辑地址分段,每段逻辑地址分段包括至少一个逻辑地址。Step 201: segment all logical addresses in the target solid state drive to obtain a plurality of logical address segments, each logical address segment including at least one logical address.
在实际应用中,目标固态硬盘中可能有较多的逻辑地址,如果针对每个逻辑地址都统计对应的抹写频率的话,可能导致目标固态硬盘需要投入较多的资源来存放逻辑地址对应的抹写频率。In actual applications, there may be more logical addresses in the target solid-state drive. If the corresponding erase and write frequencies are counted for each logical address, the target solid-state drive may need to invest more resources to store the erase and write frequencies corresponding to the logical addresses.
为了提高逻辑地址的抹写频率的统计效率,也为了减少目标固态硬盘在存储逻辑地址的抹写频率时投入的资源,本申请实施例可以预先对目标固态硬盘中的所有的逻辑地址进行分段,得到多个逻辑地址分数;其中,每个逻辑地址分段可以包括至少一个逻辑地址,当然,也可以包括多个逻辑地址,本申请实施例对此不作限制。In order to improve the statistical efficiency of the erase and write frequency of the logical addresses, and to reduce the resources invested by the target solid-state drive in storing the erase and write frequency of the logical addresses, the embodiment of the present application can pre-segment all logical addresses in the target solid-state drive to obtain multiple logical address scores; wherein each logical address segment can include at least one logical address, and of course, can also include multiple logical addresses, and the embodiment of the present application does not limit this.
例如:目标固态硬盘包括有1000个逻辑地址,将这100个逻辑地址分成100段,则每一个逻辑地址分段中可以包括有10个逻辑地址。For example, the target solid state drive includes 1000 logical addresses. The 100 logical addresses are divided into 100 segments, and each logical address segment may include 10 logical addresses.
如图3所示,分有逻辑地址分段1和逻辑地址分段2;逻辑地址分段1包括有逻辑地址1和逻辑地址2,逻辑地址分段2包括有逻辑地址3和逻辑地址4。As shown in FIG. 3 , there are logical address segment 1 and logical address segment 2 ; logical address segment 1 includes logical address 1 and logical address 2 , and logical address segment 2 includes logical address 3 and logical address 4 .
步骤202、确定各逻辑地址分段的抹写频率,并将逻辑地址分段的抹写频率,作为逻辑地址分段所包括的各逻辑地址的抹写频率。Step 202: determine the erasing and writing frequency of each logical address segment, and use the erasing and writing frequency of the logical address segment as the erasing and writing frequency of each logical address included in the logical address segment.
在得到多个逻辑地址分段后,可以分别确定每一段逻辑地址分段的抹写频率;一逻辑地址分段的抹写频率,可以基于该一段逻辑地址分段中的所有的逻辑地址对应的数据的抹写情况来确定。After obtaining multiple logical address segments, the erasure frequency of each logical address segment can be determined respectively; the erasure frequency of a logical address segment can be determined based on the erasure status of data corresponding to all logical addresses in the logical address segment.
例如:逻辑地址分段1包括逻辑地址1和逻辑地址2;逻辑地址分段2包括逻辑地址3和逻辑地址4;当逻辑地址1对应的数据进行了抹写操作时,可以对逻辑地址分段1的抹写频率进行更新;同时,将更新后的逻辑地址分段1的抹写频率作为逻辑地址1和逻辑地址2的抹写频率。For example: logical address segment 1 includes logical address 1 and logical address 2; logical address segment 2 includes logical address 3 and logical address 4; when the data corresponding to logical address 1 is erased or written, the erase frequency of logical address segment 1 can be updated; at the same time, the updated erase frequency of logical address segment 1 is used as the erase frequency of logical address 1 and logical address 2.
本申请一些实施例中,可以通过如下子步骤来确定各逻辑地址分段的抹写频率:In some embodiments of the present application, the erasing frequency of each logical address segment can be determined by the following sub-steps:
子步骤11、统计目标固态硬盘的总抹写次数,以及各逻辑地址分段的段抹写次数。Sub-step 11: Count the total number of erase/write times of the target solid state drive and the number of segment erase/write times of each logical address segment.
首先,可以先根据用户针对目标固态硬盘的抹写操作,统计目标固态硬盘的总抹写次数;该总抹写次数可以为目标固态硬盘中所存储的所有数据的抹写次数的总和。First, the total number of erasures and writes of the target SSD may be counted based on the erasure and write operations of the user on the target SSD; the total number of erasures and writes may be the sum of the number of erasures and writes of all data stored in the target SSD.
同时,可以根据用户针对目标固态硬盘的抹写操作,统计各逻辑地址分段的段抹写次数;该段抹写次数可以为一逻辑地址分段中所有逻辑地址对应数据的抹写次数的总和。At the same time, the segment erase count of each logical address segment can be counted according to the user's erase and write operations on the target solid state drive; the segment erase count can be the sum of the erase and write counts of data corresponding to all logical addresses in a logical address segment.
接上例,目标固态硬盘包括逻辑地址分段1和逻辑地址分段2;逻辑地址分段1包括逻辑地址1和逻辑地址2;逻辑地址分段2包括逻辑地址3和逻辑地址4。当逻辑地址1对应的数据进行了抹写操作时,可以对逻辑地址分段1的段抹写次数加一;对目标固态硬盘的总
抹写次数加一,本申请实施例对此不作限制。Continuing with the above example, the target SSD includes logical address segment 1 and logical address segment 2; logical address segment 1 includes logical address 1 and logical address 2; logical address segment 2 includes logical address 3 and logical address 4. When the data corresponding to logical address 1 is erased or written, the segment erase count of logical address segment 1 can be increased by one; the total erase count of the target SSD can be increased by one. The number of erase and write times is increased by one, and this embodiment of the present application does not impose any limitation on this.
子步骤12、当总抹写次数超过第一阈值时,根据段抹写次数和总抹写次数,计算各逻辑地址分段的抹写频率。Sub-step 12: When the total number of erasures exceeds the first threshold, the erasure frequency of each logical address segment is calculated according to the segment erasure number and the total erasure number.
频繁地计算抹写频率既浪费计算资源,也可能因为数据量过少,而无法准确地体现出数据的抹写情况;因此,本申请实施例在计算各逻辑地址分段的抹写频率时,先判断目标固态硬盘的总抹写次数是否超过第一阈值;第一阈值可以实际情况确定,例如:10M。Frequent calculation of the erase and write frequency not only wastes computing resources, but may also fail to accurately reflect the data erase and write status due to the small amount of data. Therefore, when calculating the erase and write frequency of each logical address segment, the embodiment of the present application first determines whether the total number of erase and write times of the target solid-state hard disk exceeds the first threshold. The first threshold can be determined according to actual conditions, for example: 10M.
如果目标固态硬盘的总抹写次数未超过第一阈值,则继续对总抹写次数和段抹写次数进行统计。If the total number of erasures and writes of the target solid state drive does not exceed the first threshold, the total number of erasures and writes and the number of segment erasures and writes continue to be counted.
如果目标固态硬盘的总抹写次数超过了第一阈值,则可以根据段抹写次数和总抹写次数,计算各逻辑地址分段的抹写频率。If the total number of erasures and writes of the target solid-state hard disk exceeds the first threshold, the erasure frequency of each logical address segment may be calculated according to the segment erasure number and the total erasure number.
作为一示例,可以构建一write Ratio Stat的数据,该write Ratio Stat数据中存储有各逻辑地址分段的抹写频率、段抹写次数,以及目标固态硬盘的总抹写次数。As an example, a write Ratio Stat data can be constructed, which stores the erase and write frequency of each logical address segment, the number of segment erase and write times, and the total erase and write times of the target solid state drive.
每当用户进行抹写操作时,可以先判断抹写操作所对应的数据的逻辑地址在哪一逻辑地址分段,并对该逻辑地址分段的段抹写次数加一,以及对目标固态硬盘的总抹写次数加一。当目标固态硬盘的总抹写次数超过第一阈值时,可以计算各逻辑地址分段的抹写频率。Whenever a user performs an erase operation, it is possible to first determine in which logical address segment the logical address of the data corresponding to the erase operation is located, and add one to the segment erase count of the logical address segment, and add one to the total erase count of the target solid-state drive. When the total erase count of the target solid-state drive exceeds a first threshold, the erase frequency of each logical address segment can be calculated.
本申请一些实施例中,数据的抹写情况可能会实时发生变化,例如:上个月频繁进行抹写操作的数据,本月却很少进行抹写操作;为了更准确地反映数据真实的抹写情况,在计算各逻辑地址分段的抹写频率后,还可以包括如下步骤:In some embodiments of the present application, the data may change in real time. For example, the data that was frequently erased last month may be rarely erased this month. In order to more accurately reflect the real data erase situation, after calculating the erase frequency of each logical address segment, the following steps may be included:
对总抹写次数和段抹写次数进行清零处理,并重新开始统计目标固态硬盘的总抹写次数,以及各逻辑地址分段的段抹写次数。The total erase and write times and the segment erase and write times are cleared, and the total erase and write times of the target solid state drive and the segment erase and write times of each logical address segment are counted again.
具体的,可以在计算得到各逻辑地址分段的抹写频率后,对目标固态硬盘的总抹写次数和各逻辑地址分段的段抹写次数进行清零处理;然后,重新开统计目标固态硬盘的总抹写次数和各逻辑地址分段的段抹写次数。Specifically, after calculating the erase and write frequency of each logical address segment, the total erase and write times of the target solid-state hard disk and the segment erase and write times of each logical address segment are cleared; then, the total erase and write times of the target solid-state hard disk and the segment erase and write times of each logical address segment are counted again.
步骤203、根据第一物理存储区域所对应的多个逻辑地址的抹写频率,确定第一物理存储区域的目标抹写频率,并获取第一物理存储区域的目标磨损程度。Step 203: Determine a target write-erase frequency of the first physical storage area according to the write-erase frequencies of the plurality of logical addresses corresponding to the first physical storage area, and obtain a target wear degree of the first physical storage area.
在需要判定第一物理存储区域是否需要进行磨损均衡的时候,可以先根据逻辑地址的抹写频率,确定第一物理存储区域的目标抹写频率。When it is necessary to determine whether the first physical storage area needs to be wear leveled, the target erasing frequency of the first physical storage area may be determined according to the erasing frequency of the logical address.
具体的,由于每个物理存储区域中存储有多个数据,而每个数据又对应于一个逻辑地址;因此,在确定第一物理存储区域的目标抹写频率的时候,可以先确定第一物理存储区域所对应的多个数据所对应的多个逻辑地址。Specifically, since each physical storage area stores multiple data and each data corresponds to a logical address, when determining the target erase frequency of the first physical storage area, the multiple logical addresses corresponding to the multiple data corresponding to the first physical storage area can be determined first.
然后,可以基于第一物理存储区域所对应的多个数据所对应的多个逻辑地址的抹写频率,计算第一物理存储区域的目标抹写频率。Then, the target erasing frequency of the first physical storage area may be calculated based on the erasing frequencies of the plurality of logical addresses corresponding to the plurality of data corresponding to the first physical storage area.
在计算第一物理存储区域的目标抹写频率的同时,还可以获取该第一物理存储区域的目标磨损程度。While calculating the target write-erase frequency of the first physical storage area, the target wear degree of the first physical storage area can also be obtained.
本申请一些实施例中,可以通过如下子步骤来确定目标抹写频率:In some embodiments of the present application, the target erase frequency can be determined by the following sub-steps:
子步骤21、确定第一物理存储区域所对应的多个逻辑地址的抹写频率的目标和值。Sub-step 21: Determine the target and value of the erase and write frequency of multiple logical addresses corresponding to the first physical storage area.
首先,可以先确定第一物理存储区域中所存储有的多个数据分别对应的逻辑地址;然后,可以确定这多个逻辑地址的抹写频率;该多个逻辑地址的抹写频率即这多个逻辑地址分别对应的逻辑地址分段的抹写频率。
First, the logical addresses corresponding to the multiple data stored in the first physical storage area can be determined; then, the erasing frequency of the multiple logical addresses can be determined; the erasing frequency of the multiple logical addresses is the erasing frequency of the logical address segments corresponding to the multiple logical addresses.
例如:第一物理存储区域中所存储的多个数据分别对应逻辑地址1、逻辑地址3和逻辑地址9;逻辑地址1位于逻辑地址分段1中,逻辑地址3位于逻辑地址分段2中,逻辑地址9位于逻辑地址分段5中。For example: the multiple data stored in the first physical storage area correspond to logical address 1, logical address 3 and logical address 9 respectively; logical address 1 is located in logical address segment 1, logical address 3 is located in logical address segment 2, and logical address 9 is located in logical address segment 5.
此时,可以确定逻辑地址分段1的抹写频率、逻辑地址分段2的抹写频率,以及逻辑地址分段5的抹写频率;逻辑地址分段1的抹写频率即逻辑地址1的抹写频率,逻辑地址分段2的抹写频率即逻辑地址3的抹写频率,逻辑地址5的抹写频率即逻辑地址5的抹写频率。At this time, the erase frequency of logical address segment 1, the erase frequency of logical address segment 2, and the erase frequency of logical address segment 5 can be determined; the erase frequency of logical address segment 1 is the erase frequency of logical address 1, the erase frequency of logical address segment 2 is the erase frequency of logical address 3, and the erase frequency of logical address 5 is the erase frequency of logical address 5.
在得到第一物理存储区域所对应的多个逻辑地址的抹写频率后,可以计算这多个逻辑地址的抹写频率的目标和值。After obtaining the erasing and writing frequencies of the plurality of logical addresses corresponding to the first physical storage area, the target and value of the erasing and writing frequencies of the plurality of logical addresses may be calculated.
接上例,在得到逻辑地址1、逻辑地址3和逻辑地址9的抹写频率后,可以计算逻辑地址1的抹写频率、逻辑地址3的抹写频率和逻辑地址9的抹写频率的和值,并将该和值作为目标和值。Continuing with the previous example, after obtaining the erase frequencies of logical address 1, logical address 3, and logical address 9, the sum of the erase frequencies of logical address 1, logical address 3, and logical address 9 can be calculated and used as the target sum.
子步骤22、确定第一物理存储区域所对应的逻辑地址的目标数量。Sub-step 22: Determine the target number of logical addresses corresponding to the first physical storage area.
在计算目标和值的时候,还可以确定第一物理存储区域所对应的逻辑地址的目标数量。When calculating the target sum value, a target number of logical addresses corresponding to the first physical storage area may also be determined.
本申请一些实施例中,由于逻辑地址和数据是一一对应的;因此,该目标数量也可以基于第一物理存储区域中所存储的数据的数量来确定,本申请实施例对此不作限制。In some embodiments of the present application, since the logical address and the data are one-to-one corresponding, the target number can also be determined based on the number of data stored in the first physical storage area, and the embodiments of the present application are not limited to this.
子步骤23、根据目标和值和目标数量,确定第一物理存储区域的目标抹写频率。Sub-step 23: Determine a target erasing frequency of the first physical storage area according to the target sum value and the target quantity.
在确定目标和值和目标数量后,可以基于目标和值和目标数量来确定第一物理存储区域的目标抹写频率。例如:可以将目标和值和目标数量的比值作为第一物理存储区域的目标抹写频率。After determining the target sum value and the target quantity, the target erasure frequency of the first physical storage area can be determined based on the target sum value and the target quantity. For example, the ratio of the target sum value and the target quantity can be used as the target erasure frequency of the first physical storage area.
如图3所示,逻辑地址1和逻辑地址3的数据存储在物理存储区域1中,逻辑地址2和逻辑地址4的数据存储在物理存储区域2中;则可以根据逻辑地址分段1和逻辑地址分段2的抹写频率,计算物理存储区域1的抹写频率。As shown in Figure 3, the data of logical address 1 and logical address 3 are stored in physical storage area 1, and the data of logical address 2 and logical address 4 are stored in physical storage area 2; the erase frequency of physical storage area 1 can be calculated based on the erase frequency of logical address segment 1 and logical address segment 2.
本申请一些实施例中,子步骤23可以通过如下方式来实现:In some embodiments of the present application, sub-step 23 can be implemented in the following manner:
计算目标和值与目标数量的第一比值;计算第一比值与目标数量的第二比值,并将第二比值作为目标抹写频率。A first ratio of the target sum value to the target quantity is calculated; a second ratio of the first ratio to the target quantity is calculated, and the second ratio is used as the target erase frequency.
为了进一步减少针对磨损均衡所投入的资源,可以通过归一化,来以更小的数值来标识目标抹写频率;具体的,可以先计算目标和值与目标数量的第一比值=目标和值/目标数量。In order to further reduce the resources invested in wear leveling, the target erase frequency may be identified with a smaller value through normalization; specifically, a first ratio of the target sum value to the target number may be calculated = target sum value/target number.
然后,计算第一比值与目标数量的第二比值=第一比值/目标数量。在得到第二比值后,可以将第二比值作为第一物理存储区域的目标抹写频率。Then, a second ratio of the first ratio to the target number is calculated = the first ratio/the target number. After the second ratio is obtained, the second ratio can be used as the target write-erase frequency of the first physical storage area.
本申请一些实施例中,可以通过如下子步骤来获取目标磨损程度:In some embodiments of the present application, the target wear degree can be obtained through the following sub-steps:
子步骤31、获取各物理存储区域的磨损次数。Sub-step 31: Obtain the number of wear times of each physical storage area.
首先,可以获取各物理存储区域的磨损次数。First, the number of wear times of each physical storage area may be obtained.
需要说明的是,磨损次数都是实时变化的;因此,在获取各物理存储区域的磨损次数的时候,需要获取最新的磨损次数。It should be noted that the wear counts are changing in real time; therefore, when obtaining the wear counts of each physical storage area, the latest wear counts need to be obtained.
子步骤32、根据各物理存储区域的磨损次数,确定第一物理存储区域的第一磨损偏差。Sub-step 32: determining a first wear deviation of a first physical storage area according to the number of wears of each physical storage area.
然后,可以基于各物理存储区域的磨损次数,来确定第一物理存储区域的磨损次数,相比于目标固态硬盘中的其他物理存储区域的磨损次数的第一磨损偏差。Then, based on the number of wear times of each physical storage area, a first wear deviation of the number of wear times of the first physical storage area compared to the number of wear times of other physical storage areas in the target solid state drive may be determined.
本申请一些实施例中,子步骤32可以通过如下方式实现:In some embodiments of the present application, sub-step 32 can be implemented in the following manner:
从各物理存储区域的磨损次数中,确定一极值磨损次数、一平均磨损次数,以及第一物
理存储区域的磨损次数;确定第一物理存储区域的磨损次数和极值磨损次数的第一差值,与平均磨损次数和极值磨损次数的第二差值;根据第一差值和第二差值的比值,确定第一磨损偏差。From the wear times of each physical storage area, determine an extreme wear time, an average wear time, and a first physical determining a first difference between the wear count and the extreme wear count of the first physical storage area, and a second difference between the average wear count and the extreme wear count; and determining a first wear deviation according to a ratio of the first difference and the second difference.
在确定各物理存储区域的磨损次数后,可以从中确定一极值磨损次数和第一物理存储区域的磨损次数;极值磨损次数可以为最大磨损次数,或者最小磨损次数。After the wear counts of each physical storage area are determined, an extreme wear count and a wear count of the first physical storage area may be determined; the extreme wear count may be a maximum wear count or a minimum wear count.
同时,可以根据各物理存储区域的磨损次数,计算所有物理存储区域的磨损次数的平均磨损次数。Meanwhile, the average wear count of all physical storage areas may be calculated according to the wear count of each physical storage area.
在得到极值磨损次数、第一物理存储区域的磨损次数,以及平均磨损次数后,可以再计算第一物理存储区域的磨损次数和极值磨损次数的第一差值=第一物理存储区域的磨损次数-极值磨损次数;以及,可以再计算平均磨损次数和极值磨损次数的第二差值=平均磨损次数-极值磨损次数。After obtaining the extreme wear count, the wear count of the first physical storage area, and the average wear count, the first difference between the wear count of the first physical storage area and the extreme wear count = the wear count of the first physical storage area - the extreme wear count can be calculated; and the second difference between the average wear count and the extreme wear count = the average wear count - the extreme wear count can be calculated.
在得到第一差值和第二差值后,可以基于第一差值和第二差值的比值,来确定第一物理存储区域的磨损次数,相比于目标固态硬盘中的其他物理存储区域的磨损次数的第一磨损偏差。After obtaining the first difference and the second difference, a first wear deviation of the number of wear times of the first physical storage area compared to the number of wear times of other physical storage areas in the target solid state drive can be determined based on the ratio of the first difference and the second difference.
例如:第一磨损偏差=第一差值/第二差值。For example: first wear deviation = first difference / second difference.
子步骤33、根据第一磨损偏差,确定目标磨损程度。Sub-step 33: determining a target wear degree according to the first wear deviation.
在确定第一磨损偏差后,可以基于第一磨损偏差来确定第一物理存储区域的目标磨损程度;例如:当第一磨损偏差=0时,可以标识第一物理存储区域的磨损次数,在目标固态硬盘的所有物理存储区域中属于中等水平;此时,该第一物理存储区域中适合存储抹写频率也处于中等水平的数据。After determining the first wear deviation, the target wear degree of the first physical storage area can be determined based on the first wear deviation; for example: when the first wear deviation = 0, the number of wear times of the first physical storage area can be identified as being at a medium level among all physical storage areas of the target solid state drive; at this time, the first physical storage area is suitable for storing data whose erase and write frequency is also at a medium level.
例如:目标固态硬盘中存储有数据1、数据2和数据3;数据1的抹写频率为20%,数据2的抹写频率为50%,数据3的抹写频率为30%;则第一物理存储区域中适合存储数据3;如果第一物理存储区域中存储的数据是数据1的话,则可以进行磨损均衡,以将数据1转移至其他物理存储区域中进行存储,并将数据3转移至第一物理存储区域中进行存储,本申请实施例对此不作限制。For example: the target solid-state hard disk stores data 1, data 2, and data 3; the erase frequency of data 1 is 20%, the erase frequency of data 2 is 50%, and the erase frequency of data 3 is 30%; then the first physical storage area is suitable for storing data 3; if the data stored in the first physical storage area is data 1, wear leveling can be performed to transfer data 1 to other physical storage areas for storage, and transfer data 3 to the first physical storage area for storage, and the embodiments of the present application are not limited to this.
步骤204、判断目标抹写频率与目标磨损程度是否满足预设匹配条件。Step 204: Determine whether the target erase frequency and the target wear degree meet a preset matching condition.
在得到第一物理存储区域的目标抹写频率和目标磨损程度后,可以判断第一物理存储区域的目标抹写频率,与第一物理存储区域的目标磨损程度是否满足预设匹配条件。After obtaining the target write/erase frequency and the target wear degree of the first physical storage area, it can be determined whether the target write/erase frequency of the first physical storage area and the target wear degree of the first physical storage area meet a preset matching condition.
具体的,如果第一物理存储区域的目标磨损程度较高的话,则可以表示第一物理存储区域相比于目标固态硬盘中的其他物理存储区域来说,将可能更早的损坏。对于可能更早损坏的第一物理存储区域来说,如果其的目标抹写频率较高的话,可以表示该第一物理存储区域中所存储的数据的抹写频率较高,而这可能会导致第一物理存储区域更快地损坏。针对这种情况,可以判定目标抹写频率与目标磨损程度是不满足预设匹配条件的。Specifically, if the target wear degree of the first physical storage area is high, it may mean that the first physical storage area may be damaged earlier than other physical storage areas in the target solid state drive. For the first physical storage area that may be damaged earlier, if its target erase frequency is high, it may mean that the erase frequency of the data stored in the first physical storage area is high, which may cause the first physical storage area to be damaged faster. In this case, it can be determined that the target erase frequency and the target wear degree do not meet the preset matching condition.
当判定目标抹写频率与目标磨损程度是不满足预设匹配条件的时候,可以表示第一物理存储区域需要进行磨损均衡;此时,可以继续执行步骤205,以对第一物理存储区域进行磨损均衡。When it is determined that the target erasing frequency and the target wear degree do not meet the preset matching condition, it may indicate that the first physical storage area needs to be wear leveled; at this time, step 205 may be continued to be executed to perform wear leveling on the first physical storage area.
而如果第一物理存储区域的目标磨损程度较高,且目标抹写频率较低的话,可以判定目标抹写频率与目标磨损程度是满足预设匹配条件的。If the target wear degree of the first physical storage area is high and the target erasure frequency is low, it can be determined that the target erasure frequency and the target wear degree meet the preset matching condition.
当判定目标抹写频率与目标磨损程度是满足预设匹配条件的时候,可以表示第一物理存
储区域不需要进行磨损均衡;此时,可以针对另一物理存储区域执行步骤201,本申请实施例对此不作限制。When it is determined that the target erase frequency and the target wear degree meet the preset matching condition, it can be indicated that the first physical storage The storage area does not need to perform wear leveling; at this time, step 201 can be performed for another physical storage area, and this embodiment of the present application does not limit this.
本申请一些实施例中,可以通过如下子步骤来判断目标抹写频率与目标磨损程度是否满足预设匹配条件:In some embodiments of the present application, the following sub-steps may be used to determine whether the target erase frequency and the target wear degree meet the preset matching condition:
子步骤41、确定目标抹写频率与目标磨损程度的匹配度。Sub-step 41: Determine the matching degree between the target erasing frequency and the target wear degree.
首先,可以计算目标抹写频率与目标磨损程度的匹配度;该匹配度可以基于目标抹写频率的数值大小,和目标磨损程度的数值大小来确定。First, the matching degree between the target erasure frequency and the target wear degree may be calculated; the matching degree may be determined based on the numerical value of the target erasure frequency and the numerical value of the target wear degree.
本申请一些实施例中,子步骤41可以通过如下方式实现:In some embodiments of the present application, sub-step 41 can be implemented in the following manner:
确定目标抹写频率与目标磨损程度的第三比值;根据第三比值,确定目标抹写频率与目标磨损程度的匹配度。A third ratio of the target erase frequency to the target wear degree is determined; and a matching degree of the target erase frequency to the target wear degree is determined based on the third ratio.
在实际应用中,可以直接计算目标抹写频率与目标磨损程度的第三比值=目标抹写频率/目标磨损程度。In practical applications, the third ratio of the target erase frequency to the target wear degree can be directly calculated as follows: target erase frequency/target wear degree.
在得到第三比值后,可以根据第三比值来确定目标抹写频率与目标磨损程度的匹配度;例如:第三比值如果与一预设值的偏差较大,则说明目标抹写频率与目标磨损程度的匹配度越小;第三比值如果与该预设值的偏差较小,则说明目标抹写频率与目标磨损程度的匹配度越高。After obtaining the third ratio, the degree of match between the target erase frequency and the target wear degree can be determined based on the third ratio; for example: if the third ratio deviates greatly from a preset value, it means that the degree of match between the target erase frequency and the target wear degree is smaller; if the third ratio deviates less from the preset value, it means that the degree of match between the target erase frequency and the target wear degree is higher.
本申请一些实施例中,子步骤41也可以通过如下方式实现:In some embodiments of the present application, sub-step 41 can also be implemented in the following manner:
按照各物理存储区域的抹写频率的大小,对各物理存储区域进行排序,并基于各物理存储区域的排序,确定各物理存储区域的频率等级;按照磨损程度的大小,对各物理存储区域进行排序,并基于各物理存储区域的排序,确定各物理存储区域的磨损等级;根据第一物理存储区域对应的磨损等级和频率等级,确定目标抹写频率与目标磨损程度的匹配度。The physical storage areas are sorted according to their erase and write frequencies, and the frequency level of each physical storage area is determined based on the sorting; the physical storage areas are sorted according to their wear levels, and the wear level of each physical storage area is determined based on the sorting; and the matching degree of the target erase and write frequency and the target wear level is determined based on the wear level and frequency level corresponding to the first physical storage area.
首先,可以按照各个物理存储区域的抹写频率的大小,对各物理存储区域段进行排序;并基于各逻辑地址分段在排序中的位置,确定各逻辑地址分段的频率等级。First, the physical storage area segments may be sorted according to the magnitude of the erasing and writing frequencies of the physical storage areas; and the frequency level of each logical address segment may be determined based on the position of each logical address segment in the sorting.
同时,可以按照各物理存储区域的磨损程度的大小,对各物理存储区域进行排序;并基于各物理存储区域在排序中的位置,确定各物理存储区域的磨损等级。At the same time, the physical storage areas may be sorted according to the degree of wear of the physical storage areas; and the wear level of each physical storage area may be determined based on the position of each physical storage area in the sorting.
然后,可以确定第一物理存储区域的目标抹写频率所对应的频率等级,以及确定第一物理存储区域的目标磨损程度所对应的磨损等级。Then, the frequency level corresponding to the target write-erase frequency of the first physical storage area may be determined, and the wear level corresponding to the target wear degree of the first physical storage area may be determined.
在得到第一物理存储区域对应的磨损等级和频率等级后,可以基于第一物理存储区域对应的磨损等级和频率等级来确定目标抹写频率与目标磨损程度的匹配度。After the wear level and frequency level corresponding to the first physical storage area are obtained, the matching degree between the target write-erase frequency and the target wear degree may be determined based on the wear level and frequency level corresponding to the first physical storage area.
例如:磨损等级分为高、中、低;磨损等级越高,则表示该物理存储区域的磨损越严重。频率等级分为高、中、低;频率等级越高,则表示该物理存储区域中的数据越频繁地被进行抹写操作。如果第一物理存储区域对应的磨损等级为高,频率等级为低,则可以确定一较高值的匹配度;而如果第一物理存储区域对应的磨损等级为高,频率等级为高,则可以确定一较低值的匹配度,本申请实施例对此不作限制。For example: the wear level is divided into high, medium and low; the higher the wear level, the more serious the wear of the physical storage area. The frequency level is divided into high, medium and low; the higher the frequency level, the more frequently the data in the physical storage area is erased and written. If the wear level corresponding to the first physical storage area is high and the frequency level is low, a higher value of the matching degree can be determined; and if the wear level corresponding to the first physical storage area is high and the frequency level is high, a lower value of the matching degree can be determined, and the embodiments of the present application do not limit this.
子步骤42、当目标抹写频率与目标磨损程度的匹配度超过第二阈值时,判定目标抹写频率与目标磨损程度满足预设匹配条件。Sub-step 42: When the matching degree between the target writing/erasing frequency and the target wear degree exceeds a second threshold, it is determined that the target writing/erasing frequency and the target wear degree meet a preset matching condition.
在实际应用中,可以为匹配度设置一第二阈值,该第二阈值可以根据实际情况设定。In practical applications, a second threshold may be set for the matching degree, and the second threshold may be set according to actual conditions.
当目标抹写频率与目标磨损程度的匹配度未超过第二阈值时,可以表示目标抹写频率与目标磨损程度是不满足预设匹配条件的;此时,可以继续执行步骤205,以进行磨损均衡。
When the matching degree between the target erasing frequency and the target wear degree does not exceed the second threshold, it may indicate that the target erasing frequency and the target wear degree do not satisfy the preset matching condition; at this time, step 205 may be continued to perform wear leveling.
而如果目标抹写频率与目标磨损程度的匹配度超过了第二阈值,可以表示目标抹写频率与目标磨损程度是满足预设匹配条件的;此时,可以重新执行步骤201,本申请实施例对此不作限制。If the matching degree between the target erase frequency and the target wear degree exceeds the second threshold, it can be indicated that the target erase frequency and the target wear degree meet the preset matching condition; at this time, step 201 can be re-executed, and the embodiment of the present application does not limit this.
步骤205、当目标抹写频率与目标磨损程度不满足预设匹配条件时,从除第一物理存储区域外的其他物理存储区域中,确定一与目标抹写频率满足预设匹配条件的第二物理存储区域。Step 205: When the target write-erase frequency and the target wear degree do not satisfy a preset matching condition, determine a second physical storage area that satisfies a preset matching condition with the target write-erase frequency from other physical storage areas except the first physical storage area.
在实际应用中,当判定目标抹写频率与目标磨损程度不满足预设匹配条件的时候,可以先确定目标固态硬盘中,除第一物理存储区域外的其他物理存储区域。In practical applications, when it is determined that the target write-erase frequency and the target wear degree do not satisfy a preset matching condition, other physical storage areas except the first physical storage area in the target solid state drive may be determined first.
然后,可以确定这些其他物理存储区域分别对应的磨损程度,并基于各其他物理存储区域的磨损程度,确定一与目标抹写频率满足预设匹配条件的第二物理存储区域;第二物理存储区域可以指磨损程度与目标抹写频率满足预设匹配条件的物理存储区域。Then, the degree of wear corresponding to these other physical storage areas can be determined, and based on the degree of wear of each other physical storage area, a second physical storage area that meets the preset matching conditions with the target erase frequency can be determined; the second physical storage area can refer to a physical storage area whose degree of wear meets the preset matching conditions with the target erase frequency.
本申请一些实施例中,在确定第二物理存储区域的时候,可以逐个判断其他物理存储区域的磨损程度是否与目标抹写频率匹配;如果一其他物理存储区域的磨损程度与目标抹写频率满足预设匹配条件的话,则可以将该一其他物理存储区域作为第二物理存储区域。In some embodiments of the present application, when determining the second physical storage area, it is possible to determine one by one whether the degree of wear of other physical storage areas matches the target erase frequency; if the degree of wear of another physical storage area and the target erase frequency meet the preset matching conditions, then the other physical storage area can be used as the second physical storage area.
步骤206、将第一物理存储区域中的数据,转移至第二物理存储区域进行存储。Step 206: Transfer the data in the first physical storage area to the second physical storage area for storage.
在确定第二物理存储区域后,可以将第一物理存储区域中的数据转移至所确定的第二物理存储区域中进行存储。After the second physical storage area is determined, the data in the first physical storage area may be transferred to the determined second physical storage area for storage.
在实际应用中,上述磨损均衡的过程可以是同时针对目标固态硬盘中的所有的物理存储区域;也就是说,在将第一物理存储区域中的数据转移至第二物理存储区域中的时候,也可能将第二物理存储区域中的数据转移至第三物理存储区域中、将第三物理存储区域中的数据转移至第一物理存储区域中;从而,实现各物理存储区域的磨损程度,与各物理存储区域所对应的抹写频率都是满足预设匹配条件的。In actual applications, the above-mentioned wear leveling process can be simultaneously performed on all physical storage areas in the target solid-state hard disk; that is, when transferring data from the first physical storage area to the second physical storage area, it is also possible to transfer data from the second physical storage area to the third physical storage area, and transfer data from the third physical storage area to the first physical storage area; thereby, the degree of wear of each physical storage area and the erase and write frequency corresponding to each physical storage area meet the preset matching conditions.
步骤207、在将第一物理存储区域中的数据,转移至第二物理存储区域进行存储后,根据所转移的数据,对第一物理存储区域和第二物理存储区域的抹写频率进行更新。Step 207: After transferring the data in the first physical storage area to the second physical storage area for storage, update the write-erase frequency of the first physical storage area and the second physical storage area according to the transferred data.
在实际应用中,在将第一物理存储区域中的数据,转移至第二物理存储区域进行存储后,第一物理存储区域和第二物理存储区域中的数据均发生了变化;此时,可以根据所转移的数据(即从第一物理存储区域转移至第二物理存储区域的数据),第一物理存储区域中的数据,转移至第二物理存储区域进行存储后,根据所转移的数据。In actual applications, after the data in the first physical storage area is transferred to the second physical storage area for storage, the data in the first physical storage area and the second physical storage area are changed; at this time, the data in the first physical storage area can be transferred to the second physical storage area for storage according to the transferred data (that is, the data transferred from the first physical storage area to the second physical storage area).
本申请一些实施例中,也可以在对所有的物理存储区域都进行完磨损均衡后,在对各物理存储区域的抹写频率进行更新,本申请实施例对此不作限制。In some embodiments of the present application, after wear leveling is completed on all physical storage areas, the erase and write frequency of each physical storage area may be updated, but the embodiments of the present application do not limit this.
本申请实施例中,可以先对目标固态硬盘中的所有的逻辑地址进行分段,得到多个逻辑地址分段,每段逻辑地址分段包括至少一个逻辑地址;然后确定各逻辑地址分段的抹写频率,并将逻辑地址分段的抹写频率,作为逻辑地址分段所包括的各逻辑地址的抹写频率;之后,根据第一物理存储区域所对应的多个逻辑地址的抹写频率,确定第一物理存储区域的目标抹写频率,以及获取第一物理存储区域的目标磨损程度,并判断目标抹写频率与目标磨损程度是否满足预设匹配条件;当目标抹写频率与目标磨损程度不满足预设匹配条件时,从除第一物理存储区域外的其他物理存储区域中,确定一与目标抹写频率满足预设匹配条件的第二物理存储区域;将第一物理存储区域中的数据,转移至第二物理存储区域进行存储;在将第一物理存储区域中的数据,转移至第二物理存储区域进行存储后,根据所转移的数据,对第一
物理存储区域和第二物理存储区域的抹写频率进行更新。通过本申请实施例,减少了固态硬盘磨损均衡时所需要使用到的数据的数据量,从而使得固态硬盘可以通过更少的资源来存储磨损均衡时所需要使用到的数据。In an embodiment of the present application, all logical addresses in the target solid-state hard disk may be segmented to obtain a plurality of logical address segments, each logical address segment including at least one logical address; then, the erase and write frequencies of each logical address segment are determined, and the erase and write frequencies of the logical address segments are used as the erase and write frequencies of each logical address included in the logical address segment; thereafter, the target erase and write frequency of the first physical storage area is determined according to the erase and write frequencies of the plurality of logical addresses corresponding to the first physical storage area, and the target degree of wear of the first physical storage area is obtained, and it is determined whether the target erase and write frequency and the target degree of wear meet a preset matching condition; when the target erase and write frequency and the target degree of wear do not meet the preset matching condition, a second physical storage area that meets the preset matching condition with the target erase and write frequency is determined from other physical storage areas except the first physical storage area; the data in the first physical storage area is transferred to the second physical storage area for storage; after the data in the first physical storage area is transferred to the second physical storage area for storage, the data in the first physical storage area is stored in the second physical storage area according to the transferred data. The physical storage area and the second physical storage area are updated in erasing and writing frequency. Through the embodiment of the present application, the amount of data required for wear leveling of the solid state drive is reduced, so that the solid state drive can use fewer resources to store the data required for wear leveling.
在实际应用中,如果对物理存储区域进行磨损均衡的话,终究会导致各物理存储区域的磨损次数出现增加,进而影响到目标固态硬盘的使用寿命。因此,为了减少磨损均衡的次数,可以预先对数据的写入进行干预,具体的,可以参考如下实施例:In actual applications, if wear leveling is performed on the physical storage areas, the number of wear times of each physical storage area will eventually increase, thereby affecting the service life of the target solid-state drive. Therefore, in order to reduce the number of wear leveling times, the writing of data can be intervened in advance. Specifically, the following embodiments can be referred to:
参考图4,示出了本申请实施例的一种数据写入的步骤流程图,可以包括如下步骤:Referring to FIG. 4 , a flowchart of a data writing step in an embodiment of the present application is shown, which may include the following steps:
步骤401、根据各逻辑地址分段的抹写频率,判断目标固态硬盘中的数据是否满足预设分层条件。Step 401: Determine whether the data in the target solid state drive meets a preset tiering condition based on the write-erase frequency of each logical address segment.
在实际应用中,目标固态硬盘中的逻辑地址分段可能存在分层的情况;例如:20%的逻辑地址分段的总的抹写频率为80%,而另外80%的逻辑地址分段的总的抹写频率为20%。针对这种分层的情况,如果将频繁进行抹写操作的数据写入20%的逻辑地址分段中的话,可能加剧这20%的逻辑地址分段对应的物理存储区域的磨损,进而影响到目标固态硬盘的使用寿命。In actual applications, the logical address segments in the target SSD may be stratified; for example, the total erase frequency of 20% of the logical address segments is 80%, while the total erase frequency of the other 80% of the logical address segments is 20%. In view of this stratification, if data that is frequently erased is written into the 20% logical address segments, it may aggravate the wear of the physical storage area corresponding to the 20% logical address segments, thereby affecting the service life of the target SSD.
为了避免这种情况的发生,本申请实施例可以预先根据各逻辑地址分段的抹写频率,来判断目标固态硬盘中所存储的数据是否满足预设分层条件。In order to avoid this situation, the embodiment of the present application can determine in advance whether the data stored in the target solid-state drive meets the preset tiering conditions according to the erase and write frequencies of each logical address segment.
本申请一些实施例中,可以通过如下子步骤来判断目标固态硬盘中的数据是否满足预设分层条件:In some embodiments of the present application, the following sub-steps may be used to determine whether the data in the target solid-state drive meets the preset tiering condition:
子步骤51、确定抹写频率最高的前M个逻辑地址分段,并计算抹写频率最高的前M个逻辑地址分段的总的抹写频率,M为正整数。Sub-step 51, determining the first M logical address segments with the highest erasure frequency, and calculating the total erasure frequency of the first M logical address segments with the highest erasure frequency, where M is a positive integer.
首先,可以先从所有的逻辑地址分段中,确定抹写频率最高的前M个逻辑地址分段;M可以为预先设置的一正整数,例如:当逻辑地址分段有100个时,M可以设置为25。First, the first M logical address segments with the highest erasure frequency can be determined from all logical address segments; M can be a preset positive integer, for example, when there are 100 logical address segments, M can be set to 25.
在确定抹写频率最高的前M个逻辑地址分段后,可以确定这些逻辑地址分段的抹写频率,并根据这些逻辑地址分段的抹写频率,计算抹写频率最高的前M个逻辑地址分段的总的抹写频率。After determining the first M logical address segments with the highest erasure frequencies, the erasure frequencies of these logical address segments can be determined, and based on the erasure frequencies of these logical address segments, the total erasure frequency of the first M logical address segments with the highest erasure frequencies can be calculated.
子步骤52、当前M个逻辑地址分段的总的抹写频率大于第三阈值时,判定目标固态硬盘中的数据满足预设分层条件。Sub-step 52: When the total erase/write frequency of the current M logical address segments is greater than a third threshold, it is determined that the data in the target solid state drive meets a preset tiering condition.
在得到抹写频率最高的前M个逻辑地址分段的总的抹写频率后,基于该总的抹写频率与一第三阈值的关系,来判断目标固态硬盘中的数据是否满足预设分层条件;其中,第三阈值可以根据实际情况设定,例如:60%。After obtaining the total erase frequency of the top M logical address segments with the highest erase frequency, based on the relationship between the total erase frequency and a third threshold, it is determined whether the data in the target solid state drive meets the preset stratification conditions; wherein the third threshold can be set according to actual conditions, for example: 60%.
如果抹写频率最高的前M个逻辑地址分段的总的抹写频率大于第三阈值,则可以判定目标固态硬盘中的数据满足预设分层条件;此时,可以执行步骤402。If the total erasure frequency of the first M logical address segments with the highest erasure frequency is greater than the third threshold, it can be determined that the data in the target solid state drive meets the preset tiering condition; at this time, step 402 can be executed.
而如果抹写频率最高的前M个逻辑地址分段的总的抹写频率不大于第三阈值,则可以判定目标固态硬盘中的数据不满足预设分层条件;此时,执行步骤405。If the total erasure frequency of the first M logical address segments with the highest erasure frequency is not greater than the third threshold, it can be determined that the data in the target solid state drive does not meet the preset tiering condition; at this time, step 405 is executed.
步骤402、当目标固态硬盘中的数据满足预设分层条件时,根据各逻辑地址分段的抹写频率,确定各逻辑地址分段的频率等级。Step 402: When the data in the target solid state drive meets the preset tiering condition, the frequency level of each logical address segment is determined according to the write-erase frequency of each logical address segment.
如果判定目标固态硬盘中的数据满足预设分层条件的话,则可以先根据各逻辑地址分段的抹写频率,确定各逻辑地址分段的频率等级。If it is determined that the data in the target solid state drive meets the preset tiering condition, the frequency level of each logical address segment can be determined based on the write-erase frequency of each logical address segment.
本申请一些实施例中,可以通过如下子步骤来确定各逻辑地址分段的频率等级:
In some embodiments of the present application, the frequency level of each logical address segment may be determined by the following sub-steps:
子步骤61、按照各逻辑地址的抹写频率的大小,对各逻辑地址分段进行排序。Sub-step 61 : sorting the logical address segments according to the erase and write frequencies of the logical addresses.
首先,可以按照各逻辑地址的抹写频率的大小,对各逻辑地址分段进行排序;该排序可以按照从大到小的顺序进行排列,也可以按照从小打到的顺序进行排列,本申请实施例对此不作限制。First, the logical address segments can be sorted according to the erase and write frequency of each logical address; the sorting can be arranged in order from large to small, or in order from small to high, and the embodiment of the present application does not limit this.
子步骤62、基于各逻辑地址分段的排序,确定各逻辑地址分段的频率等级。Sub-step 62: Determine the frequency level of each logical address segment based on the ranking of each logical address segment.
在得到各逻辑地址分段的排序后,可以基于一逻辑地址分段在该排序中的位置,确定该一逻辑地址分段的频率等级。After the ranking of the logical address segments is obtained, the frequency level of a logical address segment may be determined based on the position of the logical address segment in the ranking.
步骤403、针对待写入物理存储区域的目标数据,确定目标数据对应的目标逻辑地址分段。Step 403: for the target data to be written into the physical storage area, determine the target logical address segment corresponding to the target data.
当接收到用户待写入物理存储区域的一目标数据的时候,可以先确定该目标数据所写入的目标逻辑地址分数段。When receiving target data to be written into a physical storage area by a user, the target logical address fractional segment into which the target data is written may be determined first.
步骤404、根据目标逻辑地址分段的频率等级,确定对应的第三物理存储区域,并将目标数据写入第三物理存储区域。Step 404: Determine a corresponding third physical storage area according to the frequency level of the target logical address segment, and write the target data into the third physical storage area.
然后,可以确定该目标逻辑地址分段对应的频率等级;在确定目标逻辑地址分段对应的频率等级后,可以根据该目标逻辑地址分段对应的频率等级,确定一第三物理存储区域,Then, the frequency level corresponding to the target logical address segment can be determined; after determining the frequency level corresponding to the target logical address segment, a third physical storage area can be determined according to the frequency level corresponding to the target logical address segment.
例如:逻辑地址分段的频率等级包括高、中、低;频率等级越高,则表示该逻辑地址分段对应的数据越频繁地被进行抹写操作。当目标逻辑地址分段对应的频率等级为高时,FTL可以申请将目标数据写入磨损程度较低的物理存储区域中;该物理存储区域即为第三物理存储区域。For example, the frequency level of the logical address segment includes high, medium and low. The higher the frequency level, the more frequently the data corresponding to the logical address segment is erased and written. When the frequency level corresponding to the target logical address segment is high, the FTL can apply to write the target data into a physical storage area with a lower wear level; this physical storage area is the third physical storage area.
本申请一些实施例中,也可以简单地将逻辑地址分段对应的频率等级分成高和低;然后,可以选取抹写频率最高的前N个逻辑地址分段,并将这N个逻辑地址分段的频率等级设为高,其他的逻辑地址分段的频率等级设为低;其中,这N个逻辑地址分段的抹写频率的总和需要大于或等于第三阈值,N为一正整数。In some embodiments of the present application, the frequency levels corresponding to the logical address segments can also be simply divided into high and low; then, the first N logical address segments with the highest erase frequency can be selected, and the frequency levels of these N logical address segments can be set to high, and the frequency levels of other logical address segments can be set to low; wherein, the sum of the erase frequencies of these N logical address segments needs to be greater than or equal to a third threshold, and N is a positive integer.
在确定第三物理存储区域后,可以将目标数据写入第三物理存储区域;相比于随机将目标数据写入物理存储区域来说,本申请实施例可以通过目标数据所写入的目标逻辑地址分段的频率等级来确定对应的第三物理存储区域;从而将目标数据存储更适合的物理存储区域,进而避免将频繁被抹写操作的数据写入磨损程度较高的物理存储区域中。After determining the third physical storage area, the target data can be written into the third physical storage area; compared with randomly writing the target data into the physical storage area, the embodiment of the present application can determine the corresponding third physical storage area by the frequency level of the target logical address segment in which the target data is written; thereby storing the target data in a more suitable physical storage area, thereby avoiding writing data that is frequently erased and written into a physical storage area with a higher degree of wear.
本申请一些实施例中,在将目标数据写入第三物理存储区域后,可以对第三物理存储区域对应的磨损程度和抹写频率进行更新;其中,当第三物理存储区域写满后,可以将第三物理存储区域的抹写频率保存到第三物理存储区域的数据结构中。In some embodiments of the present application, after the target data is written into the third physical storage area, the wear degree and erase frequency corresponding to the third physical storage area can be updated; wherein, when the third physical storage area is full, the erase frequency of the third physical storage area can be saved in the data structure of the third physical storage area.
本申请一些实施例中,可以通过如下子步骤来确定第三物理存储区域:In some embodiments of the present application, the third physical storage area may be determined by the following sub-steps:
子步骤71、按照磨损程度的大小,对各物理存储区域进行排序。Sub-step 71: sort the physical storage areas according to the degree of wear.
首先,可以先按照各物理存储区域的磨损程度的大小,对各物理存储区域进行排序。First, the physical storage areas may be sorted according to the degree of wear of the physical storage areas.
子步骤72、基于各物理存储区域的排序,确定各物理存储区域的磨损等级。Sub-step 72: Determine the wear level of each physical storage area based on the ranking of each physical storage area.
在对各物理存储区域进行排序后,可以基于各物理存储区域在排序中的位置,确定各物理存储区域的磨损等级。After the physical storage areas are sorted, the wear level of each physical storage area may be determined based on the position of each physical storage area in the sort.
子步骤73、确定磨损等级与目标逻辑地址分段的频率等级匹配的第三物理存储区域。Sub-step 73: Determine a third physical storage area whose wear level matches the frequency level of the target logical address segment.
在得到各物理存储区域的磨损等级后,可以确定一磨损等级与目标逻辑地址分段的频率等级匹配的物理存储区域,并将其作为第三物理存储区域。
After the wear level of each physical storage area is obtained, a physical storage area whose wear level matches the frequency level of the target logical address segment may be determined and used as the third physical storage area.
本申请一些实施例中,子步骤73通过如下方式来实现:In some embodiments of the present application, sub-step 73 is implemented in the following manner:
预先建立逻辑地址分段的频率等级与磨损等级的对应关系;从对应关系中,确定与目标逻辑地址分段的频率等级对应的目标磨损等级;将具备目标磨损等级的物理存储区域作为第三物理存储区域。A correspondence between the frequency level and the wear level of the logical address segment is established in advance; from the correspondence, a target wear level corresponding to the frequency level of the target logical address segment is determined; and a physical storage area having the target wear level is used as a third physical storage area.
首先,可以预先建立逻辑地址分段的频率等级与磨损等级的对应关系;该对应关系可以保证频率等级高的数据可以存入磨损等级低的物理存储区域中,以及保证频率等级低的数据可以存入磨损等级高的物理存储区域中;从而减少对目标固态硬盘的磨损均衡的操作。First, a correspondence between the frequency level and the wear level of the logical address segment can be established in advance; this correspondence can ensure that data with a high frequency level can be stored in a physical storage area with a low wear level, and that data with a low frequency level can be stored in a physical storage area with a high wear level; thereby reducing the wear leveling operation on the target solid state drive.
步骤405、当目标固态硬盘中的数据不满足预设分层条件时,对各逻辑地址分段的抹写频率进行清零处理,并重新开始计算各逻辑地址分段的抹写频率。Step 405: When the data in the target solid state drive does not meet the preset tiering condition, the erase and write frequencies of each logical address segment are cleared, and the erase and write frequencies of each logical address segment are recalculated.
在实际应用中,如果目标固态硬盘中的数据不满足预设分层条件的话,可以对各逻辑地址分段的抹写频率进行清零处理;然后,可以重新开始基于各逻辑地址分段的段抹写次数和目标固态硬盘的总抹写次数,来计算各逻辑地址分段的抹写频率。In actual applications, if the data in the target solid-state drive does not meet the preset stratification conditions, the erase frequency of each logical address segment can be cleared; then, the erase frequency of each logical address segment can be recalculated based on the number of segment erases of each logical address segment and the total number of erases of the target solid-state drive.
本申请一些实施例中,在重新计算各逻辑地址分段的抹写频率的时候,可以以在先抹除的逻辑地址分段的抹写频率作为基准来进行;例如:可以以逻辑地址分段的旧的抹写频率和新的抹写频率来计算各逻辑地址分段的抹写频率,本申请实施例对此不作限制。In some embodiments of the present application, when recalculating the erase frequency of each logical address segment, the erase frequency of the previously erased logical address segment can be used as a reference; for example: the erase frequency of each logical address segment can be calculated based on the old erase frequency and the new erase frequency of the logical address segment, and the embodiments of the present application do not limit this.
本申请实施例中,可以预先根据各逻辑地址分段的抹写频率,判断目标固态硬盘中的数据是否满足预设分层条件;当目标固态硬盘中的数据满足预设分层条件时,根据各逻辑地址分段的抹写频率,确定各逻辑地址分段的频率等级;针对待写入物理存储区域的目标数据,可以确定目标数据对应的目标逻辑地址分段;根据目标逻辑地址分段的频率等级,确定对应的第三物理存储区域,并将目标数据写入第三物理存储区域;而当目标固态硬盘中的数据不满足预设分层条件时,对各逻辑地址分段的抹写频率进行清零处理,并重新开始计算各逻辑地址分段的抹写频率。本申请实施例通过目标数据所写入的目标逻辑地址分段的频率等级来确定对应的第三物理存储区域;从而将目标数据存储更适合的物理存储区域,进而避免将频繁被抹写操作的数据写入磨损程度较高的物理存储区域中。In the embodiment of the present application, it is possible to determine in advance whether the data in the target solid-state hard disk meets the preset stratification conditions according to the erasing frequency of each logical address segment; when the data in the target solid-state hard disk meets the preset stratification conditions, the frequency level of each logical address segment is determined according to the erasing frequency of each logical address segment; for the target data to be written into the physical storage area, the target logical address segment corresponding to the target data can be determined; according to the frequency level of the target logical address segment, the corresponding third physical storage area is determined, and the target data is written into the third physical storage area; and when the data in the target solid-state hard disk does not meet the preset stratification conditions, the erasing frequency of each logical address segment is cleared, and the erasing frequency of each logical address segment is recalculated. The embodiment of the present application determines the corresponding third physical storage area by the frequency level of the target logical address segment into which the target data is written; thereby storing the target data in a more suitable physical storage area, thereby avoiding writing data that is frequently erased into a physical storage area with a higher degree of wear.
需要说明的是,对于方法实施例,为了简单描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本申请实施例并不受所描述的动作顺序的限制,因为依据本申请实施例,某些步骤可以采用其他顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于优选实施例,所涉及的动作并不一定是本申请实施例所必须的。It should be noted that, for the method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present application are not limited by the described action sequence, because according to the embodiments of the present application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present application.
参照图5,示出了本申请实施例的一种磨损均衡的装置的结构示意图,可以包括如下模块:5 , a schematic diagram of the structure of a wear leveling device according to an embodiment of the present application is shown, which may include the following modules:
第一获取模块501,用于获取目标固态硬盘中各逻辑地址的抹写频率,目标固态硬盘包括多个物理存储区域;A first acquisition module 501 is used to acquire the erase and write frequency of each logical address in a target solid state drive, where the target solid state drive includes multiple physical storage areas;
第二获取模块502,用于根据第一物理存储区域所对应的多个逻辑地址的抹写频率,确定第一物理存储区域的目标抹写频率,并获取第一物理存储区域的目标磨损程度;A second acquisition module 502 is used to determine a target write/erase frequency of the first physical storage area according to the write/erase frequencies of the plurality of logical addresses corresponding to the first physical storage area, and to acquire a target wear degree of the first physical storage area;
第一判断模块503,用于判断目标抹写频率与目标磨损程度是否满足预设匹配条件;The first judgment module 503 is used to judge whether the target erasure frequency and the target wear degree meet the preset matching condition;
第一确定模块504,用于当目标抹写频率与目标磨损程度不满足预设匹配条件时,从除第一物理存储区域外的其他物理存储区域中,确定一与目标抹写频率满足预设匹配条件的第二物理存储区域;
A first determination module 504 is used to determine, from other physical storage areas except the first physical storage area, a second physical storage area that meets the preset matching condition with the target erasure frequency when the target erasure frequency and the target wear degree do not meet the preset matching condition;
转移模块505,用于将第一物理存储区域中的数据,转移至第二物理存储区域进行存储。The transfer module 505 is used to transfer the data in the first physical storage area to the second physical storage area for storage.
本申请一些实施例中,第一获取模块501,用于对目标固态硬盘中的所有的逻辑地址进行分段,得到多个逻辑地址分段,每段逻辑地址分段包括至少一个逻辑地址;确定各逻辑地址分段的抹写频率,并将逻辑地址分段的抹写频率,作为逻辑地址分段所包括的各逻辑地址的抹写频率。In some embodiments of the present application, the first acquisition module 501 is used to segment all logical addresses in the target solid-state hard disk to obtain multiple logical address segments, each logical address segment includes at least one logical address; determine the erase and write frequency of each logical address segment, and use the erase and write frequency of the logical address segment as the erase and write frequency of each logical address included in the logical address segment.
本申请一些实施例中,第一获取模块501,用于统计目标固态硬盘的总抹写次数,以及各逻辑地址分段的段抹写次数;当总抹写次数超过第一阈值时,根据段抹写次数和总抹写次数,计算各逻辑地址分段的抹写频率。In some embodiments of the present application, the first acquisition module 501 is used to count the total number of erase and write times of the target solid-state hard disk, and the number of segment erase and write times of each logical address segment; when the total number of erase and write times exceeds the first threshold, the erase and write frequency of each logical address segment is calculated based on the segment erase and write times and the total erase and write times.
本申请一些实施例中,装置还包括:In some embodiments of the present application, the device further includes:
第一清零模块,用于对总抹写次数和段抹写次数进行清零处理,并重新开始统计目标固态硬盘的总抹写次数,以及各逻辑地址分段的段抹写次数。The first clearing module is used to clear the total erase and write times and the segment erase and write times, and restart counting the total erase and write times of the target solid state drive and the segment erase and write times of each logical address segment.
本申请一些实施例中,装置还包括:In some embodiments of the present application, the device further includes:
写入模块,用于根据各逻辑地址分段的抹写频率,判断目标固态硬盘中的数据是否满足预设分层条件;当目标固态硬盘中的数据满足预设分层条件时,根据各逻辑地址分段的抹写频率,确定各逻辑地址分段的频率等级;针对待写入物理存储区域的目标数据,确定目标数据对应的目标逻辑地址分段;根据目标逻辑地址分段的频率等级,确定对应的第三物理存储区域,并将目标数据写入第三物理存储区域。A write module is used to determine whether the data in the target solid-state hard disk meets the preset stratification conditions according to the erase and write frequencies of each logical address segment; when the data in the target solid-state hard disk meets the preset stratification conditions, determine the frequency level of each logical address segment according to the erase and write frequencies of each logical address segment; for the target data to be written into the physical storage area, determine the target logical address segment corresponding to the target data; determine the corresponding third physical storage area according to the frequency level of the target logical address segment, and write the target data into the third physical storage area.
本申请一些实施例中,装置还包括:In some embodiments of the present application, the device further includes:
第二清零模块,用于当目标固态硬盘中的数据不满足预设分层条件时,对各逻辑地址分段的抹写频率进行清零处理,并重新开始计算各逻辑地址分段的抹写频率。The second clearing module is used to clear the write-erase frequency of each logical address segment and restart the calculation of the write-erase frequency of each logical address segment when the data in the target solid state drive does not meet the preset stratification condition.
本申请一些实施例中,写入模块,用于确定抹写频率最高的前M个逻辑地址分段,并计算抹写频率最高的前M个逻辑地址分段的总的抹写频率,M为正整数;当前M个逻辑地址分段的总的抹写频率大于第三阈值时,判定目标固态硬盘中的数据满足预设分层条件。In some embodiments of the present application, the write module is used to determine the top M logical address segments with the highest erase frequency, and calculate the total erase frequency of the top M logical address segments with the highest erase frequency, where M is a positive integer; when the total erase frequency of the current M logical address segments is greater than a third threshold, it is determined that the data in the target solid-state drive meets the preset stratification conditions.
本申请一些实施例中,写入模块,用于按照各逻辑地址的抹写频率的大小,对各逻辑地址分段进行排序;基于各逻辑地址分段的排序,确定各逻辑地址分段的频率等级。In some embodiments of the present application, the write module is used to sort the logical address segments according to the magnitude of the erase and write frequency of each logical address; and determine the frequency level of each logical address segment based on the sorting of the logical address segments.
本申请一些实施例中,写入模块,用于按照磨损程度的大小,对各物理存储区域进行排序;基于各物理存储区域的排序,确定各物理存储区域的磨损等级;确定磨损等级与目标逻辑地址分段的频率等级匹配的第三物理存储区域。In some embodiments of the present application, a write module is used to sort each physical storage area according to the degree of wear; determine the wear level of each physical storage area based on the sorting of each physical storage area; and determine a third physical storage area whose wear level matches the frequency level of the target logical address segment.
本申请一些实施例中,写入模块,用于预先建立逻辑地址分段的频率等级与磨损等级的对应关系;从对应关系中,确定与目标逻辑地址分段的频率等级对应的目标磨损等级;将具备目标磨损等级的物理存储区域作为第三物理存储区域。In some embodiments of the present application, a write module is used to pre-establish a correspondence between the frequency level and the wear level of the logical address segment; from the correspondence, determine the target wear level corresponding to the frequency level of the target logical address segment; and use the physical storage area with the target wear level as the third physical storage area.
本申请一些实施例中,第二获取模块502,用于确定第一物理存储区域所对应的多个逻辑地址的抹写频率的目标和值;确定第一物理存储区域所对应的逻辑地址的目标数量;根据目标和值和目标数量,确定第一物理存储区域的目标抹写频率。In some embodiments of the present application, the second acquisition module 502 is used to determine the target and value of the erase and write frequencies of multiple logical addresses corresponding to the first physical storage area; determine the target number of logical addresses corresponding to the first physical storage area; and determine the target erase and write frequency of the first physical storage area based on the target and value and the target number.
本申请一些实施例中,第二获取模块502,用于计算目标和值与目标数量的第一比值;计算第一比值与目标数量的第二比值,并将第二比值作为目标抹写频率。In some embodiments of the present application, the second acquisition module 502 is used to calculate a first ratio of the target sum value to the target quantity; calculate a second ratio of the first ratio to the target quantity, and use the second ratio as the target erase frequency.
本申请一些实施例中,第二获取模块502,用于获取各物理存储区域的磨损次数;根据各物理存储区域的磨损次数,确定第一物理存储区域的第一磨损偏差;根据第一磨损偏差,确定目标磨损程度。
In some embodiments of the present application, the second acquisition module 502 is used to obtain the number of wear times of each physical storage area; determine the first wear deviation of the first physical storage area based on the number of wear times of each physical storage area; and determine the target wear degree based on the first wear deviation.
本申请一些实施例中,第二获取模块502,用于从各物理存储区域的磨损次数中,确定一极值磨损次数、一平均磨损次数,以及第一物理存储区域的磨损次数;确定第一物理存储区域的磨损次数和极值磨损次数的第一差值,与平均磨损次数和极值磨损次数的第二差值;根据第一差值和第二差值的比值,确定第一磨损偏差。In some embodiments of the present application, the second acquisition module 502 is used to determine an extreme wear count, an average wear count, and the wear count of the first physical storage area from the wear counts of each physical storage area; determine a first difference between the wear count and the extreme wear count of the first physical storage area, and a second difference between the average wear count and the extreme wear count; and determine a first wear deviation based on the ratio of the first difference to the second difference.
本申请一些实施例中,第一判断模块503,用于确定目标抹写频率与目标磨损程度的匹配度;当目标抹写频率与目标磨损程度的匹配度超过第二阈值时,判定目标抹写频率与目标磨损程度满足预设匹配条件。In some embodiments of the present application, the first judgment module 503 is used to determine the matching degree between the target erasure frequency and the target wear degree; when the matching degree between the target erasure frequency and the target wear degree exceeds a second threshold, it is determined that the target erasure frequency and the target wear degree meet a preset matching condition.
本申请一些实施例中,第一判断模块503,用于确定目标抹写频率与目标磨损程度的第三比值;根据第三比值,确定目标抹写频率与目标磨损程度的匹配度。In some embodiments of the present application, the first judgment module 503 is used to determine a third ratio of the target erase frequency to the target wear degree; and determine the matching degree of the target erase frequency and the target wear degree according to the third ratio.
本申请一些实施例中,第一判断模块503,用于按照各物理存储区域的抹写频率的大小,对各物理存储区域进行排序,并基于各物理存储区域的排序,确定各物理存储区域的频率等级;按照磨损程度的大小,对各物理存储区域进行排序,并基于各物理存储区域的排序,确定各物理存储区域的磨损等级;根据第一物理存储区域对应的磨损等级和频率等级,确定目标抹写频率与目标磨损程度的匹配度。In some embodiments of the present application, the first judgment module 503 is used to sort each physical storage area according to the erase and write frequency of each physical storage area, and determine the frequency level of each physical storage area based on the sorting of each physical storage area; sort each physical storage area according to the degree of wear, and determine the wear level of each physical storage area based on the sorting of each physical storage area; determine the matching degree of the target erase and write frequency and the target wear level according to the wear level and frequency level corresponding to the first physical storage area.
本申请一些实施例中,装置还包括:In some embodiments of the present application, the device further includes:
更新模块,用于在将第一物理存储区域中的数据,转移至第二物理存储区域进行存储后,根据所转移的数据,对第一物理存储区域和第二物理存储区域的抹写频率进行更新。The update module is used to update the erasing frequency of the first physical storage area and the second physical storage area according to the transferred data after transferring the data in the first physical storage area to the second physical storage area for storage.
本申请实施例中,可以先获取目标固态硬盘中各逻辑地址的抹写频率;然后根据第一物理存储区域所对应的多个逻辑地址的抹写频率,确定第一物理存储区域的目标抹写频率,并获取第一物理存储区域的目标磨损程度;之后,判断目标抹写频率与目标磨损程度是否满足预设匹配条件;如果目标抹写频率与目标磨损程度不满足预设匹配条件的话,则从除第一物理存储区域外的其他物理存储区域中,确定一与目标抹写频率满足预设匹配条件的第二物理存储区域,并将第一物理存储区域中的数据,转移至第二物理存储区域进行存储。通过关注物理存储区域的整体的抹写频率,和对应的磨损程度的关系,来进行磨损均衡,可以避免现有技术中仅关注磨损程度来进行磨损均衡所存在的问题,从而提高了磨损均衡的效率,避免了固态硬盘寿命的浪费。In the embodiment of the present application, the write-erase frequency of each logical address in the target solid-state hard disk can be obtained first; then, according to the write-erase frequency of multiple logical addresses corresponding to the first physical storage area, the target write-erase frequency of the first physical storage area is determined, and the target wear degree of the first physical storage area is obtained; then, it is determined whether the target write-erase frequency and the target wear degree meet the preset matching condition; if the target write-erase frequency and the target wear degree do not meet the preset matching condition, then a second physical storage area that meets the preset matching condition with the target write-erase frequency is determined from other physical storage areas except the first physical storage area, and the data in the first physical storage area is transferred to the second physical storage area for storage. By focusing on the relationship between the overall write-erase frequency of the physical storage area and the corresponding wear degree to perform wear leveling, the problem existing in the prior art of only focusing on the wear degree to perform wear leveling can be avoided, thereby improving the efficiency of wear leveling and avoiding the waste of the life of the solid-state hard disk.
本申请实施例还提供了一种电子设备,如图6所示,该电子设备6包括处理器601、存储器602及存储在存储器602上并能够在处理器上运行的计算机程序,计算机程序被处理器执行时实现如上的磨损均衡的方法。An embodiment of the present application also provides an electronic device, as shown in FIG6 , the electronic device 6 includes a processor 601, a memory 602, and a computer program stored in the memory 602 and capable of running on the processor, and the computer program implements the above wear leveling method when executed by the processor.
本申请实施例还提供了一种非易失性可读存储介质,如图7所示,该非易失性可读存储介质7上存储计算机程序701,计算机程序701被处理器执行时实现如上的磨损均衡的方法。The embodiment of the present application further provides a non-volatile readable storage medium, as shown in FIG. 7 , the non-volatile readable storage medium 7 stores a computer program 701 , and the computer program 701 implements the above wear leveling method when executed by a processor.
对于装置实施例而言,由于其与方法实施例基本相似,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
本说明书中的各个实施例均采用递进的方式描述,每个实施例重点说明的都是与其他实施例的不同之处,各个实施例之间相同相似的部分互相参见即可。The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
本领域内的技术人员应明白,本申请实施例可提供为方法、装置、或计算机程序产品。因此,本申请实施例可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请实施例可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程
序产品的形式。It should be understood by those skilled in the art that the embodiments of the present application may be provided as methods, devices, or computer program products. Therefore, the embodiments of the present application may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present application may take the form of a computer program implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code. The form of the sequence product.
本申请实施例是参照根据本申请实施例的方法、终端设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理终端设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理终端设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present application embodiment is described with reference to the flowchart and/or block diagram of the method, terminal device (system) and computer program product according to the embodiment of the present application. It should be understood that each process and/or box in the flowchart and/or block diagram, and the combination of the process and/or box in the flowchart and/or block diagram can be realized 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 terminal device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device produce a device for realizing the function specified in one process or multiple processes in the flowchart and/or one box or multiple boxes in the block diagram.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理终端设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device that implements the functions specified in one or more processes in the flowchart and/or one or more boxes in the block diagram.
这些计算机程序指令也可装载到计算机或其他可编程数据处理终端设备上,使得在计算机或其他可编程终端设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程终端设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce computer-implemented processing, so that the instructions executed on the computer or other programmable terminal device provide steps for implementing the functions specified in one or more processes in the flowchart and/or one or more boxes in the block diagram.
尽管已描述了本申请实施例的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例做出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本申请实施例范围的所有变更和修改。Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present application.
最后,还需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性地包含,从而使得包括一系列要素的过程、方法、物品或者终端设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者终端设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者终端设备中还存在另外的相同要素。Finally, it should be noted that, in this article, relational terms such as first and second, etc. 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 terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.
以上对所提供的一种磨损均衡的方法、装置、电子设备和存储介质,进行了详细介绍,本文中应用了具体个例对本申请的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本申请的方法及其核心思想;同时,对于本领域的一般技术人员,依据本申请的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本申请的限制。
The above provides a detailed introduction to a wear leveling method, device, electronic device and storage medium. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for a person skilled in the art, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims (21)
- 一种磨损均衡的方法,其特征在于,所述方法包括:A wear leveling method, characterized in that the method comprises:获取目标固态硬盘中各逻辑地址的抹写频率,所述目标固态硬盘包括多个物理存储区域;Obtaining the write-erase frequency of each logical address in a target solid-state hard disk, wherein the target solid-state hard disk includes a plurality of physical storage areas;根据第一物理存储区域所对应的多个逻辑地址的抹写频率,确定所述第一物理存储区域的目标抹写频率,并获取所述第一物理存储区域的目标磨损程度;Determine a target write-erase frequency of the first physical storage area according to the write-erase frequencies of a plurality of logical addresses corresponding to the first physical storage area, and obtain a target wear degree of the first physical storage area;判断所述目标抹写频率与所述目标磨损程度是否满足预设匹配条件;Determining whether the target erasing frequency and the target wear degree meet a preset matching condition;当所述目标抹写频率与所述目标磨损程度不满足所述预设匹配条件时,从除所述第一物理存储区域外的其他物理存储区域中,确定一与所述目标抹写频率满足所述预设匹配条件的第二物理存储区域;When the target write-erase frequency and the target wear degree do not satisfy the preset matching condition, determining a second physical storage area that satisfies the preset matching condition with the target write-erase frequency from other physical storage areas except the first physical storage area;将所述第一物理存储区域中的数据,转移至所述第二物理存储区域进行存储。The data in the first physical storage area is transferred to the second physical storage area for storage.
- 根据权利要求1所述的方法,其特征在于,所述获取目标固态硬盘中各逻辑地址的抹写频率,包括:The method according to claim 1, wherein obtaining the erase and write frequency of each logical address in the target solid-state drive comprises:对所述目标固态硬盘中的所有的逻辑地址进行分段,得到多个逻辑地址分段,每段逻辑地址分段包括至少一个逻辑地址;Segmenting all logical addresses in the target solid state drive to obtain a plurality of logical address segments, each logical address segment including at least one logical address;确定各逻辑地址分段的抹写频率,并将逻辑地址分段的抹写频率,作为逻辑地址分段所包括的各逻辑地址的抹写频率。The erasing and writing frequency of each logical address segment is determined, and the erasing and writing frequency of the logical address segment is used as the erasing and writing frequency of each logical address included in the logical address segment.
- 根据权利要求2所述的方法,其特征在于,所述确定各逻辑地址分段的抹写频率,包括:The method according to claim 2, characterized in that the step of determining the erasing and writing frequency of each logical address segment comprises:统计所述目标固态硬盘的总抹写次数,以及各逻辑地址分段的段抹写次数;Counting the total number of erase/write times of the target solid-state hard disk and the number of segment erase/write times of each logical address segment;当所述总抹写次数超过第一阈值时,根据所述段抹写次数和所述总抹写次数,计算各逻辑地址分段的抹写频率。When the total number of erasures exceeds a first threshold, the erasure frequency of each logical address segment is calculated according to the segment erasure number and the total number of erasures.
- 根据权利要求3所述的方法,其特征在于,所述方法还包括:The method according to claim 3, characterized in that the method further comprises:对所述总抹写次数和所述段抹写次数进行清零处理,并重新开始统计所述目标固态硬盘的总抹写次数,以及各逻辑地址分段的段抹写次数。The total erase/write times and the segment erase/write times are cleared, and the total erase/write times of the target solid-state hard disk and the segment erase/write times of each logical address segment are counted again.
- 根据权利要求3所述的方法,其特征在于,所述方法还包括:The method according to claim 3, characterized in that the method further comprises:根据各逻辑地址分段的抹写频率,判断所述目标固态硬盘中的数据是否满足预设分层条件;Determining whether the data in the target solid-state hard disk meets a preset tiering condition according to the erase and write frequency of each logical address segment;当所述目标固态硬盘中的数据满足预设分层条件时,根据各逻辑地址分段的抹写频率,确定各逻辑地址分段的频率等级;When the data in the target solid state drive meets the preset tiering condition, determining the frequency level of each logical address segment according to the erasing and writing frequency of each logical address segment;针对待写入物理存储区域的目标数据,确定所述目标数据对应的目标逻辑地址分段;For target data to be written into the physical storage area, determining a target logical address segment corresponding to the target data;根据所述目标逻辑地址分段的频率等级,确定对应的第三物理存储区域,并将所述目标数据写入所述第三物理存储区域。According to the frequency level of the target logical address segment, a corresponding third physical storage area is determined, and the target data is written into the third physical storage area.
- 根据权利要求5所述的方法,其特征在于,所述方法还包括:The method according to claim 5, characterized in that the method further comprises:当所述目标固态硬盘中的数据不满足预设分层条件时,对各逻辑地址分段的抹写频率进行清零处理,并重新开始计算各逻辑地址分段的抹写频率。When the data in the target solid state drive does not meet the preset stratification condition, the write-erase frequency of each logical address segment is cleared, and the write-erase frequency of each logical address segment is recalculated.
- 根据权利要求5所述的方法,其特征在于,所述根据各逻辑地址分段的抹写频率,判断所述目标固态硬盘中的数据是否满足预设分层条件,包括:The method according to claim 5, characterized in that judging whether the data in the target solid-state drive meets a preset tiering condition according to the erasing and writing frequency of each logical address segment comprises:确定抹写频率最高的前M个逻辑地址分段,并计算抹写频率最高的前M个逻辑地址 分段的总的抹写频率,M为正整数;Determine the top M logical address segments with the highest erase and write frequency, and calculate the top M logical addresses with the highest erase and write frequency The total erasure frequency of the segment, M is a positive integer;当所述前M个逻辑地址分段的总的抹写频率大于第三阈值时,判定所述目标固态硬盘中的数据满足预设分层条件。When the total write-erasure frequency of the first M logical address segments is greater than a third threshold, it is determined that the data in the target solid state drive meets a preset tiering condition.
- 根据权利要求5所述的方法,其特征在于,所述根据各逻辑地址分段的抹写频率,确定各逻辑地址分段的频率等级,包括:The method according to claim 5, characterized in that the step of determining the frequency level of each logical address segment according to the erasing and writing frequency of each logical address segment comprises:按照各逻辑地址的抹写频率的大小,对各逻辑地址分段进行排序;Sort the logical address segments according to the erase and write frequencies of the logical addresses;基于各逻辑地址分段的排序,确定各逻辑地址分段的频率等级。Based on the ranking of the logical address segments, a frequency rank of the logical address segments is determined.
- 根据权利要求8所述的方法,其特征在于,所述根据所述目标逻辑地址分段的频率等级,确定对应的第三物理存储区域,包括:The method according to claim 8, characterized in that the step of determining the corresponding third physical storage area according to the frequency level of the target logical address segment comprises:按照磨损程度的大小,对各物理存储区域进行排序;Sort each physical storage area according to the degree of wear;基于各物理存储区域的排序,确定各物理存储区域的磨损等级;Determine the wear level of each physical storage area based on the ranking of each physical storage area;确定磨损等级与所述目标逻辑地址分段的频率等级匹配的第三物理存储区域。A third physical storage area having a wear level matching the frequency level of the target logical address segment is determined.
- 根据权利要求9所述的方法,其特征在于,所述确定磨损等级与所述目标逻辑地址分段的频率等级匹配的第三物理存储区域,包括:The method according to claim 9, characterized in that the determining of the third physical storage area whose wear level matches the frequency level of the target logical address segment comprises:预先建立逻辑地址分段的频率等级与磨损等级的对应关系;Pre-establishing the correspondence between the frequency level and the wear level of the logical address segment;从所述对应关系中,确定与所述目标逻辑地址分段的频率等级对应的目标磨损等级;From the corresponding relationship, determining a target wear level corresponding to the frequency level of the target logical address segment;将具备所述目标磨损等级的物理存储区域作为所述第三物理存储区域。A physical storage area having the target wear level is used as the third physical storage area.
- 根据权利要求1所述的方法,其特征在于,所述根据第一物理存储区域所对应的多个逻辑地址的抹写频率,确定所述第一物理存储区域的目标抹写频率,包括:The method according to claim 1, characterized in that the step of determining a target erase/write frequency of the first physical storage area according to the erase/write frequencies of a plurality of logical addresses corresponding to the first physical storage area comprises:确定所述第一物理存储区域所对应的多个逻辑地址的抹写频率的目标和值;Determine targets and values of erase and write frequencies of a plurality of logical addresses corresponding to the first physical storage area;确定所述第一物理存储区域所对应的逻辑地址的目标数量;Determining a target number of logical addresses corresponding to the first physical storage area;根据所述目标和值和所述目标数量,确定所述第一物理存储区域的目标抹写频率。A target erasing frequency of the first physical storage area is determined according to the target sum value and the target quantity.
- 根据权利要求11所述的方法,其特征在于,所述根据所述目标和值和所述目标数量,确定所述第一物理存储区域的目标抹写频率,包括:The method according to claim 11, characterized in that the step of determining the target erasing frequency of the first physical storage area according to the target value and the target quantity comprises:计算所述目标和值与所述目标数量的第一比值;calculating a first ratio of the target sum value to the target quantity;计算所述第一比值与所述目标数量的第二比值,并将所述第二比值作为所述目标抹写频率。A second ratio of the first ratio to the target number is calculated, and the second ratio is used as the target erasing frequency.
- 根据权利要求1所述的方法,其特征在于,所述获取所述第一物理存储区域的目标磨损程度,包括:The method according to claim 1, characterized in that obtaining the target wear degree of the first physical storage area comprises:获取各物理存储区域的磨损次数;Get the number of wear times of each physical storage area;根据各物理存储区域的磨损次数,确定所述第一物理存储区域的第一磨损偏差;Determining a first wear deviation of the first physical storage area according to the number of wears of each physical storage area;根据所述第一磨损偏差,确定所述目标磨损程度。The target wear degree is determined according to the first wear deviation.
- 根据权利要求13所述的方法,其特征在于,所述根据各物理存储区域的磨损次数,确定所述第一物理存储区域的第一磨损偏差,包括:The method according to claim 13, wherein determining the first wear deviation of the first physical storage area according to the number of wears of each physical storage area comprises:从各物理存储区域的磨损次数中,确定一极值磨损次数、一平均磨损次数,以及所述第一物理存储区域的磨损次数;Determine an extreme wear count, an average wear count, and the wear count of the first physical storage area from the wear counts of each physical storage area;确定所述第一物理存储区域的磨损次数和所述极值磨损次数的第一差值,与所述平均磨损次数和所述极值磨损次数的第二差值;Determine a first difference between the number of times the first physical storage area is worn and the number of times the extreme wear is worn, and a second difference between the average number of times the first physical storage area is worn and the number of times the extreme wear is worn;根据所述第一差值和第二差值的比值,确定所述第一磨损偏差。The first wear deviation is determined based on a ratio of the first difference to the second difference.
- 根据权利要求13所述的方法,其特征在于,所述判断所述目标抹写频率与所述 目标磨损程度是否满足预设匹配条件,包括:The method according to claim 13, characterized in that the determination of the target erasing frequency and the Whether the target wear level meets the preset matching conditions, including:确定所述目标抹写频率与所述目标磨损程度的匹配度;Determining a matching degree between the target erasing frequency and the target wear degree;当所述目标抹写频率与所述目标磨损程度的匹配度超过第二阈值时,判定所述目标抹写频率与所述目标磨损程度满足预设匹配条件。When the matching degree between the target erasing frequency and the target wear degree exceeds a second threshold, it is determined that the target erasing frequency and the target wear degree satisfy a preset matching condition.
- 根据权利要求15所述的方法,其特征在于,所述确定所述目标抹写频率与所述目标磨损程度的匹配度,包括:The method according to claim 15, characterized in that the determining the matching degree between the target erase frequency and the target wear degree comprises:确定所述目标抹写频率与所述目标磨损程度的第三比值;determining a third ratio of the target erasure frequency to the target wear degree;根据所述第三比值,确定所述目标抹写频率与所述目标磨损程度的匹配度。The matching degree between the target erasing frequency and the target wear degree is determined according to the third ratio.
- 根据权利要求15所述的方法,其特征在于,所述确定所述目标抹写频率与所述目标磨损程度的匹配度,包括:The method according to claim 15, characterized in that the determining the matching degree between the target erase frequency and the target wear degree comprises:按照各物理存储区域的抹写频率的大小,对各物理存储区域进行排序,并基于各物理存储区域的排序,确定各物理存储区域的频率等级;Sort the physical storage areas according to the magnitude of the erase and write frequencies of the physical storage areas, and determine the frequency level of the physical storage areas based on the sorting of the physical storage areas;按照磨损程度的大小,对各物理存储区域进行排序,并基于各物理存储区域的排序,确定各物理存储区域的磨损等级;Sort the physical storage areas according to the degree of wear, and determine the wear level of each physical storage area based on the sort of the physical storage areas;根据所述第一物理存储区域对应的磨损等级和频率等级,确定所述目标抹写频率与所述目标磨损程度的匹配度。According to the wear level and frequency level corresponding to the first physical storage area, the matching degree between the target write-erase frequency and the target wear degree is determined.
- 根据权利要求1所述的方法,其特征在于,在将所述第一物理存储区域中的数据,转移至所述第二物理存储区域进行存储后,所述方法还包括:The method according to claim 1, characterized in that after transferring the data in the first physical storage area to the second physical storage area for storage, the method further comprises:根据所转移的数据,对所述第一物理存储区域和第二物理存储区域的抹写频率进行更新。The write-erase frequencies of the first physical storage area and the second physical storage area are updated according to the transferred data.
- 一种磨损均衡的装置,其特征在于,所述装置包括:A wear leveling device, characterized in that the device comprises:第一获取模块,用于获取目标固态硬盘中各逻辑地址的抹写频率,所述目标固态硬盘包括多个物理存储区域;A first acquisition module is used to acquire the erase and write frequency of each logical address in a target solid-state hard disk, wherein the target solid-state hard disk includes multiple physical storage areas;第二获取模块,用于根据第一物理存储区域所对应的多个逻辑地址的抹写频率,确定所述第一物理存储区域的目标抹写频率,并获取所述第一物理存储区域的目标磨损程度;A second acquisition module, configured to determine a target write-erase frequency of the first physical storage area according to the write-erase frequencies of a plurality of logical addresses corresponding to the first physical storage area, and to acquire a target wear degree of the first physical storage area;第一判断模块,用于判断所述目标抹写频率与所述目标磨损程度是否满足预设匹配条件;A first judgment module is used to judge whether the target erasure frequency and the target wear degree meet a preset matching condition;第一确定模块,用于当所述目标抹写频率与所述目标磨损程度不满足所述预设匹配条件时,从除所述第一物理存储区域外的其他物理存储区域中,确定一与所述目标抹写频率满足所述预设匹配条件的第二物理存储区域;A first determination module is used to determine, from other physical storage areas except the first physical storage area, a second physical storage area that meets the preset matching condition with the target erasure frequency when the target erasure frequency and the target wear degree do not meet the preset matching condition;转移模块,用于将所述第一物理存储区域中的数据,转移至所述第二物理存储区域进行存储。The transfer module is used to transfer the data in the first physical storage area to the second physical storage area for storage.
- 一种电子设备,其特征在于,包括处理器、存储器及存储在所述存储器上并能够在所述处理器上运行的计算机程序,所述计算机程序被所述处理器执行时实现如权利要求1至18中任一项所述磨损均衡的方法。An electronic device, characterized in that it includes a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein when the computer program is executed by the processor, the wear leveling method as described in any one of claims 1 to 18 is implemented.
- 一种非易失性可读存储介质,其特征在于,所述非易失性可读存储介质上存储计算机程序,所述计算机程序被处理器执行时实现如权利要求1至18中任一项所述磨损均衡的方法。 A non-volatile readable storage medium, characterized in that a computer program is stored on the non-volatile readable storage medium, and when the computer program is executed by a processor, the wear leveling method as described in any one of claims 1 to 18 is implemented.
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310029810.9A CN115793987B (en) | 2023-01-09 | 2023-01-09 | Wear balancing method and device, electronic equipment and storage medium |
CN202310029810.9 | 2023-01-09 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2024148874A1 true WO2024148874A1 (en) | 2024-07-18 |
Family
ID=85428843
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2023/122278 WO2024148874A1 (en) | 2023-01-09 | 2023-09-27 | Wear leveling method and apparatus, and electronic device and storage medium |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN115793987B (en) |
WO (1) | WO2024148874A1 (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115793987B (en) * | 2023-01-09 | 2023-05-09 | 苏州浪潮智能科技有限公司 | Wear balancing method and device, electronic equipment and storage medium |
Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101419834A (en) * | 2007-10-22 | 2009-04-29 | 群联电子股份有限公司 | Average abrasion method and controller using the method |
CN102081576A (en) * | 2011-03-01 | 2011-06-01 | 华中科技大学 | Flash memory wear balance method |
CN105159602A (en) * | 2015-08-03 | 2015-12-16 | 联想(北京)有限公司 | Data processing method and storage device |
CN107562641A (en) * | 2017-07-11 | 2018-01-09 | 捷开通讯(深圳)有限公司 | The balance abrasion mthods, systems and devices of memory space |
CN108205423A (en) * | 2016-12-20 | 2018-06-26 | 华为技术有限公司 | A kind of physical hard disk abrasion equilibrium method, apparatus and system |
CN112328169A (en) * | 2020-10-20 | 2021-02-05 | 浙江大华存储科技有限公司 | Wear leveling method and device for solid state disk and computer readable storage medium |
US20210089226A1 (en) * | 2019-09-20 | 2021-03-25 | International Business Machines Corporation | Adaptive wear leveling for drive arrays |
CN115793987A (en) * | 2023-01-09 | 2023-03-14 | 苏州浪潮智能科技有限公司 | Wear leveling method and device, electronic equipment and storage medium |
Family Cites Families (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US9153337B2 (en) * | 2006-12-11 | 2015-10-06 | Marvell World Trade Ltd. | Fatigue management system and method for hybrid nonvolatile solid state memory system |
CN101558392A (en) * | 2006-12-11 | 2009-10-14 | 马维尔国际贸易有限公司 | Hybrid non-volatile solid state memory system |
CN100592427C (en) * | 2007-12-05 | 2010-02-24 | 苏州壹世通科技有限公司 | Abrasion wear process method and device of data block |
CN112988037A (en) * | 2019-12-17 | 2021-06-18 | 国民技术股份有限公司 | Static wear leveling method, terminal and computer-readable storage medium |
CN112527693B (en) * | 2020-12-11 | 2023-01-06 | 苏州浪潮智能科技有限公司 | Wear leveling method, system, equipment and medium for solid state disk |
CN112817880A (en) * | 2021-03-17 | 2021-05-18 | 深圳市安信达存储技术有限公司 | Solid state disk, wear balance method thereof and terminal equipment |
-
2023
- 2023-01-09 CN CN202310029810.9A patent/CN115793987B/en active Active
- 2023-09-27 WO PCT/CN2023/122278 patent/WO2024148874A1/en unknown
Patent Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101419834A (en) * | 2007-10-22 | 2009-04-29 | 群联电子股份有限公司 | Average abrasion method and controller using the method |
CN102081576A (en) * | 2011-03-01 | 2011-06-01 | 华中科技大学 | Flash memory wear balance method |
CN105159602A (en) * | 2015-08-03 | 2015-12-16 | 联想(北京)有限公司 | Data processing method and storage device |
CN108205423A (en) * | 2016-12-20 | 2018-06-26 | 华为技术有限公司 | A kind of physical hard disk abrasion equilibrium method, apparatus and system |
CN107562641A (en) * | 2017-07-11 | 2018-01-09 | 捷开通讯(深圳)有限公司 | The balance abrasion mthods, systems and devices of memory space |
US20210089226A1 (en) * | 2019-09-20 | 2021-03-25 | International Business Machines Corporation | Adaptive wear leveling for drive arrays |
CN112328169A (en) * | 2020-10-20 | 2021-02-05 | 浙江大华存储科技有限公司 | Wear leveling method and device for solid state disk and computer readable storage medium |
CN115793987A (en) * | 2023-01-09 | 2023-03-14 | 苏州浪潮智能科技有限公司 | Wear leveling method and device, electronic equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN115793987B (en) | 2023-05-09 |
CN115793987A (en) | 2023-03-14 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111090398B (en) | Garbage recycling method, device and equipment for solid state disk and readable storage medium | |
US11474702B2 (en) | Storage device that writes data from a host during garbage collection | |
US10204042B2 (en) | Memory system having persistent garbage collection | |
US10838859B2 (en) | Recency based victim block selection for garbage collection in a solid state device (SSD) | |
US11704239B2 (en) | Garbage collection method for storage medium, storage medium, and program product | |
US20090172255A1 (en) | Wear leveling method and controller using the same | |
US20090323419A1 (en) | Read-time wear-leveling method in storage system using flash memory device | |
TWI454916B (en) | Storage unit management method, memory controller and memory storage device using the same | |
US8484406B2 (en) | Method of evenly using a plurality of blocks of a flash memory, and associated memory device and controller thereof | |
US20120023144A1 (en) | Managing Wear in Flash Memory | |
TW201349099A (en) | Data storage device and method for managing blocks of a flash memory | |
KR20050084879A (en) | Tracking the least frequently erased blocks in non-volatile memory systems | |
US20130173842A1 (en) | Adaptive Logical Group Sorting to Prevent Drive Fragmentation | |
CN113535074B (en) | Method and apparatus for block management for non-volatile memory | |
KR20210099870A (en) | Memory system and operating method thereof | |
WO2024148874A1 (en) | Wear leveling method and apparatus, and electronic device and storage medium | |
CN111159059A (en) | Garbage recycling method and device and nonvolatile storage equipment | |
KR20210039163A (en) | Memory system and operating method thereof | |
CN112068782A (en) | Memory management method, memory storage device and memory control circuit unit | |
CN110275678B (en) | STT-MRAM-based solid state memory device random access performance improvement method | |
TW202032563A (en) | Data storage device and control method for non-volatile memory | |
CN108153481B (en) | NAND storage block recovery method and device | |
CN112181276B (en) | Large-block construction and distribution method for improving service quality of storage device and storage device thereof | |
CN117806986B (en) | Multi-stream management method of application data and flash memory device | |
CN110688056A (en) | Storage medium replacement for NVM groups |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 23915632 Country of ref document: EP Kind code of ref document: A1 |