A management method for storing files
By calculating the storage changes of file storage operations in real time in the cache, the inaccuracy of file storage resource management in the prior art is solved, and resource limit judgment is realized before file data synchronization, thereby improving the accuracy and reliability of file storage.
Patent Information
- Application Number
- CN202211054486.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-30
- Publication Date
- 2026-01-06
- Estimated Expiration
- 2042-08-30
AI Technical Summary
Existing technologies cannot accurately count the data in the cache during file storage, which may lead to exceeding resource limits. Furthermore, the verification information changes as the data is modified, resulting in high computational complexity.
By obtaining the current status of the file and operation instructions, the file data, current storage amount and storage threshold of the file are obtained and stored. Operations are performed in response to operation instructions, and the storage change is calculated in the cache to determine whether it exceeds the threshold. If it does not exceed the threshold, the current storage amount is updated.
Before file data is synchronized to the storage file, resource limitations of the storage file are effectively avoided, improving the accuracy and reliability of file storage.
Smart Images

Figure CN115470184B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of persistent storage technology, and more particularly to a method for managing stored files. Background Technology
[0002] AP (Adaptive Autosar) persistent storage provides a mechanism for AP applications and other function sets to store information in the non-volatile memory of the Adaptive Machine. It offers two storage methods: file storage and file-based storage, both stored as files on the I / O device (i.e., storage device), including redundancy and verification information. Users can configure a maximum number of bytes for each storage location; the space occupied by that storage on the storage device must not exceed the configured number of bytes.
[0003] Currently, when managing file storage resources, the following situations often need to be considered:
[0004] 1. The limitation on file storage is the total space occupied by the file storage file and the redundant files generated based on the redundancy configuration information in the storage device;
[0005] 2. When writing or modifying data, the data is temporarily stored in the cache and will only be synchronized to the file when the user calls the synchronization interface or the handle is released.
[0006] 3. The file storage has multiple interfaces that can modify the file data;
[0007] 4. Storage size can be estimated by obtaining the file size and redundancy-related file size, but this method cannot estimate the data in the cache. If the data in the cache is synchronized to the file before the calculation is performed, the resource limit may be exceeded.
[0008] 5. If the user configures redundant information, some information, such as verification information, is of integer type, and the verification information may also be modified as the data is modified. If this information is stored in a file in bytes, then the size of the verification file will vary. If the size of the verification file is to be accurately estimated, the entire file content needs to be read and the changed data needs to be combined to calculate the accurate verification information. When there is a lot of data in the file, the amount of calculation is large. Summary of the Invention
[0009] To address the problems existing in the prior art, this invention provides a file management method that can determine whether changes in file data exceed resource limits before synchronization, offering high accuracy and reliability. The technical solution is as follows:
[0010] On one hand, the present invention provides a method for managing stored files, wherein the stored files include target stored files, and the method includes:
[0011] In response to a file storage path start command, the file data of the stored file, the current storage amount of the stored file, and the storage threshold of the stored file are obtained and stored.
[0012] Obtain operation instructions for the target storage file;
[0013] In response to the operation instruction, the target storage file is processed according to the operation instruction to obtain the processed file data of the storage file and the storage change between the processed file data and the file data;
[0014] Based on the current storage amount and the storage change amount, determine whether the processed storage amount corresponding to the processed file data is less than or equal to the storage threshold;
[0015] If so, the current storage quantity is updated based on the processed storage quantity.
[0016] Further, if so, after updating the current storage quantity based on the processed storage quantity, the method further includes:
[0017] The processed file data is then updated in the storage file.
[0018] Furthermore, the storage file also includes a backup file and a verification file of the target storage file.
[0019] Furthermore, the operation process includes a first operation process and a second operation process; wherein, the first operation process includes deleting the target storage file and modifying the target storage file; the second operation process is used to change the data in the target storage file, and the second operation process includes clearing the data in the target storage file, writing data to the target storage file, and setting the size of the target storage file.
[0020] Further, the step of responding to the operation instruction by performing the operation processing corresponding to the operation instruction on the target storage file to obtain the processed file data of the storage file, and the storage change between the processed file data and the original file data, includes:
[0021] When the operation is to delete the target storage file, the first storage amount occupied by the target storage file in the storage file is obtained according to the configuration information;
[0022] The storage change is obtained based on the first storage amount and the configuration information.
[0023] Furthermore, after obtaining the storage change amount based on the first storage amount and the configuration information, the method further includes:
[0024] The current storage quantity is updated directly based on the processed storage quantity.
[0025] Further, the step of responding to the operation instruction by performing the operation processing corresponding to the operation instruction on the target storage file to obtain the processed file data of the storage file, and the storage change between the processed file data and the original file data, includes:
[0026] When the operation is to modify the target storage file, the first storage amount occupied by the target storage file before the operation is performed and the second storage amount occupied after the operation are performed are obtained according to the configuration information.
[0027] The storage change is obtained based on the first storage amount, the second storage amount, and the configuration information.
[0028] Furthermore, after obtaining the operation instructions for the target storage file, the method further includes:
[0029] When the operation is processed as the second operation, the file opening interface in the target storage file is called.
[0030] Furthermore, after calling the file open interface in the target storage file when the operation processing is the second operation processing, the method further includes:
[0031] When the operation process is to clear the data in the target storage file, the first storage amount occupied by the target storage file in the storage file is obtained according to the configuration information;
[0032] The storage change is obtained based on the first storage amount and the configuration information;
[0033] The current storage quantity is updated based on the processed storage quantity, and the verification file corresponding to the target storage file is deleted.
[0034] Further, the step of responding to the operation instruction by performing the operation processing corresponding to the operation instruction on the target storage file to obtain the processed file data of the storage file, and the storage change between the processed file data and the original file data, includes:
[0035] When the update operation is to write data to the target storage file or set the size of the target storage file, the change in the storage amount of the target storage file in the storage file is obtained according to the configuration information;
[0036] The storage change amount corresponding to the target storage file is obtained based on the storage change and the configuration information.
[0037] Implementing this invention has the following beneficial effects:
[0038] This invention addresses various operational processes and obtains the corresponding storage changes. Before the processed file data is synchronized to the storage file, the storage space occupied in the final storage file is pre-calculated in the cache. This allows for the determination of whether the operational process will cause the processed storage amount to exceed the storage threshold, effectively preventing the storage file from exceeding resource limits. It is highly accurate and reliable. Attached Figure Description
[0039] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly described below. Obviously, the drawings described below are merely some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without any creative effort.
[0040] Figure 1 A logical structure diagram of a file storage management method provided in an embodiment of the present invention;
[0041] Figure 2 A logical structure diagram of a file storage management method for performing deletion operations, provided in an embodiment of the present invention;
[0042] Figure 3 A logical structure diagram of a file storage modification management method provided in an embodiment of the present invention;
[0043] Figure 4 A logical structure diagram of a file storage management method for clearing operations provided in an embodiment of the present invention;
[0044] Figure 5 A logical structure diagram of a file storage management method for writing operations provided in an embodiment of the present invention;
[0045] Figure 6 A logical structure diagram of a file data synchronization method provided in an embodiment of the present invention;
[0046] Figure 7 A timing diagram of a file storage management method provided in an embodiment of the present invention;
[0047] Figure 8 This is a schematic diagram of a file management device provided in an embodiment of the present invention. Detailed Implementation
[0048] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments, and therefore should not be construed as limiting the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0049] It should be noted that the terms "first," "second," etc., in the specification, claims, and drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of the invention can be implemented in orders other than those shown in the figures or descriptions below. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or server that includes a series of steps or units is not necessarily limited to those explicitly listed, but may include other steps or units not explicitly listed or inherent to these processes, methods, products, or devices.
[0050] In file storage, multiple interfaces operate on file data. During operation, the data is temporarily stored in a cache, and is only synchronized to the storage file when the synchronization interface is called or the operation handle is released. However, existing technologies cannot count the data temporarily stored in the cache. If the data in the cache is counted after it has been synchronized to the storage file, it is very likely that the resource limit will be exceeded. To address this issue, this embodiment provides a file storage management method, mainly applied to the middleware Adaptive Autosar for autonomous driving and intelligent connected vehicles, to perform persistent storage resource management for file storage.
[0051] For multiple interfaces that change the storage size of stored files, when a user uses file storage, the program first obtains the file storage path so that it can find the target file to operate on. In response to the file storage path initiation command, it obtains the file data of the entire stored file, the total current storage size of the stored file, and the storage threshold of the stored file, and stores them in the cache. The stored file includes the target stored file. Then, it obtains the operation instructions for the target stored file. In response to the operation instructions, it performs the corresponding operations on the target stored file, obtaining the processed file data of the entire stored file, and the total storage change between the file data before and after the operation and the processed file data. Based on the current storage size and the storage change, it determines whether the final processed storage size of the stored file is less than or equal to... The storage threshold that the storage file can be stored at is set. If so, it means that the operation will not cause the final storage file to exceed the resource limit. In this case, the current storage amount is updated in the cache based on the processed storage amount. This process is all performed in the cache, which can estimate the storage size changes caused by operations such as deletion, modification, and writing before the file data is synchronized to the storage file, and determine whether it exceeds the resource limit. This effectively avoids exceeding the resource limit and greatly improves the accuracy and reliability of the file storage process. Only after determining that the processed storage amount is within the storage threshold range will the processed file data in the cache be updated to the storage file. Otherwise, the current storage amount in the cache will not be updated, and the processed file data will not be synchronized to the storage file. That is, the target storage file and the original file data in the entire storage file will not change, resulting in high reliability.
[0052] The technical solutions of the embodiments of the present invention will be described in detail below, with reference to the appendix to the specification. Figure 1 The method includes:
[0053] S101, in response to the file storage path start command, obtain and store the file data of the stored file, the current storage amount of the stored file, and the storage threshold of the stored file.
[0054] First, the storage files include multiple files of various types, including the target storage file, the backup file corresponding to the target storage file, and the corresponding verification file. The target storage file is the object of operation in the subsequent S103 step, that is, the original file to be processed. In one possible implementation, the target storage file can be one of many storage files, multiple files, or all files in the storage files, allowing for flexible operation.
[0055] When a file storage path is opened, configuration information can be obtained. This configuration information is redundant information corresponding to the target storage file. It is information configured by the user and is not used as a statistical object itself. Instead, it is used to determine the number of backup files and whether to use the verification information of the verification file. For example, by configuring the number of backup files, the number of backup files can be obtained for statistical purposes to improve statistical efficiency and reduce the amount of calculation. In addition, although the configuration information itself does not participate in the storage quantity statistics, the redundant files generated by the configuration information are still within the statistical scope and need to be included in the calculation when performing storage change statistics.
[0056] In file storage, the verification file is stored separately. The verification information of the target file is stored in binary format in the corresponding verification file. As long as the corresponding target file still exists, the storage size occupied by the verification file in the entire file storage remains constant. Therefore, in the entire management process, it only needs to be counted once in step S101, eliminating the need for multiple counts, saving computational load, and improving statistical efficiency.
[0057] When a user uses file storage, the system can automatically retrieve the filenames of each file (including backup and verification files) under the file storage path and store these filenames as the file data of the entire storage file in the cache (memory) for subsequent steps.
[0058] Simultaneously, when the file storage path is opened, the storage size occupied by the current storage file, i.e., the current storage volume, can be obtained based on the user-configured information. This current storage volume information is also stored in the cache for subsequent steps to call and perform calculations and logical judgments. In one possible implementation, the current storage size of the entire storage file can be directly calculated based on the configuration information to obtain a current storage volume. In subsequent steps, the storage volume of the original file (or each backup file) and the size of the verification file can be calculated separately using the configuration information. In another possible implementation, the storage volume of each original file and the storage volume of the verification file can be obtained based on the configuration information when calculating the current storage size of the entire storage file. The storage volume of the original file, the storage volume of all backup files (equal to the storage volume of the original file multiplied by the number of backups), and the storage volume of the verification file are added together to obtain the total current storage volume of the storage file. That is, the storage volume of each file is implicitly included in the current storage volume and stored together in the cache, eliminating the need for repeated and frequent calculations and saving computational resources.
[0059] In this step, the storage threshold is configured by the user. When the file storage path is opened, the storage threshold will be automatically retrieved and then stored in the cache. It should be noted that this storage threshold is the maximum amount of file data that can be stored in the entire storage space of the storage file. It is for the entire storage file and includes the maximum amount of storage occupied by all file data, including all original files, all backup files, and verification files, in order to improve the accuracy of subsequent calculations and logical judgments and avoid errors.
[0060] S103, Obtain operation instructions for the target storage file.
[0061] S105, in response to the operation instruction, perform the operation processing corresponding to the operation instruction on the target storage file to obtain the processed file data of the storage file and the storage change amount between the processed file data and the file data.
[0062] In this step, the operation is performed on the target storage file. When the data in the original target storage file changes, the data in the backup file also changes synchronously. Therefore, the statistics include the changes in all file data, including the target storage file, its corresponding backup file, and the verification file. The resulting data is the processed file data and the amount of storage change. This storage change is specific to the entire storage file to ensure the accuracy of the statistics and improve the reliability of the management method.
[0063] In one possible implementation, the change in the storage size of the target storage file before and after the operation can be counted first. Then, based on the number of backup files, the change in the storage size of the target storage file can be multiplied by the number of backups, and the original change in the storage size of the target storage file can be added. Combined with the storage size of other storage files, such as the storage size of verification files and the storage size of redundant files generated by configuration information, the total storage change can be calculated, saving the calculation workload of the backup file part and improving the statistical efficiency.
[0064] This operation is performed in the cache, and the processed file data is temporarily stored in the cache and is not directly synchronized to the target storage file.
[0065] S107, Based on the current storage amount and the storage change amount, determine whether the processed storage amount corresponding to the processed file data is less than or equal to the storage threshold.
[0066] In file storage, file data is written to the file in byte form and read without formatting. The size of the corresponding file in bytes can be read directly. The current storage amount, storage change amount, and storage amount after processing are all counted in bytes. The storage threshold is the maximum number of bytes that the entire storage file can store. The logical judgment is consistent in format and has good accuracy.
[0067] S109, if so, then update the current storage quantity based on the processed storage quantity.
[0068] At this point, the storage changes caused by the operation will not cause the final stored file to exceed the resource limit, allowing the operation to modify the stored file. Furthermore, after the operation, the storage amount after this processing can be used as the current storage amount in the cache for the next operation, and the file data after this processing can be used as the file data for the next operation. The cache will then be managed again in a new round according to steps S101 to S109, and the process will be iterated in a loop.
[0069] If the result of step S107 is negative, meaning the processed storage amount is greater than the storage threshold, it means that after this operation, if the processed file data is updated to the final storage file, the storage space occupied by the processed file data will exceed the resource limit of the storage file, making reliable storage impossible. In this case, the current storage amount will not be updated in the cache, nor will the original target storage file or the file data in the entire storage file be changed. The current storage amount will still be used as the storage size occupied by the current file data, resulting in good storage stability. In one possible implementation, when the processed storage amount is greater than the storage threshold, an error will be reported to serve as a reminder.
[0070] It should be noted that steps S101 to S109 are all performed in the cache and are not synchronized to the final storage file. Therefore, before synchronization, it is possible to effectively determine whether the operation will exceed the resource limit based on the current storage amount and storage threshold temporarily stored in the cache, combined with the storage change amount, which greatly improves the reliability of storage.
[0071] Specifically, for file storage, the operation processing includes two types: a first operation processing and a second operation processing. The first operation processing is an operation performed on the entire target storage file, including deleting the target storage file (hereinafter referred to as deletion operation) and modifying the target storage file (hereinafter referred to as modification operation), and may also include obtaining relevant information about the target storage file. In one possible implementation, modifying the target storage file may specifically include resetting file data in the target storage file, overwriting file data, and restoring file data. The second operation processing is used to change the data in the target storage file, modifying the content data in the target storage file. The second operation processing includes clearing the data in the target storage file (hereinafter referred to as clearing operation), writing data to the target storage file, and setting the size of the target storage file (hereinafter referred to as writing operation).
[0072] As per the instruction manual Figure 7 The diagram shown is a timing diagram of a file storage management method provided by an embodiment of the present invention, in which different operation processes are performed on file data according to different operation instructions.
[0073] Specifically, when an operation instruction to delete the target storage file is obtained in step S103, the target storage file is deleted, as follows: Figure 2 As shown, in step S105, the step of responding to the operation instruction by performing the operation processing corresponding to the operation instruction on the target storage file to obtain the processed file data of the storage file, and the storage change between the processed file data and the file data includes:
[0074] S202, when the operation is to delete the target storage file, the first storage amount occupied by the target storage file in the storage file is obtained according to the configuration information.
[0075] S204, Based on the first storage amount and the configuration information, the storage change amount is obtained.
[0076] In step S101, based on the configuration information, the current storage size of the entire storage file can be directly obtained. Similarly, based on the configuration information, the number of bytes occupied by the target storage file in the entire file storage space, i.e., the first storage size, can be obtained. Then, based on the first storage size and the number of backup files in the configuration information, the storage size change between the target storage file and the backup files can be calculated. Furthermore, when the target storage file is deleted, its corresponding verification file is also deleted and no longer exists. Therefore, the storage size of the verification file corresponding to the target storage file can also be obtained through the configuration information. Based on the first storage size, the storage size of the backup files, and the storage size of the verification file, the total storage size change of the entire storage file caused by deleting the target storage file, i.e., the storage change amount, can be calculated. This method is convenient, fast, efficient, and accurate.
[0077] Specifically, such as Figure 2 As shown, after obtaining the storage change amount based on the first storage amount and the configuration information, the method further includes:
[0078] Execute step S109 directly to update the current storage quantity based on the processed storage quantity.
[0079] The deletion operation only reduces the file data in the target storage file. That is, the storage amount after processing is always less than the current storage amount. The current storage amount is the number of bytes occupied by all file data in the storage file. This current storage amount is less than the storage threshold of the storage file to ensure that the current storage file can be stored stably. Therefore, the storage amount after processing is always less than the storage threshold.
[0080] At this point, there is no need to perform logical judgment in step S107; step S109 can be executed directly to update the current storage amount in the cache. The storage amount obtained from this deletion operation will be used as the current storage amount for the next operation.
[0081] Specifically, such as Figure 3 As shown, when an operation instruction to modify the target storage file is obtained in step S103, and the target storage file is modified, then in step S105, in response to the operation instruction, the target storage file is processed according to the operation instruction to obtain the processed file data of the storage file, and the storage change between the processed file data and the original file data includes:
[0082] S301, when the operation is to modify the target storage file, the first storage amount occupied by the target storage file before the operation is performed and the second storage amount occupied after the operation are performed are obtained according to the configuration information.
[0083] S303, the storage change amount is obtained based on the first storage amount, the second storage amount and the configuration information.
[0084] Based on the configuration information, the storage size of the backup file and the storage size of the verification file corresponding to the target storage file can be obtained. When the target storage file exists and is not empty, the storage size of the verification file corresponding to the target storage file remains unchanged. Therefore, the verification file does not need to be considered when calculating the storage change, further saving computation.
[0085] In this step, based on the configuration information, the number of bytes currently occupied by the target storage file in the entire file storage space can be obtained, i.e., the first storage amount; and in the cache, the number of bytes occupied by the target storage file in the file storage space after the modification operation can also be calculated, i.e., the second storage amount; based on the first storage amount and the second storage amount, the change in the number of bytes of the target storage file before and after the modification operation can be known. Combined with the configuration information, the change in the number of bytes of the entire storage file before and after the modification operation can be obtained based on the number of backup files, i.e., the storage change amount; then, step S107 is executed, and the number of bytes of the storage file after the modification operation is determined based on the current storage amount. If it does not exceed the storage threshold, the current storage amount is updated; otherwise, it is not updated and an error is reported.
[0086] Specifically, such as Figure 4 and Figure 5 As shown, between steps S103 and S105, that is, after obtaining the operation instructions for the target storage file, the method further includes:
[0087] S402, when the operation processing is the second operation processing, the file opening interface in the target storage file is called.
[0088] When a user needs to create a file or read / write content from a file, i.e., when the operation processing for the target storage file is obtained as the second operation processing, it means that the operation processing needs to open the target storage file in order to operate on the data stored in the target storage file. So, based on the file name under the file storage path, the corresponding target storage file is found, and the file opening interface in the target storage file is called to open the target storage file. If the target storage file does not exist, the target storage file is created, and a file read / write handle is obtained so that the second operation processing can be performed within the target storage file.
[0089] In file I / O, the file read / write handle is crucial. To read data from a file, the program first calls an operating system function, passing the filename and selecting a path to open the file. This function retrieves a sequence number, the file handle, which is uniquely identified for the opened file. When reading data from the file, the program calls the ReadFile function, sending the memory address of the file handle and the number of bytes to be copied to the operating system. After completing the task, the program closes the file by calling a system function.
[0090] Specifically, such as Figure 4 As shown, after step S402, that is, after calling the file open interface in the target storage file when the operation processing is the second operation processing, the method further includes:
[0091] S404, when the operation process is to clear the data in the target storage file, the first storage amount occupied by the target storage file in the storage file is obtained according to the configuration information.
[0092] S406, the storage change amount is obtained based on the first storage amount and the configuration information.
[0093] S408, directly execute the update of the current storage quantity based on the processed storage quantity, and delete the verification file corresponding to the target storage file.
[0094] At this point, when the operation instruction is obtained in step S103, it can be determined that the operation is a clear operation, which belongs to the second operation. The clear operation is similar to the deletion operation. Steps S404 to S406 are the same as steps S202 to S204. The clear operation will only reduce the file data in the file storage space, so that the processed file data is always less than the current file data, and the processed storage amount is always less than the current storage amount. There is no need to perform the logical judgment in step S107, and the current storage amount can be directly updated in the cache.
[0095] When calculating storage changes, before opening the target storage file, the system first calculates the first storage amount occupied by the target storage file in the file storage space based on the configuration information. This first storage amount is the change in the storage amount of the target storage file itself when the contents of the target storage file are cleared. Based on the first storage amount, combined with the number of backup files and the storage amount of verification files in the configuration information, the system calculates the total storage change of the entire storage file caused by clearing the contents of the target storage file, i.e., the storage change amount.
[0096] Since the contents of the target storage file are cleared, meaning the target storage file becomes an empty file, and its corresponding verification file is also deleted in the subsequent S408 step, the storage volume of the verification file also needs to be counted during the statistics. The storage volume of the target storage file, the storage volume of all corresponding backup files, and the storage volume of the verification file are added together to obtain the total storage change, making the statistics more accurate.
[0097] Step S408 is similar to step S109, and at the same time, the verification file corresponding to the target storage file is deleted so that after the current storage amount is updated, the processed file data in the cache corresponds to the processed storage amount.
[0098] Specifically, such as Figure 5 As shown, after step S402, the step of responding to the operation instruction by performing the operation processing corresponding to the operation instruction on the target storage file to obtain the processed file data of the storage file, and the storage change between the processed file data and the file data includes:
[0099] S501, when the update operation is to write data to the target storage file or set the size of the target storage file, the change in the storage amount of the target storage file in the storage file is obtained according to the configuration information.
[0100] S503, based on the storage quantity change corresponding to the target storage file and the configuration information, the storage change amount corresponding to the storage file is obtained.
[0101] After opening the target storage file, data in the target storage file can be read and written using the file read / write handle, and the size of the target storage file can be set. Based on the configuration information, the change in the number of bytes in the target storage file in the storage space before and after writing data to the target storage file, as well as the change in the number of bytes in the entire storage file before and after the operation, are calculated. Then, the logical judgment in step S107 is executed, and the number of bytes in the final storage file, i.e., the storage amount after processing, is calculated in combination with the current storage amount in the cache. If it does not exceed the maximum number of bytes, it means that the file data can be written to the target storage file, and the number of bytes in the cache is updated. Otherwise, it means that if the operation continues to be executed, the number of bytes in the final storage file will exceed the maximum number of bytes, and the file data cannot be written to the target storage file. In this case, the current number of bytes in the cache will not be updated, an error will be reported, and the file data in the final storage file will not be changed, thereby improving storage efficiency and storage reliability.
[0102] Specifically, such as Figure 6 As shown, if so, after updating the current storage amount based on the processed storage amount, i.e. after step S109, the method further includes:
[0103] S602, update the processed file data to the storage file.
[0104] When processing the target storage file, the file data is temporarily stored in a cache. Statistical analysis and logical judgments are performed in the cache. Only when the judgment results indicate that the final file data will not exceed resource limits can the processed file data be synchronously updated to the storage file (i.e., physical storage). In one possible implementation, the system waits for the user to call the synchronization interface. In response to the synchronization command, the processed file data in the cache is synchronized to the storage file. In another possible implementation, if the synchronization interface is not called, the status information of the file read / write handle is monitored. When information indicating that the file read / write handle has been released is received, the written data is automatically refreshed to the storage file.
[0105] In one possible implementation, the processed file data is synchronized to the target storage file, while the backup file is updated synchronously as the target storage file is updated, thereby achieving synchronous update storage of the entire storage file.
[0106] Furthermore, the node for synchronous update can be arbitrarily selected, offering good flexibility. In one possible implementation, after each operation, following steps S103 to S109, step S602 can be executed for a synchronous update. In another possible implementation, multiple operation processes can be performed, which can be multiple operations of the same type or multiple combinations of different types of operations. Specifically, for files in the storage file, operations could include deleting part of the target storage file, modifying part of the target storage file, clearing data in the target storage file, writing data to the target storage file, and setting the target storage file size. There are two less types. Each operation goes through steps S103 to S109 for logical judgment and update, but is not synchronized to the final storage file. At this time, the cache finally stores the final processed file data and the final storage amount after multiple operations. Then, step S602 is executed to synchronize the final file data stored in the cache to the storage file. In this process, as long as the processing storage amount corresponding to the judgment after each operation is less than or equal to the storage threshold, or the final processing storage amount is less than or equal to the storage threshold, then when updating the final processed file data to the storage file, the resource limit of the storage file will not be exceeded, resulting in high reliability.
[0107] In addition, in one possible implementation, during multiple operation processing, the current file data and current storage amount in the storage file can be counted only once initially. After that, it is only necessary to count the file data that changes during the current operation processing and the amount of storage change. The storage change amount is added to the initial current storage amount and can be used as the current storage amount for subsequent multiple operation processing. There is no need to re-count the current storage amount based on the configuration information, which further reduces the amount of calculation and improves the statistical efficiency.
[0108] As can be seen from the above embodiments of the file management method provided by the present invention, the present invention has the following beneficial effects:
[0109] 1. This invention addresses various operation processes and obtains the storage change corresponding to each operation. Before the processed file data is synchronized to the storage file, the storage space occupied in the final storage file is pre-calculated in the cache. This allows for the determination of whether the operation will cause the processed storage to exceed the storage threshold, effectively preventing the storage file from exceeding resource limits. It is highly accurate and reliable.
[0110] 2. This invention can accurately calculate the storage amount of configuration information, thereby further improving the accuracy of the calculation and the reliability of persistent storage resource management.
[0111] Corresponding to the file management method provided in this embodiment above, this embodiment of the invention also provides a file management device, capable of implementing the file management method in the above method embodiments, such as... Figure 8 As shown, the device may include:
[0112] The first acquisition module 810 is used to acquire and store the file data of the stored file, the current storage amount of the stored file, and the storage threshold of the stored file in response to the file storage path start command;
[0113] The second acquisition module 820 is used to acquire operation instructions for the target storage file;
[0114] The operation and statistics module 830 is used to respond to the operation instruction, perform operation processing on the target storage file corresponding to the operation instruction, and obtain the processed file data of the storage file, as well as the storage change between the processed file data and the file data.
[0115] The judgment module 840 is used to determine whether the processed storage amount corresponding to the processed file data is less than or equal to the storage threshold based on the current storage amount and the storage change amount;
[0116] The update module 850 is used to update the current storage quantity based on the processed storage quantity if the judgment result is yes.
[0117] In one possible implementation, the device further includes:
[0118] A synchronization module is used to update the processed file data to the storage file.
[0119] It should be noted that the apparatus provided in the above embodiments is only illustrated by the division of the above functional modules when implementing its functions. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the apparatus and method embodiments provided in the above embodiments belong to the same concept, and the specific implementation process can be found in the method embodiments, which will not be repeated here.
[0120] This invention also provides a medium storing at least one instruction or at least one program segment, wherein the at least one instruction or the at least one program segment is loaded and executed by a processor to implement the above-described file storage management method; optionally, the medium may be located at at least one network server among multiple network servers in a computer network; furthermore, the medium may be, but is not limited to, various storage media capable of storing program code, such as random access memory (RAM), read-only memory (ROM), USB flash drive, portable hard drive, disk storage device, flash memory device, and other volatile solid-state storage devices.
[0121] It should be noted that the order of the above embodiments of the present invention is merely for descriptive purposes and does not represent the superiority or inferiority of the embodiments. Furthermore, specific embodiments have been described above. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps described in the claims can be performed in a different order than that shown in the embodiments and still achieve the desired result. Additionally, the processes depicted in the drawings do not necessarily require a specific or sequential order to achieve the desired result. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0122] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the apparatus embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.
[0123] The above description is merely some embodiments of the present invention and is not intended to limit the present invention. Those skilled in the art should understand that the present invention can have various changes and improvements, and any modifications, equivalent substitutions and improvements made in accordance with the present invention fall within the scope of protection claimed by the present invention.
Claims
1. A management method for storing files, the storing files including a target storing file, characterized by, The method comprises the following steps: in response to a file storage path starting instruction, obtaining and storing file data of the storage file, a current storage amount of the storage file, and a storage threshold of the storage file; the storage file comprises a backup file and a check file of the target storage file; obtaining an operation instruction for the target storage file; in response to the operation instruction, performing an operation corresponding to the operation instruction on the target storage file to obtain processed file data of the storage file and a storage change amount between the processed file data and the file data; the operation comprises a first operation and a second operation; the first operation comprises deleting the target storage file and modifying the target storage file; the second operation is used for changing data in the target storage file, and the second operation comprises emptying data in the target storage file, writing data into the target storage file, and setting a size of the target storage file; determining whether a processed storage amount corresponding to the processed file data is less than or equal to the storage threshold according to the current storage amount and the storage change amount; if yes, updating the current storage amount based on the processed storage amount; if no, keeping the current storage amount and performing error processing.
2. The management method according to claim 1, characterized in that, After the step of if yes, updating the current storage amount based on the processed storage amount, the method further comprises: updating the processed file data into the storage file.
3. The management method according to claim 1, characterized by, The step of in response to the operation instruction, performing an operation corresponding to the operation instruction on the target storage file to obtain processed file data of the storage file and a storage change amount between the processed file data and the file data comprises: when the operation is deleting the target storage file, obtaining a first storage amount occupied by the target storage file in the storage file according to configuration information; obtaining the storage change amount according to the first storage amount and the configuration information.
4. The management method according to claim 3, characterized in that, After the step of obtaining the storage change amount according to the first storage amount and the configuration information, the method further comprises: directly performing the step of updating the current storage amount based on the processed storage amount.
5. The management method according to claim 1, characterized by, The step of in response to the operation instruction, performing an operation corresponding to the operation instruction on the target storage file to obtain processed file data of the storage file and a storage change amount between the processed file data and the file data comprises: when the operation is modifying the target storage file, obtaining a first storage amount occupied by the target storage file before the operation and a second storage amount occupied by the target storage file after the operation according to configuration information; obtaining the storage change amount according to the first storage amount, the second storage amount, and the configuration information.
6. The management method according to claim 1, characterized by, After the step of obtaining an operation instruction for the target storage file, the method further comprises: when the operation is the second operation, calling a file opening interface in the target storage file.
7. The management method according to claim 6, characterized in that, After the calling the file open interface in the target storage file when the operation processing is the second operation processing, the method further comprises: When the operation processing is emptying data in the target storage file, obtaining a first storage amount occupied by the target storage file in the storage file according to configuration information; According to the first storage amount and the configuration information, obtaining the storage change amount; Directly performing the updating the current storage amount based on the processing storage amount, and deleting the check file corresponding to the target storage file.
8. The management method according to claim 6, characterized by, The obtaining the processing file data of the storage file and the storage change amount between the processing file data and the file data in response to the operation instruction and performing the operation processing corresponding to the operation instruction on the target storage file comprises: When the update operation is writing data into the target storage file or setting the size of the target storage file, obtaining a storage amount change of the target storage file in the storage file according to configuration information; According to the storage amount change corresponding to the target storage file and the configuration information, obtaining the storage change amount corresponding to the storage file.
Citation Information
Patent Citations
Data synchronization method and device, electronic equipment, storage medium and program product
CN114741367A