A Filecoin scenario adaptation method and system based on attached storage
Through classified storage and log append recording technology for files in Filecoin scenarios, the efficiency and reliability problems of hard drives in large-scale data storage are solved, and efficient file management and data recovery are achieved.
Patent Information
- Application Number
- CN202410776690.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-17
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2044-06-17
AI Technical Summary
In existing Filecoin scenarios, hard drives have problems such as read and write amplification, low storage resource utilization, low data access efficiency, and insufficient data integrity and reliability when dealing with large-scale data storage.
By classifying files into large files and small files, using different storage methods, using parallel reading and writing and LSM tree management technology, combined with file importance and device environment information to determine whether to perform additional logging, and regularly triggering the garbage collection mechanism to ensure Data integrity and efficiency.
It improves file reading and writing efficiency and resource utilization, guarantees the integrity and reliability of file data, and can effectively restore data especially in the event of hardware failure or crash.
Smart Images

Figure CN118349532B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of scene adaptation technology, and in particular to a Filecoin scene adaptation method and system based on additional storage. Background Art
[0002] IPFS (Inter-Planetary-File-System) is a network transmission protocol designed to create persistent and distributed storage and sharing of files. The Filecoin system is a decentralized distributed storage project based on IPFS. The underlying blockchain technology of the Filecoin system relies on distributed storage for data storage. Users who maintain Filecoin nodes and provide storage functions on the public blockchain will be rewarded with tokens by the public blockchain. Therefore, the faster the file is written and read, the greater the probability that the user will be rewarded. Conversely, if the file cannot read the data in time or the data is lost, the user will not be able to obtain the reward and may even have to deduct a certain amount of tokens.
[0003] The existing Filecoin scenario mainly relies on hard disk drives (HDDs) for data storage and stores all files in a unified manner, which has the following defects:
[0004] 1. Mixed storage of large and small files can easily lead to disk read and write amplification, which refers to a large number of irrelevant data read and write operations in order to read and write small blocks of data, further reducing the read and write efficiency of files in the Filecoin scenario. Hard drives have poor performance in handling random writes, especially when storing small files, which will increase write latency and reduce the overall storage performance of hard drives in the Filecoin scenario.
[0005] 2. When faced with large-scale data storage needs, a single storage mode cannot effectively utilize the advantages of multiple disks, resulting in low storage resource utilization. In addition, in large-scale storage systems, when data needs to be frequently accessed or verified, data access efficiency will be reduced.
[0006] 3. When hardware failure occurs or data recovery is required, the adaptation system may be inadequate in handling data integrity and reliability, resulting in file data loss or damage.
[0007] Based on this, this paper proposes a Filecoin scenario adaptation method and system based on additional storage. After classifying files into large files and small files, large files and small files are stored in different ways. When it is determined that log appending records are needed for files, file modification information is recorded in the form of log appending records. This not only effectively improves file reading and writing efficiency and resource utilization, but also effectively ensures the integrity of file data. Summary of the invention
[0008] The purpose of the present invention is to provide a Filecoin scenario adaptation method and system based on additional storage to address the deficiencies in the background technology.
[0009] In order to achieve the above object, the present invention provides the following technical solution: a Filecoin scenario adaptation method based on additional storage, the adaptation method comprising the following steps:
[0010] When the adaptation system receives several files, it divides the files into large file sets or small file sets based on the threshold comparison method, and segments each file in the large file set into chunk stripes according to the predetermined size. Each stripe is stored in different HDD disks for parallel read and write operations. Multiple files in the small file set are aggregated into a total file, which is managed through the LSM tree, and the random write of the total file is converted into sequential append write;
[0011] When a file modification operation occurs, the adaptation system determines whether it is necessary to perform an additional log recording in combination with the file importance information and the device computing environment information. The file importance information includes the percentage of modified content and the importance assignment. The device computing environment information includes the real-time load. The percentage of modified content, the importance assignment and the real-time load are comprehensively calculated to generate a record index. If the record index is greater than or equal to the index threshold, it is determined that the file modification needs to be recorded in an additional log. If the record index is less than the index threshold, it is determined that the file modification does not need to be recorded in an additional log. If it is determined that an additional log recording is required, the file modification is recorded in the BLOB attached storage management unit in an additional log manner, and a new log entry is generated for each write operation.
[0012] The garbage collection mechanism is triggered regularly to integrate the modified data in the log and clean up historical log entries. If the Filecoin system crashes during the file modification process, the data status is rebuilt based on the integrated log entries.
[0013] In a preferred embodiment, the file importance information includes the modified content ratio and the importance value, and the device computing environment information includes the real-time load. The adaptation system calculates the modified content ratio, the importance value and the real-time load to generate a record index. The function expression is:
[0014] In the formula, To record the index, To modify the content ratio, Assign importance values, Indicates the number of historical transactions using the file in the Filecoin system. Indicates the file The transaction importance score when used in transactions, For real-time load, , are the importance assignment and the proportional coefficient of real-time load respectively, and .
[0015] In a preferred embodiment, the adaptation system obtains the real-time load of the device once when receiving the file modification operation, obtains multiple device loads at the same time interval within a period of time before the real-time load acquisition time point, renames the real-time load of the device and the multiple device loads as load values, calculates the average load and load standard deviation of the device in combination with the multiple load values, and predicts the change trend of the device load through the average load and load standard deviation;
[0016] If the average load of the device is less than the load threshold, and the load standard deviation is less than or equal to the standard deviation threshold, it is predicted that the device load will change towards a low load trend in the future, and the change speed will be fast;
[0017] If the average load of the device is less than the load threshold, and the load standard deviation is greater than the standard deviation threshold, it is predicted that the device load will change towards a low load trend in the future, and the change speed will be moderate;
[0018] If the average load of the device is greater than the load threshold, and the load standard deviation is greater than the standard deviation threshold, it is predicted that the device load will change towards a high load trend in the future, and the change speed will be moderate;
[0019] If the average load of the device is greater than the load threshold, and the load standard deviation is less than or equal to the standard deviation threshold, it is predicted that the device load will change towards a high load trend in the future, and the change speed will be fast;
[0020] If the average load of the device is equal to the load threshold, it is predicted that the device load will not change in the future, and the index threshold is dynamically adjusted based on the prediction result.
[0021] In a preferred embodiment, if the Filecoin system crashes during the file modification process, the data state is rebuilt based on the integrated log entries, including the following steps:
[0022] Trigger garbage collection based on time intervals. When the log file reaches a predetermined size, trigger garbage collection. Read all entries in the current log file, integrate all modification operations based on file identifiers and offsets, and merge modification operations of the same file to generate the latest data status.
[0023] Write the integrated data into a new data file, generate a new index and record the latest data position and offset of each file, mark the log entries integrated into the new data file as outdated, and clean up the log entries marked as outdated;
[0024] After the Filecoin system crashes and restarts, it reads the latest checkpoint file, replays the unintegrated log entries from the checkpoint position to reconstruct the data state, and updates the data structure and index in memory based on the replayed log entries.
[0025] In a preferred embodiment, each file in a large file set is segmented into chunk strips according to a predetermined size, and each strip is dispersedly stored on different HDD disks for parallel reading and writing operations, including the following steps:
[0026] Each large file is segmented according to the set segment size to generate multiple chunk stripes, a different HDD disk is selected for each chunk stripe, each chunk is written to the selected HDD disk, the location and order of each chunk stripe is recorded in the BLOB additional storage management unit, metadata is generated for each file, the metadata includes the location information and order information of each chunk stripe, and the generated metadata is saved in the form of key-value pairs in the database of the additional storage structure.
[0027] In a preferred implementation, each large file is segmented according to a set segment size to generate multiple chunk stripes, and a different HDD disk is selected for each chunk stripe, including the following steps:
[0028] Obtain the number of key tags and the number of stripe associations of each chunk stripe, normalize the number of key tags and the number of stripe associations, obtain the normalized value of the number of key tags and the normalized value of the stripe associations, sum the normalized value of the number of key tags and the normalized value of the stripe associations to obtain the importance score of the chunk stripe, and sort all chunk stripes from large to small according to the importance score to generate a stripe list;
[0029] Obtain the read / write efficiency and historical crash frequency of each HDD disk, normalize the read / write efficiency and historical crash frequency to obtain the normalized value of the read / write efficiency and the normalized value of the historical crash frequency, subtract the normalized value of the historical crash frequency from the normalized value of the read / write efficiency to obtain the performance score of the HDD disk, and sort all HDD disks from large to small according to the performance score to generate a disk list;
[0030] Assign the chunk stripes in the stripe list to the HDD disks in the disk list in corresponding order.
[0031] In a preferred embodiment, the total file random write is converted into sequential append write by management through LSM tree, including the following steps:
[0032] Arrange multiple small files in sequence and merge them into a total file. The LSM tree manages data through a hierarchical structure and writes the data of the total file into the memory layer in sequence. When the memory layer reaches the predetermined size, the write disk layer operation is triggered, and the data of the memory layer is sequentially written to the disk to generate an SSTable. The log file is appended and the write operation is recorded. The merged total file is sequentially written to the SSTable, and the aggregated total file is stored in the BLOB additional storage management unit. The BLOB additional storage management unit generates metadata for each total file. The metadata contains the location information and sequence information of each file in the total file.
[0033] In a preferred embodiment, when the adaptation system receives a plurality of files, the files are classified into a large file set or a small file set based on a threshold comparison method, including the following steps:
[0034] Obtain all the files that need to be stored and the data volume of all the files, compare the data volume of the file with the preset data volume threshold. If the data volume of the file is greater than the data volume threshold, judge the file as a large file, classify the file into the large file collection and mark it with B. If the data volume of the file is less than or equal to the data volume threshold, judge the file as a small file, classify the file into the small file collection and mark it with S.
[0035] In a preferred embodiment, each file in a large file collection is segmented into chunk stripes according to a predetermined size, the location and order of each chunk is recorded in a BLOB additional storage management unit, metadata is saved in the form of key-value pairs, random writes of the total file are converted into sequential append writes, and the aggregated total file is stored in the BLOB additional storage management unit in the form of chunk stripes.
[0036] A Filecoin scenario adaptation system based on attached storage, including a file collection partitioning module, a file management module, a modification judgment module, an append log recording module, and a file data reconstruction module;
[0037] File collection division module: when receiving several files, the files are divided into large file collection or small file collection based on the threshold comparison method;
[0038] File management module: Each file in a large file collection is segmented into chunk stripes according to a predetermined size. Each stripe is stored on different HDD disks for parallel read and write operations. Multiple files in a small file collection are aggregated into a total file, which is managed through an LSM tree, and random writes of the total file are converted into sequential append writes.
[0039] Modification judgment module: When a file modification operation occurs, it determines whether additional log recording is required based on the file importance information and the device computing environment information;
[0040] Append log recording module: if it is determined that append log recording is required, the modification of the file in the BLOB additional storage management unit is recorded in the append log mode, and each write operation generates a new log entry;
[0041] File data reconstruction module: Regularly trigger the garbage collection mechanism to integrate the modified data in the log and clean up historical log entries. If the Filecoin system crashes during the file modification process, the data status is rebuilt based on the integrated log entries.
[0042] In the above technical solution, the technical effects and advantages provided by the present invention are:
[0043] 1. The present invention divides each file in a large file collection into chunk stripes according to a predetermined size, and each stripe is dispersedly stored on different HDD disks for parallel read and write operations, thereby maximizing the read and write throughput of a single file, recording the location and order of each chunk in a BLOB attached storage management unit, and storing metadata in the form of key-value pairs to ensure data traceability and convenient management. Multiple files in a small file collection are aggregated into a total file, which is managed through an LSM (Log-Structured-Merge) tree, and the total file random write is converted into sequential append write, and the aggregated total file is stored in a BLOB attached storage management unit. The adaptation system classifies files into large files and small files, and stores large files and small files in different ways, effectively improving file read and write efficiency and improving resource utilization.
[0044] 2. In the present invention, when a file modification operation occurs, the adaptation system combines the file importance information and the device computing environment information to determine whether it is necessary to perform an additional log record. If it is determined that an additional log record is required, the modification of the file in the BLOB additional storage management unit is recorded by an additional log, and no modification is performed in situ. A new log entry is generated for each write operation, and the garbage collection mechanism is triggered regularly to integrate the modified data in the log, and the historical log entries are cleaned up to release storage space. If the Filecoin system crashes during the file modification process, the data state is rebuilt according to the integrated log entries. When the adaptation system determines that a file needs to be logged, it records the file modification information in the form of an additional log record, so that the file data can be restored when the Filecoin system crashes, effectively ensuring the integrity of the file data. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present invention. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.
[0046] Figure 1 The present invention is a flow chart of the method.
[0047] Figure 2 It is a system module diagram of the present invention.
[0048] Figure 3 The figure is a schematic diagram of file management by the file management module of the present invention. DETAILED DESCRIPTION
[0049] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0050] Example 1: Please refer to Figure 1 As shown, the present embodiment describes a Filecoin scenario adaptation method based on attached storage, and the adaptation method includes the following steps:
[0051] When the adaptation system receives several files, it classifies the files into a large file set or a small file set based on the threshold comparison method, and segments each file in the large file set into chunk stripes according to a predetermined size. Each stripe is stored in a dispersed manner on different HDD disks for parallel read and write operations, thereby maximizing the read and write throughput of a single file. The location and order of each chunk are recorded in the BLOB attached storage management unit, and the metadata is saved in the form of key-value pairs to ensure data traceability and convenient management. Multiple files in the small file set are aggregated into a total file, which is managed through an LSM (Log-Structured-Merge) tree. The random write of the total file is converted into a sequential append write, and the aggregated total file is stored in the BLOB attached storage management unit.
[0052] When a file modification operation occurs, the adaptation system determines whether it is necessary to record it in an additional log based on the file importance information and the device computing environment information. If it is determined that it is necessary to record it in an additional log, the file modification is recorded in the BLOB additional storage management unit in an additional log without making any in-place modifications. A new log entry is generated for each write operation. Since recording in an additional log will increase the read and write time and increase the storage burden of the Filecoin system, in order to improve the efficiency of file management, it is necessary to determine whether it is necessary to record it in an additional log based on the file information and device information. The garbage collection mechanism is triggered regularly to integrate the modified data in the log and clean up historical log entries to release storage space. If the Filecoin system crashes during the file modification process, the data status is rebuilt based on the integrated log entries.
[0053] This application divides each file in a large file collection into chunk stripes according to a predetermined size, and each stripe is dispersed and stored on different HDD disks for parallel read and write operations, thereby maximizing the read and write throughput of a single file, recording the location and order of each chunk in a BLOB attached storage management unit, and saving metadata in the form of key-value pairs to ensure data traceability and convenient management. Multiple files in a small file collection are aggregated into a total file, which is managed through an LSM (Log-Structured-Merge) tree, converting random writes of the total file into sequential append writes, and storing the aggregated total file in a BLOB attached storage management unit. This adaptation system classifies files into large files and small files, and stores large files and small files in different ways, effectively improving file read and write efficiency and improving resource utilization.
[0054] In this application, when a file modification operation occurs, the adaptation system combines the file importance information and the device computing environment information to determine whether it is necessary to record it in an additional log format. If it is determined that an additional log format is required, the modification of the file is recorded in the BLOB additional storage management unit by an additional log format, without in-place modification. Each write operation generates a new log entry, and the garbage collection mechanism is triggered regularly to integrate the modified data in the log. At the same time, the historical log entries are cleaned up to release storage space. If the Filecoin system crashes during the file modification process, the data state is rebuilt according to the integrated log entries. When the adaptation system determines that it is necessary to append log records to the file, it records the file modification information in the form of log append records, so that the file data can be restored when the Filecoin system crashes, effectively ensuring the integrity of the file data.
[0055] Embodiment 2: When the adaptation system receives a number of files, the files are classified into a large file set or a small file set based on a threshold comparison method, including the following steps:
[0056] Obtain all files that need to be stored, and obtain the data volume of all files, compare the data volume of the file with the preset data volume threshold, if the data volume of the file is greater than the data volume threshold, judge the file as a large file, classify the file into a large file set and mark it with a label B, if the data volume of the file is less than or equal to the data volume threshold, judge the file as a small file, classify the file into a small file set and mark it with a label S;
[0057] It should be noted that the data volume threshold value range is usually 100MB-1000MB, and the specific value is set according to the specific scenario, which will not be elaborated here.
[0058] Each file in a large file collection is segmented into chunk strips according to a predetermined size. Each strip is stored in different HDD disks for parallel read and write operations to maximize the read and write throughput of a single file. The location and order of each chunk are recorded in the BLOB attached storage management unit. The metadata is saved in the form of key-value pairs to ensure data traceability and convenient management. The following steps are included:
[0059] Each large file is segmented according to the set segment size to generate multiple chunk stripes. A different HDD disk is selected for each chunk stripe to achieve parallel storage. Each chunk is written to the selected HDD disk to ensure that the chunk stripes are distributed on multiple disks to improve the read and write throughput. The location and order of each chunk stripe are recorded in the BLOB attached storage management unit. Metadata is generated for each file, including the location information and order information of each chunk stripe. The generated metadata is saved in the form of key-value pairs in the database of the attached storage structure.
[0060] in:
[0061] Key: file identifier (such as file name or file ID);
[0062] Value: Contains details of the chunk location and order.
[0063] For example, the specific steps are as follows:
[0064] According to the system settings, determine the size of each chunk stripe (such as 64MB), divide each large file into segments according to the predetermined size, and generate multiple chunk stripes. For example, for a file of 256MB, divide it into 4 chunk stripes, each chunk stripe is 64MB, select a different HDD disk for each chunk stripe to ensure even distribution, and write each chunk stripe to the selected HDD disk. For example, store the first chunk stripe on Disk1, the second chunk stripe on Disk2, and so on;
[0065] The location and order of each chunk stripe are recorded in the BLOB attached storage management unit. The metadata records:
[0066] File ID or file name: file123:
[0067] Chunk information:
[0068] chunk1: stored in Disk1, with an offset of 0 and a length of 64MB;
[0069] chunk2: stored in Disk2, with an offset of 0 and a length of 64MB;
[0070] chunk3: stored in Disk3, with an offset of 0 and a length of 64MB;
[0071] chunk4: stored in Disk4, with an offset of 0 and a length of 64MB;
[0072] The metadata of the file is saved in the form of key-value pairs in a database of the attached storage structure.
[0073] Each large file is segmented according to the set segment size to generate multiple chunk stripes, and a different HDD disk is selected for each chunk stripe. Generally speaking, the existing adaptation system usually randomly selects HDD disks for chunk stripes. However, in actual applications, due to the different importance of different chunk stripes and the different performance of different HDD disks, we want to achieve that the more important the chunk stripe is, the more it needs to be stored in the HDD disk with excellent performance. Therefore, there are the following solutions:
[0074] Each large file is segmented according to the set segment size to generate multiple chunk stripes, the number of key tags and the number of stripe associations of each chunk stripe are obtained, the number of key tags and the number of stripe associations are normalized to obtain the normalized value of the number of key tags and the normalized value of the number of stripe associations, the normalized value of the number of key tags and the normalized value of the number of stripe associations are summed to obtain the importance score of the chunk stripe, all chunk stripes are sorted from large to small according to the importance score to generate a stripe list, the read and write efficiency of each HDD disk and the historical crash frequency are obtained, and the read and write efficiency is analyzed. Normalize the read / write efficiency and historical crash frequency to obtain the normalized value of the read / write efficiency and the normalized value of the historical crash frequency. Subtract the normalized value of the historical crash frequency from the normalized value of the read / write efficiency to obtain the performance score of the HDD disk. Sort all the HDD disks from large to small according to the performance score to generate a disk list. In the stripe list, the higher the ranking of the chunk stripe, the greater the importance of the chunk stripe. In the disk list, the higher the ranking of the HDD disk, the better the performance of the HDD disk. Therefore, the chunk stripes in the stripe list are allocated to the HDD disks in the disk list according to the corresponding ranking.
[0075] If the number of chunk stripes in the stripe list is greater than the number of HDD disks in the disk list, the following example method is used for allocation:
[0076] For example, there are 7 chunk stripes in the stripe list, namely {chunk1, chunk2, chunk3, chunk4, chunk5, chunk6, chunk7}, and there are 5 HDD disks in the disk list, namely {Disk1, Disk2, Disk3, Disk4, Disk5}. At this time, the number of chunk stripes in the stripe list is greater than the number of HDD disks in the disk list. The allocation result is:
[0077] Disk1 (chunk1, chunk2);
[0078] Disk2 (chunk3, chunk4);
[0079] Disk3 (chunk5);
[0080] Disk4 (chunk6);
[0081] Disk5 (chunk7);
[0082] And so on for distribution.
[0083] The number of key tags is obtained as follows: The number of key tags refers to the number of tags related to key business logic in each chunk stripe. These tags may reflect the importance, access rights, priority, etc. of the data. Use log analysis tools (such as ELK Stack) to extract relevant information and count the number of key tags in each chunk stripe.
[0084] The stripe association quantity is obtained as follows: The stripe association quantity refers to the degree of association between each chunk stripe and other chunk stripes, which usually reflects the relationship and dependency between data. The stripe association quantity can be queried from a database or graph database.
[0085] The read and write efficiency and historical crash frequency of the HDD disk can be obtained online through a monitoring tool of the computer system, which belongs to the prior art and is not limited here.
[0086] Aggregate multiple files in a small file set into a total file, manage them through an LSM (Log-Structured-Merge) tree, convert random writes of the total file into sequential append writes, and store the aggregated total file in a BLOB attached storage management unit, including the following steps:
[0087] Arrange multiple small files in sequence and merge them into a total file. The LSM tree manages data through a hierarchical structure and writes the data of the total file into the memory layer (MemTable) in sequence. When the memory layer reaches the predetermined size, the write disk layer operation is triggered, and the data of the memory layer is written sequentially to the disk to generate SSTable. The write log file is appended to record the write operation to ensure data persistence. The merged total file is written sequentially to SSTable to form an ordered and immutable data file. The aggregated total file is stored in the BLOB additional storage management unit. The BLOB additional storage management unit generates metadata for each total file. The metadata contains the location information and sequence information of each file in the total file.
[0088] When a file modification operation occurs, the adaptation system determines whether additional log recording is required based on the file importance information and the device computing environment information, including the following steps:
[0089] The file importance information includes the percentage of modified content and the importance value assigned. The device computing environment information includes the real-time load. The percentage of modified content, the importance value assigned and the real-time load are comprehensively calculated to generate a record index. The function expression is:
[0090] In the formula, To record the index, To modify the content ratio, Assign importance values, Indicates the number of historical transactions using the file in the Filecoin system. Indicates the file The transaction importance score when used in transactions, For real-time load, , are the importance assignment and the proportional coefficient of real-time load respectively, and ;
[0091] The larger the value of the record index is, the more it is necessary to perform additional log recording after the file is modified. The obtained record index is compared with the preset index threshold. The index threshold is used to determine whether additional log recording is required. If the record index is greater than or equal to the index threshold, it is determined that additional log recording is required after the file is modified. If the record index is less than the index threshold, it is determined that additional log recording is not required after the file is modified.
[0092] The logic for obtaining the modified content ratio is as follows: obtain the total data volume and the modified data volume of the file, and divide the modified data volume by the total data volume to obtain the modified content ratio. The larger the modified content ratio, the more modifications the user has made to the file, and the more it is necessary to record the file in the form of additional logs.
[0093] The calculation expression of transaction importance score is: , where Score the importance of the transaction, is the historical transaction volume of the file, is the historical transaction frequency of the file, is the total transaction volume of the Filecoin system, It represents the historical average transaction importance score of the file, that is, the historical average transaction importance score of the file is used as the importance value of the file.
[0094] The real-time load of the device is monitored online in real time through the Nagios monitoring tool. Nagios: A widely used system monitoring tool that can monitor various performance indicators of the device in real time. The real-time CPU usage and memory usage are monitored through the Nagios monitoring tool. The real-time load is obtained by adding the CPU usage to the memory usage. The larger the real-time load, the greater the current workload of the device, that is, the fewer remaining computing resources and storage resources. Therefore, the larger the real-time load, the less it is necessary to add logs after file modification to avoid device paralysis.
[0095] However, in actual applications, the real-time load of the device is a fluctuating value when the device is running. That is, the real-time load detected by the adaptation system may be too large or too small when the file is modified, but in a short period of time, the real-time load changes from too large to too small or from too small to too large. Therefore, we also need to predict the change of load changes in the future, so as to dynamically adjust the index threshold and improve the accuracy of the adaptation system's judgment. The specific solution is as follows:
[0096] When the adaptation system receives a file modification operation, the real-time load of the device is obtained once, and multiple device loads are obtained at the same time interval before the real-time load acquisition time point. The real-time load of the device and the multiple device loads are renamed as load values, and the average load and load standard deviation of the device are calculated by combining the multiple load values. The change trend of the device load is predicted by the average load and load standard deviation;
[0097] The calculation expression of load standard deviation is:
[0098] In the formula, represents the load standard deviation, Indicates the number of monitoring points, Indicates The equipment load at each monitoring point, Indicates the average load.
[0099] If the average load of the device is less than the load threshold, and the load standard deviation is less than or equal to the standard deviation threshold, it is predicted that the device load will change towards a low load trend in the future, and the change speed will be fast; if the average load of the device is less than the load threshold, and the load standard deviation is greater than the standard deviation threshold, it is predicted that the device load will change towards a low load trend in the future, and the change speed will be moderate; if the average load of the device is greater than the load threshold, and the load standard deviation is greater than the standard deviation threshold, it is predicted that the device load will change towards a high load trend in the future, and the change speed will be moderate; if the average load of the device is greater than the load threshold, and the load standard deviation is less than or equal to the standard deviation threshold, it is predicted that the device load will change towards a high load trend in the future, and the change speed will be fast; if the average load of the device is equal to the load threshold, it is predicted that the device load will not change in the future; the index threshold is dynamically adjusted according to the prediction results, and the adjustment results are shown in Table 1:
[0100]
[0101] As can be seen from Table 1, the index threshold is dynamically adjusted according to the change of equipment load, so that the comparison between the recorded index and the index threshold can better reflect the actual situation, thereby improving the accuracy of the adaptation system judgment.
[0102] If it is determined that additional log recording is required, the modification of the file is recorded in the BLOB additional storage management unit in an additional log manner without in-place modification. Each write operation generates a new log entry, including the following steps:
[0103] When it is determined that additional logging is required and a modification request for a file is received (including write or update operations), a new log entry is created for each modification, containing the following information:
[0104] Operation type (e.g., write, update, delete);
[0105] File identification (such as file name or file ID);
[0106] Modified offset and data content;
[0107] Timestamp and operation ID (ensuring operation sequence and traceability).
[0108] Append new log entries to the log file in sequence and ensure that the log entries are written to the disk to prevent data loss. Update the modification operations to the data structure in the memory (such as cache or index) for fast access and query. Update the index information of the file and record the new data location and version. When the log file reaches a certain size or time interval, trigger the merge and compression operations to merge multiple entries in the log file, generate new data files and update the index. Clean up obsolete log entries to release storage space. Generate checkpoints regularly to record the current file status and log progress. Persist the checkpoint information to the disk for fast recovery after a system crash.
[0109] For example:
[0110] The adapter system receives a write request for file 'file123', writes new data at offset '1024', and creates the following log entry:
[0111] {
[0112] "operation": "write",
[0113] "file_id": "file123",
[0114] "offset": 1024,
[0115] "data": "new data content",
[0116] "timestamp": "2024-05-24T12:34:56Z",
[0117] "operation_id": "op789";
[0118] }
[0119] Write log entries to the log file 'logfile.log', update the mapping and index in memory, record the new data at offset '1024' of 'file123', and when the log file reaches the predetermined size, perform a merge operation to merge multiple log entries to generate a new data file 'datafile.dat', update the index, and clean up the old log entries. Generate a checkpoint 'checkpoint.chk' to record the current file status and log progress.
[0120] The garbage collection mechanism is triggered regularly to integrate the modified data in the log, and historical log entries are cleaned up to release storage space. If the Filecoin system crashes during the file modification process, the data state is rebuilt based on the integrated log entries, including the following steps:
[0121] Trigger garbage collection based on time intervals (such as every hour, every day). Trigger garbage collection when the log file reaches a predetermined size. Read all entries in the current log file. Integrate all modification operations based on file identifiers (such as file name or file ID) and offsets. Merge modification operations on the same file to generate the latest data state. Write the integrated data to a new data file to form an ordered, up-to-date data file. Generate a new index. Record the latest data position and offset of each file. Mark the log entries that have been integrated into the new data file as outdated. Clean up log entries marked outdated. Release storage space. Create a new checkpoint file. Record the current Filecoin system state, including the latest data files and indexes. Persist the checkpoint file to disk to ensure that the Filecoin system can recover quickly after a crash. After the Filecoin system crashes and restarts, read the latest checkpoint file to restore the Filecoin system state. Starting from the checkpoint position, replay the unintegrated log entries to rebuild the data state. Based on the replayed log entries, update the data structure and index in memory to ensure data consistency.
[0122] For example:
[0123] Trigger garbage collection operations every hour, or when the log file size exceeds 100MB, read all entries in the current log file, merge all modification operations of file 'file123', generate the latest data status, write the integrated data to the new data file 'datafile.dat', update the index, record the position and offset of 'file123' in 'datafile.dat', mark the log entries in 'logfile.log' that have been integrated into 'datafile.dat' as outdated, generate a checkpoint file 'checkpoint.chk', record the current Filecoin system status and the latest data files and indexes, persist 'checkpoint.chk' to disk, read 'checkpoint.chk', restore the Filecoin system to the latest status, replay the log entries in 'logfile.log' starting from the checkpoint position, update the data status of 'file123', rebuild the data structure and index in memory, and ensure data consistency.
[0124] Example 3: Please refer to Figure 2 As shown, the Filecoin scenario adaptation system based on additional storage described in this embodiment includes a file collection division module, a file management module, a modification judgment module, an additional log recording module, and a file data reconstruction module;
[0125] File collection division module: when receiving several files, the files are divided into large file collection or small file collection based on the threshold comparison method, and the large file collection or small file collection is sent to the file management module;
[0126] File management module: Each file in a large file collection is segmented into chunk stripes according to a predetermined size. Each stripe is dispersed and stored on different HDD disks for parallel read and write operations to maximize the read and write throughput of a single file. The location and order of each chunk are recorded in the BLOB additional storage management unit. The metadata is saved in the form of key-value pairs to ensure data traceability and convenient management. Multiple files in a small file collection are aggregated into a total file and managed through an LSM (Log-Structured-Merge) tree. The random write of the total file is converted into a sequential append write. The aggregated total file is stored in the BLOB additional storage management unit, and the BLOB additional storage management unit sends it to the append log recording module;
[0127] Modification judgment module: When a file modification operation occurs, it is determined whether additional log recording is required based on the file importance information and the device computing environment information, and the judgment result is sent to the additional log recording module;
[0128] Append log recording module: If it is determined that additional log recording is required, the modification of the file in the BLOB additional storage management unit is recorded in the form of additional logs, without in-place modification. Each write operation generates a new log entry. Since the additional log recording will increase the reading and writing time and the storage burden of the Filecoin system, in order to improve the management efficiency of files, it is necessary to combine the file information and device information to determine whether additional log recording is required. The accumulated information of the log entries is sent to the file data reconstruction module;
[0129] File data reconstruction module: Regularly trigger the garbage collection mechanism to integrate the modified data in the log, and clean up historical log entries to release storage space. If the Filecoin system crashes during the file modification process, the data status is rebuilt according to the integrated log entries.
[0130] In this application, the description of key technical terms is shown in Table 2:
[0131]
[0132] The BLOB additional storage management unit is implemented through Append-only, that is, the modified data will not be replaced in place, but will be modified by continuously adding logs. When the logs accumulate to a certain level, a garbage collection mechanism is used to organize the results and save checkpoints. If a crash occurs, it can also be replayed and restored through the logs. The management unit of the additional storage is BLOB, and each BLOB is composed of multiple chunks. The size of each chunk is not fixed and can be 4MB, 64MB, 1GB, etc., which is determined by the business according to the situation. The metadata and data in the chunk are stored continuously. The advantage of this is that writing and reading can be completed in one operation;
[0133] In order to ensure that the space for writing to multiple chunks in the same local file system is relatively continuous, a pre-allocation mechanism is used here. That is, when a chunk needs to be written, the fallocat call is called to let the underlying storage apply for a continuous space, ensuring that subsequent writes fall into the continuous space and reducing layout disturbances.
[0134] like Figure 3 As shown in the figure: the file management module manages the storage behavior of files by separating the storage of large and small files. Large files are stored in segments in a striped manner, and the data part is filled into different BLOBs according to different segments. Meta information is stored in the form of KV in the DB constructed with additional storage; small files are stored in the form of KV in the DB constructed with additional storage. Through separate management, large files can place segmented files on more disks, and small files are merged into large storage blocks, so that each can use disk resources in the best way;
[0135] in:
[0136] The layout of large files is affected by the stripe size and the number of segments. The default number of segments is 4 and the segment size is 2MB. Therefore, for an 18MB file, it will be divided into 4 small segment files and sent to different underlying attached storage units. The storage order is determined by the metadata when the file is created. As shown in the figure, 0-2MB, 8-10MB, and 16-18MB of the file will be sent to the underlying Blob1 and constitute a complete segment file; 2-4MB and 10-12MB of the file will be sent to the underlying Blob2 and constitute a complete segment file, and so on.
[0137] In order to support modification and writing of each segmented file, the segmented file is divided into multiple slice files, each slice file is placed in a BLOB, and if there is a modification and writing request, it is appended to the end of the slice file. After the modification and writing reaches the modification number limit or the modification capacity limit, the business enters the compaction process. Compaction is divided into foreground and background. If the amount of modification is not large, the compaction task is submitted to the background thread for execution first, which can guarantee the performance of the foreground business to a certain extent; but if the amount of modification is very high, it is necessary to enter the foreground compaction, that is, complete the blob data merge in the user thread.
[0138] In the overall architecture of small files, the relationship between File and Blob is many-to-many. The mapping relationship between files and Blob is recorded at the same time, and invalid data is removed through background compaction. When the data written to a small file reaches a certain size, the small file is converted to the large file area through a background conversion task.
[0139] The data stored in small files is in KV format. The Key is the user file path + offset, and the Val is the actual stored LBA information. The data is recorded in the LOG file. For ease of management, the Key offset is managed according to a certain grain size. For example, if the grain size is 4KB, then an 8KB user file has only two keys in the DB: user filename + 0 and user file name + 4096.
[0140] The above formulas are all dimensionless and numerical calculations. The formula is a formula for the most recent real situation obtained by collecting a large amount of data and performing software simulation. The preset parameters in the formula are set by technicians in this field according to actual conditions.
[0141] It should be understood that the term "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. A and B can be singular or plural. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship, but it may also indicate an "and / or" relationship. Please refer to the context for specific understanding.
[0142] It should be understood that in the various embodiments of the present application, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0143] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can 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. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process of the above-described system, device and unit can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0144] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A Filecoin scenario adaptation method based on attached storage, Features: The adaptation method comprises the following steps: When the adaptation system receives several files, it divides the files into large file sets or small file sets based on the threshold comparison method, and segments each file in the large file set into chunk stripes according to the predetermined size. Each stripe is stored in different HDD disks for parallel read and write operations. Multiple files in the small file set are aggregated into a total file, which is managed through the LSM tree, and the random write of the total file is converted into sequential append write; When a file modification operation occurs, the adaptation system determines whether it is necessary to perform an additional log recording in combination with the file importance information and the device computing environment information. The file importance information includes the percentage of modified content and the importance assignment. The device computing environment information includes the real-time load. The percentage of modified content, the importance assignment and the real-time load are comprehensively calculated to generate a record index. If the record index is greater than or equal to the index threshold, it is determined that the file modification needs to be recorded in an additional log. If the record index is less than the index threshold, it is determined that the file modification does not need to be recorded in an additional log. If it is determined that an additional log recording is required, the file modification is recorded in the BLOB attached storage management unit in an additional log manner, and a new log entry is generated for each write operation. The garbage collection mechanism is triggered regularly to integrate the modified data in the log and clean up the historical log entries. If the Filecoin system crashes during the file modification process, the data status is rebuilt based on the integrated log entries. The file importance information includes the modified content ratio and the importance value, and the device computing environment information includes the real-time load. The adaptation system calculates the modified content ratio, the importance value and the real-time load to generate a record index. The function expression is: In the formula, To record the index, To modify the content ratio, Assign importance values, Indicates the number of historical transactions using the file in the Filecoin system. Indicates the file The transaction importance score when used in transactions, For real-time load, , are the importance assignment and the proportional coefficient of real-time load respectively, and .
2. According to the Filecoin scenario adaptation method based on attached storage according to claim 1, Features: The adaptation system obtains the real-time load of the device once when receiving the file modification operation, obtains multiple device loads at the same time interval within a period of time before the real-time load acquisition time point, renames the real-time load of the device and the multiple device loads as load values, calculates the average load and load standard deviation of the device by combining the multiple load values, and predicts the change trend of the device load by the average load and load standard deviation; If the average load of the device is less than the load threshold, and the load standard deviation is less than or equal to the standard deviation threshold, it is predicted that the device load will change towards a low load trend in the future, and the change speed will be fast; If the average load of the device is less than the load threshold, and the load standard deviation is greater than the standard deviation threshold, it is predicted that the device load will change towards a low load trend in the future, and the change speed will be moderate; If the average load of the device is greater than the load threshold, and the load standard deviation is greater than the standard deviation threshold, it is predicted that the device load will change towards a high load trend in the future, and the change speed will be moderate; If the average load of the device is greater than the load threshold, and the load standard deviation is less than or equal to the standard deviation threshold, it is predicted that the device load will change towards a high load trend in the future, and the change speed will be fast; If the average load of the device is equal to the load threshold, it is predicted that the device load will not change in the future, and the index threshold is dynamically adjusted based on the prediction result.
3. According to the Filecoin scenario adaptation method based on attached storage according to claim 2, Features: If the Filecoin system crashes during file modification, the data state is rebuilt based on the integrated log entries, including the following steps: Trigger garbage collection based on time intervals. When the log file reaches a predetermined size, trigger garbage collection. Read all entries in the current log file, integrate all modification operations based on file identifiers and offsets, and merge modification operations of the same file to generate the latest data status. Write the integrated data into a new data file, generate a new index and record the latest data position and offset of each file, mark the log entries integrated into the new data file as outdated, and clean up the log entries marked as outdated; After the Filecoin system crashes and restarts, it reads the latest checkpoint file, replays the unintegrated log entries from the checkpoint position to reconstruct the data state, and updates the data structure and index in memory based on the replayed log entries.
4. According to the Filecoin scenario adaptation method based on attached storage according to claim 1, Features: Each file in the large file collection is segmented into chunk strips according to a predetermined size, and each strip is scattered and stored on different HDD disks for parallel reading and writing operations, including the following steps: Each large file is segmented according to the set segment size to generate multiple chunk stripes, a different HDD disk is selected for each chunk stripe, each chunk is written to the selected HDD disk, the location and order of each chunk stripe is recorded in the BLOB additional storage management unit, metadata is generated for each file, the metadata includes the location information and order information of each chunk stripe, and the generated metadata is saved in the form of key-value pairs in the database of the additional storage structure.
5. According to the Filecoin scenario adaptation method based on attached storage according to claim 4, Features: Each large file is segmented according to the set segment size to generate multiple chunk stripes, and a different HDD disk is selected for each chunk stripe, including the following steps: Obtain the number of key tags and the number of stripe associations of each chunk stripe, normalize the number of key tags and the number of stripe associations, obtain the normalized value of the number of key tags and the normalized value of the stripe associations, sum the normalized value of the number of key tags and the normalized value of the stripe associations to obtain the importance score of the chunk stripe, and sort all chunk stripes from large to small according to the importance score to generate a stripe list; Obtain the read / write efficiency and historical crash frequency of each HDD disk, normalize the read / write efficiency and historical crash frequency to obtain the normalized value of the read / write efficiency and the normalized value of the historical crash frequency, subtract the normalized value of the historical crash frequency from the normalized value of the read / write efficiency to obtain the performance score of the HDD disk, and sort all HDD disks from large to small according to the performance score to generate a disk list; Assign the chunk stripes in the stripe list to the HDD disks in the disk list in corresponding order.
6. According to a Filecoin scenario adaptation method based on attached storage according to claim 1, Features: The LSM tree is used to manage and convert the total file random write into sequential append write, including the following steps: Arrange multiple small files in sequence and merge them into a total file. The LSM tree manages data through a hierarchical structure and writes the data of the total file into the memory layer in sequence. When the memory layer reaches the predetermined size, the write disk layer operation is triggered, and the data of the memory layer is sequentially written to the disk to generate an SSTable. The log file is appended and the write operation is recorded. The merged total file is sequentially written to the SSTable, and the aggregated total file is stored in the BLOB additional storage management unit. The BLOB additional storage management unit generates metadata for each total file. The metadata contains the location information and sequence information of each file in the total file.
7. According to claim 6, a Filecoin scenario adaptation method based on additional storage, Features: When the adaptation system receives a number of files, it classifies the files into a large file set or a small file set based on a threshold comparison method, including the following steps: Obtain all the files that need to be stored and the data volume of all the files, compare the data volume of the file with the preset data volume threshold. If the data volume of the file is greater than the data volume threshold, judge the file as a large file, classify the file into the large file collection and mark it with B. If the data volume of the file is less than or equal to the data volume threshold, judge the file as a small file, classify the file into the small file collection and mark it with S.
8. According to the Filecoin scenario adaptation method based on attached storage according to claim 7, Features: Each file in a large file collection is segmented into chunk stripes according to a predetermined size, the location and order of each chunk is recorded in the BLOB attached storage management unit, the metadata is saved in the form of key-value pairs, the total file random write is converted into sequential append write, and the aggregated total file is stored in the BLOB attached storage management unit in the form of chunk stripes.
9. A Filecoin scenario adaptation system based on additional storage, used to implement the adaptation method described in any one of claims 1 to 8, Features: It includes a file collection division module, a file management module, a modification judgment module, an additional log recording module, and a file data reconstruction module; File collection division module: when receiving several files, the files are divided into large file collection or small file collection based on the threshold comparison method; File management module: Each file in a large file collection is segmented into chunk stripes according to a predetermined size. Each stripe is stored on different HDD disks for parallel read and write operations. Multiple files in a small file collection are aggregated into a total file, which is managed through an LSM tree, and random writes of the total file are converted into sequential append writes. Modification judgment module: When a file modification operation occurs, it determines whether additional log recording is required based on the file importance information and the device computing environment information; The file importance information includes the modified content ratio and the importance value, and the device computing environment information includes the real-time load. The adaptation system calculates the modified content ratio, the importance value and the real-time load to generate a record index. The function expression is: In the formula, To record the index, To modify the content ratio, Assign importance values, Indicates the number of historical transactions using the file in the Filecoin system. Indicates the file The transaction importance score when used in transactions, For real-time load, , are the importance assignment and the proportional coefficient of real-time load respectively, and ; Append log recording module: if it is determined that append log recording is required, the modification of the file in the BLOB additional storage management unit is recorded in the append log mode, and each write operation generates a new log entry; File data reconstruction module: Regularly trigger the garbage collection mechanism to integrate the modified data in the log and clean up historical log entries. If the Filecoin system crashes during the file modification process, the data status is rebuilt based on the integrated log entries.
