Optimization method and device for copy-on-write mechanism of file system
By adding an upperopt layer to the OverlayFS file system to record application operations, the problem of time-consuming copy-on-write was solved, and phenomena such as application freezing, stuttering, and frame drops were reduced, thus optimizing the performance of the file system.
Patent Information
- Application Number
- CN202411829870.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-12
- Publication Date
- 2025-01-10
- Estimated Expiration
- 2044-12-12
AI Technical Summary
The OverlayFS file system takes a long time to copy during write, which can cause problems such as application freezing, stuttering, and frame drops.
A new upperopt layer is added to the OverlayFS file system to record application operations on the first file. The copy-on-write mechanism logic is modified so that the lower layer file is no longer copied to the upper layer, but a second file is created in the upperopt layer to record the operations.
It reduces the time spent on copy-on-write in the OverlayFS file system, thus reducing the occurrence of problems such as application freezing, stuttering, and frame drops.
Smart Images

Figure CN119293009A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of cloud applications, and in particular to an optimization method and device for a copy-on-write mechanism of a file system. Background Art
[0002] Cloud applications (such as cloud games, cloud phones, etc.) are an emerging online application model. It places the application running, rendering and processing processes on a remote cloud server and transmits the application screen to the user's device, allowing users to enjoy high-quality application experience on various devices without the need for high-performance hardware support.
[0003] With the development of cloud application field, mainstream companies use containerization solution to run applications, that is, create containers in cloud servers and run applications in containers. In this solution, application data is often stored on storage servers, and multiple containers can share the same application data by mounting NFS network file system, so as to save storage space of cloud servers and start service as soon as possible. At the same time, application data stored on storage servers must be read-only and cannot be modified by any user, otherwise it will cause inconsistent application data. However, from the perspective of the application, these application data belong to the application itself, and it should have the right to modify or create new files at any time. In order to solve this conflict / problem, OverlayFS file system is generally used. OverlayFS is a stacked file system that is widely used in container technology. It mainly divides files into three layers: lower layer, upper layer and merged layer. In specific implementation, after mounting the application data on the storage server to the cloud server, you can use the joint mounting technology to mount the application data's mounting directory as the lower layer and a directory in the container as the upper layer to the directory actually used by the application (the directory is the merged layer). In this way, the applications in each container can read the files in the lower layer and use the copy-on-write mechanism of the OverlayFS file system to modify the files in the upper layer, so that the files modified by the application actually become the files in the upper layer, and the application data on the storage server can maintain consistency. Among them, the copy-on-write mechanism of the OverlayFS file system is: when the application opens the file in the lower layer in write mode, the OverlayFS file system will copy the file in the lower layer to the upper layer, and then the application's writing to the lower layer file becomes writing to the upper layer file. When the file to be copied is large or there are many files to be copied at one time, it takes a long time, which will cause the application to freeze, freeze, drop frames, and other problems.
[0004] Therefore, how to provide an optimization solution for the write-time copy mechanism of the file system to reduce the time consumption of the write-time copy process of the OverlayFS file system has become a technical problem that needs to be solved urgently. Summary of the invention
[0005] In view of the technical problems existing in the prior art, the embodiments of the present application provide a method and device for optimizing the copy-on-write mechanism of a file system.
[0006] In a first aspect, an embodiment of the present application provides an optimization method for a file system copy-on-write mechanism, including: When the copy-on-write mechanism of the OverlayFS file system is triggered for the first file, a second file is created on the newly added upperopt layer, wherein the OverlayFS file system includes; a lower layer, an upper layer, a merged layer, and an upperopt layer, the mount directory of the application data on the storage server on the cloud server is the lower layer, the specified directory in the container on the cloud server is the upper layer, the directory actually accessed by the application in the container is the merged layer, and the first file is a file of the lower layer; The operation of the application on the first file is recorded in the second file.
[0007] In a second aspect, the embodiment of the present application further provides an optimization device for a file system copy-on-write mechanism, including: A creation unit, configured to create a second file on a newly added upperopt layer when a copy-on-write mechanism of the OverlayFS file system is triggered for the first file, wherein the OverlayFS file system includes a lower layer, an upper layer, a merged layer, and an upperopt layer, the mount directory of the application data on the storage server on the cloud server is the lower layer, the designated directory in the container on the cloud server is the upper layer, the directory actually accessed by the application in the container is the merged layer, and the first file is a file of the lower layer; The recording unit is used to record the operation of the application on the first file in the second file.
[0008] In a third aspect, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the optimization method for the copy-on-write mechanism of the file system as described in the first aspect are executed.
[0009] In a fourth aspect, an embodiment of the present application further provides an electronic device, comprising: a processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor communicates with the storage medium through the bus, and the processor executes the machine-readable instructions to perform the steps of the optimization method for the copy-on-write mechanism of the file system as described in the first aspect.
[0010] In summary, the optimization method and device, electronic device and storage medium for the write-time copy mechanism of the file system provided in the embodiments of the present application modify the logic of the write-time copy mechanism of the OverlayFS file system. When the write-time copy mechanism is triggered, the files in the lower layer are no longer copied to the upper layer. Instead, a second file for recording the application's operations on the first file is created on the newly added upperopt layer. This can reduce the time consumption of the write-time copy process of the OverlayFS file system, and thereby reduce the occurrence of problems such as application freezing, freezes, and frame drops. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] Figure 1 A flowchart of an embodiment of an optimization method for a file system copy-on-write mechanism provided in an embodiment of the present application; Figure 2 A schematic diagram of the structure of an embodiment of an optimization device for a file system copy-on-write mechanism provided in an embodiment of the present application; Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0012] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the drawings in the present application only serve the purpose of explanation and description and are not used to limit the scope of protection of the present application. In addition, it should be understood that the schematic drawings are not drawn in real proportion. The flowchart used in this application shows the operations implemented according to some embodiments of the present application. It should be understood that the operations of the flowchart can be implemented out of sequence, and the steps without logical context can be reversed in order or implemented simultaneously. In addition, those skilled in the art can add one or more other operations to the flowchart under the guidance of the content of the present application, or remove one or more operations from the flowchart.
[0013] In addition, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.
[0014] It should be noted that the term "comprising" will be used in the embodiments of the present application to indicate the existence of the features declared thereafter, but does not exclude the addition of other features.
[0015] Reference Figure 1 As shown, an embodiment of the present application provides a flow chart of an optimization method for a file system copy-on-write mechanism, the method comprising: S10. When the copy-on-write mechanism of the OverlayFS file system is triggered for the first file, a second file is created on the newly added upperopt layer, wherein the OverlayFS file system includes: a lower layer, an upper layer, a merged layer, and an upperopt layer, the mount directory of the application data on the storage server on the cloud server is the lower layer, the specified directory in the container on the cloud server is the upper layer, the directory actually accessed by the application in the container is the merged layer, and the first file is a file of the lower layer; In this embodiment, it should be noted that the upperopt layer is a new layer added on the upper layer. After the upperopt layer is added, the hierarchical structure of the OverlayFS file system includes at least the lower layer, the upper layer, the merged layer and the upperopt layer. When the first file exists in the lower layer and the application opens the first file in write mode, it is determined that the copy-on-write mechanism of the OverlayFS file system is triggered for the first file. At this time, the OverlayFS file system will create a second file on the upperopt layer.
[0016] S11. Record the operation of the application on the first file in the second file.
[0017] The optimization method for the write-time copy mechanism of the file system provided in the embodiment of the present application modifies the logic of the write-time copy mechanism of the OverlayFS file system. When the write-time copy mechanism is triggered, the file of the lower layer is no longer copied to the upper layer. Instead, a second file for recording the application's operations on the first file is created on the newly added upperopt layer. This can reduce the time consumption of the write-time copy process of the OverlayFS file system, and then reduce the occurrence of problems such as application freezing, freezing, and frame dropping.
[0018] Based on the foregoing method embodiment, recording the operation of the application on the first file in the second file may include: At least one of the first information, the second information, the third information and the fourth information is recorded in the second file, wherein the first information is used to indicate the creation of the third file, the second information is used to indicate the information of the data written into the first file by the application, the third information is used to indicate the renaming of the third file, the fourth information is used to indicate the attribute modification of the third file, the third file is a file of the upperopt layer, and the name of the third file when it is created is the same as the name of the first file.
[0019] In this embodiment, it should be noted that the second file is a header information file, which records at least one of the first information, the second information, the third information and the fourth information; the third file is a data file, which records the data written by the application to the first file. The second file and the third file can be the same file or different files. Specifically, if the second file and the third file are the same file, one file is created; if the second file and the third file are different files, in addition to creating the second file, it is also necessary to create the third file in the upperopt layer. The relative path of the third file relative to the upperopt layer directory is the same as the relative path of the first file relative to the lower layer directory; if the second file and the third file are different files, in order to facilitate finding the second file corresponding to the third file, the directory where the second file is located can be the same as the directory where the third file is located, and even the second file name and the third file name can have the same characters.
[0020] After creating the third file, the OverlayFS file system can record the first information (such as created) in the second file to indicate that the third file has been created. After that, each time the application writes to the first file, the information of the content actually written by the application (i.e., the second information) can be recorded in the second file, and the content actually written by the application can be recorded in the third file. The second information may include the writing method (including overwriting, appending, random writing, etc.), writing position, and writing length.
[0021] When the application renames the first file, the name of the third file can be renamed to a new name, and the third information (which may include the rename identifier rename and the name of the third file before renaming) can be recorded in the second file to indicate that the third file has been renamed; if the second file and the third file are different, and the second file name and the third file name have the same characters, the name of the second file can also be modified according to the renamed name of the third file. In addition to renaming the name of the third file to a new name, a new second file can be created in the upperopt layer with the name of the second file corresponding to the name of the third file before renaming, and information indicating that there is no file with the name of the third file before renaming in the lower layer is recorded in the new second file. This is explained by taking the second file and the third file as different files. Assume that the first file in the lower layer is test.txt, and its path is / data / data / lower / test / 1dir / test.txt (the relative path of the first file to the lower layer directory is / 1dir / test.txt), the path of the third file test.txt created on the upperopt layer is / data / data / packagename1 / 1dir / test.txt (the relative path of the third file to the upperopt layer directory is / 1dir / test.txt), and the path of the second file testhead.txt created on the upperopt layer is / data / data / packagename1 / 1dir / testhead.txt (in order to facilitate finding the second file corresponding to the third file, the second file is placed in the directory where the third file is located, and the name of the second file contains the specific character test in the name of the third file), then when the application renames the first file to 1test.txt, the name of the third file can be modified to 1test.txt, the third information can be recorded in the second file, the name of the second file can be modified to 1testhead.txt, and a second file named testhead.txt can be created in the upperopt layer, and information indicating that there is no file named test.txt in the lower layer can be recorded in testhead.txt.
[0022] When the application modifies the attributes of the first file, the attributes of the third file may be modified, and fourth information may be recorded in the second file to indicate that the attributes of the third file are modified.
[0023] Based on the foregoing method embodiment, the method may further include: When the application reads the target file, if it is determined that the target file exists in the upperopt layer, the target data is obtained according to the information recorded in the second file corresponding to the target file and returned to the application; or If it is determined that the target file does not exist in the upperopt layer, and it is determined that the target file exists in the upper layer, then the data of the target file in the upper layer is obtained and returned to the application; or If it is determined that the target file does not exist in the upperopt layer, and it is determined that the target file does not exist in the upper layer, and it is determined that the target file exists in the lower layer, then the data of the target file in the lower layer is obtained and returned to the application.
[0024] In this embodiment, it should be noted that, since the upperopt layer is located above the upper layer, when the application reads the target file, the OverlayFS file system will read the data of the corresponding file and return it to the application in the order of the upperopt layer, the upper layer, and the lower layer. Specifically, the OverlayFS file system will determine whether the target file exists in the upperopt layer. If the target file exists in the upperopt layer, the target data will be obtained according to the information recorded in the second file corresponding to the target file and returned to the application. If the target file does not exist in the upperopt layer, the OverlayFS file system will determine whether the target file exists in the upper layer. If the target file exists in the upper layer, the data of the target file in the upper layer will be obtained and returned to the application, or if the target file does not exist in the upper layer, it will determine whether the target file exists in the lower layer. If the target file exists in the lower layer, the data of the target file in the lower layer will be obtained and returned to the application, or if the target file does not exist in the lower layer, information indicating that the target file does not exist will be returned.
[0025] It should be noted that obtaining target data according to the information recorded in the second file corresponding to the target file and returning it to the application includes the following situations: (1) If the second information is recorded in the second file but the third information is not recorded, then the corresponding content is obtained from the third file (i.e., the target file) according to the second information and returned to the application, or the third file and the target file of the lower layer are merged and the merged content is returned to the application, so that the application obtains the final modified file content.
[0026] For example, assuming that the second information includes information 1, information 2 and information 3, where information 1 is written earlier than information 2, and information 2 is written earlier than information 3, information 1 includes append writing and writing 100 bytes, information 2 includes overwriting writing and writing 200 bytes, and information 3 includes random writing, an offset of 50 bytes and writing 100 bytes, then the OverlayFS file system obtains the first 50 bytes of data written by overwriting, the 100 bytes of data written by random writing, and the last 50 bytes of data written by overwriting.
[0027] To give another example, assume that the target file of the lower layer contains 1000 bytes of data, and the second information contains information 4 and information 5, wherein information 4 is written earlier than information 5, information 4 includes append write and write 100 bytes, and information 5 includes random write, an offset of 50 bytes and write 100 bytes. Then the OverlayFS file system obtains the first 50 bytes of data of the target file of the lower layer, the 100 bytes of data written by random write, the last 850 bytes of data of the target file of the lower layer, and the 100 bytes of data written by append write.
[0028] In other words, the OverlayFS file system actually merges the upperopt layer target file and the lower layer target file, so that the application obtains the data after the lower layer target file is actually modified.
[0029] (2) If the second file records the second information and the third information, then the corresponding content is obtained from the third file (i.e., the target file) according to the second information and returned to the application, or the third file and the lower layer file (the file name is the name in the third information) are merged, and the merged content is returned to the application, so that the application obtains the final modified file content.
[0030] For example, assume that the second information includes information 1, information 2, and information 3, where information 1 is written earlier than information 2, and information 2 is written earlier than information 3. Information 1 includes appending and writing 100 bytes, information 2 includes overwriting and writing 200 bytes, and information 3 includes random writing, an offset of 50 bytes, and writing 100 bytes. The third information includes rename and test.txt, where test.txt represents the name of the third file before renaming. The OverlayFS file system obtains the first 50 bytes of data written by overwriting, the 100 bytes of data written by random writing, and the last 50 bytes of data written by overwriting.
[0031] As another example, assume that the second information includes information 4 and information 5, wherein information 4 is written earlier than information 5, information 4 includes append write and write 100 bytes, and information 5 includes random write, offset of 50 bytes and write 100 bytes. The third information includes rename and test.txt, wherein test.txt represents the name of the third file before renaming, the lower layer file test.txt contains 1000 bytes of data, and information 5 is written earlier than the third information. Then the OverlayFS file system obtains the first 50 bytes of the lower layer file test.txt, the 100 bytes of data written by random write, the last 850 bytes of the lower layer file test.txt, and the 100 bytes of data written by append write.
[0032] That is to say, the OverlayFS file system actually determines the files for merging in the lower layer based on the third information, and merges the determined files with the target files in the upperopt layer. In this way, the application obtains the data after the lower layer files are actually modified.
[0033] (3) If the second information is not recorded in the second file, the file at the lower layer is determined based on the information recorded in the second file, and the content of the file is obtained and returned to the application. For example, if the second information is not recorded in the second file, but the first information is recorded, the content of the target file at the lower layer is obtained and returned to the application; for another example, if the second information is not recorded in the second file, but the third information is recorded, the file at the lower layer is determined based on the third information (the file name is the name in the third information), and the content of the file is obtained and returned to the application.
[0034] Based on the foregoing method embodiment, the method may further include: When the application opens the target file in a create mode, if it is determined that the upperopt layer has a second file corresponding to the target file and the target file does not exist, and the information recorded in the second file indicates that the target file does not exist in the lower layer, then the target file is created in the upperopt layer; or When the application opens the target file in a create mode, if it is determined that the upperopt layer has a second file corresponding to the target file and the target file does not exist, and the information recorded in the second file indicates that the target file does not exist in the lower layer, the target file is created in the upper layer, and the second file corresponding to the target file in the upperopt layer is deleted; or When the application opens the target file in a manner other than creation, if it is determined that there is a second file corresponding to the target file in the upperopt layer and the target file does not exist and the information recorded in the second file indicates that the target file does not exist in the lower layer, information indicating that the target file does not exist is returned to the application.
[0035] In this embodiment, it should be noted that when creating a target file in the upper layer, the original method of the OverlayFS file system can be used to create it. When the application opens the target file in write mode, if the information recorded in the second file corresponding to the target file indicates that the target file does not exist in the lower layer, it is determined that the target file does not exist in the lower layer, and the write-time copy mechanism of the OverlayFS file system will not be triggered. At this time, if the target file does not exist in the upperopt layer, information indicating that the target file does not exist will be returned to the application.
[0036] Reference Figure 2 FIG. 1 is a schematic diagram of a structure of an optimization device for a file system copy-on-write mechanism provided by an embodiment of the present application, the device comprising: The creation unit 20 is used to create a second file on the newly added upperopt layer when the write-time copy mechanism of the OverlayFS file system is triggered for the first file, wherein the OverlayFS file system includes: a lower layer, an upper layer, a merged layer and an upperopt layer, the mount directory of the application data on the storage server on the cloud server is the lower layer, the specified directory in the container on the cloud server is the upper layer, the directory actually accessed by the application in the container is the merged layer, and the first file is a file of the lower layer; The recording unit 21 is used to record the operation of the application on the first file in the second file.
[0037] The optimization device for the write-time copy mechanism of the file system provided in the embodiment of the present application modifies the logic of the write-time copy mechanism of the OverlayFS file system. When the write-time copy mechanism is triggered, the file of the lower layer is no longer copied to the upper layer. Instead, a second file for recording the application's operation on the first file is created on the newly added upperopt layer. This can reduce the time consumption of the write-time copy process of the OverlayFS file system, and then reduce the occurrence of problems such as application freezing, freezing, and frame dropping.
[0038] Based on the above device embodiment, the recording unit may be used for: At least one of the first information, the second information, the third information and the fourth information is recorded in the second file, wherein the first information is used to indicate the creation of the third file, the second information is used to indicate the information of the data written into the first file by the application, the third information is used to indicate the renaming of the third file, the fourth information is used to indicate the attribute modification of the third file, the third file is a file of the upperopt layer, and the name of the third file when it is created is the same as the name of the first file.
[0039] Based on the above device embodiment, the recording unit may also be used for: The data written by the application into the first file is recorded in the third file.
[0040] Based on the above device embodiment, the device may further include: The first processing unit is configured to: When the application reads the target file, if it is determined that the target file exists in the upperopt layer, the target data is obtained according to the information recorded in the second file corresponding to the target file and returned to the application; or If it is determined that the target file does not exist in the upperopt layer, and it is determined that the target file exists in the upper layer, then the data of the target file in the upper layer is obtained and returned to the application; or If it is determined that the target file does not exist in the upperopt layer, and it is determined that the target file does not exist in the upper layer, and it is determined that the target file exists in the lower layer, then the data of the target file in the lower layer is obtained and returned to the application.
[0041] Based on the above device embodiment, the device may further include: The second processing unit is configured to: When the application opens the target file in a create mode, if it is determined that the upperopt layer has a second file corresponding to the target file and the target file does not exist, and the information recorded in the second file indicates that the target file does not exist in the lower layer, then the target file is created in the upperopt layer; or When the application opens the target file in a create mode, if it is determined that the upperopt layer has a second file corresponding to the target file and the target file does not exist, and the information recorded in the second file indicates that the target file does not exist in the lower layer, the target file is created in the upper layer, and the second file corresponding to the target file in the upperopt layer is deleted; or When the application opens the target file in a manner other than creation, if it is determined that there is a second file corresponding to the target file in the upperopt layer and the target file does not exist and the information recorded in the second file indicates that the target file does not exist in the lower layer, information indicating that the target file does not exist is returned to the application.
[0042] The optimization device for the copy-on-write mechanism of the file system provided in the embodiment of the present application has an implementation process that is consistent with the optimization method for the copy-on-write mechanism of the file system provided in the embodiment of the present application, and the effect that can be achieved is also the same as the optimization method for the copy-on-write mechanism of the file system provided in the embodiment of the present application, and will not be repeated here.
[0043] like Figure 3 As shown, an electronic device provided by an embodiment of the present application includes: a processor 30, a memory 31 and a bus 32, wherein the memory 31 stores machine-readable instructions executable by the processor 30, and when the electronic device is running, the processor 30 communicates with the memory 31 through the bus 32, and the processor 30 executes the machine-readable instructions to perform the steps of the above-mentioned optimization method for the copy-on-write mechanism of the file system.
[0044] Specifically, the above-mentioned memory 31 and processor 30 can be general-purpose memories and processors, which are not specifically limited here. When the processor 30 runs the computer program stored in the memory 31, the above-mentioned optimization method for the copy-on-write mechanism of the file system can be executed.
[0045] Corresponding to the above-mentioned optimization method for the copy-on-write mechanism of the file system, an embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned optimization method for the copy-on-write mechanism of the file system are executed.
[0046] The above are only specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the 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 method for optimizing the copy-on-write mechanism of a file system, characterized in that: include: When the copy-on-write mechanism of the OverlayFS file system is triggered for the first file, a second file is created on the newly added upperopt layer, wherein the OverlayFS file system includes; a lower layer, an upper layer, a merged layer, and an upperopt layer, the mount directory of the application data on the storage server on the cloud server is the lower layer, the specified directory in the container on the cloud server is the upper layer, the directory actually accessed by the application in the container is the merged layer, and the first file is a file of the lower layer; The operation of the application on the first file is recorded in the second file.
2. The method according to claim 1, characterized in that The step of recording the operation of the application on the first file in the second file includes: At least one of the first information, the second information, the third information and the fourth information is recorded in the second file, wherein the first information is used to indicate the creation of the third file, the second information is used to indicate the information of the data written into the first file by the application, the third information is used to indicate the renaming of the third file, the fourth information is used to indicate the attribute modification of the third file, the third file is a file of the upperopt layer, and the name of the third file when it is created is the same as the name of the first file.
3. The method according to claim 2, characterized in that Also includes: The data written by the application into the first file is recorded in the third file.
4. The method according to any one of claims 1 to 3, characterized in that Also includes: When the application reads the target file, if it is determined that the target file exists in the upperopt layer, the target data is obtained according to the information recorded in the second file corresponding to the target file and returned to the application; or If it is determined that the target file does not exist in the upperopt layer, and it is determined that the target file exists in the upper layer, the data of the target file in the upper layer is obtained and returned to the application; or If it is determined that the target file does not exist in the upperopt layer, and it is determined that the target file does not exist in the upper layer, and it is determined that the target file exists in the lower layer, then the data of the target file in the lower layer is obtained and returned to the application.
5. The method according to any one of claims 1 to 3, characterized in that: Also includes: When the application opens the target file in a create mode, if it is determined that the upperopt layer has a second file corresponding to the target file and the target file does not exist, and the information recorded in the second file indicates that the target file does not exist in the lower layer, then the target file is created in the upperopt layer; or When the application opens the target file in a create mode, if it is determined that the upperopt layer has a second file corresponding to the target file and the target file does not exist, and the information recorded in the second file indicates that the target file does not exist in the lower layer, the target file is created in the upper layer, and the second file corresponding to the target file in the upperopt layer is deleted; or When the application opens the target file in a manner other than creation, if it is determined that there is a second file corresponding to the target file in the upperopt layer and the target file does not exist and the information recorded in the second file indicates that the target file does not exist in the lower layer, information indicating that the target file does not exist is returned to the application.
6. An optimization device for a file system copy-on-write mechanism, characterized in that: include: A creation unit, configured to create a second file on a newly added upperopt layer when a copy-on-write mechanism of the OverlayFS file system is triggered for the first file, wherein the OverlayFS file system includes a lower layer, an upper layer, a merged layer, and an upperopt layer, the mount directory of the application data on the storage server on the cloud server is the lower layer, the designated directory in the container on the cloud server is the upper layer, the directory actually accessed by the application in the container is the merged layer, and the first file is a file of the lower layer; The recording unit is used to record the operation of the application on the first file in the second file.
7. The device according to claim 6, characterized in that The recording unit is used for: At least one of the first information, the second information, the third information and the fourth information is recorded in the second file, wherein the first information is used to indicate the creation of the third file, the second information is used to indicate the information of the data written into the first file by the application, the third information is used to indicate the renaming of the third file, the fourth information is used to indicate the attribute modification of the third file, the third file is a file of the upperopt layer, and the name of the third file when it is created is the same as the name of the first file.
8. The device according to claim 7, characterized in that The recording unit is further used for: The data written by the application into the first file is recorded in the third file.
9. The device according to any one of claims 6 to 8, characterized in that Also includes: The first processing unit is configured to: When the application reads the target file, if it is determined that the target file exists in the upperopt layer, the target data is obtained according to the information recorded in the second file corresponding to the target file and returned to the application; or If it is determined that the target file does not exist in the upperopt layer, and it is determined that the target file exists in the upper layer, the data of the target file in the upper layer is obtained and returned to the application; or If it is determined that the target file does not exist in the upperopt layer, and it is determined that the target file does not exist in the upper layer, and it is determined that the target file exists in the lower layer, then the data of the target file in the lower layer is obtained and returned to the application.
10. The device according to any one of claims 6 to 8, characterized in that Also includes: The second processing unit is configured to: When the application opens the target file in a create mode, if it is determined that the upperopt layer has a second file corresponding to the target file and the target file does not exist, and the information recorded in the second file indicates that the target file does not exist in the lower layer, then the target file is created in the upperopt layer; or When the application opens the target file in a create mode, if it is determined that the upperopt layer has a second file corresponding to the target file and the target file does not exist, and the information recorded in the second file indicates that the target file does not exist in the lower layer, the target file is created in the upper layer, and the second file corresponding to the target file in the upperopt layer is deleted; or When the application opens the target file in a manner other than creation, if it is determined that there is a second file corresponding to the target file in the upperopt layer and the target file does not exist and the information recorded in the second file indicates that the target file does not exist in the lower layer, information indicating that the target file does not exist is returned to the application.
Citation Information
Patent Citations
File system data volume updating method and device, terminal equipment and storage medium
CN112631832A
Cloud mobile phone application increment updating method and device equipment, medium and product
CN114064099A
Method and device for processing file in overlay file system
CN116909998A
Container management method and device, equipment and medium
CN118132203A
Electronic device and method for operating file system of electronic device
WO2023027371A1
Cited By
Method and device for optimizing file access speed of cloud application
CN120336270A
Method and apparatus for optimizing file access speed of cloud application
CN120336270B
Range-level incremental copy-on-write method and system in joint file system
CN122570436A