Storage control method, storage device and electronic device
By determining the reading/writing strategy according to the label information of the file and the degree of wear of the storage block in the solid -state hard disk, the data reading/writing performance of the storage block wear is solved, and the more efficient data access is achieved.
Patent Information
- Application Number
- CN202411388353.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-30
- Publication Date
- 2025-01-24
AI Technical Summary
There is a condition of storage block wear in the solid-state drive, resulting in a degradation in data read/write performance.
By obtaining the label information of the file and the degree of wear of the storage block, determine the target reading/writing strategy, to control the storage device to perform the corresponding reading/writing operation, and avoid reading/writing directly to the storage block with large wear.
Improved data reading/writing performance, and avoids decreased performance caused by large wear storage blocks.
Smart Images

Figure CN119356604A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a storage control method, a storage device, and an electronic device. Background Art
[0002] Currently, in solid-state drives, there are often storage blocks that are worn out. When reading / writing data, there may be a situation where storage blocks with severe wear are read / written, which will affect the data read / write performance. Summary of the invention
[0003] In view of this, the present application provides a storage control method, a storage device, and an electronic device, as follows:
[0004] A storage control method, comprising:
[0005] In response to obtaining a read / write operation for a first file, obtaining tag information of the first file;
[0006] Obtaining a degree of wear of a first storage block of a target storage device, where the first storage block is an operation block of the read / write operation;
[0007] Determine a corresponding target read / write strategy based on the tag information and the wear degree, so as to control the target storage device to perform a corresponding read / write operation according to the target read / write strategy;
[0008] The tag information is used to represent access information of the first file.
[0009] In the above method, preferably, obtaining the tag information of the first target file includes:
[0010] The target reference information of the first file is obtained, and the tag information of the first file is obtained based on the target reference information and with a corresponding acquisition strategy, wherein different target reference information corresponds to different acquisition strategies.
[0011] In the above method, preferably, obtaining the tag information of the first file based on the target reference information with a corresponding acquisition strategy includes at least one of the following:
[0012] Obtaining historical access data of the first file, and generating tag information of the first file based on the historical access data;
[0013] Obtaining file information of the first file, and acquiring tag information of the first file based on the file information;
[0014] A target operation acting on the first file is obtained, and tag information of the first file is configured based on the target operation.
[0015] In the above method, preferably, generating the tag information of the first file based on the historical access data includes at least one of the following:
[0016] In a case where it is determined based on the historical access data that the number of times the first file has been accessed in a recent first time period is greater than or equal to a first threshold, determining that the first file has a first label;
[0017] In a case where it is determined based on the historical access data that the access frequency of the first file is greater than or equal to a second threshold, determining that the first file has a first label;
[0018] In a case where it is determined based on the historical access data that the number of times the first file has been accessed in a recent first time period is less than the first threshold, determining that the first file has a second tag;
[0019] When it is determined based on the historical access data that the access frequency of the first file is less than the second threshold, it is determined that the first file has a second label.
[0020] In the above method, preferably, obtaining the tag information of the first file based on the file information includes at least one of the following:
[0021] Determining tag information matching the first file from a target tag library based on the file identification information of the first file;
[0022] configuring tag information of the first file based on access information of the storage block where the first file is located;
[0023] predicting tag information of the first file based on a file generation time of the first file;
[0024] The tag information of the first file is configured based on the status information of the source to which the first file belongs.
[0025] Preferably, the method above, wherein obtaining the degree of wear of the first storage block of the target storage device comprises:
[0026] Determining the first storage block based on a read position or a write position of the first file;
[0027] The wear degree of the first storage block is determined based on historical read / write data of the first storage block.
[0028] The above method, preferably, wherein determining a corresponding target read / write strategy based on the tag information and the wear degree includes:
[0029] Determine a matching result between the first file and the first storage block based on the tag information and the wear degree;
[0030] If the first file matches the first storage block, performing a write operation to write the first file to the first storage block, or performing a read operation to read the first file from the first storage block;
[0031] If the first file does not match the first storage block, write the first file to a second storage block of the target storage device, the wear level of the second storage block matches the first file;
[0032] If the first file does not match the first storage block, an operation of migrating the first file from the first storage block to a third storage block is performed, and a read operation of reading the first file from the third storage block is performed, and the wear level of the third storage block matches the first file.
[0033] The above method preferably further comprises at least one of the following:
[0034] Monitoring label change information of the first file, and performing a migration operation on the first file based on the label change information;
[0035] Monitoring usage information of the target storage device, and configuring read / write configuration parameters of a first storage block in the target storage device based on the usage information.
[0036] A storage device, comprising at least:
[0037] A main control chip and a storage area, wherein the main control chip can perform the following operations:
[0038] In response to obtaining a read / write operation for a first file, obtaining tag information of the first file;
[0039] Obtaining a degree of wear of a first storage block in the storage area, where the first storage block is an operation block for the read / write operation;
[0040] Determine a corresponding target read / write strategy based on the tag information and the wear degree, so as to perform a corresponding read / write operation based on the determined target read / write strategy;
[0041] The tag information is used to represent access information of the first file.
[0042] An electronic device includes a processor and a storage device, wherein the processor is capable of performing the following operations: in response to obtaining a read / write operation for a first file, obtaining tag information of the first file;
[0043] Obtaining a degree of wear of a first storage block in the storage device, where the first storage block is an operation block for the read / write operation;
[0044] Determine a corresponding target read / write strategy based on the tag information and the wear degree, so as to control the storage device to perform a corresponding read / write operation according to the target read / write strategy;
[0045] The tag information is used to represent access information of the first file.
[0046] It can be seen from the above technical solutions that in a storage control method, storage device and electronic device disclosed in the present application, in response to a read / write operation on a file, tag information representing the accessed information of the file and the degree of wear of the storage block to be read / written are obtained, thereby determining a corresponding read / write strategy based on the tag information and the degree of wear of the storage block to control the storage device to perform the corresponding read / write operation. It can be seen that in the present application, the file reading / writing will not be performed directly on the storage block, but when reading / writing the file on the storage block, the corresponding read / write strategy is first determined according to the tag information of the file and the degree of wear of the storage block, and then the reading / writing is performed according to the read / write strategy, so as to avoid the situation where the read / write performance is poor due to the direct reading / writing of the storage block with large wear, thereby improving the data reading / writing performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments 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 work.
[0048] Figure 1 A flowchart of a storage control method provided in an embodiment of the present application;
[0049] Figure 2 This is an architectural diagram of a storage device in an embodiment of the present application;
[0050] Figure 3 A partial flow chart of a storage control method provided in an embodiment of the present application;
[0051] Figure 4 Another partial flow chart of a storage control method provided in an embodiment of the present application;
[0052] Figure 5 Another partial flow chart of a storage control method provided in an embodiment of the present application;
[0053] Figure 6A schematic diagram of the structure of a storage device provided in an embodiment of the present application;
[0054] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0055] Figure 8 This is an example diagram of the balanced use of physical blocks in an SSD applicable to the present application. DETAILED DESCRIPTION
[0056] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0057] refer to Figure 1 As shown, it is a flow chart of implementing a storage control method provided by an embodiment of the present application. The method can be applied to a storage device having a storage block. The storage device can include multiple storage blocks, such as Figure 2 As shown in , the wear degree of different storage blocks may be the same or different. Each storage block can be used to store data. The technical solution in this embodiment is mainly used to improve the read / write performance of data in the storage block.
[0058] Specifically, the method in this embodiment may include the following steps:
[0059] Step 101: In response to obtaining a read / write operation for a first file, obtain tag information of the first file.
[0060] The read / write operation for the first file includes: an operation of reading the first file from the first storage block, or an operation of writing the first file to the first storage block.
[0061] The tag information of the first file is used to represent the access information of the first file. The access information of the first file may include at least one of the following information: the number of times the first file has been accessed, the time of access, and the comments made during access. Specifically, the tag information of the first file may be represented by access attributes, such as the access attributes of a cold file or a hot file. A cold file indicates that the first file will not be accessed frequently, and a hot file indicates that the first file will be accessed frequently.
[0062] For example, in this embodiment, in response to obtaining a read operation for "file 1" in storage block a, such as a read operation of reading "file 1" from storage block a, the tag information of file 1 is obtained as "cold file";
[0063] For another example, in this embodiment, in response to obtaining a write operation for "file 2" to storage block b, such as a write operation of writing "file 2" to storage block b, the tag information of file 2 is obtained as "hot file".
[0064] Step 102: Obtain the wear level of the first storage block of the target storage device.
[0065] The first storage block is an operation block for a read / write operation, such as an operation block for writing a first file, or an operation block for reading a first file.
[0066] It should be noted that the degree of wear of the first storage block represents the read / write performance of the first storage block. For example, the greater the degree of wear of the first storage block, the worse the data read / write performance of the first storage block; the smaller the degree of wear of the first storage block, the better the data read / write performance of the first storage block.
[0067] Specifically, the wear degree of the first storage block can be represented by large or small, high or low, or cold block or hot block. For example, if the first storage block is a hot block, it indicates that the wear degree of the first storage block is small; if the first storage block is a cold block, it indicates that the wear degree of the first storage block is large.
[0068] Step 103: Determine a corresponding target read / write policy based on the tag information and the wear degree, so as to control the target storage device to perform a corresponding read / write operation according to the target read / write policy.
[0069] The target read / write policy may include at least one of a policy of whether to read / write the first file for the first storage block and a policy of whether to migrate the first file.
[0070] It should be noted that the target read / write policy may also include other policies. The read / write operation performed by the target storage device with the target read / write policy may include at least one of: a read operation, a write operation, a read / write operation, a migration operation, and the like.
[0071] For example, the read / write operation may include: reading file 1 from storage block a, writing file 2 to storage block b, migrating file 1 from storage block a to other storage blocks, writing file 2 to other storage blocks, etc.
[0072] It can be seen from the above technical solution that in a storage control method provided by an embodiment of the present application, in response to a read / write operation on a file, tag information representing the accessed information of the file and the degree of wear of the storage block to be read / written are obtained, thereby determining a corresponding read / write strategy based on the tag information and the degree of wear of the storage block to control the storage device to perform the corresponding read / write operation. It can be seen that in this embodiment, the file reading / writing will not be performed directly in the storage block, but the corresponding read / write strategy will be determined according to the tag information of the file and the degree of wear of the storage block, and then the reading / writing will be performed according to the read / write strategy, so as to avoid the situation where the read / write performance is poor due to the direct reading / writing of the storage block with large wear, thereby improving the data reading / writing performance.
[0073] In one implementation, step 103 may be implemented in the following manner: Figure 3 As shown in:
[0074] Step 301: Determine a matching result between a first file and a first storage block based on tag information and a wear degree.
[0075] Among them, if the label information indicates that the first file is a cold file, and the degree of wear of the first storage block is large, then it is determined that the first file matches the first storage block; if the label information indicates that the first file is a cold file, and the degree of wear of the first storage block is small, then it is determined that the first file does not match the first storage block; if the label information indicates that the first file is a hot file, and the degree of wear of the first storage block is large, then it is determined that the first file does not match the first storage block; if the label information indicates that the first file is a hot file, and the degree of wear of the first storage block is small, then it is determined that the first file matches the first storage block.
[0076] Step 302: According to the matching result, determine whether the first file matches the first storage block. If the first file matches the first storage block, execute step 303; if the first file does not match the first storage block, execute step 304.
[0077] Step 303: Execute a write operation to write the first file into the first storage block, or execute a read operation to read the first file from the first storage block.
[0078] For example, if file 1 is a "cold file" and the wear degree of storage block a is large, then file 1 matches storage block a, and file 1 is read from storage block a.
[0079] For another example, if file 2 is a "hot file" and the wear degree of storage block b is small, then file 2 matches storage block b, and file 2 is written to storage block b.
[0080] Step 304: Determine the read / write operation. If the read / write operation is a write operation, execute step 305. If the read / write operation is a read operation, execute step 306.
[0081] Step 305: Write the first file to the second storage block of the target storage device.
[0082] The wear degree of the second storage block matches the first file. For example, if the first file is a cold file, the wear degree of the second storage block is greater than that of the first storage block, and the second storage block with a greater wear degree is a cold block; if the first file is a hot file, the wear degree of the second storage block is less than that of the first storage block, and the second storage block with a lesser wear degree is a hot block.
[0083] For example, if file 2 is a "hot file" and the degree of wear of storage block b is large, then file 2 does not match storage block b. At this time, file 2 is written to storage block c. The degree of wear of storage block c is small. Storage block c with a small degree of wear matches file 2, which is a "hot file". This can avoid further wear of storage block b and ensure the read / write performance of storage block b. At the same time, file 2 can be stored in storage block c with a small degree of wear, thereby improving the read / write performance of file 2.
[0084] Step 306: Execute an operation of migrating the first file from the first storage block to the third storage block, and execute a read operation of reading the first file from the third storage block.
[0085] The wear degree of the third storage block matches the first file. For example, if the first file is a cold file, the wear degree of the third storage block is greater than that of the first storage block, and the third storage block with a greater wear degree is a cold block; if the first file is a hot file, the wear degree of the third storage block is less than that of the first storage block, and the third storage block with a lesser wear degree is a hot block.
[0086] For example, if file 1 is a "cold file" and the degree of wear of storage block a is small, then file 1 does not match storage block a. At this time, file 1 in storage block a is first migrated to storage block d, and then file 1 is read from storage block d. Storage block d has a large degree of wear, and storage block d with a large degree of wear matches file 1, which is a "cold file". This can prevent the cold file from continuing to occupy the storage space of storage block a, making it easier for other hot files to be stored in storage block a.
[0087] For another example, if file 1 is a "hot file" and storage block a has a large degree of wear, then file 1 does not match storage block a. At this time, file 1 in storage block a is first migrated to storage block e, and then file 1 is read from storage block e. Storage block e has a small degree of wear, and storage block e with a small degree of wear matches file 1 of the "hot file". This can avoid further wear of storage block a and ensure the read / write performance of storage block a. At the same time, file 1 can be stored in storage block e with a small degree of wear, thereby improving the read / write performance of file 1.
[0088] In one implementation, when obtaining the tag information of the first target file in step 101, it can be implemented in the following manner: Figure 4 As shown in:
[0089] Step 401: Obtain target reference information of a first file.
[0090] Among them, the target reference information of the first file may include at least one of the storage location of the first file such as storage path, generation time of the first file, source information of the first file such as application or device information, file name of the first file, file type of the first file, etc.
[0091] Step 402: Based on the target reference information, obtain the tag information of the first file using a corresponding acquisition strategy.
[0092] Different target reference information corresponds to different acquisition strategies. For example, the acquisition strategy may include at least one of: a strategy based on historical access data, a strategy based on a machine learning model, a strategy based on a file type, a strategy based on a target operation (an operation of manually setting tag information), etc.
[0093] Specifically, in step 402, the target reference information may be parsed first, and then a corresponding acquisition strategy may be determined, and then the tag information of the first file may be obtained according to the determined acquisition strategy.
[0094] In one implementation, in step 402, historical access data of the first file may be obtained first, and then tag information of the first file may be generated based on the historical access data.
[0095] The historical access data may include: historical access data in a storage device such as a hard disk where the first file is located; historical access data in a cloud where the first file is located; and historical access data in other devices where the first file is located.
[0096] For example, in step 402, when it is determined based on the historical access data that the number of accesses to the first file in the most recent first period is greater than or equal to the first threshold, it is determined that the first file has a first label. The first label indicates that the first file is a hot file. When it is determined based on the historical access data that the number of accesses to the first file in the most recent first period is less than the first threshold, it is determined that the first file has a second label, and the second label indicates that the first file is a cold file.
[0097] The first threshold value can be set according to the demand, such as being accessed 20 times in the last week. The historical access data can be obtained by the file system, and the file system monitors the first file in real time to obtain the number of times the first file is accessed in the most recent first time period, such as within a week. If the number of times the first file is accessed in the most recent first time period, such as within the most recent week, is greater than or equal to the first threshold value, such as 20 times, then the first file can be determined to be a first-labeled, i.e., a hot file. If the number of times the first file is accessed in the most recent first time period is less than the first threshold value, then the first file can be determined to be a second-labeled, i.e., a cold file.
[0098] For another example, in step 402, when it is determined based on the historical access data that the access frequency of the first file is greater than or equal to the second threshold, it is determined that the first file has a first label. The first label indicates that the first file is a hot file. When it is determined based on the historical access data that the access frequency of the first file is less than the second threshold, it is determined that the first file has a second label, and the second label indicates that the first file is a cold file.
[0099] The second threshold value can be set according to the demand, such as an access frequency of 10 times a day or an access frequency of 5 times a day. The historical access data can be obtained by the file system, and the file system monitors the first file in real time to obtain the access frequency of the first file. If the access frequency of the first file is greater than or equal to the second threshold value, such as an access frequency of 10 times a day, then the first file can be determined to be a first label, i.e., a hot file. If the access frequency of the first file is less than the second threshold value, then the first file can be determined to be a second label, i.e., a cold file.
[0100] For another example, in step 402, a machine learning model such as a classification model can be used to process the access frequency and the most recent access time of the first file in the historical access data to obtain label information of the first file output by the machine learning model.
[0101] Among them, the machine learning model here, such as the classification model, can be trained using the first training sample, the first training sample uses at least one of the historical access frequency and the historical most recent access time of the sample file as the input sample, and uses the first label or the second label corresponding to the input sample as the output sample.
[0102] It should be noted that if the first file is a newly created file, the file system cannot obtain the historical access data of the first file. At this time, the associated file corresponding to the first file can be determined first, and the associated file is associated with the first file regarding at least one associated feature such as file name, file content, file type, etc., and then the historical access data of the associated file is used as the historical access data of the first file.
[0103] In another implementation, in step 402, the file information of the first file may be obtained first, and then the tag information of the first file may be obtained based on the file information.
[0104] The file information of the first file may include: source information of the first file, generation time of the first file, file name of the first file, storage path of the first file, etc. The source of the first file may be an application or a device, and accordingly, the source information of the first file may include: activity of the application (frequency of use of the application), communication activity (frequency of communication) between the storage device and the source device of the first file, and other information.
[0105] For example, in step 402, tag information matching the first file may be determined from the target tag library based on the file identification information of the first file in the file information, such as the file name or the file type.
[0106] Among them, the target tag library contains the mapping relationship between file identification information such as file name or file type and tag information. For example, the access frequency of video type files is lower than that of picture type files, and the access frequency of picture type files is lower than that of text type files. Based on this, frequency type files are mapped to the tag information of cold files, and picture type files and text type files are mapped to the tag information of hot files. Based on this, in this embodiment, the corresponding mapping relationship is searched in the target tag library according to the file identification information of the first file, and then the tag information in the found mapping relationship is used as the tag information of the first file.
[0107] For another example, in step 402, when the first file needs to be written into the first storage block, the tag information of the first file may be configured based on the access information of the storage block where the first file is located in the file information.
[0108] Among them, the access information of the storage block where the first file is located may include: the access frequency of the storage block where the first file is located. Based on this, in this embodiment, when the access frequency of the storage block where the first file is located is greater than or equal to the third threshold, it can be determined that the storage block where the first file is located is a storage block with a large degree of wear, that is, a cold block. At this time, the first file can be configured as a cold file with the first label; if the access frequency of the storage block where the first file is located is less than the third threshold, it can be determined that the storage block where the first file is located is a storage block with a small degree of wear, that is, a hot block. At this time, the first file can be configured as a hot file with the second label.
[0109] The third threshold here can be set according to requirements.
[0110] For another example, in step 402, the tag information of the first file may be predicted based on the file generation time of the first file.
[0111] The file generation time of the first file can be obtained from the file system. If the file generation time of the first file represents that the time length when the first file is generated is greater than or equal to the fourth threshold, then it can be determined that the first file is a file created too early, and at this time, it can be predicted that the first file is a second label, i.e., a cold file; if the file generation time of the first file represents that the time length when the first file is generated is less than the fourth threshold, then it can be determined that the first file is a file created recently, and at this time, it can be predicted that the first file is a first label, i.e., a hot file.
[0112] Alternatively, if the first file is characterized as a newly created file at the file generation time of the first file, then in this embodiment, a machine learning model such as a prediction model can be used to process the file name, file type, file content, etc. of the first file to obtain label information of the first file output by the machine learning model.
[0113] The machine learning model here, such as the prediction model, can be trained using the second training sample. The second training sample uses at least one of the file name, file type, and file content of the sample file as an input sample, and uses the first label or the second label corresponding to the input sample as an output sample.
[0114] The fourth threshold can be set according to requirements.
[0115] For another example, in step 402, tag information of the first file may be configured based on status information of a source to which the first file belongs.
[0116] The state information of the source to which the first file belongs may include: application activity information of the application of the source to which the first file belongs, or historical communication status between the device of the source to which the first file belongs and the target storage device, such as communication activity (communication frequency) and other information. Based on this, in this embodiment, when the application activity is greater than or equal to the fifth threshold or the communication activity is greater than or equal to the sixth threshold, the first file can be determined as a first label, i.e., a hot file; if the application activity is less than the fifth threshold or the communication activity is less than the sixth threshold, the first file can be determined as a second label, i.e., a cold file.
[0117] The fifth threshold and the sixth threshold can be set according to requirements.
[0118] In another implementation, in step 402, a target operation acting on the first file may be obtained first, and tag information of the first file may be configured based on the target operation.
[0119] The target operation may be a configuration operation of a user configuring a label for the first file. For example, the user sets the first file as a first label or a second label through an interactive interface to indicate that the first file is a hot file or a cold file.
[0120] In one implementation, when obtaining the wear degree of the first storage block of the target storage device in step 102, it can be implemented in the following manner: Figure 5 As shown in:
[0121] Step 501: Determine a first storage block based on a read position or a write position of a first file.
[0122] Among them, in this embodiment, the read position or write position of the first file can be compared with the address range of each storage block in the target storage device to obtain the storage block where the read position of the first file is located, or the storage block where the write position is located, that is, the first storage block.
[0123] Step 502: Determine the wear level of the first storage block based on the historical read / write data of the first storage block.
[0124] The historical read / write data of the first storage block may include: the number of read / writes, the number of erases, at least one wear parameter, etc. of the first storage block. The wear parameter is a hardware parameter of the first storage block. The historical read / write data can use the firmware program deployed in the target storage device to read the read / write monitoring data of the first storage block from the interface of the disk controller of the target storage device to obtain the number of read / writes, the number of erases, the wear parameter, etc. in the historical read / write data. Based on this, in this embodiment, the historical read / write data can be processed to obtain the degree of wear of the first storage block.
[0125] For example, in step 502, the number of writes (or read / writes) of all storage areas in the target storage device may first be averaged, and then it may be determined whether the number of writes of the first storage block is greater than or equal to the average value. If the number of writes of the first storage block is greater than or equal to the average value, then it may be determined that the degree of wear of the first storage block is large, i.e., it is a cold block. If the number of writes of the first storage block is less than the average value, then it may be determined that the degree of wear of the first storage block is small, i.e., it is a hot block.
[0126] For another example, in step 502, a clustering algorithm can be used to cluster all storage blocks in the target storage device according to the number of writes and wear parameters of all storage blocks in the target storage device, so as to cluster a first set consisting of storage blocks with a large degree of wear and a second set consisting of storage blocks with a small degree of wear. If the first storage block is in the first set, then the first storage block has a large degree of wear, that is, a cold block; if the first storage block is in the second set, then the first storage block has a small degree of wear, that is, a hot block.
[0127] For another example, in step 502, a machine learning model such as a classification model may be used to process the number of writes and wear parameters of the first storage block to obtain the degree of wear of the first storage block.
[0128] Among them, the machine learning model here, such as the classification model, can be trained using the third training sample. The third training sample uses at least one of the number of writes and wear parameters of the sample storage block as the input sample, and the wear degree corresponding to the input sample as the output sample.
[0129] In an implementation manner, this embodiment may also monitor label change information of the first file, and then perform a migration operation on the first file based on the label change information.
[0130] For example, in this embodiment, it is possible to continuously monitor whether the label information of the first file has changed. If the label information of the first file has changed, the matching result between the first file and the storage block where the first file is located is determined based on the changed label information of the first file and the degree of wear of the storage block where the first file is located. If there is a mismatch between the first file and the storage block where the first file is located, a migration operation can be performed on the first file.
[0131] Specifically, in this embodiment, a fourth storage block matching the first file may be selected in the target storage device, and then the first file may be migrated to the fourth storage block, and the wear degree of the fourth storage block may match the label information of the first file after the change.
[0132] For example, if file 3 changes from a cold file to a hot file, then the degree of wear of the storage block f where file 3 is located is determined. The degree of wear of the storage block f where file 3 is located will only become greater. At this time, file 3 does not match the storage block f. At this time, file 3 is migrated to storage block j. The degree of wear of storage block j is small. The storage block j with a small degree of wear matches the hot file 3.
[0133] For example, if file 4 changes from a hot file to a cold file, the wear degree of storage block h where file 4 is located is determined, and the wear degree of storage block h where file 4 is located may still be small. At this time, file 4 does not match storage block h. At this time, file 4 is migrated to storage block k. Storage block k has a large wear degree, and storage block k with a large wear degree matches cold file 4. The wear degree of storage block h where file 4 is located may also increase (because file 4 is frequently accessed, resulting in frequent reading / writing of storage block h, resulting in increased wear degree). At this time, file 4 still matches storage block h, and file 4 does not need to be migrated at this time.
[0134] In one implementation, the present embodiment may also monitor usage information of the target storage device, and configure the read / write configuration parameters of the first storage block in the target storage device based on the usage information.
[0135] The read / write configuration parameter of the first storage block represents the wear degree of the first storage block, that is, the wear degree of the first storage block, ie, the cold block or the hot block, is written into the read / write configuration parameter.
[0136] Based on this, in this embodiment, the wear degree of each storage block in the target storage device is dynamically updated, and the read / write operation of the target storage device on each storage block is controlled accordingly to ensure the service life and performance optimization of the target storage device.
[0137] In a specific implementation, the usage information of the target storage device includes information such as the number of writes and wear parameters of each storage block.
[0138] In one implementation, in this embodiment, the number of writes (or read / writes) of all storage areas in the target storage device can be first averaged, and then it can be determined whether the number of writes of each storage block is greater than or equal to the average value. If the number of writes of the storage block is greater than or equal to the average value, then the read / write configuration parameters of the storage block can be configured to have a large degree of wear, that is, a cold block; if the number of writes of the storage block is less than the average value, then the read / write configuration parameters of the storage block can be configured to have a small degree of wear, that is, a hot block.
[0139] In another implementation, a clustering algorithm is used in this embodiment to cluster all storage blocks in the target storage device according to the number of writes and wear parameters of all storage blocks respectively, so as to cluster a first set consisting of storage blocks with a large degree of wear and a second set consisting of storage blocks with a small degree of wear. Thus, the read / write configuration parameters of the storage blocks in the first set are set to those with a large degree of wear, i.e., cold blocks, and the read / write configuration parameters of the storage blocks in the second set are set to those with a small degree of wear, i.e., hot blocks.
[0140] In another implementation, in this embodiment, a machine learning model such as a classification model can be used to process the number of writes and wear parameters of each storage block in the target storage device to obtain the degree of wear of each storage block, and set the read / write configuration parameters of each storage block according to the degree of wear to a cold block with a large degree of wear or a hot block with a small degree of wear.
[0141] In another implementation, in this embodiment, after obtaining the degree value characterizing the degree of wear of each storage block in the target storage device, the storage blocks are sorted according to the degree value, and the read / write configuration parameters of the storage blocks in the top 50% of the degree value are set to the blocks with the largest degree of wear, i.e., cold blocks, and the read / write configuration parameters of the storage blocks in the bottom 50% of the degree value are set to the blocks with the smallest degree of wear, i.e., hot blocks.
[0142] refer to Figure 6 , is a schematic diagram of the structure of a storage device provided in an embodiment of the present application. The storage device, such as the target storage device mentioned above, may at least include the following structures:
[0143] Storage area 601 and main control chip 602; wherein the main control chip 602 can perform the following operations:
[0144] In response to obtaining a read / write operation for a first file, obtaining tag information of the first file; obtaining a degree of wear of a first storage block 611 in the storage area 601, the first storage block 611 being an operation block of the read / write operation; determining a corresponding target read / write strategy based on the tag information and the degree of wear, and performing a corresponding read / write operation based on the determined target read / write strategy;
[0145] The tag information is used to represent access information of the first file.
[0146] It can be seen from the above technical solution that in a storage device provided by an embodiment of the present application, in response to a read / write operation on a file, tag information representing the accessed information of the file and the degree of wear of the storage block to be read / written are obtained, thereby determining a corresponding read / write strategy based on the tag information and the degree of wear of the storage block to control the storage device to perform the corresponding read / write operation. It can be seen that in this embodiment, the file reading / writing will not be performed directly on the storage block, but when reading / writing the file on the storage block, the corresponding read / write strategy is first determined according to the tag information of the file and the degree of wear of the storage block, and then the reading / writing is performed according to the read / write strategy, so as to avoid the situation where the read / write performance is poor due to the direct reading / writing of the storage block with large wear, thereby improving the data reading / writing performance.
[0147] In one implementation, when the main control chip 602 obtains the tag information of the first target file, it is specifically used to: obtain the target reference information of the first file, and obtain the tag information of the first file based on the target reference information with a corresponding acquisition strategy, wherein different target reference information corresponds to different acquisition strategies.
[0148] In one implementation, when the main control chip 602 obtains the tag information of the first file based on the target reference information with a corresponding acquisition strategy, it can be implemented by at least one of the following:
[0149] Obtaining historical access data of the first file, and generating tag information of the first file based on the historical access data;
[0150] Obtaining file information of the first file, and acquiring tag information of the first file based on the file information;
[0151] A target operation acting on the first file is obtained, and tag information of the first file is configured based on the target operation.
[0152] In one implementation, the main control chip 602 may generate the tag information of the first file based on the historical access data by at least one of the following:
[0153] In a case where it is determined based on the historical access data that the number of times the first file has been accessed in a recent first time period is greater than or equal to a first threshold, determining that the first file has a first label;
[0154] In a case where it is determined based on the historical access data that the access frequency of the first file is greater than or equal to a second threshold, determining that the first file has a first label;
[0155] In a case where it is determined based on the historical access data that the number of times the first file has been accessed in a recent first time period is less than the first threshold, determining that the first file has a second tag;
[0156] When it is determined based on the historical access data that the access frequency of the first file is less than the second threshold, it is determined that the first file has a second label.
[0157] In one implementation, the main control chip 602 may obtain the tag information of the first file based on the file information by at least one of the following:
[0158] Determining tag information matching the first file from a target tag library based on the file identification information of the first file;
[0159] configuring tag information of the first file based on access information of the storage block where the first file is located;
[0160] predicting tag information of the first file based on a file generation time of the first file;
[0161] The tag information of the first file is configured based on the status information of the source to which the first file belongs.
[0162] In one implementation, when obtaining the wear degree of the first storage block of the target storage device, the main control chip 602 is specifically used to: determine the first storage block based on the read position or write position of the first file; determine the wear degree of the first storage block based on the historical read / write data of the first storage block.
[0163] In one implementation, when the main control chip 602 determines the corresponding target read / write strategy based on the tag information and the wear degree, it is specifically used to:
[0164] Determine a matching result between the first file and the first storage block based on the tag information and the wear degree;
[0165] If the first file matches the first storage block, performing a write operation to write the first file to the first storage block, or performing a read operation to read the first file from the first storage block;
[0166] If the first file does not match the first storage block, write the first file to a second storage block of the target storage device, the wear level of the second storage block matches the first file;
[0167] If the first file does not match the first storage block, an operation of migrating the first file from the first storage block to a third storage block is performed, and a read operation of reading the first file from the third storage block is performed, and the wear level of the third storage block matches the first file.
[0168] In one implementation, the main control chip 602 is further configured to implement at least one of the following:
[0169] Monitoring label change information of the first file, and performing a migration operation on the first file based on the label change information;
[0170] Monitoring usage information of the target storage device, and configuring read / write configuration parameters of a first storage block in the target storage device based on the usage information.
[0171] It should be noted that the specific implementation of the main control chip 602 can refer to the corresponding content in the previous text and will not be described in detail here.
[0172] refer to Figure 7 , is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application, the electronic device may include a storage device 701 and a processor 702, and the electronic device may also include other structures, such as a processor, a communication module, etc.;
[0173] The structure of the storage device 701 is as follows: Figure 6 The processor 702 can perform the following operations:
[0174] In response to obtaining a read / write operation for a first file, obtaining tag information of the first file; obtaining a degree of wear of a first storage block in the storage device 701, the first storage block being an operation block of the read / write operation; determining a corresponding target read / write strategy based on the tag information and the degree of wear, so as to control the storage device to perform the corresponding read / write operation with the target read / write strategy;
[0175] The tag information is used to represent access information of the first file.
[0176] It can be seen from the above technical solution that in an electronic device provided by an embodiment of the present application, in response to a read / write operation on a file, tag information representing the accessed information of the file and the degree of wear of the storage block to be read / written are obtained, thereby determining a corresponding read / write strategy based on the tag information and the degree of wear of the storage block to control the storage device to perform the corresponding read / write operation. It can be seen that in this embodiment, the file reading / writing will not be performed directly on the storage block, but when reading / writing the file on the storage block, the corresponding read / write strategy is first determined according to the tag information of the file and the degree of wear of the storage block, and then the reading / writing is performed according to the read / write strategy, so as to avoid the situation where the read / write performance is poor due to the direct reading / writing of the storage block with large wear, thereby improving the data reading / writing performance.
[0177] Taking the storage device as a solid state disk SSD (Solid State Disk or Solid State Drive) as an example, the technical solution of the present application is illustrated below:
[0178] This application proposes a method for extending the service life of SSD based on a dynamic algorithm, which combines the hot and cold states of files and the degree of wear of physical blocks (i.e., storage blocks mentioned above) to dynamically divide the files to optimize write performance and balance wear. The key points include:
[0179] 1. File hot and cold classification: monitor the access frequency and last access time of files in real time, and dynamically classify files into hot files and cold files.
[0180] 2. Wear monitoring and evaluation: The firmware layer monitors the number of writes and wear of each physical block in real time, and dynamically updates the wear status of the physical block.
[0181] 3. Dynamic area division: Dynamically adjust the size and position of hot and cold areas according to the hot and cold status of the file and the degree of wear of the physical block.
[0182] (1) Cold area: select physical blocks with higher wear (i.e., larger) to store cold files, reduce write operations, and prevent further wear of these blocks.
[0183] (2) Hot zone: select physical blocks with less wear (i.e., smaller size) to store hot files, use these blocks evenly, and optimize write performance.
[0184] 4. Data migration strategy: Regularly evaluate the hot and cold status of files and the wear of physical blocks, perform necessary data migration, and ensure that hot and cold files are stored in appropriate areas.
[0185] The advantages of adopting the solution of this application are as follows:
[0186] 1. Reduce write amplification effect: By dynamically dividing the hot and cold physical blocks and the hot and cold classification of files, the impact of frequent writing of hot files on cold blocks is reduced, thereby reducing the write amplification effect.
[0187] 2. Wear balance: Dynamically adjust the storage area according to the degree of wear, evenly use physical blocks, and extend the service life of the SSD.
[0188] 3. Performance optimization: Reasonable division of hot blocks and cold blocks to improve overall write performance.
[0189] The technical solution of this application is described in detail below:
[0190] 1. File access monitoring:
[0191] 1) The file system monitors the access frequency and last access time of files in real time.
[0192] 2) Based on access monitoring data, dynamically classify files into hot files and cold files.
[0193] 2. Wear monitoring and evaluation:
[0194] 1) The firmware layer (i.e., the firmware program mentioned above) monitors and records the number of writes and wear of each physical block in real time.
[0195] 2) Dynamically update the wear status of the physical block to ensure the real-time and accuracy of the wear status.
[0196] 3. Dynamic block division:
[0197] 1) Dynamically adjust the size and position of hot blocks and cold blocks according to the hot and cold status of the file and the degree of wear of the physical blocks.
[0198] 2) Cold blocks: Select physical blocks with higher wear levels to store cold files and reduce write operations on these blocks.
[0199] 3) Hot Zone: Select physical blocks with lower wear levels to store hot files, use these blocks evenly, and optimize write performance, such as Figure 8 as shown in .
[0200] 4. Data migration strategy:
[0201] 1) Regularly evaluate the hot and cold status of files and the wear of physical blocks, and perform necessary data migration.
[0202] 2) When a hot file becomes a cold file, it is migrated from the hot block to the cold block.
[0203] 3) When a cold file becomes a hot file, it is migrated from the cold block to the hot block.
[0204] The specific implementation steps are as follows:
[0205] 1. Changes to the file system layer:
[0206] 1) Implement a file access monitoring module to record the access frequency and last access time of files.
[0207] 2) Implement a hot and cold file classification module to dynamically classify files into hot files and cold files based on access monitoring data.
[0208] 2. Firmware layer changes:
[0209] 1) Implement a wear monitoring module to monitor and record the number of writes and wear conditions of each physical block in real time.
[0210] 2) Implement a dynamic area division module to dynamically adjust the size and position of hot and cold areas according to the hot and cold status and wear of the file.
[0211] 3. Data migration strategy:
[0212] 1) Regularly execute data migration strategies to migrate files between hot blocks and cold blocks to ensure that data is stored in the appropriate area.
[0213] 2) Design and implement algorithms to minimize write amplification effects during the migration process and ensure optimal system performance.
[0214] Here is how the hot and cold blocks are calculated:
[0215] In order to implement the SSD wear leveling strategy based on the dynamic algorithm, in this embodiment, the hot blocks and cold blocks can be dynamically divided by formula calculation to ensure the service life and performance optimization of the SSD. For example, in this embodiment, the physical blocks of the SSD can be sorted according to the degree of wear, and then divided into hot blocks and cold blocks according to a 50% ratio.
[0216] For example, the following is the formula definition in this embodiment:
[0217] Total number of blocks N: The total number of all physical blocks in the SSD.
[0218] The number of times a block is written W i : Number of writes to the ith physical block.
[0219] Average number of writes The average number of writes to all physical blocks.
[0220] Hot zone threshold Thot and cold zone threshold Tcold: the write count thresholds used to distinguish hot blocks and cold blocks.
[0221] Step 1: As shown in formula (1), it is used to calculate the average number of writes, that is, the average value in the previous text:
[0222] Calculate the average number of writes:
[0223]
[0224] Step 2: Set the threshold: The ratio of 50% sets the threshold for hot blocks and cold blocks.
[0225] Hot blocks: Select blocks whose wear level is lower than the average number of writes, as shown in formula (2).
[0226] Cold blocks: Select blocks with a wear level higher than the average number of writes, as shown in formula (3).
[0227] Step 3: Dynamically adjust hot blocks and cold blocks: Dynamically adjust the thresholds based on the number of writes monitored in real time.
[0228] Hot block = {i|Wi≤Thot} (2)
[0229] Cold block = {iWi>Tcold} (3)
[0230] Through the above steps, SSD optimization technology based on dynamic algorithms can be implemented to reduce write amplification effect, balance wear, optimize write performance, and extend the service life of the SSD.
[0231] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0232] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0233] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0234] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A storage control method, comprising: In response to obtaining a read / write operation for a first file, obtaining tag information of the first file; Obtaining a degree of wear of a first storage block of a target storage device, where the first storage block is an operation block of the read / write operation; Determine a corresponding target read / write strategy based on the tag information and the wear degree to control the target storage device to perform a corresponding read / write operation according to the target read / write strategy; The tag information is used to represent access information of the first file.
2. The method according to claim 1, wherein: Get the tag information of the first target file, including: Target reference information of the first file is obtained, and tag information of the first file is obtained based on the target reference information using a corresponding acquisition strategy, wherein different reference information corresponds to different acquisition strategies.
3. The method according to claim 2, wherein: Obtaining the tag information of the first file based on the target reference information using a corresponding acquisition strategy includes at least one of the following: Obtaining historical access data of the first file, and generating tag information of the first file based on the historical access data; Obtaining file information of the first file, and acquiring tag information of the first file based on the file information; A target operation acting on the first file is obtained, and tag information of the first file is configured based on the target operation.
4. The method according to claim 3, wherein: Generating the tag information of the first file based on the historical access data includes at least one of the following: In a case where it is determined based on the historical access data that the number of times the first file has been accessed in a recent first time period is greater than or equal to a first threshold, determining that the first file has a first label; In a case where it is determined based on the historical access data that the access frequency of the first file is greater than or equal to a second threshold, determining that the first file has a first label; In a case where it is determined based on the historical access data that the number of times the first file has been accessed in a recent first time period is less than the first threshold, determining that the first file has a second tag; When it is determined based on the historical access data that the access frequency of the first file is less than the second threshold, it is determined that the first file has a second label.
5. The method according to claim 3, wherein: Acquiring the tag information of the first file based on the file information includes at least one of the following: Determining tag information matching the first file from a target tag library based on the file identification information of the first file; configuring tag information of the first file based on access information of the storage block where the first file is located; predicting tag information of the first file based on a file generation time of the first file; The tag information of the first file is configured based on the status information of the source to which the first file belongs.
6. The method according to claim 1, wherein: Obtaining the wear level of the first storage block of the target storage device includes: Determining the first storage block based on a read position or a write position of the first file; The wear degree of the first storage block is determined based on historical read / write data of the first storage block.
7. The method according to claim 1, wherein: Determining a corresponding target read / write strategy based on the tag information and the wear degree includes: Determine a matching result between the first file and the first storage block based on the tag information and the wear degree; If the first file matches the first storage block, performing a write operation to write the first file to the first storage block, or performing a read operation to read the first file from the first storage block; If the first file does not match the first storage block, write the first file to a second storage block of the target storage device, the wear level of the second storage block matches the first file; If the first file does not match the first storage block, an operation of migrating the first file from the first storage block to a third storage block is performed, and a read operation of reading the first file from the third storage block is performed, and the wear level of the third storage block matches the first file.
8. The method according to claim 1 or 7, further comprising at least one of the following: Monitoring label change information of the first file, and performing a migration operation on the first file based on the label change information; Monitoring usage information of the target storage device, and configuring read / write configuration parameters of a first storage block in the target storage device based on the usage information.
9. A storage device, comprising at least a main control chip and a storage area, wherein: The main control chip can perform the following operations: In response to obtaining a read / write operation for a first file, obtaining tag information of the first file; Obtaining a degree of wear of a first storage block in the storage area, where the first storage block is an operation block for the read / write operation; Determine a corresponding target read / write strategy based on the tag information and the wear degree, so as to perform a corresponding read / write operation based on the determined target read / write strategy; The tag information is used to represent access information of the first file.
10. An electronic device, comprising a processor and a storage device, wherein the processor is capable of performing the following operations: In response to obtaining a read / write operation for a first file, obtaining tag information of the first file; Obtaining a degree of wear of a first storage block in the storage device, where the first storage block is an operation block for the read / write operation; Determine a corresponding target read / write strategy based on the tag information and the wear degree, so as to control the storage device to perform a corresponding read / write operation according to the target read / write strategy; in, The tag information is used to represent access information of the first file.
Citation Information
Patent Citations
Solid state disk wear balancing method and device and computer readable storage medium
CN111124305A
Storage optimization method and device of solid state disk, computer equipment and storage medium
CN116974491A
Adaptive Wear Leveling Using Multiple Partitions
US20210165576A1